/[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 424 by schoenebeck, Fri Mar 4 22:54:11 2005 UTC revision 438 by persson, Wed Mar 9 22:12:15 2005 UTC
# Line 56  namespace LinuxSampler { namespace gig { Line 56  namespace LinuxSampler { namespace gig {
56          // check if there's already an engine for the given audio output device          // check if there's already an engine for the given audio output device
57          if (engines.count(pDevice)) {          if (engines.count(pDevice)) {
58              dmsg(4,("Using existing gig::Engine.\n"));              dmsg(4,("Using existing gig::Engine.\n"));
59              pEngine = engines[pDevice];                          pEngine = engines[pDevice];
60          } else { // create a new engine (and disk thread) instance for the given audio output device          } else { // create a new engine (and disk thread) instance for the given audio output device
61              dmsg(4,("Creating new gig::Engine.\n"));              dmsg(4,("Creating new gig::Engine.\n"));
62              pEngine = (Engine*) EngineFactory::Create("gig");              pEngine = (Engine*) EngineFactory::Create("gig");
63              pEngine->Connect(pDevice);              pEngine->Connect(pDevice);
64              engines[pDevice] = pEngine;                          engines[pDevice] = pEngine;
65          }          }
66          // register engine channel to the engine instance          // register engine channel to the engine instance
67          pEngine->engineChannels.push_back(pChannel);          pEngine->engineChannels.push_back(pChannel);
# Line 101  namespace LinuxSampler { namespace gig { Line 101  namespace LinuxSampler { namespace gig {
101          pSysexBuffer       = new RingBuffer<uint8_t>(SYSEX_BUFFER_SIZE, 0);          pSysexBuffer       = new RingBuffer<uint8_t>(SYSEX_BUFFER_SIZE, 0);
102          pEventQueue        = new RingBuffer<Event>(MAX_EVENTS_PER_FRAGMENT, 0);          pEventQueue        = new RingBuffer<Event>(MAX_EVENTS_PER_FRAGMENT, 0);
103          pEventPool         = new Pool<Event>(MAX_EVENTS_PER_FRAGMENT);          pEventPool         = new Pool<Event>(MAX_EVENTS_PER_FRAGMENT);
104          pVoicePool         = new Pool<Voice>(MAX_AUDIO_VOICES);                  pVoicePool         = new Pool<Voice>(MAX_AUDIO_VOICES);
105          pVoiceStealingQueue = new RTList<Event>(pEventPool);          pVoiceStealingQueue = new RTList<Event>(pEventPool);
106          pEvents            = new RTList<Event>(pEventPool);          pEvents            = new RTList<Event>(pEventPool);
107          pCCEvents          = new RTList<Event>(pEventPool);          pCCEvents          = new RTList<Event>(pEventPool);
108            
109          for (uint i = 0; i < Event::destination_count; i++) {          for (uint i = 0; i < Event::destination_count; i++) {
110              pSynthesisEvents[i] = new RTList<Event>(pEventPool);              pSynthesisEvents[i] = new RTList<Event>(pEventPool);
111          }          }
# Line 201  namespace LinuxSampler { namespace gig { Line 201  namespace LinuxSampler { namespace gig {
201    
202          // delete all input events          // delete all input events
203          pEventQueue->init();          pEventQueue->init();
204      }          }
205    
206      void Engine::Connect(AudioOutputDevice* pAudioOut) {      void Engine::Connect(AudioOutputDevice* pAudioOut) {
207          pAudioOutputDevice = pAudioOut;          pAudioOutputDevice = pAudioOut;
# Line 216  namespace LinuxSampler { namespace gig { Line 216  namespace LinuxSampler { namespace gig {
216              String msg = "Audio output device unable to provide 2 audio channels, cause: " + e.Message();              String msg = "Audio output device unable to provide 2 audio channels, cause: " + e.Message();
217              throw LinuxSamplerException(msg);              throw LinuxSamplerException(msg);
218          }          }
219            
220          this->MaxSamplesPerCycle      = pAudioOutputDevice->MaxSamplesPerCycle();          this->MaxSamplesPerCycle      = pAudioOutputDevice->MaxSamplesPerCycle();
221          this->SampleRate              = pAudioOutputDevice->SampleRate();          this->SampleRate              = pAudioOutputDevice->SampleRate();
222    
# Line 320  namespace LinuxSampler { namespace gig { Line 320  namespace LinuxSampler { namespace gig {
320              *pEvents->allocAppend() = *pEvent;              *pEvents->allocAppend() = *pEvent;
321          }          }
322          eventQueueReader.free(); // free all copied events from input queue          eventQueueReader.free(); // free all copied events from input queue
323      }          }
324    
325      /**      /**
326       *  Let this engine proceed to render the given amount of sample points. The       *  Let this engine proceed to render the given amount of sample points. The
# Line 401  namespace LinuxSampler { namespace gig { Line 401  namespace LinuxSampler { namespace gig {
401    
402          // get all events from the engine channels's input event queue which belong to the current fragment          // get all events from the engine channels's input event queue which belong to the current fragment
403          // (these are the common events like NoteOn, NoteOff, ControlChange, etc.)          // (these are the common events like NoteOn, NoteOff, ControlChange, etc.)
404          ImportEvents(pEngineChannel->pEventQueue, Samples);                ImportEvents(pEngineChannel->pEventQueue, Samples);
405    
406    
407          // process events          // process events
# Line 452  namespace LinuxSampler { namespace gig { Line 452  namespace LinuxSampler { namespace gig {
452              }              }
453          }          }
454    
455            
456          // now render all postponed voices from voice stealing          // now render all postponed voices from voice stealing
457          {          {
458              RTList<Event>::Iterator itVoiceStealEvent = pVoiceStealingQueue->first();              RTList<Event>::Iterator itVoiceStealEvent = pVoiceStealingQueue->first();
# Line 476  namespace LinuxSampler { namespace gig { Line 476  namespace LinuxSampler { namespace gig {
476          pVoiceStealingQueue->clear();          pVoiceStealingQueue->clear();
477          pEngineChannel->itLastStolenVoice = RTList<Voice>::Iterator();          pEngineChannel->itLastStolenVoice = RTList<Voice>::Iterator();
478          pEngineChannel->iuiLastStolenKey  = RTList<uint>::Iterator();          pEngineChannel->iuiLastStolenKey  = RTList<uint>::Iterator();
479            
480    
481          // free all keys which have no active voices left          // free all keys which have no active voices left
482          {          {
# Line 540  namespace LinuxSampler { namespace gig { Line 540  namespace LinuxSampler { namespace gig {
540       *  @param itNoteOnEvent - key, velocity and time stamp of the event       *  @param itNoteOnEvent - key, velocity and time stamp of the event
541       */       */
542      void Engine::ProcessNoteOn(EngineChannel* pEngineChannel, Pool<Event>::Iterator& itNoteOnEvent) {      void Engine::ProcessNoteOn(EngineChannel* pEngineChannel, Pool<Event>::Iterator& itNoteOnEvent) {
543            
544          const int key = itNoteOnEvent->Param.Note.Key;          const int key = itNoteOnEvent->Param.Note.Key;
545    
546          // Change key dimension value if key is in keyswitching area          // Change key dimension value if key is in keyswitching area
# Line 570  namespace LinuxSampler { namespace gig { Line 570  namespace LinuxSampler { namespace gig {
570    
571          // allocate and trigger a new voice for the key          // allocate and trigger a new voice for the key
572          LaunchVoice(pEngineChannel, itNoteOnEventOnKeyList, 0, false, true);          LaunchVoice(pEngineChannel, itNoteOnEventOnKeyList, 0, false, true);
573    
574            pKey->RoundRobinIndex++;
575      }      }
576    
577      /**      /**
# Line 992  namespace LinuxSampler { namespace gig { Line 994  namespace LinuxSampler { namespace gig {
994             m[i+2] = val;             m[i+2] = val;
995             m[i+3] = val;             m[i+3] = val;
996          }          }
997      }          }
998    
999      uint Engine::VoiceCount() {      uint Engine::VoiceCount() {
1000          return ActiveVoiceCount;          return ActiveVoiceCount;
# Line 1031  namespace LinuxSampler { namespace gig { Line 1033  namespace LinuxSampler { namespace gig {
1033      }      }
1034    
1035      String Engine::Version() {      String Engine::Version() {
1036          String s = "$Revision: 1.29 $";          String s = "$Revision: 1.30 $";
1037          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
1038      }      }
1039    

Legend:
Removed from v.424  
changed lines
  Added in v.438

  ViewVC Help
Powered by ViewVC