Here's how I'll (probably) implement exclusive groups:
In Iiwu_synth.c, iiwu_voice_noteon, the new synthesis process ('voice')
is set up and running just before the 'return r' statement.
Into the same file I'll put an 'iiwu_voice_noteoff_by_exclusive_group'
function, which is then called at this point, if the voice has an
exclusive group != 0. This will then change all other voices from the
same group into release state.
i think it would be better to put any sounding voice from the same
preset / exclusive class into released state before / at the same
time with allocating the new voice.
to illustrate why i think so: imagine the open hihat is sounding, and
some crash cymbals maybe, bass, strings and an organ; bringing us to
max polyphony.
the hihat is to be closed now. your proposal would rather blindly cut
any one of the voices sounding to free a voice first. it would however
be much better to first put the open hihat into released state (we
have to do that anyway), so that when we ask for a new voice, the open
hihat becomes the natural choice for a voice to kill.
and i think you can't just kill by exclusive group -- you have to take
into account which preset the active voice belongs to, too. otherwise
if two presets define the same exclusive class, their voices will
interact in strange ways.
now if i understand things correctly, this would mean that
_iiwu_voice_t needs to be extended to remember which preset the voice
belongs to. but i may be wrong.