
    -is                     v    d dl mZ d dlZd dlmZ d dlmZ d dlm	Z	 d dl
mZ e G d de	                      ZdS )	    )	dataclassN)Clip)audio_video_effect)Effect)convert_to_secondsc                   f    e Zd ZU dZeed<   dZeed<   dZeed<   d Zd Z	e
ded	efd
            ZdS )MultiplyVolumea(  Returns a clip with audio volume multiplied by the
    value `factor`. Can be applied to both audio and video clips.

    Parameters
    ----------

    factor : float
      Volume multiplication factor.

    start_time : float, optional
      Time from the beginning of the clip until the volume transformation
      begins to take effect, in seconds. By default at the beginning.

    end_time : float, optional
      Time from the beginning of the clip until the volume transformation
      ends to take effect, in seconds. By default at the end.

    Examples
    --------

    .. code:: python

        from moviepy import AudioFileClip

        music = AudioFileClip("music.ogg")
        # doubles audio volume
        doubled_audio_clip = music.with_effects([afx.MultiplyVolume(2)])
        # halves audio volume
        half_audio_clip = music.with_effects([afx.MultiplyVolume(0.5)])
        # silences clip during one second at third
        effect = afx.MultiplyVolume(0, start_time=2, end_time=3)
        silenced_clip = clip.with_effects([effect])
    factorN
start_timeend_timec                     | j         t          | j                   | _         | j        t          | j                  | _        d S d S N)r   r   r   )selfs    ]/var/www/html/speakWrite/venv/lib/python3.11/site-packages/moviepy/audio/fx/MultiplyVolume.py__post_init__zMultiplyVolume.__post_init__3   s@    ?&0AADO=$.t}==DMMM %$    c                 F    fdfd}fd}dk    r|n|S )Nc                 J     t          j         fd|D                       S )Nc                 8    g | ]}|cxk    rk    rn nnd S )    ).0t_r   r
   r   s     r   
<listcomp>zTMultiplyVolume._multiply_volume_in_range.<locals>.factors_filter.<locals>.<listcomp><   s>    WWWrzR'C'C'C'C8'C'C'C'C'CVVWWWr   )nparray)r
   tr   r   s   ` r   factors_filterz@MultiplyVolume._multiply_volume_in_range.<locals>.factors_filter;   s0    8WWWWWWUVWWWXXXr   c           	          t          j         |           t          j        fdt                    D                       j                  S )Nc                 (    g | ]}           S r   r   )r   _r
   r   r   s     r   r   z\MultiplyVolume._multiply_volume_in_range.<locals>.multiply_stereo_volume.<locals>.<listcomp>A   s%    NNN..33NNNr   )r   multiplyr   rangeT)	get_framer   r
   r   	nchannelss    `r   multiply_stereo_volumezHMultiplyVolume._multiply_volume_in_range.<locals>.multiply_stereo_volume>   sV    ;	!NNNNNNU9=M=MNNNOOQ  r   c                 T    t          j         | |           |                    S r   )r   r"   )r%   r   r
   r   s     r   multiply_mono_volumezFMultiplyVolume._multiply_volume_in_range.<locals>.multiply_mono_volumeD   s)    ;yy||^^FA-F-FGGGr   r   r   )r   r
   r   r   r&   r'   r)   r   s    ````  @r   _multiply_volume_in_rangez(MultiplyVolume._multiply_volume_in_range:   s    	Y 	Y 	Y 	Y 	Y 	Y	 	 	 	 	 	 		H 	H 	H 	H 	H 	H (1A~~##;QQr   clipreturnc                      j         ! j        |                     fdd          S |                                          j         j         |j        n j          j        |j        n j        |j                  d          S )zApply the effect to the clip.Nc                 *    j          | |          z  S r   )r
   )r%   r   r   s     r   <lambda>z&MultiplyVolume.apply.<locals>.<lambda>N   s    T[99Q<<%? r   T)keep_duration)r   r   	transformr*   r
   startendr&   )r   r+   s   ` r   applyzMultiplyVolume.applyI   s     ?"t}'<>>????" "   
 ~~**"o5

4? M1t}	    
 
 	
r   )__name__
__module____qualname____doc__float__annotations__r   r   r   r*   r   r   r4   r   r   r   r	   r	      s            D MMMJHe> > >R R R 
$ 
4 
 
 
 
 
 
r   r	   )dataclassesr   numpyr   moviepy.Clipr   moviepy.decoratorsr   moviepy.Effectr   moviepy.toolsr   r	   r   r   r   <module>rA      s    ! ! ! ! ! !           1 1 1 1 1 1 ! ! ! ! ! ! , , , , , , N
 N
 N
 N
 N
V N
 N
 N
 N
 N
r   