The Fader class
- class audiomath.Fader(duration=1.0, start=1, end=0, transform=None, pauseWhenDone='auto')
Bases:
objectA callable object that can be assigned to one of the dynamic properties of a
Playerto smoothly transition from astartto anendvalue. It is a self- terminating dynamic: when the transition is finished, it will raise aStopIterationexception, 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,endand any value linearly interpolated between them.pauseWhenDone – if
True,Pause()theSoundwhen the transition is finished. IfFalse, do not. A value of'auto', means “pause the sound when the transition is finished if theendvalue is zero”.