EnvelopeTimer
Call a function with a series of values, each delivered at its own time.
envelopetimer = EnvelopeTimer(action, values, times)
An EnvelopeTimer steps your function through a list of values at a matching list of times, and can cycle back to the start after the last value. It is handy for shaping a sound's volume, panning, or frequency over time. The values and times lists run in parallel, and the times are absolute milliseconds from the start, in increasing order.
A value that is itself a list or tuple is unpacked into several arguments to the function. Start it with start(), and stop it with stop().
Creating an EnvelopeTimer
EnvelopeTimer(action, values, times, repeat=False)
You can create an EnvelopeTimer with the following parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
action |
function |
required | The function to call; it receives the current value, or several arguments if the value is a list or tuple. |
values |
list |
required | The values to deliver, in order. |
times |
list[int or float] |
required | When to deliver each value, in milliseconds from the start; each must be later than the one before. |
repeat |
bool |
False |
Whether to cycle back to the start after the last value (True) or stop (False). |
Functions
Once an EnvelopeTimer envelopetimer has been created, the following functions are available:
| Function | Description |
|---|---|
envelopetimer.start() |
Start the envelope from the beginning. |
envelopetimer.stop() |
Stop the envelope and reset it to the beginning. |
envelopetimer.pause() |
Pause the envelope, remembering where it is. |
envelopetimer.resume() |
Resume the envelope from where it was paused. |
envelopetimer.isRunning() |
Report whether the envelope is running. |
envelopetimer.isPaused() |
Report whether the envelope is paused. |