/[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 271 by schoenebeck, Fri Oct 8 20:51:39 2004 UTC revision 354 by schoenebeck, Sat Jan 29 15:17:59 2005 UTC
# Line 23  Line 23 
23  #include <sstream>  #include <sstream>
24  #include "DiskThread.h"  #include "DiskThread.h"
25  #include "Voice.h"  #include "Voice.h"
26    #include "EGADSR.h"
27    
28  #include "Engine.h"  #include "Engine.h"
29    #include <malloc.h>
30    
31  namespace LinuxSampler { namespace gig {  namespace LinuxSampler { namespace gig {
32    
# Line 75  namespace LinuxSampler { namespace gig { Line 77  namespace LinuxSampler { namespace gig {
77    
78      Engine::~Engine() {      Engine::~Engine() {
79          if (pDiskThread) {          if (pDiskThread) {
80                dmsg(1,("Stopping disk thread..."));
81              pDiskThread->StopThread();              pDiskThread->StopThread();
82              delete pDiskThread;              delete pDiskThread;
83                dmsg(1,("OK\n"));
84          }          }
85    
86            if (pInstrument) Instruments.HandBack(pInstrument, this);
87    
88          if (pGig)  delete pGig;          if (pGig)  delete pGig;
89          if (pRIFF) delete pRIFF;          if (pRIFF) delete pRIFF;
90          for (uint i = 0; i < 128; i++) {          for (uint i = 0; i < 128; i++) {
# Line 87  namespace LinuxSampler { namespace gig { Line 94  namespace LinuxSampler { namespace gig {
94          for (uint i = 0; i < Event::destination_count; i++) {          for (uint i = 0; i < Event::destination_count; i++) {
95              if (pSynthesisEvents[i]) delete pSynthesisEvents[i];              if (pSynthesisEvents[i]) delete pSynthesisEvents[i];
96          }          }
         delete[] pSynthesisEvents;  
97          if (pEvents)     delete pEvents;          if (pEvents)     delete pEvents;
98          if (pCCEvents)   delete pCCEvents;          if (pCCEvents)   delete pCCEvents;
99          if (pEventQueue) delete pEventQueue;          if (pEventQueue) delete pEventQueue;
100          if (pEventPool)  delete pEventPool;          if (pEventPool)  delete pEventPool;
101          if (pVoicePool)  delete pVoicePool;          if (pVoicePool) {
102                    pVoicePool->clear();
103                    delete pVoicePool;
104            }
105          if (pActiveKeys) delete pActiveKeys;          if (pActiveKeys) delete pActiveKeys;
106          if (pSysexBuffer) delete pSysexBuffer;          if (pSysexBuffer) delete pSysexBuffer;
107          if (pEventGenerator) delete pEventGenerator;          if (pEventGenerator) delete pEventGenerator;
108          if (pMainFilterParameters) delete[] pMainFilterParameters;          if (pMainFilterParameters) delete[] pMainFilterParameters;
109          if (pBasicFilterParameters) delete[] pBasicFilterParameters;          if (pBasicFilterParameters) delete[] pBasicFilterParameters;
110          if (pSynthesisParameters[0]) delete[] pSynthesisParameters[0];          if (pSynthesisParameters[0]) free(pSynthesisParameters[0]);
111          if (pVoiceStealingQueue) delete pVoiceStealingQueue;          if (pVoiceStealingQueue) delete pVoiceStealingQueue;
112      }      }
113    
# Line 157  namespace LinuxSampler { namespace gig { Line 166  namespace LinuxSampler { namespace gig {
166          ActiveVoiceCount    = 0;          ActiveVoiceCount    = 0;
167          ActiveVoiceCountMax = 0;          ActiveVoiceCountMax = 0;
168          GlobalVolume        = 1.0;          GlobalVolume        = 1.0;
169            CurrentKeyDimension = 0;
170    
171          // reset voice stealing parameters          // reset voice stealing parameters
172          itLastStolenVoice = RTList<Voice>::Iterator();          itLastStolenVoice = RTList<Voice>::Iterator();
# Line 313  namespace LinuxSampler { namespace gig { Line 323  namespace LinuxSampler { namespace gig {
323          this->MaxSamplesPerCycle      = pAudioOutputDevice->MaxSamplesPerCycle();          this->MaxSamplesPerCycle      = pAudioOutputDevice->MaxSamplesPerCycle();
324          this->SampleRate              = pAudioOutputDevice->SampleRate();          this->SampleRate              = pAudioOutputDevice->SampleRate();
325    
326            // FIXME: audio drivers with varying fragment sizes might be a problem here
327            MaxFadeOutPos = MaxSamplesPerCycle - int(double(SampleRate) * EG_MIN_RELEASE_TIME) - 1;
328            if (MaxFadeOutPos < 0)
329                throw LinuxSamplerException("EG_MIN_RELEASE_TIME in EGADSR.h to big for current audio fragment size / sampling rate!");
330    
331          // (re)create disk thread          // (re)create disk thread
332          if (this->pDiskThread) {          if (this->pDiskThread) {
333                dmsg(1,("Stopping disk thread..."));
334              this->pDiskThread->StopThread();              this->pDiskThread->StopThread();
335              delete this->pDiskThread;              delete this->pDiskThread;
336                dmsg(1,("OK\n"));
337          }          }
338          this->pDiskThread = new DiskThread(((pAudioOut->MaxSamplesPerCycle() << MAX_PITCH) << 1) + 6); //FIXME: assuming stereo          this->pDiskThread = new DiskThread(((pAudioOut->MaxSamplesPerCycle() << MAX_PITCH) << 1) + 6); //FIXME: assuming stereo
339          if (!pDiskThread) {          if (!pDiskThread) {
# Line 335  namespace LinuxSampler { namespace gig { Line 352  namespace LinuxSampler { namespace gig {
352          pEventGenerator = new EventGenerator(pAudioOut->SampleRate());          pEventGenerator = new EventGenerator(pAudioOut->SampleRate());
353    
354          // (re)allocate synthesis parameter matrix          // (re)allocate synthesis parameter matrix
355          if (pSynthesisParameters[0]) delete[] pSynthesisParameters[0];          if (pSynthesisParameters[0]) free(pSynthesisParameters[0]);
356          pSynthesisParameters[0] = new float[Event::destination_count * pAudioOut->MaxSamplesPerCycle()];          pSynthesisParameters[0] = (float *) memalign(16,(Event::destination_count * sizeof(float) * pAudioOut->MaxSamplesPerCycle()));
357          for (int dst = 1; dst < Event::destination_count; dst++)          for (int dst = 1; dst < Event::destination_count; dst++)
358              pSynthesisParameters[dst] = pSynthesisParameters[dst - 1] + pAudioOut->MaxSamplesPerCycle();              pSynthesisParameters[dst] = pSynthesisParameters[dst - 1] + pAudioOut->MaxSamplesPerCycle();
359    
# Line 392  namespace LinuxSampler { namespace gig { Line 409  namespace LinuxSampler { namespace gig {
409          }          }
410    
411    
412            // update time of start and end of this audio fragment (as events' time stamps relate to this)
413            pEventGenerator->UpdateFragmentTime(Samples);
414    
415    
416          // empty the event lists for the new fragment          // empty the event lists for the new fragment
417          pEvents->clear();          pEvents->clear();
418          pCCEvents->clear();          pCCEvents->clear();
# Line 406  namespace LinuxSampler { namespace gig { Line 427  namespace LinuxSampler { namespace gig {
427              }              }
428          }          }
429    
         // read and copy events from input queue  
         Event event = pEventGenerator->CreateEvent();  
         while (true) {  
             if (!pEventQueue->pop(&event) || pEvents->poolIsEmpty()) break;  
             *pEvents->allocAppend() = event;  
         }  
   
430    
431          // update time of start and end of this audio fragment (as events' time stamps relate to this)          // get all events from the input event queue which belong to the current fragment
432          pEventGenerator->UpdateFragmentTime(Samples);          {
433                RingBuffer<Event>::NonVolatileReader eventQueueReader = pEventQueue->get_non_volatile_reader();
434                Event* pEvent;
435                while (true) {
436                    // get next event from input event queue
437                    if (!(pEvent = eventQueueReader.pop())) break;
438                    // if younger event reached, ignore that and all subsequent ones for now
439                    if (pEvent->FragmentPos() >= Samples) {
440                        eventQueueReader--;
441                        dmsg(2,("Younger Event, pos=%d ,Samples=%d!\n",pEvent->FragmentPos(),Samples));
442                        pEvent->ResetFragmentPos();
443                        break;
444                    }
445                    // copy event to internal event list
446                    if (pEvents->poolIsEmpty()) {
447                        dmsg(1,("Event pool emtpy!\n"));
448                        break;
449                    }
450                    *pEvents->allocAppend() = *pEvent;
451                }
452                eventQueueReader.free(); // free all copied events from input queue
453            }
454    
455    
456          // process events          // process events
# Line 466  namespace LinuxSampler { namespace gig { Line 501  namespace LinuxSampler { namespace gig {
501                      itVoice->Render(Samples);                      itVoice->Render(Samples);
502                      if (itVoice->IsActive()) active_voices++; // still active                      if (itVoice->IsActive()) active_voices++; // still active
503                      else { // voice reached end, is now inactive                      else { // voice reached end, is now inactive
504                          KillVoiceImmediately(itVoice); // remove voice from the list of active voices                          FreeVoice(itVoice); // remove voice from the list of active voices
505                      }                      }
506                  }                  }
507              }              }
# Line 480  namespace LinuxSampler { namespace gig { Line 515  namespace LinuxSampler { namespace gig {
515              for (; itVoiceStealEvent != end; ++itVoiceStealEvent) {              for (; itVoiceStealEvent != end; ++itVoiceStealEvent) {
516                  Pool<Voice>::Iterator itNewVoice = LaunchVoice(itVoiceStealEvent, itVoiceStealEvent->Param.Note.Layer, itVoiceStealEvent->Param.Note.ReleaseTrigger, false);                  Pool<Voice>::Iterator itNewVoice = LaunchVoice(itVoiceStealEvent, itVoiceStealEvent->Param.Note.Layer, itVoiceStealEvent->Param.Note.ReleaseTrigger, false);
517                  if (itNewVoice) {                  if (itNewVoice) {
518                      itNewVoice->Render(Samples);                      for (; itNewVoice; itNewVoice = itNewVoice->itChildVoice) {
519                      if (itNewVoice->IsActive()) active_voices++; // still active                          itNewVoice->Render(Samples);
520                      else { // voice reached end, is now inactive                          if (itNewVoice->IsActive()) active_voices++; // still active
521                          KillVoiceImmediately(itNewVoice); // remove voice from the list of active voices                          else { // voice reached end, is now inactive
522                                FreeVoice(itNewVoice); // remove voice from the list of active voices
523                            }
524                      }                      }
525                  }                  }
526                  else dmsg(1,("Ouch, voice stealing didn't work out!\n"));                  else dmsg(1,("gig::Engine: ERROR, voice stealing didn't work out!\n"));
527              }              }
528          }          }
529          // reset voice stealing for the new fragment          // reset voice stealing for the new fragment
# Line 495  namespace LinuxSampler { namespace gig { Line 532  namespace LinuxSampler { namespace gig {
532          iuiLastStolenKey  = RTList<uint>::Iterator();          iuiLastStolenKey  = RTList<uint>::Iterator();
533    
534    
535            // free all keys which have no active voices left
536            {
537                RTList<uint>::Iterator iuiKey = pActiveKeys->first();
538                RTList<uint>::Iterator end    = pActiveKeys->end();
539                while (iuiKey != end) { // iterate through all active keys
540                    midi_key_info_t* pKey = &pMIDIKeyInfo[*iuiKey];
541                    ++iuiKey;
542                    if (pKey->pActiveVoices->isEmpty()) FreeKey(pKey);
543                    #if DEVMODE
544                    else { // FIXME: should be removed before the final release (purpose: just a sanity check for debugging)
545                        RTList<Voice>::Iterator itVoice     = pKey->pActiveVoices->first();
546                        RTList<Voice>::Iterator itVoicesEnd = pKey->pActiveVoices->end();
547                        for (; itVoice != itVoicesEnd; ++itVoice) { // iterate through all voices on this key
548                            if (itVoice->itKillEvent) {
549                                dmsg(1,("gig::Engine: ERROR, killed voice survived !!!\n"));
550                            }
551                        }
552                    }
553                    #endif // DEVMODE
554                }
555            }
556    
557    
558          // write that to the disk thread class so that it can print it          // write that to the disk thread class so that it can print it
559          // on the console for debugging purposes          // on the console for debugging purposes
560          ActiveVoiceCount = active_voices;          ActiveVoiceCount = active_voices;
# Line 603  namespace LinuxSampler { namespace gig { Line 663  namespace LinuxSampler { namespace gig {
663       *  @param itNoteOnEvent - key, velocity and time stamp of the event       *  @param itNoteOnEvent - key, velocity and time stamp of the event
664       */       */
665      void Engine::ProcessNoteOn(Pool<Event>::Iterator& itNoteOnEvent) {      void Engine::ProcessNoteOn(Pool<Event>::Iterator& itNoteOnEvent) {
666          midi_key_info_t* pKey = &pMIDIKeyInfo[itNoteOnEvent->Param.Note.Key];  
667            const int key = itNoteOnEvent->Param.Note.Key;
668    
669            // Change key dimension value if key is in keyswitching area
670            if (key >= pInstrument->DimensionKeyRange.low && key <= pInstrument->DimensionKeyRange.high)
671                CurrentKeyDimension = ((key - pInstrument->DimensionKeyRange.low) * 128) /
672                    (pInstrument->DimensionKeyRange.high - pInstrument->DimensionKeyRange.low + 1);
673    
674            midi_key_info_t* pKey = &pMIDIKeyInfo[key];
675    
676          pKey->KeyPressed = true; // the MIDI key was now pressed down          pKey->KeyPressed = true; // the MIDI key was now pressed down
677    
# Line 621  namespace LinuxSampler { namespace gig { Line 689  namespace LinuxSampler { namespace gig {
689          RTList<Event>::Iterator itNoteOnEventOnKeyList = itNoteOnEvent.moveToEndOf(pKey->pEvents);          RTList<Event>::Iterator itNoteOnEventOnKeyList = itNoteOnEvent.moveToEndOf(pKey->pEvents);
690    
691          // allocate and trigger a new voice for the key          // allocate and trigger a new voice for the key
692          LaunchVoice(itNoteOnEventOnKeyList);          LaunchVoice(itNoteOnEventOnKeyList, 0, false, true);
693      }      }
694    
695      /**      /**
# Line 647  namespace LinuxSampler { namespace gig { Line 715  namespace LinuxSampler { namespace gig {
715    
716          // spawn release triggered voice(s) if needed          // spawn release triggered voice(s) if needed
717          if (pKey->ReleaseTrigger) {          if (pKey->ReleaseTrigger) {
718              LaunchVoice(itNoteOffEventOnKeyList, 0, true);              LaunchVoice(itNoteOffEventOnKeyList, 0, true, false); //FIXME: for the moment we don't perform voice stealing for release triggered samples
719              pKey->ReleaseTrigger = false;              pKey->ReleaseTrigger = false;
720          }          }
721      }      }
# Line 677  namespace LinuxSampler { namespace gig { Line 745  namespace LinuxSampler { namespace gig {
745       *                               when there is no free voice       *                               when there is no free voice
746       *                               (optional, default = true)       *                               (optional, default = true)
747       *  @returns pointer to new voice or NULL if there was no free voice or       *  @returns pointer to new voice or NULL if there was no free voice or
748       *           if an error occured while trying to trigger the new voice       *           if the voice wasn't triggered (for example when no region is
749         *           defined for the given key).
750       */       */
751      Pool<Voice>::Iterator Engine::LaunchVoice(Pool<Event>::Iterator& itNoteOnEvent, int iLayer, bool ReleaseTriggerVoice, bool VoiceStealing) {      Pool<Voice>::Iterator Engine::LaunchVoice(Pool<Event>::Iterator& itNoteOnEvent, int iLayer, bool ReleaseTriggerVoice, bool VoiceStealing) {
752          midi_key_info_t* pKey = &pMIDIKeyInfo[itNoteOnEvent->Param.Note.Key];          midi_key_info_t* pKey = &pMIDIKeyInfo[itNoteOnEvent->Param.Note.Key];
# Line 686  namespace LinuxSampler { namespace gig { Line 755  namespace LinuxSampler { namespace gig {
755          Pool<Voice>::Iterator itNewVoice = pKey->pActiveVoices->allocAppend();          Pool<Voice>::Iterator itNewVoice = pKey->pActiveVoices->allocAppend();
756          if (itNewVoice) {          if (itNewVoice) {
757              // launch the new voice              // launch the new voice
758              if (itNewVoice->Trigger(itNoteOnEvent, this->Pitch, this->pInstrument, iLayer, ReleaseTriggerVoice) < 0) {              if (itNewVoice->Trigger(itNoteOnEvent, this->Pitch, this->pInstrument, iLayer, ReleaseTriggerVoice, VoiceStealing) < 0) {
759                  dmsg(1,("Triggering new voice failed!\n"));                  dmsg(4,("Voice not triggered\n"));
760                  pKey->pActiveVoices->free(itNewVoice);                  pKey->pActiveVoices->free(itNewVoice);
761              }              }
762              else { // on success              else { // on success
# Line 716  namespace LinuxSampler { namespace gig { Line 785  namespace LinuxSampler { namespace gig {
785                  return itNewVoice; // success                  return itNewVoice; // success
786              }              }
787          }          }
788          else if (VoiceStealing) StealVoice(itNoteOnEvent, iLayer, ReleaseTriggerVoice); // no free voice left, so steal one          else if (VoiceStealing) {
789                // first, get total amount of required voices (dependant on amount of layers)
790                ::gig::Region* pRegion = pInstrument->GetRegion(itNoteOnEvent->Param.Note.Key);
791                if (!pRegion) return Pool<Voice>::Iterator(); // nothing defined for this MIDI key, so no voice needed
792                int voicesRequired = pRegion->Layers;
793    
794                // now steal the (remaining) amount of voices
795                for (int i = iLayer; i < voicesRequired; i++)
796                    StealVoice(itNoteOnEvent);
797    
798                // put note-on event into voice-stealing queue, so it will be reprocessed after killed voice died
799                RTList<Event>::Iterator itStealEvent = pVoiceStealingQueue->allocAppend();
800                if (itStealEvent) {
801                    *itStealEvent = *itNoteOnEvent; // copy event
802                    itStealEvent->Param.Note.Layer = iLayer;
803                    itStealEvent->Param.Note.ReleaseTrigger = ReleaseTriggerVoice;
804                }
805                else dmsg(1,("Voice stealing queue full!\n"));
806            }
807    
808          return Pool<Voice>::Iterator(); // no free voice or error          return Pool<Voice>::Iterator(); // no free voice or error
809      }      }
# Line 727  namespace LinuxSampler { namespace gig { Line 814  namespace LinuxSampler { namespace gig {
814       *  voice stealing and postpone the note-on event until the selected       *  voice stealing and postpone the note-on event until the selected
815       *  voice actually died.       *  voice actually died.
816       *       *
817       *  @param itNoteOnEvent       - key, velocity and time stamp of the event       *  @param itNoteOnEvent - key, velocity and time stamp of the event
      *  @param iLayer              - layer index for the new voice  
      *  @param ReleaseTriggerVoice - if new voice is a release triggered voice  
818       */       */
819      void Engine::StealVoice(Pool<Event>::Iterator& itNoteOnEvent, int iLayer, bool ReleaseTriggerVoice) {      void Engine::StealVoice(Pool<Event>::Iterator& itNoteOnEvent) {
820          if (!pEventPool->poolIsEmpty()) {          if (!pEventPool->poolIsEmpty()) {
821    
822              RTList<uint>::Iterator  iuiOldestKey;              RTList<uint>::Iterator  iuiOldestKey;
# Line 773  namespace LinuxSampler { namespace gig { Line 858  namespace LinuxSampler { namespace gig {
858                                  midi_key_info_t* pOldestKey = &pMIDIKeyInfo[*iuiOldestKey];                                  midi_key_info_t* pOldestKey = &pMIDIKeyInfo[*iuiOldestKey];
859                                  itOldestVoice = pOldestKey->pActiveVoices->first();                                  itOldestVoice = pOldestKey->pActiveVoices->first();
860                              }                              }
861                              else { // too less voices, even for voice stealing                              else {
862                                  dmsg(1,("Voice overflow! - You might recompile with higher MAX_AUDIO_VOICES!\n"));                                  dmsg(1,("gig::Engine: Warning, too less voices, even for voice stealing! - Better recompile with higher MAX_AUDIO_VOICES.\n"));
863                                  return;                                  return;
864                              }                              }
865                          }                          }
# Line 796  namespace LinuxSampler { namespace gig { Line 881  namespace LinuxSampler { namespace gig {
881                  }                  }
882              }              }
883    
884                //FIXME: can be removed, just a sanity check for debugging
885                if (!itOldestVoice->IsActive()) dmsg(1,("gig::Engine: ERROR, tried to steal a voice which was not active !!!\n"));
886    
887              // now kill the selected voice              // now kill the selected voice
888              itOldestVoice->Kill(itNoteOnEvent);              itOldestVoice->Kill(itNoteOnEvent);
889              // remember which voice on which key we stole, so we can simply proceed for the next voice stealing              // remember which voice on which key we stole, so we can simply proceed for the next voice stealing
890              this->itLastStolenVoice = itOldestVoice;              this->itLastStolenVoice = itOldestVoice;
891              this->iuiLastStolenKey = iuiOldestKey;              this->iuiLastStolenKey = iuiOldestKey;
             // 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;  
             }  
             else dmsg(1,("Voice stealing queue full!\n"));  
892          }          }
893          else dmsg(1,("Event pool emtpy!\n"));          else dmsg(1,("Event pool emtpy!\n"));
894      }      }
895    
896      /**      /**
897       *  Immediately kills the voice given with pVoice (no matter if sustain is       *  Removes the given voice from the MIDI key's list of active voices.
898       *  pressed or not) and removes it from the MIDI key's list of active voice.       *  This method will be called when a voice went inactive, e.g. because
899       *  This method will e.g. be called if a voice went inactive by itself.       *  it finished to playback its sample, finished its release stage or
900         *  just was killed.
901       *       *
902       *  @param itVoice - points to the voice to be killed       *  @param itVoice - points to the voice to be freed
903       */       */
904      void Engine::KillVoiceImmediately(Pool<Voice>::Iterator& itVoice) {      void Engine::FreeVoice(Pool<Voice>::Iterator& itVoice) {
905          if (itVoice) {          if (itVoice) {
             if (itVoice->IsActive()) itVoice->KillImmediately();  
   
906              midi_key_info_t* pKey = &pMIDIKeyInfo[itVoice->MIDIKey];              midi_key_info_t* pKey = &pMIDIKeyInfo[itVoice->MIDIKey];
907    
908              uint keygroup = itVoice->KeyGroup;              uint keygroup = itVoice->KeyGroup;
# Line 831  namespace LinuxSampler { namespace gig { Line 910  namespace LinuxSampler { namespace gig {
910              // free the voice object              // free the voice object
911              pVoicePool->free(itVoice);              pVoicePool->free(itVoice);
912    
913              // check if there are no voices left on the MIDI key and update the key info if so              // if no other voices left and member of a key group, remove from key group
914              if (pKey->pActiveVoices->isEmpty()) {              if (pKey->pActiveVoices->isEmpty() && keygroup) {
915                  if (keygroup) { // if voice / key belongs to a key group                  uint** ppKeyGroup = &ActiveKeyGroups[keygroup];
916                      uint** ppKeyGroup = &ActiveKeyGroups[keygroup];                  if (*ppKeyGroup == &*pKey->itSelf) *ppKeyGroup = NULL; // remove key from key group
                     if (*ppKeyGroup == &*pKey->itSelf) *ppKeyGroup = NULL; // remove key from key group  
                 }  
                 pKey->Active = false;  
                 pActiveKeys->free(pKey->itSelf); // remove key from list of active keys  
                 pKey->itSelf = RTList<uint>::Iterator();  
                 pKey->ReleaseTrigger = false;  
                 pKey->pEvents->clear();  
                 dmsg(3,("Key has no more voices now\n"));  
917              }              }
918          }          }
919          else std::cerr << "Couldn't release voice! (pVoice == NULL)\n" << std::flush;          else std::cerr << "Couldn't release voice! (!itVoice)\n" << std::flush;
920        }
921    
922        /**
923         *  Called when there's no more voice left on a key, this call will
924         *  update the key info respectively.
925         *
926         *  @param pKey - key which is now inactive
927         */
928        void Engine::FreeKey(midi_key_info_t* pKey) {
929            if (pKey->pActiveVoices->isEmpty()) {
930                pKey->Active = false;
931                pActiveKeys->free(pKey->itSelf); // remove key from list of active keys
932                pKey->itSelf = RTList<uint>::Iterator();
933                pKey->ReleaseTrigger = false;
934                pKey->pEvents->clear();
935                dmsg(3,("Key has no more voices now\n"));
936            }
937            else dmsg(1,("gig::Engine: Oops, tried to free a key which contains voices.\n"));
938      }      }
939    
940      /**      /**
# Line 1095  namespace LinuxSampler { namespace gig { Line 1184  namespace LinuxSampler { namespace gig {
1184      }      }
1185    
1186      String Engine::Version() {      String Engine::Version() {
1187          String s = "$Revision: 1.15 $";          String s = "$Revision: 1.22 $";
1188          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
1189      }      }
1190    

Legend:
Removed from v.271  
changed lines
  Added in v.354

  ViewVC Help
Powered by ViewVC