/[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 3283 by schoenebeck, Wed Jun 21 20:59:06 2017 UTC revision 3360 by schoenebeck, Fri Oct 27 21:19:18 2017 UTC
# Line 202  namespace LinuxSampler { Line 202  namespace LinuxSampler {
202                      PostProcess(engineChannels[i]);                      PostProcess(engineChannels[i]);
203                  }                  }
204    
205                    // Just for debugging: dump the amount of free Note objects to
206                    // the terminal (note due to the static variables being used,
207                    // this is currently just intended for debugging with only one
208                    // engine channel).
209                    #if (CONFIG_DEBUG_LEVEL >= 3)
210                    {
211                        static int slice = 0;
212                        static int noteCount = -1;
213                        if (slice++ % 10 == 0) {
214                            int n = pNotePool->countFreeElements();
215                            if (n != noteCount) {
216                                noteCount = n;
217                                dmsg(1,("[%d] free Note objects count = %d\n", slice / 10, n));
218                            }
219                        }
220                    }
221                    #endif
222    
223                  // empty the engine's event list for the next audio fragment                  // empty the engine's event list for the next audio fragment
224                  ClearEventLists();                  ClearEventLists();
# Line 739  namespace LinuxSampler { Line 756  namespace LinuxSampler {
756                  // move new note to its host key                  // move new note to its host key
757                  MidiKey* pKey = &pChannel->pMIDIKeyInfo[itNewNote->hostKey];                  MidiKey* pKey = &pChannel->pMIDIKeyInfo[itNewNote->hostKey];
758                  itNewNote.moveToEndOf(pKey->pActiveNotes);                  itNewNote.moveToEndOf(pKey->pActiveNotes);
759                    pChannel->markKeyAsActive(pKey);
760    
761                  // 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
762                  itNoteOnEvent->Param.Note.ID = newNoteID;                  itNoteOnEvent->Param.Note.ID = newNoteID;
# Line 1024  namespace LinuxSampler { Line 1042  namespace LinuxSampler {
1042                  itScriptEvent->executionSlices = 0;                  itScriptEvent->executionSlices = 0;
1043                  itScriptEvent->ignoreAllWaitCalls = false;                  itScriptEvent->ignoreAllWaitCalls = false;
1044                  itScriptEvent->handlerType = pEventHandler->eventHandlerType();                  itScriptEvent->handlerType = pEventHandler->eventHandlerType();
1045                    itScriptEvent->parentHandlerID = 0;
1046                    itScriptEvent->childHandlerID[0] = 0;
1047                    itScriptEvent->autoAbortByParent = false;
1048                    itScriptEvent->forkIndex = 0;
1049                  // this is the native representation of the $EVENT_ID script variable                  // this is the native representation of the $EVENT_ID script variable
1050                  itScriptEvent->id =                  itScriptEvent->id =
1051                      (itEvent->Type == Event::type_note_on)                      (itEvent->Type == Event::type_note_on)
# Line 1136  namespace LinuxSampler { Line 1158  namespace LinuxSampler {
1158               *  @returns 0 on success, a value < 0 if no active voice could be picked for voice stealing               *  @returns 0 on success, a value < 0 if no active voice could be picked for voice stealing
1159               */               */
1160              int StealVoice(EngineChannel* pEngineChannel, Pool<Event>::Iterator& itNoteOnEvent) {              int StealVoice(EngineChannel* pEngineChannel, Pool<Event>::Iterator& itNoteOnEvent) {
1161                    dmsg(3,("StealVoice()\n"));
1162                  if (VoiceSpawnsLeft <= 0) {                  if (VoiceSpawnsLeft <= 0) {
1163                      dmsg(1,("Max. voice thefts per audio fragment reached (you may raise CONFIG_MAX_VOICES).\n"));                      dmsg(1,("Max. voice thefts per audio fragment reached (you may raise CONFIG_MAX_VOICES).\n"));
1164                      return -1;                      return -1;
# Line 1160  namespace LinuxSampler { Line 1183  namespace LinuxSampler {
1183                  int                          iChannelIndex;                  int                          iChannelIndex;
1184                  VoiceIterator                itSelectedVoice;                  VoiceIterator                itSelectedVoice;
1185    
1186                    #if CONFIG_DEVMODE
1187                    EngineChannel* pBegin = NULL; // to detect endless loop
1188                    #endif
1189    
1190                  // select engine channel                  // select engine channel
1191                  if (pLastStolenChannel) {                  if (pLastStolenChannel) {
1192                      pSelectedChannel = pLastStolenChannel;                      pSelectedChannel = pLastStolenChannel;
# Line 1202  namespace LinuxSampler { Line 1229  namespace LinuxSampler {
1229                  }                  }
1230    
1231                  #if CONFIG_DEVMODE                  #if CONFIG_DEVMODE
1232                  EngineChannel* pBegin = pSelectedChannel; // to detect endless loop                  pBegin = pSelectedChannel; // to detect endless loop
1233                  #endif // CONFIG_DEVMODE                  #endif // CONFIG_DEVMODE
1234    
1235                  while (true) { // iterate through engine channels                                          while (true) { // iterate through engine channels                        
# Line 1299  namespace LinuxSampler { Line 1326  namespace LinuxSampler {
1326                              itScriptEvent->cause.Type = (Event::type_t) -1; // some invalid type to avoid random event processing                              itScriptEvent->cause.Type = (Event::type_t) -1; // some invalid type to avoid random event processing
1327                              itScriptEvent->cause.pEngineChannel = pEngineChannel;                              itScriptEvent->cause.pEngineChannel = pEngineChannel;
1328                              itScriptEvent->cause.pMidiInputPort = pEngineChannel->GetMidiInputPort();                              itScriptEvent->cause.pMidiInputPort = pEngineChannel->GetMidiInputPort();
1329                                itScriptEvent->id = 0;
1330                              itScriptEvent->handlers[0] = pEngineChannel->pScript->handlerInit;                              itScriptEvent->handlers[0] = pEngineChannel->pScript->handlerInit;
1331                              itScriptEvent->handlers[1] = NULL;                              itScriptEvent->handlers[1] = NULL;
1332                              itScriptEvent->currentHandler = 0;                              itScriptEvent->currentHandler = 0;
1333                              itScriptEvent->executionSlices = 0;                              itScriptEvent->executionSlices = 0;
1334                              itScriptEvent->ignoreAllWaitCalls = false;                              itScriptEvent->ignoreAllWaitCalls = false;
1335                              itScriptEvent->handlerType = VM_EVENT_HANDLER_INIT;                              itScriptEvent->handlerType = VM_EVENT_HANDLER_INIT;
1336                                itScriptEvent->parentHandlerID = 0;
1337                                itScriptEvent->childHandlerID[0] = 0;
1338                                itScriptEvent->autoAbortByParent = false;
1339                                itScriptEvent->forkIndex = 0;
1340    
1341                              VMExecStatus_t res;                              VMExecStatus_t res;
1342                              size_t instructionsCount = 0;                              size_t instructionsCount = 0;
# Line 1380  namespace LinuxSampler { Line 1412  namespace LinuxSampler {
1412                          // usually there should already be a new Note object                          // usually there should already be a new Note object
1413                          NoteIterator itNote = GetNotePool()->fromID(itVoiceStealEvent->Param.Note.ID);                          NoteIterator itNote = GetNotePool()->fromID(itVoiceStealEvent->Param.Note.ID);
1414                          if (!itNote) { // should not happen, but just to be sure ...                          if (!itNote) { // should not happen, but just to be sure ...
1415                                dmsg(2,("Engine: No Note object for stolen voice!\n"));
1416                              const note_id_t noteID = LaunchNewNote(pEngineChannel, itVoiceStealEvent);                              const note_id_t noteID = LaunchNewNote(pEngineChannel, itVoiceStealEvent);
1417                              if (!noteID) {                              if (!noteID) {
1418                                  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"));
# Line 1424  namespace LinuxSampler { Line 1457  namespace LinuxSampler {
1457              void PostProcess(EngineChannel* pEngineChannel) {              void PostProcess(EngineChannel* pEngineChannel) {
1458                  EngineChannelBase<V, R, I>* pChannel =                  EngineChannelBase<V, R, I>* pChannel =
1459                      static_cast<EngineChannelBase<V, R, I>*>(pEngineChannel);                      static_cast<EngineChannelBase<V, R, I>*>(pEngineChannel);
1460                   pChannel->FreeAllInactiveKyes();                   pChannel->FreeAllInactiveKeys();
1461    
1462                  // empty the engine channel's own event lists                  // empty the engine channel's own event lists
1463                  // (only events of the current audio fragment cycle)                  // (only events of the current audio fragment cycle)
# Line 2034  namespace LinuxSampler { Line 2067  namespace LinuxSampler {
2067                          }                          }
2068                          itEvent->Param.NoteSynthParam.AbsValue = pNote->Override.Pan;                          itEvent->Param.NoteSynthParam.AbsValue = pNote->Override.Pan;
2069                          break;                          break;
2070                        case Event::synth_param_pan_time:
2071                            pNote->Override.PanTime = itEvent->Param.NoteSynthParam.AbsValue = itEvent->Param.NoteSynthParam.Delta;
2072                            break;
2073                        case Event::synth_param_pan_curve:
2074                            itEvent->Param.NoteSynthParam.AbsValue = itEvent->Param.NoteSynthParam.Delta;
2075                            pNote->Override.PanCurve = (fade_curve_t) itEvent->Param.NoteSynthParam.AbsValue;
2076                            break;
2077                      case Event::synth_param_cutoff:                      case Event::synth_param_cutoff:
2078                          pNote->Override.Cutoff = itEvent->Param.NoteSynthParam.AbsValue = itEvent->Param.NoteSynthParam.Delta;                          pNote->Override.Cutoff = itEvent->Param.NoteSynthParam.AbsValue = itEvent->Param.NoteSynthParam.Delta;
2079                          break;                          break;
# Line 2046  namespace LinuxSampler { Line 2086  namespace LinuxSampler {
2086                      case Event::synth_param_decay:                      case Event::synth_param_decay:
2087                          pNote->Override.Decay = itEvent->Param.NoteSynthParam.AbsValue = itEvent->Param.NoteSynthParam.Delta;                          pNote->Override.Decay = itEvent->Param.NoteSynthParam.AbsValue = itEvent->Param.NoteSynthParam.Delta;
2088                          break;                          break;
2089                        case Event::synth_param_sustain:
2090                            pNote->Override.Sustain = itEvent->Param.NoteSynthParam.AbsValue = itEvent->Param.NoteSynthParam.Delta;
2091                            break;
2092                      case Event::synth_param_release:                      case Event::synth_param_release:
2093                          pNote->Override.Release = itEvent->Param.NoteSynthParam.AbsValue = itEvent->Param.NoteSynthParam.Delta;                          pNote->Override.Release = itEvent->Param.NoteSynthParam.AbsValue = itEvent->Param.NoteSynthParam.Delta;
2094                          break;                          break;
2095    
2096                        case Event::synth_param_cutoff_attack:
2097                            pNote->Override.CutoffAttack = itEvent->Param.NoteSynthParam.AbsValue = itEvent->Param.NoteSynthParam.Delta;
2098                            break;
2099                        case Event::synth_param_cutoff_decay:
2100                            pNote->Override.CutoffDecay = itEvent->Param.NoteSynthParam.AbsValue = itEvent->Param.NoteSynthParam.Delta;
2101                            break;
2102                        case Event::synth_param_cutoff_sustain:
2103                            pNote->Override.CutoffSustain = itEvent->Param.NoteSynthParam.AbsValue = itEvent->Param.NoteSynthParam.Delta;
2104                            break;
2105                        case Event::synth_param_cutoff_release:
2106                            pNote->Override.CutoffRelease = itEvent->Param.NoteSynthParam.AbsValue = itEvent->Param.NoteSynthParam.Delta;
2107                            break;
2108    
2109                      case Event::synth_param_amp_lfo_depth:                      case Event::synth_param_amp_lfo_depth:
2110                          pNote->Override.AmpLFODepth = itEvent->Param.NoteSynthParam.AbsValue = itEvent->Param.NoteSynthParam.Delta;                          pNote->Override.AmpLFODepth = itEvent->Param.NoteSynthParam.AbsValue = itEvent->Param.NoteSynthParam.Delta;
2111                          break;                          break;
2112                      case Event::synth_param_amp_lfo_freq:                      case Event::synth_param_amp_lfo_freq:
2113                          pNote->Override.AmpLFOFreq = itEvent->Param.NoteSynthParam.AbsValue = itEvent->Param.NoteSynthParam.Delta;                          pNote->Override.AmpLFOFreq = itEvent->Param.NoteSynthParam.AbsValue = itEvent->Param.NoteSynthParam.Delta;
2114                          break;                          break;
2115                        case Event::synth_param_cutoff_lfo_depth:
2116                            pNote->Override.CutoffLFODepth = itEvent->Param.NoteSynthParam.AbsValue = itEvent->Param.NoteSynthParam.Delta;
2117                            break;
2118                        case Event::synth_param_cutoff_lfo_freq:
2119                            pNote->Override.CutoffLFOFreq = itEvent->Param.NoteSynthParam.AbsValue = itEvent->Param.NoteSynthParam.Delta;
2120                            break;
2121                      case Event::synth_param_pitch_lfo_depth:                      case Event::synth_param_pitch_lfo_depth:
2122                          pNote->Override.PitchLFODepth = itEvent->Param.NoteSynthParam.AbsValue = itEvent->Param.NoteSynthParam.Delta;                          pNote->Override.PitchLFODepth = itEvent->Param.NoteSynthParam.AbsValue = itEvent->Param.NoteSynthParam.Delta;
2123                          break;                          break;
# Line 2189  namespace LinuxSampler { Line 2252  namespace LinuxSampler {
2252                      }                      }
2253                      else { // on success                      else { // on success
2254                          --VoiceSpawnsLeft;                          --VoiceSpawnsLeft;
2255                          if (!pKey->Active) { // mark as active key  
2256                              pKey->Active = true;                          // should actually be superfluous now, since this is
2257                              pKey->itSelf = pChannel->pActiveKeys->allocAppend();                          // already done in LaunchNewNote()
2258                              *pKey->itSelf = itNoteOnEvent->Param.Note.Key;                          pChannel->markKeyAsActive(pKey);
2259                          }  
2260                          if (itNewVoice->Type & Voice::type_release_trigger_required) pKey->ReleaseTrigger = true; // mark key for the need of release triggered voice(s)                          if (itNewVoice->Type & Voice::type_release_trigger_required) pKey->ReleaseTrigger = true; // mark key for the need of release triggered voice(s)
2261                          return 0; // success                          return 0; // success
2262                      }                      }

Legend:
Removed from v.3283  
changed lines
  Added in v.3360

  ViewVC Help
Powered by ViewVC