/[svn]/linuxsampler/trunk/src/engines/gig/Engine.cpp
ViewVC logotype

Diff of /linuxsampler/trunk/src/engines/gig/Engine.cpp

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

revision 2026 by iliev, Fri Oct 23 17:53:17 2009 UTC revision 2027 by iliev, Tue Nov 3 19:27:42 2009 UTC
# Line 173  namespace LinuxSampler { namespace gig { Line 173  namespace LinuxSampler { namespace gig {
173          // key group, so the layered voices won't kill each other          // key group, so the layered voices won't kill each other
174          int iKeyGroup = (iLayer == 0 && !ReleaseTriggerVoice) ? pRegion->KeyGroup : 0;          int iKeyGroup = (iLayer == 0 && !ReleaseTriggerVoice) ? pRegion->KeyGroup : 0;
175    
176          // handle key group (a.k.a. exclusive group) conflicts          if (HandleKeyGroupConflicts) pChannel->HandleKeyGroupConflicts(iKeyGroup, itNoteOnEvent);
         if (HandleKeyGroupConflicts) {  
             if (iKeyGroup) { // if this voice / key belongs to a key group  
                 uint** ppKeyGroup = &pChannel->ActiveKeyGroups[iKeyGroup];  
                 if (*ppKeyGroup) { // if there's already an active key in that key group  
                     EngineChannel::MidiKey* pOtherKey = &pChannel->pMIDIKeyInfo[**ppKeyGroup];  
                     // kill all voices on the (other) key  
                     RTList<Voice>::Iterator itVoiceToBeKilled = pOtherKey->pActiveVoices->first();  
                     RTList<Voice>::Iterator end               = pOtherKey->pActiveVoices->end();  
                     for (; itVoiceToBeKilled != end; ++itVoiceToBeKilled) {  
                         if (itVoiceToBeKilled->Type != Voice::type_release_trigger) {  
                             itVoiceToBeKilled->Kill(itNoteOnEvent);  
                             --VoiceSpawnsLeft; //FIXME: just a hack, we should better check in StealVoice() if the voice was killed due to key conflict  
                         }  
                     }  
                 }  
             }  
         }  
177    
178          Voice::type_t VoiceType = Voice::type_normal;          Voice::type_t VoiceType = Voice::type_normal;
179    
# Line 315  namespace LinuxSampler { namespace gig { Line 298  namespace LinuxSampler { namespace gig {
298    
299          // allocate a new voice for the key          // allocate a new voice for the key
300          Pool<Voice>::Iterator itNewVoice = pKey->pActiveVoices->allocAppend();          Pool<Voice>::Iterator itNewVoice = pKey->pActiveVoices->allocAppend();
301          if (itNewVoice) {  
302              // launch the new voice          int res = InitNewVoice (
303              if (itNewVoice->Trigger(pChannel, itNoteOnEvent, pChannel->Pitch, pDimRgn, VoiceType, iKeyGroup) < 0) {                  pChannel, pDimRgn, itNoteOnEvent, VoiceType, iLayer,
304                  dmsg(4,("Voice not triggered\n"));                  iKeyGroup, ReleaseTriggerVoice, VoiceStealing, itNewVoice
305                  pKey->pActiveVoices->free(itNewVoice);          );
306              }          if (!res) return itNewVoice;
             else { // on success  
                 --VoiceSpawnsLeft;  
                 if (!pKey->Active) { // mark as active key  
                     pKey->Active = true;  
                     pKey->itSelf = pChannel->pActiveKeys->allocAppend();  
                     *pKey->itSelf = itNoteOnEvent->Param.Note.Key;  
                 }  
                 if (itNewVoice->KeyGroup) {  
                     uint** ppKeyGroup = &pChannel->ActiveKeyGroups[itNewVoice->KeyGroup];  
                     *ppKeyGroup = &*pKey->itSelf; // put key as the (new) active key to its key group  
                 }  
                 if (itNewVoice->Type == Voice::type_release_trigger_required) pKey->ReleaseTrigger = true; // mark key for the need of release triggered voice(s)  
                 return itNewVoice; // success  
             }  
         }  
         else if (VoiceStealing) {  
             // try to steal one voice  
             int result = StealVoice(pChannel, itNoteOnEvent);  
             if (!result) { // voice stolen successfully  
                 // put note-on event into voice-stealing queue, so it will be reprocessed after killed voice died  
                 RTList<Event>::Iterator itStealEvent = pVoiceStealingQueue->allocAppend();  
                 if (itStealEvent) {  
                     *itStealEvent = *itNoteOnEvent; // copy event  
                     itStealEvent->Param.Note.Layer = iLayer;  
                     itStealEvent->Param.Note.ReleaseTrigger = ReleaseTriggerVoice;  
                     pKey->VoiceTheftsQueued++;  
                 }  
                 else dmsg(1,("Voice stealing queue full!\n"));  
             }  
         }  
307    
308          return Pool<Voice>::Iterator(); // no free voice or error          return Pool<Voice>::Iterator(); // no free voice or error
309      }      }
# Line 364  namespace LinuxSampler { namespace gig { Line 317  namespace LinuxSampler { namespace gig {
317      }      }
318    
319      String Engine::Version() {      String Engine::Version() {
320          String s = "$Revision: 1.105 $";          String s = "$Revision: 1.106 $";
321          return s.substr(11, s.size() - 13); // cut dollar signs, spaces and CVS macro keyword          return s.substr(11, s.size() - 13); // cut dollar signs, spaces and CVS macro keyword
322      }      }
323    

Legend:
Removed from v.2026  
changed lines
  Added in v.2027

  ViewVC Help
Powered by ViewVC