/[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 3204 by schoenebeck, Fri May 19 14:23:12 2017 UTC revision 3205 by schoenebeck, Wed May 24 20:05:38 2017 UTC
# Line 676  namespace LinuxSampler { Line 676  namespace LinuxSampler {
676               * @param pNoteOnEvent - event which caused this               * @param pNoteOnEvent - event which caused this
677               * @returns new note's unique ID (or zero on error)               * @returns new note's unique ID (or zero on error)
678               */               */
679              note_id_t LaunchNewNote(LinuxSampler::EngineChannel* pEngineChannel, Event* pNoteOnEvent) OVERRIDE {              note_id_t LaunchNewNote(LinuxSampler::EngineChannel* pEngineChannel, Pool<Event>::Iterator& itNoteOnEvent) OVERRIDE {
680                  EngineChannelBase<V, R, I>* pChannel = static_cast<EngineChannelBase<V, R, I>*>(pEngineChannel);                  EngineChannelBase<V, R, I>* pChannel = static_cast<EngineChannelBase<V, R, I>*>(pEngineChannel);
681                  Pool< Note<V> >* pNotePool = GetNotePool();                  Pool< Note<V> >* pNotePool = GetNotePool();
682    
# Line 691  namespace LinuxSampler { Line 691  namespace LinuxSampler {
691                  const note_id_t newNoteID = pNotePool->getID(itNewNote);                  const note_id_t newNoteID = pNotePool->getID(itNewNote);
692    
693                  // remember the engine's time when this note was triggered exactly                  // remember the engine's time when this note was triggered exactly
694                  itNewNote->triggerSchedTime = pNoteOnEvent->SchedTime();                  itNewNote->triggerSchedTime = itNoteOnEvent->SchedTime();
695    
696                  // usually the new note (and its subsequent voices) will be                  // usually the new note (and its subsequent voices) will be
697                  // allocated on the key provided by the event's note number,                  // allocated on the key provided by the event's note number,
# Line 699  namespace LinuxSampler { Line 699  namespace LinuxSampler {
699                  // note, but rather a child note, then this new note will be                  // note, but rather a child note, then this new note will be
700                  // allocated on the parent note's key instead in order to                  // allocated on the parent note's key instead in order to
701                  // release the child note simultaniously with its parent note                  // release the child note simultaniously with its parent note
702                  itNewNote->hostKey = pNoteOnEvent->Param.Note.Key;                  itNewNote->hostKey = itNoteOnEvent->Param.Note.Key;
703    
704                  // in case this new note was requested to be a child note,                  // in case this new note was requested to be a child note,
705                  // then retrieve its parent note and link them with each other                  // then retrieve its parent note and link them with each other
706                  const note_id_t parentNoteID = pNoteOnEvent->Param.Note.ParentNoteID;                  const note_id_t parentNoteID = itNoteOnEvent->Param.Note.ParentNoteID;
707                  if (parentNoteID) {                  if (parentNoteID) {
708                      NoteIterator itParentNote = pNotePool->fromID(parentNoteID);                                              NoteIterator itParentNote = pNotePool->fromID(parentNoteID);                        
709                      if (itParentNote) {                      if (itParentNote) {
# Line 731  namespace LinuxSampler { Line 731  namespace LinuxSampler {
731                  dmsg(2,("Launched new note on host key %d\n", itNewNote->hostKey));                  dmsg(2,("Launched new note on host key %d\n", itNewNote->hostKey));
732    
733                  // copy event which caused this note                  // copy event which caused this note
734                  itNewNote->cause = *pNoteOnEvent;                  itNewNote->cause = *itNoteOnEvent;
735                  itNewNote->eventID = pEventPool->getID(pNoteOnEvent);                  itNewNote->eventID = pEventPool->getID(itNoteOnEvent);
736                    if (!itNewNote->eventID) {
737                        dmsg(0,("Engine: No valid event ID resolved for note. This is a bug!!!\n"));
738                    }
739    
740                  // move new note to its host key                  // move new note to its host key
741                  MidiKey* pKey = &pChannel->pMIDIKeyInfo[itNewNote->hostKey];                  MidiKey* pKey = &pChannel->pMIDIKeyInfo[itNewNote->hostKey];
742                  itNewNote.moveToEndOf(pKey->pActiveNotes);                  itNewNote.moveToEndOf(pKey->pActiveNotes);
743    
744                  // assign unique note ID of this new note to the original note on event                  // assign unique note ID of this new note to the original note on event
745                  pNoteOnEvent->Param.Note.ID = newNoteID;                  itNoteOnEvent->Param.Note.ID = newNoteID;
746    
747                  return newNoteID; // success                  return newNoteID; // success
748              }              }
# Line 1013  namespace LinuxSampler { Line 1016  namespace LinuxSampler {
1016    
1017                  // initialize/reset other members                  // initialize/reset other members
1018                  itScriptEvent->cause = *itEvent;                  itScriptEvent->cause = *itEvent;
1019                    itScriptEvent->scheduleTime = itEvent->SchedTime();
1020                  itScriptEvent->currentHandler = 0;                  itScriptEvent->currentHandler = 0;
1021                  itScriptEvent->executionSlices = 0;                  itScriptEvent->executionSlices = 0;
1022                  itScriptEvent->ignoreAllWaitCalls = false;                  itScriptEvent->ignoreAllWaitCalls = false;
# Line 1359  namespace LinuxSampler { Line 1363  namespace LinuxSampler {
1363                          // usually there should already be a new Note object                          // usually there should already be a new Note object
1364                          NoteIterator itNote = GetNotePool()->fromID(itVoiceStealEvent->Param.Note.ID);                          NoteIterator itNote = GetNotePool()->fromID(itVoiceStealEvent->Param.Note.ID);
1365                          if (!itNote) { // should not happen, but just to be sure ...                          if (!itNote) { // should not happen, but just to be sure ...
1366                              const note_id_t noteID = LaunchNewNote(pEngineChannel, &*itVoiceStealEvent);                              const note_id_t noteID = LaunchNewNote(pEngineChannel, itVoiceStealEvent);
1367                              if (!noteID) {                              if (!noteID) {
1368                                  dmsg(1,("Engine: Voice stealing failed; No Note object and Note pool empty!\n"));                                  dmsg(1,("Engine: Voice stealing failed; No Note object and Note pool empty!\n"));
1369                                  continue;                                  continue;
# Line 1836  namespace LinuxSampler { Line 1840  namespace LinuxSampler {
1840                                          itPseudoNoteOnEvent->Param.Note.Key      = i;                                          itPseudoNoteOnEvent->Param.Note.Key      = i;
1841                                          itPseudoNoteOnEvent->Param.Note.Velocity = pOtherKey->Velocity;                                          itPseudoNoteOnEvent->Param.Note.Velocity = pOtherKey->Velocity;
1842                                          // assign a new note to this note-on event                                          // assign a new note to this note-on event
1843                                          if (LaunchNewNote(pChannel, &*itPseudoNoteOnEvent)) {                                          if (LaunchNewNote(pChannel, itPseudoNoteOnEvent)) {
1844                                              // allocate and trigger new voice(s) for the other key                                              // allocate and trigger new voice(s) for the other key
1845                                              TriggerNewVoices(pChannel, itPseudoNoteOnEvent, false);                                              TriggerNewVoices(pChannel, itPseudoNoteOnEvent, false);
1846                                          }                                          }
# Line 1923  namespace LinuxSampler { Line 1927  namespace LinuxSampler {
1927                  // spawn release triggered voice(s) if needed                  // spawn release triggered voice(s) if needed
1928                  if (pKey->ReleaseTrigger && pChannel->pInstrument) {                  if (pKey->ReleaseTrigger && pChannel->pInstrument) {
1929                      // assign a new note to this release event                      // assign a new note to this release event
1930                      if (LaunchNewNote(pChannel, &*itEvent)) {                      if (LaunchNewNote(pChannel, itEvent)) {
1931                          // allocate and trigger new release voice(s)                          // allocate and trigger new release voice(s)
1932                          TriggerReleaseVoices(pChannel, itEvent);                          TriggerReleaseVoices(pChannel, itEvent);
1933                      }                      }

Legend:
Removed from v.3204  
changed lines
  Added in v.3205

  ViewVC Help
Powered by ViewVC