The Fader
class
- class audiomath.Fader(duration=1.0, start=1, end=0, transform=None, pauseWhenDone='auto')
Bases:
object
A callable object that can be assigned to one of the dynamic properties of a
Player
to smoothly transition from astart
to anend
value. It is a self- terminating dynamic: when the transition is finished, it will raise aStopIteration
exception, which will be caught by thePlayer
, causing it to replace the dynamic with a final static value.Example:
import time, audiomath as am p = am.Player(am.TestSound('12')) fadeIn = am.Fader(3.0, start=0, end=1) p.Play(loop=1, volume=fadeIn) # fade in time.sleep(6.0) # wait for fade-in, then # stay constant for a few seconds p.volume = am.Fader(3.0) # fade out, then stop.
- Parameters:
duration (float) – duration of the transition, in seconds
start (float, numpy.ndarray) – start value
end (float, numpy.ndarray) – end value
transform – an optional function through which to transform
start
,end
and any value linearly interpolated between them.pauseWhenDone – if
True
,Pause()
theSound
when the transition is finished. IfFalse
, do not. A value of'auto'
, means “pause the sound when the transition is finished if theend
value is zero”.