
    W|h                     t    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KJr  \ " S S	\5      5       rg)
    )	dataclassN)CompositeAudioClip)MultiplyVolume)Clip)audio_video_effect)Effectc                   `    \ rS rSr% SrSr\\S'   Sr\	\S'   Sr
\\S'   \S	\S
\4S j5       rSrg)
AudioDelay   a  Repeats audio certain number of times at constant intervals multiplying
their volume levels using a linear space in the range 1 to ``decay`` argument
value.

Parameters
----------

offset : float, optional
  Gap between repetitions start times, in seconds.

n_repeats : int, optional
  Number of repetitions (without including the clip itself).

decay : float, optional
  Multiplication factor for the volume level of the last repetition. Each
  repetition will have a value in the linear function between 1 and this value,
  increasing or decreasing constantly. Keep in mind that the last repetition
  will be muted if this is 0, and if is greater than 1, the volume will increase
  for each repetition.

Examples
--------

.. code:: python

    from moviepy import *
    videoclip = AudioFileClip('myaudio.wav').with_effects([
        afx.AudioDelay(offset=.2, n_repeats=10, decayment=.2)
    ])

    # stereo A note
    frame_function = lambda t: np.array(
        [np.sin(440 * 2 * np.pi * t), np.sin(880 * 2 * np.pi * t)]
    ).T
    clip = AudioClip(frame_function=frame_function, duration=0.1, fps=44100)
    clip = clip.with_effects([afx.AudioDelay(offset=.2, n_repeats=11, decay=0)])
g?offset   	n_repeats   decayclipreturnc                 x   [         R                  " S[        SU R                  5      U R                  S-   5      n[        UR                  5       /[        U R                  5       Vs/ s HB  nUR                  US-   U R                  -  5      R                  [        X#S-      5      /5      PMD     snQ5      $ s  snf )zApply the effect to the clip.r   r   )nplinspacemaxr   r   r   copyrange
with_startr   with_effectsr   )selfr   
decaymentsreps       U/home/james-whalen/.local/lib/python3.13/site-packages/moviepy/audio/fx/AudioDelay.pyapplyAudioDelay.apply8   s     [[C4::$68JK
!		  %T^^4	  5 OOS1W$;<II'
7(;<=  5	

 
	
s   &A	B7
 N)__name__
__module____qualname____firstlineno____doc__r   float__annotations__r   intr   r   r   r   __static_attributes__r!       r   r
   r
      sH    $L FEIsE5
$ 
4 
 
r+   r
   )dataclassesr   numpyr   moviepy.audio.AudioClipr   moviepy.audio.fx.MultiplyVolumer   moviepy.Clipr   moviepy.decoratorsr   moviepy.Effectr   r
   r!   r+   r   <module>r3      s5    !  6 :  1 ! 9
 9
 9
r+   