
    W|h                     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                   R    \ rS rSr% Sr\\S'   S rS rS r	\
S\S\4S	 j5       rS
rg)AudioFadeOut   ay  Return a sound clip where the sound fades out progressively
over ``duration`` seconds at the end of the clip.

Parameters
----------

duration : float
  How long does it take for the sound to reach the zero level at the end
  of the clip.

Examples
--------

.. code:: python

    clip = VideoFileClip("media/chaplin.mp4")
    clip.with_effects([afx.AudioFadeOut("00:00:06")])
durationc                 8    [        U R                  5      U l        g N)r   r   )selfs    W/home/james-whalen/.local/lib/python3.13/site-packages/moviepy/audio/fx/AudioFadeOut.py__post_init__AudioFadeOut.__post_init__"   s    *4==9    c                    ^ U4S j$ )Nc                 D   > [         R                  " STU -
  -  U-  S5      $ Ng      ?   )npminimum)tr   clip_durations     r   <lambda>2AudioFadeOut._mono_factor_getter.<locals>.<lambda>&   s     2::c]Q5F.G(.RTU#Vr    )r   r   s    `r   _mono_factor_getter AudioFadeOut._mono_factor_getter%   s	    VVr   c                    ^^ UU4S jnU$ )Nc                    > [         R                  " STU -
  -  U-  S5      n[         R                  " [        T5       Vs/ s H  o2PM     sn5      R                  $ s  snf r   )r   r   arrayrangeT)r   r   factor_r   	nchannelss       r   getter2AudioFadeOut._stereo_factor_getter.<locals>.getter)   sP    ZZ}q'8 9H DaHF88U9-=>-=V-=>?AAA>s   Ar   )r   r   r'   r(   s    `` r   _stereo_factor_getter"AudioFadeOut._stereo_factor_getter(   s    	B r   clipreturnc                   ^ ^ UR                   c  [        S5      eUR                  S:X  a  T R                  UR                   5      O%T R	                  UR                   UR                  5      mUR                  UU 4S jSS9$ )zApply the effect to the clip.zAttribute 'duration' not setr   c                 <   > T" UTR                   5      U " U5      -  $ r   r   )	get_framer   
get_factorr   s     r   r   $AudioFadeOut.apply.<locals>.<lambda><   s    At}}!=	!!Lr   T)keep_duration)r   
ValueErrorr'   r   r*   	transform)r   r,   r2   s   ` @r   applyAudioFadeOut.apply/   sx     == ;<< ~~" $$T]]3++DMM4>>J 	 ~~L  
 	
r   r0   N)__name__
__module____qualname____firstlineno____doc__float__annotations__r   r   r*   r   r   r7   __static_attributes__r   r   r   r	   r	      s@    & O:W 
$ 
4 
 
r   r	   )dataclassesr   numpyr   moviepy.Clipr   moviepy.decoratorsr   moviepy.Effectr   moviepy.toolsr   r	   r   r   r   <module>rG      s2    !   1 ! , 2
6 2
 2
r   