
    gs                     h    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y)	    )	dataclassN)Clip)audio_video_effect)Effect)convert_to_secondsc                   ^    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y)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                        | _        y y N)r   r   r   )selfs    h/var/www/it7/html/youtubeDownloader/venv/lib/python3.12/site-packages/moviepy/audio/fx/MultiplyVolume.py__post_init__zMultiplyVolume.__post_init__3   s;    ??&0ADO==$.t}}=DM %    c                 D    fdfd}fd}dk(  r|S |S )Nc                 t    t        j                  |D cg c]  }|cxk  rk  rn n| nd c}      S c c}w )N   )nparray)r
   tt_r   r   s      r   factors_filterz@MultiplyVolume._multiply_volume_in_range.<locals>.factors_filter;   s2    88UVWrzR'C8'CVJWXXWs   5c                     t        j                   | |      t        j                  t              D cg c]  } |       c}      j                        S c c}w r   )r   multiplyr   rangeT)	get_framer   _r
   r   	nchannelss      r   multiply_stereo_volumezHMultiplyVolume._multiply_volume_in_range.<locals>.multiply_stereo_volume>   sG    ;;!U9=MN.3NOQQ Ns   Ac                 J    t        j                   | |       |            S r   )r   r   )r   r   r
   r   s     r   multiply_mono_volumezFMultiplyVolume._multiply_volume_in_range.<locals>.multiply_mono_volumeD   s    ;;y|^FA-FGGr   r    )r   r
   r   r   r!   r"   r$   r   s    ````  @r   _multiply_volume_in_rangez(MultiplyVolume._multiply_volume_in_range:   s)    	Y		H (1A~#Q;QQr   clipreturnc                 Z     j                   " j                  |j                   fdd      S |j                   j                   j                   j                   |j
                  n j                    j                  |j                  n j                  |j                        d      S )zApply the effect to the clip.c                 .    j                    | |      z  S r   )r
   )r   r   r   s     r   <lambda>z&MultiplyVolume.apply.<locals>.<lambda>N   s    T[[9Q<%? r   T)keep_duration)r   r   	transformr&   r
   startendr!   )r   r'   s   ` r   applyzMultiplyVolume.applyI   s     ??"t}}'<>>?" "  
 ~~**"oo5

4?? MM1t}}	   
 	
r   )__name__
__module____qualname____doc__float__annotations__r   r   r   r&   r   r   r0   r%   r   r   r	   r	      sP     D MJHe>R 
$ 
4 
 
r   r	   )dataclassesr   numpyr   moviepy.Clipr   moviepy.decoratorsr   moviepy.Effectr   moviepy.toolsr   r	   r%   r   r   <module>r=      s5    !   1 ! , N
V N
 N
r   