[sdiy] Voice assignment algorithms
Tom Wiltshire
tom at electricdruid.net
Thu Mar 25 18:27:18 CET 2010
Hi All,
I've been thinking about voice assignment recently, and doing some
experiments with software. Once I've got an algorithm I'm happy with,
I'll probably move the principles onto a PIC or dsPIC in either C or
assembly. But first I need to know what I'm doing - I'd be a damn
fool to try and develop the logic in assembly.
The system I've got currently stores two stacks of voices; the free
stack and the busy stack. All the free voices are stored in the free
stack, and all the voices that are playing a note are in the busy
stack. Each stack also stores pointers to the first voice in the
stack and the last voice. Additionally, there is an array of all the
MIDI notes, which stores which voice is playing that note, if any
(the 'notes' array).
When a new note is played (a Note On event) the voice assigner looks
to see if the pointer to the first free voice is valid. If it is,
we've got a free voice, and it removes that voice from the free stack
and puts it on the end of the busy stack (at the position indicated
by the 'last' pointer for that stack). If there's no free voice, it
instead takes the voice from the front of the busy stack (e.g. the
oldest busy voice), sets it up with its new data, and sticks it back
on the end of the busy stack.
When a Note Off event arrives, we can look up which voice is playing
that note in the 'notes' array. This is mostly for speed and
convenience- I could have searched through the stack, it wouldn't
have taken *that* long. The voice is then removed from the busy stack
(from whichever position it's in) and placed back on the end of the
free stack.
This seems like a reasonable scheme from many points of view (and
seems to be fast), but there are things it doesn't do. For example,
it doesn't cope particularly well when set up with only a single
voice (e.g. monophonic). And specifically, if you play and release a
note whilst holding down a previous note, you'll get silence after
the release, whereas most monophonic synths store the held keys and
fall back to the previously-held key.
Does anyone know of any papers that discuss this sort of stuff, or
where I could find more information? Has anyone else tried writing
polyphonic/monophonic voice assignment schemes? Any experience to offer?
Thanks,
Tom
More information about the Synth-diy
mailing list