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

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

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

revision 2879 by schoenebeck, Tue Apr 19 14:07:53 2016 UTC revision 2927 by schoenebeck, Thu Jun 30 16:44:46 2016 UTC
# Line 771  namespace LinuxSampler { Line 771  namespace LinuxSampler {
771                      //                      //
772                      // FIXME: it would probably be better to just schedule newly spawned script executions here and then execute them altogether with already suspended ones all at once in order of all their scheduled timing                      // FIXME: it would probably be better to just schedule newly spawned script executions here and then execute them altogether with already suspended ones all at once in order of all their scheduled timing
773                      for (RTList<Event>::Iterator itEvent = pChannel->pEvents->first(),                      for (RTList<Event>::Iterator itEvent = pChannel->pEvents->first(),
774                          end = pChannel->pEvents->end(); itEvent != end; ++itEvent)                          end = pChannel->pEvents->end(); itEvent != end; )
775                      {                      {
776                            //HACK: avoids iterator invalidation which might happen below since an instrument script might drop an event by direct raw pointer access (it would be considerable to extend the Iterator class to detect and circumvent this case by checking the "reincarnation" member variable).
777                            RTList<Event>::Iterator itNext = itEvent;
778                            ++itNext;
779    
780                          switch (itEvent->Type) {                          switch (itEvent->Type) {
781                              case Event::type_note_on:                              case Event::type_note_on:
782                                  if (pChannel->pScript->handlerNote)                                  if (pChannel->pScript->handlerNote)
# Line 792  namespace LinuxSampler { Line 796  namespace LinuxSampler {
796                                  //TODO: ...                                  //TODO: ...
797                                  break;                                  break;
798                          }                          }
799    
800                            // see HACK comment above
801                            itEvent = itNext;
802                      }                      }
803    
804                      // this has to be run again, since the newly spawned scripts                      // this has to be run again, since the newly spawned scripts
# Line 1780  namespace LinuxSampler { Line 1787  namespace LinuxSampler {
1787                  // if no solo mode (the usual case) or if solo mode and no other key pressed, then release voices on this key if needed                  // if no solo mode (the usual case) or if solo mode and no other key pressed, then release voices on this key if needed
1788                  if (bShouldRelease) {                  if (bShouldRelease) {
1789                      itNoteOffEventOnKeyList->Type = Event::type_release; // transform event type                      itNoteOffEventOnKeyList->Type = Event::type_release; // transform event type
   
1790                      // spawn release triggered voice(s) if needed                      // spawn release triggered voice(s) if needed
1791                      if (pKey->ReleaseTrigger && pChannel->pInstrument) {                      ProcessReleaseTrigger(pChannel, itNoteOffEventOnKeyList, pKey);
                         // assign a new note to this release event  
                         if (LaunchNewNote(pChannel, &*itNoteOffEventOnKeyList)) {  
                             // allocate and trigger new release voice(s)  
                             TriggerReleaseVoices(pChannel, itNoteOffEventOnKeyList);  
                         }  
                         pKey->ReleaseTrigger = false;  
                     }  
1792                  }                  }
1793    
1794                  // if neither a voice was spawned or postponed on this key then remove note off event from key again                  // if neither a voice was spawned or postponed on this key then remove note off event from key again
# Line 1800  namespace LinuxSampler { Line 1799  namespace LinuxSampler {
1799              }              }
1800    
1801              /**              /**
1802                 * Called on sustain pedal up events to check and if required,
1803                 * launch release trigger voices on the respective active key.
1804                 *
1805                 * @param pEngineChannel - engine channel on which this event occurred on
1806                 * @param itEvent - release trigger event (contains note number)
1807                 */
1808                virtual void ProcessReleaseTrigger(EngineChannel* pEngineChannel, RTList<Event>::Iterator& itEvent) OVERRIDE {
1809                    EngineChannelBase<V, R, I>* pChannel = static_cast<EngineChannelBase<V, R, I>*>(pEngineChannel);
1810    
1811                    const int iKey = itEvent->Param.Note.Key;
1812                    if (iKey < 0 || iKey > 127) return; // ignore event, key outside allowed key range
1813    
1814                    MidiKey* pKey = &pChannel->pMIDIKeyInfo[iKey];
1815    
1816                    ProcessReleaseTrigger(pChannel, itEvent, pKey);
1817                }
1818    
1819                /**
1820                 * Called on note-off and sustain pedal up events to check and if
1821                 * required, launch release trigger voices on the respective active
1822                 * key.
1823                 *
1824                 * @param pEngineChannel - engine channel on which this event occurred on
1825                 * @param itEvent - note off event / release trigger event
1826                 * @param pKey - key on which the release trigger voices shall be spawned
1827                 */
1828                inline void ProcessReleaseTrigger(EngineChannelBase<V, R, I>* pChannel, RTList<Event>::Iterator& itEvent, MidiKey* pKey) {
1829                    // spawn release triggered voice(s) if needed
1830                    if (pKey->ReleaseTrigger && pChannel->pInstrument) {
1831                        // assign a new note to this release event
1832                        if (LaunchNewNote(pChannel, &*itEvent)) {
1833                            // allocate and trigger new release voice(s)
1834                            TriggerReleaseVoices(pChannel, itEvent);
1835                        }
1836                        pKey->ReleaseTrigger = false;
1837                    }
1838                }
1839    
1840                /**
1841               *  Reset all voices and disk thread and clear input event queue and all               *  Reset all voices and disk thread and clear input event queue and all
1842               *  control and status variables. This method is protected by a mutex.               *  control and status variables. This method is protected by a mutex.
1843               */               */

Legend:
Removed from v.2879  
changed lines
  Added in v.2927

  ViewVC Help
Powered by ViewVC