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 a start to an end value. It is a self- terminating dynamic: when the transition is finished, it will raise a StopIteration exception, which will be caught by the Player, causing it to replace the dynamic with a final static value.


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.
  • 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() the Sound when the transition is finished. If False, do not. A value of 'auto', means “pause the sound when the transition is finished if the end value is zero”.