/[svn]/linuxsampler/trunk/src/engines/gig/EngineChannel.cpp
ViewVC logotype

Diff of /linuxsampler/trunk/src/engines/gig/EngineChannel.cpp

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

revision 846 by persson, Sun Mar 19 16:38:22 2006 UTC revision 1424 by schoenebeck, Sun Oct 14 22:00:17 2007 UTC
# Line 3  Line 3 
3   *   LinuxSampler - modular, streaming capable sampler                     *   *   LinuxSampler - modular, streaming capable sampler                     *
4   *                                                                         *   *                                                                         *
5   *   Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck   *   *   Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck   *
6   *   Copyright (C) 2005, 2006 Christian Schoenebeck                        *   *   Copyright (C) 2005 - 2007 Christian Schoenebeck                       *
7   *                                                                         *   *                                                                         *
8   *   This program is free software; you can redistribute it and/or modify  *   *   This program is free software; you can redistribute it and/or modify  *
9   *   it under the terms of the GNU General Public License as published by  *   *   it under the terms of the GNU General Public License as published by  *
# Line 23  Line 23 
23    
24  #include "EngineChannel.h"  #include "EngineChannel.h"
25    
26    #include "../../common/global_private.h"
27    
28  namespace LinuxSampler { namespace gig {  namespace LinuxSampler { namespace gig {
29    
30      EngineChannel::EngineChannel() {      EngineChannel::EngineChannel() {
# Line 30  namespace LinuxSampler { namespace gig { Line 32  namespace LinuxSampler { namespace gig {
32          pEngine      = NULL;          pEngine      = NULL;
33          pInstrument  = NULL;          pInstrument  = NULL;
34          pEvents      = NULL; // we allocate when we retrieve the right Engine object          pEvents      = NULL; // we allocate when we retrieve the right Engine object
35          pEventQueue  = new RingBuffer<Event>(CONFIG_MAX_EVENTS_PER_FRAGMENT, 0);          pEventQueue  = new RingBuffer<Event,false>(CONFIG_MAX_EVENTS_PER_FRAGMENT, 0);
36          pActiveKeys  = new Pool<uint>(128);          pActiveKeys  = new Pool<uint>(128);
37          for (uint i = 0; i < 128; i++) {          for (uint i = 0; i < 128; i++) {
38              pMIDIKeyInfo[i].pActiveVoices  = NULL; // we allocate when we retrieve the right Engine object              pMIDIKeyInfo[i].pActiveVoices  = NULL; // we allocate when we retrieve the right Engine object
# Line 43  namespace LinuxSampler { namespace gig { Line 45  namespace LinuxSampler { namespace gig {
45          }          }
46          InstrumentIdx  = -1;          InstrumentIdx  = -1;
47          InstrumentStat = -1;          InstrumentStat = -1;
48            pChannelLeft  = NULL;
49            pChannelRight = NULL;
50          AudioDeviceChannelLeft  = -1;          AudioDeviceChannelLeft  = -1;
51          AudioDeviceChannelRight = -1;          AudioDeviceChannelRight = -1;
52          pMidiInputPort = NULL;          pMidiInputPort = NULL;
# Line 59  namespace LinuxSampler { namespace gig { Line 63  namespace LinuxSampler { namespace gig {
63          if (pEventQueue) delete pEventQueue;          if (pEventQueue) delete pEventQueue;
64          if (pActiveKeys) delete pActiveKeys;          if (pActiveKeys) delete pActiveKeys;
65          if (pMIDIKeyInfo) delete[] pMIDIKeyInfo;          if (pMIDIKeyInfo) delete[] pMIDIKeyInfo;
66            RemoveAllFxSends();
67      }      }
68    
69      /**      /**
# Line 156  namespace LinuxSampler { namespace gig { Line 161  namespace LinuxSampler { namespace gig {
161       * This method will then actually start to load the instrument and block       * This method will then actually start to load the instrument and block
162       * the calling thread until loading was completed.       * the calling thread until loading was completed.
163       *       *
      * @returns detailed description of the method call result  
164       * @see PrepareLoadInstrument()       * @see PrepareLoadInstrument()
165       */       */
166      void EngineChannel::LoadInstrument() {      void EngineChannel::LoadInstrument() {
167            ::gig::Instrument* oldInstrument = pInstrument;
         if (pEngine) pEngine->DisableAndLock();  
   
         ResetInternal();  
168    
169          // free old instrument          // free old instrument
170          if (pInstrument) {          if (oldInstrument) {
171              // give old instrument back to instrument manager              if (pEngine) {
172              Engine::instruments.HandBack(pInstrument, this);                  // make sure we don't trigger any new notes with the
173                    // old instrument
174                    ::gig::DimensionRegion** dimRegionsInUse = pEngine->ChangeInstrument(this, 0);
175    
176                    // give old instrument back to instrument manager, but
177                    // keep the dimension regions and samples that are in
178                    // use
179                    Engine::instruments.HandBackInstrument(oldInstrument, this, dimRegionsInUse);
180                } else {
181                    Engine::instruments.HandBack(oldInstrument, this);
182                }
183          }          }
184    
185          // delete all key groups          // delete all key groups
186          ActiveKeyGroups.clear();          ActiveKeyGroups.clear();
187    
188          // request gig instrument from instrument manager          // request gig instrument from instrument manager
189            ::gig::Instrument* newInstrument;
190          try {          try {
191              instrument_id_t instrid;              InstrumentManager::instrument_id_t instrid;
192              instrid.FileName    = InstrumentFile;              instrid.FileName  = InstrumentFile;
193              instrid.iInstrument = InstrumentIdx;              instrid.Index     = InstrumentIdx;
194              pInstrument = Engine::instruments.Borrow(instrid, this);              newInstrument = Engine::instruments.Borrow(instrid, this);
195              if (!pInstrument) {              if (!newInstrument) {
196                  InstrumentStat = -1;                  throw InstrumentManagerException("resource was not created");
                 dmsg(1,("no instrument loaded!!!\n"));  
                 exit(EXIT_FAILURE);  
197              }              }
198          }          }
199          catch (RIFF::Exception e) {          catch (RIFF::Exception e) {
200              InstrumentStat = -2;              InstrumentStat = -2;
201                StatusChanged(true);
202              String msg = "gig::Engine error: Failed to load instrument, cause: " + e.Message;              String msg = "gig::Engine error: Failed to load instrument, cause: " + e.Message;
203              throw LinuxSamplerException(msg);              throw Exception(msg);
204          }          }
205          catch (InstrumentResourceManagerException e) {          catch (InstrumentManagerException e) {
206              InstrumentStat = -3;              InstrumentStat = -3;
207                StatusChanged(true);
208              String msg = "gig::Engine error: Failed to load instrument, cause: " + e.Message();              String msg = "gig::Engine error: Failed to load instrument, cause: " + e.Message();
209              throw LinuxSamplerException(msg);              throw Exception(msg);
210          }          }
211          catch (...) {          catch (...) {
212              InstrumentStat = -4;              InstrumentStat = -4;
213              throw LinuxSamplerException("gig::Engine error: Failed to load instrument, cause: Unknown exception while trying to parse gig file.");              StatusChanged(true);
214                throw Exception("gig::Engine error: Failed to load instrument, cause: Unknown exception while trying to parse gig file.");
215          }          }
216    
217          // rebuild ActiveKeyGroups map with key groups of current instrument          // rebuild ActiveKeyGroups map with key groups of current instrument
218          for (::gig::Region* pRegion = pInstrument->GetFirstRegion(); pRegion; pRegion = pInstrument->GetNextRegion())          for (::gig::Region* pRegion = newInstrument->GetFirstRegion(); pRegion; pRegion = newInstrument->GetNextRegion())
219              if (pRegion->KeyGroup) ActiveKeyGroups[pRegion->KeyGroup] = NULL;              if (pRegion->KeyGroup) ActiveKeyGroups[pRegion->KeyGroup] = NULL;
220    
221          InstrumentIdxName = pInstrument->pInfo->Name;          InstrumentIdxName = newInstrument->pInfo->Name;
222          InstrumentStat = 100;          InstrumentStat = 100;
223    
224          // inform audio driver for the need of two channels          if (pEngine) pEngine->ChangeInstrument(this, newInstrument);
225          try {          else pInstrument = newInstrument;
226              if (pEngine && pEngine->pAudioOutputDevice)          
227                  pEngine->pAudioOutputDevice->AcquireChannels(2); // gig Engine only stereo          StatusChanged(true);
         }  
         catch (AudioOutputException e) {  
             String msg = "Audio output device unable to provide 2 audio channels, cause: " + e.Message();  
             throw LinuxSamplerException(msg);  
         }  
   
         if (pEngine) pEngine->Enable();  
228      }      }
229    
230      /**      /**
# Line 269  namespace LinuxSampler { namespace gig { Line 275  namespace LinuxSampler { namespace gig {
275          }          }
276          AudioDeviceChannelLeft  = 0;          AudioDeviceChannelLeft  = 0;
277          AudioDeviceChannelRight = 1;          AudioDeviceChannelRight = 1;
278          pOutputLeft             = pAudioOut->Channel(0)->Buffer();          if (fxSends.empty()) { // render directly into the AudioDevice's output buffers
279          pOutputRight            = pAudioOut->Channel(1)->Buffer();              pChannelLeft  = pAudioOut->Channel(AudioDeviceChannelLeft);
280                pChannelRight = pAudioOut->Channel(AudioDeviceChannelRight);
281            } else { // use local buffers for rendering and copy later
282                // ensure the local buffers have the correct size
283                if (pChannelLeft)  delete pChannelLeft;
284                if (pChannelRight) delete pChannelRight;
285                pChannelLeft  = new AudioChannel(0, pAudioOut->MaxSamplesPerCycle());
286                pChannelRight = new AudioChannel(1, pAudioOut->MaxSamplesPerCycle());
287            }
288            if (pEngine->EngineDisabled.GetUnsafe()) pEngine->Enable();
289          MidiInputPort::AddSysexListener(pEngine);          MidiInputPort::AddSysexListener(pEngine);
290      }      }
291    
# Line 297  namespace LinuxSampler { namespace gig { Line 312  namespace LinuxSampler { namespace gig {
312              Engine::FreeEngine(this, oldAudioDevice);              Engine::FreeEngine(this, oldAudioDevice);
313              AudioDeviceChannelLeft  = -1;              AudioDeviceChannelLeft  = -1;
314              AudioDeviceChannelRight = -1;              AudioDeviceChannelRight = -1;
315                if (!fxSends.empty()) { // free the local rendering buffers
316                    if (pChannelLeft)  delete pChannelLeft;
317                    if (pChannelRight) delete pChannelRight;
318                }
319                pChannelLeft  = NULL;
320                pChannelRight = NULL;
321          }          }
322      }      }
323    
324        AudioOutputDevice* EngineChannel::GetAudioOutputDevice() {
325            return (pEngine) ? pEngine->pAudioOutputDevice : NULL;
326        }
327    
328      void EngineChannel::SetOutputChannel(uint EngineAudioChannel, uint AudioDeviceChannel) {      void EngineChannel::SetOutputChannel(uint EngineAudioChannel, uint AudioDeviceChannel) {
329          if (!pEngine || !pEngine->pAudioOutputDevice) throw AudioOutputException("No audio output device connected yet.");          if (!pEngine || !pEngine->pAudioOutputDevice) throw AudioOutputException("No audio output device connected yet.");
330    
# Line 307  namespace LinuxSampler { namespace gig { Line 332  namespace LinuxSampler { namespace gig {
332          if (!pChannel) throw AudioOutputException("Invalid audio output device channel " + ToString(AudioDeviceChannel));          if (!pChannel) throw AudioOutputException("Invalid audio output device channel " + ToString(AudioDeviceChannel));
333          switch (EngineAudioChannel) {          switch (EngineAudioChannel) {
334              case 0: // left output channel              case 0: // left output channel
335                  pOutputLeft = pChannel->Buffer();                  if (fxSends.empty()) pChannelLeft = pChannel;
336                  AudioDeviceChannelLeft = AudioDeviceChannel;                  AudioDeviceChannelLeft = AudioDeviceChannel;
337                  break;                  break;
338              case 1: // right output channel              case 1: // right output channel
339                  pOutputRight = pChannel->Buffer();                  if (fxSends.empty()) pChannelRight = pChannel;
340                  AudioDeviceChannelRight = AudioDeviceChannel;                  AudioDeviceChannelRight = AudioDeviceChannel;
341                  break;                  break;
342              default:              default:
343                  throw AudioOutputException("Invalid engine audio channel " + ToString(EngineAudioChannel));                  throw AudioOutputException("Invalid engine audio channel " + ToString(EngineAudioChannel));
344          }          }
345    
346            bStatusChanged = true;
347      }      }
348    
349      int EngineChannel::OutputChannel(uint EngineAudioChannel) {      int EngineChannel::OutputChannel(uint EngineAudioChannel) {
# Line 352  namespace LinuxSampler { namespace gig { Line 379  namespace LinuxSampler { namespace gig {
379          return midiChannel;          return midiChannel;
380      }      }
381    
382        FxSend* EngineChannel::AddFxSend(uint8_t MidiCtrl, String Name) throw (Exception) {
383            if (pEngine) pEngine->DisableAndLock();
384            FxSend* pFxSend = new FxSend(this, MidiCtrl, Name);
385            if (fxSends.empty()) {
386                if (pEngine && pEngine->pAudioOutputDevice) {
387                    AudioOutputDevice* pDevice = pEngine->pAudioOutputDevice;
388                    // create local render buffers
389                    pChannelLeft  = new AudioChannel(0, pDevice->MaxSamplesPerCycle());
390                    pChannelRight = new AudioChannel(1, pDevice->MaxSamplesPerCycle());
391                } else {
392                    // postpone local render buffer creation until audio device is assigned
393                    pChannelLeft  = NULL;
394                    pChannelRight = NULL;
395                }
396            }
397            fxSends.push_back(pFxSend);
398            if (pEngine) pEngine->Enable();
399            fireFxSendCountChanged(iSamplerChannelIndex, GetFxSendCount());
400            
401            return pFxSend;
402        }
403    
404        FxSend* EngineChannel::GetFxSend(uint FxSendIndex) {
405            return (FxSendIndex < fxSends.size()) ? fxSends[FxSendIndex] : NULL;
406        }
407    
408        uint EngineChannel::GetFxSendCount() {
409            return fxSends.size();
410        }
411    
412        void EngineChannel::RemoveFxSend(FxSend* pFxSend) {
413            if (pEngine) pEngine->DisableAndLock();
414            for (
415                std::vector<FxSend*>::iterator iter = fxSends.begin();
416                iter != fxSends.end(); iter++
417            ) {
418                if (*iter == pFxSend) {
419                    delete pFxSend;
420                    fxSends.erase(iter);
421                    if (fxSends.empty()) {
422                        // destroy local render buffers
423                        if (pChannelLeft)  delete pChannelLeft;
424                        if (pChannelRight) delete pChannelRight;
425                        // fallback to render directly into AudioOutputDevice's buffers
426                        if (pEngine && pEngine->pAudioOutputDevice) {
427                            pChannelLeft  = pEngine->pAudioOutputDevice->Channel(AudioDeviceChannelLeft);
428                            pChannelRight = pEngine->pAudioOutputDevice->Channel(AudioDeviceChannelRight);
429                        } else { // we update the pointers later
430                            pChannelLeft  = NULL;
431                            pChannelRight = NULL;
432                        }
433                    }
434                    break;
435                }
436            }
437            if (pEngine) pEngine->Enable();
438            fireFxSendCountChanged(iSamplerChannelIndex, GetFxSendCount());
439        }
440    
441      /**      /**
442       *  Will be called by the MIDIIn Thread to let the audio thread trigger a new       *  Will be called by the MIDIIn Thread to let the audio thread trigger a new
443       *  voice for the given key.       *  voice for the given key. This method is meant for real time rendering,
444         *  that is an event will immediately be created with the current system
445         *  time as time stamp.
446       *       *
447       *  @param Key      - MIDI key number of the triggered key       *  @param Key      - MIDI key number of the triggered key
448       *  @param Velocity - MIDI velocity value of the triggered key       *  @param Velocity - MIDI velocity value of the triggered key
# Line 372  namespace LinuxSampler { namespace gig { Line 460  namespace LinuxSampler { namespace gig {
460      }      }
461    
462      /**      /**
463         *  Will be called by the MIDIIn Thread to let the audio thread trigger a new
464         *  voice for the given key. This method is meant for offline rendering
465         *  and / or for cases where the exact position of the event in the current
466         *  audio fragment is already known.
467         *
468         *  @param Key         - MIDI key number of the triggered key
469         *  @param Velocity    - MIDI velocity value of the triggered key
470         *  @param FragmentPos - sample point position in the current audio
471         *                       fragment to which this event belongs to
472         */
473        void EngineChannel::SendNoteOn(uint8_t Key, uint8_t Velocity, int32_t FragmentPos) {
474            if (FragmentPos < 0) {
475                dmsg(1,("EngineChannel::SendNoteOn(): negative FragmentPos! Seems MIDI driver is buggy!"));
476            }
477            else if (pEngine) {
478                Event event               = pEngine->pEventGenerator->CreateEvent(FragmentPos);
479                event.Type                = Event::type_note_on;
480                event.Param.Note.Key      = Key;
481                event.Param.Note.Velocity = Velocity;
482                event.pEngineChannel      = this;
483                if (this->pEventQueue->write_space() > 0) this->pEventQueue->push(&event);
484                else dmsg(1,("EngineChannel: Input event queue full!"));
485            }
486        }
487    
488        /**
489       *  Will be called by the MIDIIn Thread to signal the audio thread to release       *  Will be called by the MIDIIn Thread to signal the audio thread to release
490       *  voice(s) on the given key.       *  voice(s) on the given key. This method is meant for real time rendering,
491         *  that is an event will immediately be created with the current system
492         *  time as time stamp.
493       *       *
494       *  @param Key      - MIDI key number of the released key       *  @param Key      - MIDI key number of the released key
495       *  @param Velocity - MIDI release velocity value of the released key       *  @param Velocity - MIDI release velocity value of the released key
# Line 391  namespace LinuxSampler { namespace gig { Line 507  namespace LinuxSampler { namespace gig {
507      }      }
508    
509      /**      /**
510         *  Will be called by the MIDIIn Thread to signal the audio thread to release
511         *  voice(s) on the given key. This method is meant for offline rendering
512         *  and / or for cases where the exact position of the event in the current
513         *  audio fragment is already known.
514         *
515         *  @param Key         - MIDI key number of the released key
516         *  @param Velocity    - MIDI release velocity value of the released key
517         *  @param FragmentPos - sample point position in the current audio
518         *                       fragment to which this event belongs to
519         */
520        void EngineChannel::SendNoteOff(uint8_t Key, uint8_t Velocity, int32_t FragmentPos) {
521            if (FragmentPos < 0) {
522                dmsg(1,("EngineChannel::SendNoteOff(): negative FragmentPos! Seems MIDI driver is buggy!"));
523            }
524            else if (pEngine) {
525                Event event               = pEngine->pEventGenerator->CreateEvent(FragmentPos);
526                event.Type                = Event::type_note_off;
527                event.Param.Note.Key      = Key;
528                event.Param.Note.Velocity = Velocity;
529                event.pEngineChannel      = this;
530                if (this->pEventQueue->write_space() > 0) this->pEventQueue->push(&event);
531                else dmsg(1,("EngineChannel: Input event queue full!"));
532            }
533        }
534    
535        /**
536       *  Will be called by the MIDIIn Thread to signal the audio thread to change       *  Will be called by the MIDIIn Thread to signal the audio thread to change
537       *  the pitch value for all voices.       *  the pitch value for all voices. This method is meant for real time
538         *  rendering, that is an event will immediately be created with the
539         *  current system time as time stamp.
540       *       *
541       *  @param Pitch - MIDI pitch value (-8192 ... +8191)       *  @param Pitch - MIDI pitch value (-8192 ... +8191)
542       */       */
# Line 408  namespace LinuxSampler { namespace gig { Line 552  namespace LinuxSampler { namespace gig {
552      }      }
553    
554      /**      /**
555         *  Will be called by the MIDIIn Thread to signal the audio thread to change
556         *  the pitch value for all voices. This method is meant for offline
557         *  rendering and / or for cases where the exact position of the event in
558         *  the current audio fragment is already known.
559         *
560         *  @param Pitch       - MIDI pitch value (-8192 ... +8191)
561         *  @param FragmentPos - sample point position in the current audio
562         *                       fragment to which this event belongs to
563         */
564        void EngineChannel::SendPitchbend(int Pitch, int32_t FragmentPos) {
565            if (FragmentPos < 0) {
566                dmsg(1,("EngineChannel::SendPitchBend(): negative FragmentPos! Seems MIDI driver is buggy!"));
567            }
568            else if (pEngine) {
569                Event event             = pEngine->pEventGenerator->CreateEvent(FragmentPos);
570                event.Type              = Event::type_pitchbend;
571                event.Param.Pitch.Pitch = Pitch;
572                event.pEngineChannel    = this;
573                if (this->pEventQueue->write_space() > 0) this->pEventQueue->push(&event);
574                else dmsg(1,("EngineChannel: Input event queue full!"));
575            }
576        }
577    
578        /**
579       *  Will be called by the MIDIIn Thread to signal the audio thread that a       *  Will be called by the MIDIIn Thread to signal the audio thread that a
580       *  continuous controller value has changed.       *  continuous controller value has changed. This method is meant for real
581         *  time rendering, that is an event will immediately be created with the
582         *  current system time as time stamp.
583       *       *
584       *  @param Controller - MIDI controller number of the occured control change       *  @param Controller - MIDI controller number of the occured control change
585       *  @param Value      - value of the control change       *  @param Value      - value of the control change
# Line 426  namespace LinuxSampler { namespace gig { Line 596  namespace LinuxSampler { namespace gig {
596          }          }
597      }      }
598    
599        /**
600         *  Will be called by the MIDIIn Thread to signal the audio thread that a
601         *  continuous controller value has changed. This method is meant for
602         *  offline rendering and / or for cases where the exact position of the
603         *  event in the current audio fragment is already known.
604         *
605         *  @param Controller  - MIDI controller number of the occured control change
606         *  @param Value       - value of the control change
607         *  @param FragmentPos - sample point position in the current audio
608         *                       fragment to which this event belongs to
609         */
610        void EngineChannel::SendControlChange(uint8_t Controller, uint8_t Value, int32_t FragmentPos) {
611            if (FragmentPos < 0) {
612                dmsg(1,("EngineChannel::SendControlChange(): negative FragmentPos! Seems MIDI driver is buggy!"));
613            }
614            else if (pEngine) {
615                Event event               = pEngine->pEventGenerator->CreateEvent(FragmentPos);
616                event.Type                = Event::type_control_change;
617                event.Param.CC.Controller = Controller;
618                event.Param.CC.Value      = Value;
619                event.pEngineChannel      = this;
620                if (this->pEventQueue->write_space() > 0) this->pEventQueue->push(&event);
621                else dmsg(1,("EngineChannel: Input event queue full!"));
622            }
623        }
624    
625      void EngineChannel::ClearEventLists() {      void EngineChannel::ClearEventLists() {
626          pEvents->clear();          pEvents->clear();
627          // empty MIDI key specific event lists          // empty MIDI key specific event lists
# Line 442  namespace LinuxSampler { namespace gig { Line 638  namespace LinuxSampler { namespace gig {
638          Pitch          = 0;          Pitch          = 0;
639          SustainPedal   = false;          SustainPedal   = false;
640          SostenutoPedal = false;          SostenutoPedal = false;
641          GlobalVolume   = CONFIG_GLOBAL_ATTENUATION;          GlobalVolume   = 1.0f;
642            MidiVolume     = 1.0;
643          GlobalPanLeft  = 1.0f;          GlobalPanLeft  = 1.0f;
644          GlobalPanRight = 1.0f;          GlobalPanRight = 1.0f;
645            GlobalTranspose = 0;
646          // set all MIDI controller values to zero          // set all MIDI controller values to zero
647          memset(ControllerTable, 0x00, 128);          memset(ControllerTable, 0x00, 129);
648            // reset all FX Send levels
649            for (
650                std::vector<FxSend*>::iterator iter = fxSends.begin();
651                iter != fxSends.end(); iter++
652            ) {
653                (*iter)->Reset();
654            }
655      }      }
656    
657      /**      /**
# Line 463  namespace LinuxSampler { namespace gig { Line 668  namespace LinuxSampler { namespace gig {
668       *                  current audio cycle       *                  current audio cycle
669       */       */
670      void EngineChannel::ImportEvents(uint Samples) {      void EngineChannel::ImportEvents(uint Samples) {
671          RingBuffer<Event>::NonVolatileReader eventQueueReader = pEventQueue->get_non_volatile_reader();          RingBuffer<Event,false>::NonVolatileReader eventQueueReader = pEventQueue->get_non_volatile_reader();
672          Event* pEvent;          Event* pEvent;
673          while (true) {          while (true) {
674              // get next event from input event queue              // get next event from input event queue
# Line 485  namespace LinuxSampler { namespace gig { Line 690  namespace LinuxSampler { namespace gig {
690          eventQueueReader.free(); // free all copied events from input queue          eventQueueReader.free(); // free all copied events from input queue
691      }      }
692    
693        void EngineChannel::RemoveAllFxSends() {
694            if (pEngine) pEngine->DisableAndLock();
695            if (!fxSends.empty()) { // free local render buffers
696                if (pChannelLeft) {
697                    delete pChannelLeft;
698                    if (pEngine && pEngine->pAudioOutputDevice) {
699                        // fallback to render directly to the AudioOutputDevice's buffer
700                        pChannelLeft = pEngine->pAudioOutputDevice->Channel(AudioDeviceChannelLeft);
701                    } else pChannelLeft = NULL;
702                }
703                if (pChannelRight) {
704                    delete pChannelRight;
705                    if (pEngine && pEngine->pAudioOutputDevice) {
706                        // fallback to render directly to the AudioOutputDevice's buffer
707                        pChannelRight = pEngine->pAudioOutputDevice->Channel(AudioDeviceChannelRight);
708                    } else pChannelRight = NULL;
709                }
710            }
711            for (int i = 0; i < fxSends.size(); i++) delete fxSends[i];
712            fxSends.clear();
713            if (pEngine) pEngine->Enable();
714        }
715    
716      float EngineChannel::Volume() {      float EngineChannel::Volume() {
717          return GlobalVolume;          return GlobalVolume;
718      }      }

Legend:
Removed from v.846  
changed lines
  Added in v.1424

  ViewVC Help
Powered by ViewVC