ExtensionNPVoicerSwitcher maintains a pool of NPVoicer objects organised into three roles:
numSaves voicers that have been stepped down from the current role and are still audible.numSaves voicers that are fading out (or silent), ready to be recycled.The core operation is -swapCurrentToSaved, which rotates the three roles atomically: the current voicer moves to the chosen saved slot, the previous saved voicer begins fading out and moves to the matching released slot, and the previous released voicer becomes the new current.
All Ndef proxies are created automatically in *new and are named with an optional prefix followed by an index starting at 0.
Create a new NPVoicerSwitcher.
| numSaves |
Number of saved (and released) voicer slots. Default: |
| voicerClass |
The voicer class to instantiate for each slot. Default: |
| prefix |
A String prepended to the Ndef name of each internal voicer proxy. Default: |
An NPVoicerSwitcher instance.
The voicer currently in the active role.
An Array of numSaves voicers in the saved role.
An Array of numSaves voicers in the released (fading-out) role.
All managed voicers as a flat Array:. The order is always [current, saved..., released...].
A Function that is called after every successful -swapCurrentToSaved call. Passed arguments are:
Default: nil.
Atomically rotate the three roles for a given slot index.
Steps performed:
releaseAll(fadeTime) on the voicer currently in saved[idx].released[idx].saved[idx].released[idx] to current.| idx |
Zero-based index into the saved/released arrays ( |
| fadeTime |
Fade duration in seconds applied when releasing the outgoing saved voicer. Default: |
The receiver.
A Function that is called after every successful -releaseSaved call. Passed arguments are:
Default: nil.
Release a saved voicer by index, not moving it to the released role. This can be used to free up saved slots without affecting the current/released rotation.
Steps performed:
releaseAll(fadeTime) on the voicer currently in saved[idx].| idx |
index of the saved slot to release. |
Load a sound definition into the voicers. The call is forwarded to NPVoicer: -prime.
| obj |
The sound object to prime (e.g. a SynthDef name symbol). |
| useSpawn |
Boolean — passed through to |
| which |
Optional symbol restricting which role receives the prime call:
|
Forward a play call to every managed voicer.
| outs |
Output bus number or Array of bus numbers (wrapped if shorter than the voicer count). |
| numChannels |
Passed through to |
| group |
Passed through to |
| multi |
Passed through to |
| vol |
Passed through to |
| fadeTime |
Passed through to |
| addAction |
Passed through to |
Call stop(fadeTime) on every managed voicer.
| fadeTime |
Fade duration in seconds. Default: |
Call releaseAll(fadeTime) on every managed voicer.
| fadeTime |
Fade duration in seconds. Default: |
The number of saved (and released) slots.
The voicer class used when creating internal voicer objects.
The string prefix used for internal Ndef names.
All examples assume the following setup: