/[svn]/linuxsampler/trunk/src/engines/EngineChannelBase.h
ViewVC logotype

Diff of /linuxsampler/trunk/src/engines/EngineChannelBase.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2012 by iliev, Fri Oct 23 17:53:17 2009 UTC revision 2072 by persson, Sat Mar 20 11:37:52 2010 UTC
# Line 3  Line 3 
3   *   LinuxSampler - modular, streaming capable sampler                     *   *   LinuxSampler - modular, streaming capable sampler                     *
4   *                                                                         *   *                                                                         *
5   *   Copyright (C) 2003,2004 by Benno Senoner and Christian Schoenebeck    *   *   Copyright (C) 2003,2004 by Benno Senoner and Christian Schoenebeck    *
6   *   Copyright (C) 2005-2009 Christian Schoenebeck                         *   *   Copyright (C) 2005-2008 Christian Schoenebeck                         *
7   *   Copyright (C) 2009 Grigor Iliev                                       *   *   Copyright (C) 2009-2010 Christian Schoenebeck and Grigor Iliev        *
8   *                                                                         *   *                                                                         *
9   *   This program is free software; you can redistribute it and/or modify  *   *   This program is free software; you can redistribute it and/or modify  *
10   *   it under the terms of the GNU General Public License as published by  *   *   it under the terms of the GNU General Public License as published by  *
# Line 347  namespace LinuxSampler { Line 347  namespace LinuxSampler {
347              }              }
348    
349              virtual void ProcessKeySwitchChange(int key) = 0;              virtual void ProcessKeySwitchChange(int key) = 0;
350    
351                /**
352                 * Handle key group (a.k.a. exclusive group) conflicts
353                 */
354                void HandleKeyGroupConflicts(uint KeyGroup, Pool<Event>::Iterator& itNoteOnEvent, bool UseRelease = false) {
355                    if (KeyGroup) { // if this voice / key belongs to a key group
356                        uint* pKeyGroup = MidiKeyboardManager<V>::ActiveKeyGroups[KeyGroup];
357                        if (pKeyGroup) { // if there's already an active key in that key group
358                            MidiKey* pOtherKey = &MidiKeyboardManager<V>::pMIDIKeyInfo[*pKeyGroup];
359    
360                            if (UseRelease) {
361                                // send a note off to the other key
362                                if (pOtherKey->KeyPressed && itNoteOnEvent->Param.Note.Key != *pKeyGroup) {
363                                    RTList<Event>::Iterator itNewEvent = pEngine->pGlobalEvents->allocAppend();
364                                    if (itNewEvent) {
365                                        pOtherKey->ReleaseTrigger = false;
366                                        *itNewEvent = *itNoteOnEvent;
367                                        itNewEvent->Type = Event::type_note_off;
368                                        itNewEvent->Param.Note.Key = *pKeyGroup;
369                                        pEngine->ProcessNoteOff(this, itNewEvent);
370                                    }
371                                }
372                            } else {
373                                // kill all voices on the (other) key
374                                typename RTList<V>::Iterator itVoiceToBeKilled = pOtherKey->pActiveVoices->first();
375                                typename RTList<V>::Iterator end               = pOtherKey->pActiveVoices->end();
376                                for (; itVoiceToBeKilled != end; ++itVoiceToBeKilled) {
377                                    if (itVoiceToBeKilled->Type != Voice::type_release_trigger) {
378                                        itVoiceToBeKilled->Kill(itNoteOnEvent);
379                                        --pEngine->VoiceSpawnsLeft; //FIXME: just a hack, we should better check in StealVoice() if the voice was killed due to key conflict
380                                    }
381                                }
382                            }
383                        }
384                    }
385                }
386      };      };
387    
388  } // namespace LinuxSampler  } // namespace LinuxSampler

Legend:
Removed from v.2012  
changed lines
  Added in v.2072

  ViewVC Help
Powered by ViewVC