
    W|hs                     h    S SK Jr  S SKrS SKJr  S SKJr  S SKJ	r	  S SK
Jr  \ " S S\	5      5       rg)	    )	dataclassN)Clip)audio_video_effect)Effect)convert_to_secondsc                   h    \ rS rSr% Sr\\S'   Sr\\S'   Sr\\S'   S r	S r
\S	\S
\4S j5       rSrg)MultiplyVolume   a  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                     U R                   b  [        U R                   5      U l         U R                  b  [        U R                  5      U l        g g N)r   r   r   )selfs    Y/home/james-whalen/.local/lib/python3.13/site-packages/moviepy/audio/fx/MultiplyVolume.py__post_init__MultiplyVolume.__post_init__3   s;    ??&0ADO==$.t}}=DM %    c                 L   ^^^^^ UU4S jmUUU4S jnUU4S jnTS:X  a  U$ U$ )Nc                    > [         R                  " U Vs/ s H  nTUs=::  a  T::  a  O  OU OSPM     sn5      $ s  snf )N   )nparray)r   tt_r   r   s      r   factors_filter@MultiplyVolume._multiply_volume_in_range.<locals>.factors_filter;   s8    88UVWUVrzR'C8'CVJUVWXXWs   ;c                    > [         R                  " U " U5      [         R                  " [        T5       Vs/ s H  nT" TU5      PM     sn5      R                  5      $ s  snf r   )r   multiplyr   rangeT)	get_framer   _r   r   	nchannelss      r   multiply_stereo_volumeHMultiplyVolume._multiply_volume_in_range.<locals>.multiply_stereo_volume>   sM    ;;!U9=MN=M.3=MNOQQ Ns   Ac                 L   > [         R                  " U " U5      T" TU5      5      $ r   )r   r   )r"   r   r   r   s     r   multiply_mono_volumeFMultiplyVolume._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_range(MultiplyVolume._multiply_volume_in_range:   s)    	Y		H (1A~#Q;QQr   clipreturnc                 X  ^  T R                   c!  T R                  c  UR                  U 4S jSS9$ UR                  T R                  T R                  T R                   c  UR
                  OT R                   T R                  c  UR                  OT R                  UR                  5      SS9$ )zApply the effect to the clip.c                 .   > TR                   U " U5      -  $ r   )r   )r"   r   r   s     r   <lambda>&MultiplyVolume.apply.<locals>.<lambda>N   s    T[[9Q<%?r   T)keep_duration)r   r   	transformr+   r   startendr$   )r   r-   s   ` r   applyMultiplyVolume.applyI   s     ??"t}}'<>>?" "  
 ~~**"oo5

4?? MM1t}}	   
 	
r   )r   r   )__name__
__module____qualname____firstlineno____doc__float__annotations__r   r   r   r+   r   r   r7   __static_attributes__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>rG      s5    !   1 ! , N
V N
 N
r   