--- linuxsampler/trunk/src/engines/EngineChannelBase.h 2009/10/23 17:53:17 2012 +++ linuxsampler/trunk/src/engines/EngineChannelBase.h 2009/11/03 19:27:42 2027 @@ -347,6 +347,27 @@ } virtual void ProcessKeySwitchChange(int key) = 0; + + /** + * Handle key group (a.k.a. exclusive group) conflicts + */ + void HandleKeyGroupConflicts(uint KeyGroup, Pool::Iterator& itNoteOnEvent) { + if (KeyGroup) { // if this voice / key belongs to a key group + uint** ppKeyGroup = &MidiKeyboardManager::ActiveKeyGroups[KeyGroup]; + if (*ppKeyGroup) { // if there's already an active key in that key group + MidiKey* pOtherKey = &MidiKeyboardManager::pMIDIKeyInfo[**ppKeyGroup]; + // kill all voices on the (other) key + typename RTList::Iterator itVoiceToBeKilled = pOtherKey->pActiveVoices->first(); + typename RTList::Iterator end = pOtherKey->pActiveVoices->end(); + for (; itVoiceToBeKilled != end; ++itVoiceToBeKilled) { + if (itVoiceToBeKilled->Type != Voice::type_release_trigger) { + itVoiceToBeKilled->Kill(itNoteOnEvent); + --pEngine->VoiceSpawnsLeft; //FIXME: just a hack, we should better check in StealVoice() if the voice was killed due to key conflict + } + } + } + } + } }; } // namespace LinuxSampler