/[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 670 by schoenebeck, Tue Jun 21 18:00:52 2005 UTC revision 1005 by schoenebeck, Fri Dec 29 20:06:14 2006 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 Christian Schoenebeck                              *   *   Copyright (C) 2005, 2006 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 30  namespace LinuxSampler { namespace gig { Line 30  namespace LinuxSampler { namespace gig {
30          pEngine      = NULL;          pEngine      = NULL;
31          pInstrument  = NULL;          pInstrument  = NULL;
32          pEvents      = NULL; // we allocate when we retrieve the right Engine object          pEvents      = NULL; // we allocate when we retrieve the right Engine object
33          pCCEvents    = NULL; // we allocate when we retrieve the right Engine object          pEventQueue  = new RingBuffer<Event,false>(CONFIG_MAX_EVENTS_PER_FRAGMENT, 0);
         pEventQueue  = new RingBuffer<Event>(CONFIG_MAX_EVENTS_PER_FRAGMENT, 0);  
34          pActiveKeys  = new Pool<uint>(128);          pActiveKeys  = new Pool<uint>(128);
35          for (uint i = 0; i < 128; i++) {          for (uint i = 0; i < 128; i++) {
36              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 42  namespace LinuxSampler { namespace gig { Line 41  namespace LinuxSampler { namespace gig {
41              pMIDIKeyInfo[i].VoiceTheftsQueued = 0;              pMIDIKeyInfo[i].VoiceTheftsQueued = 0;
42              pMIDIKeyInfo[i].RoundRobinIndex = 0;              pMIDIKeyInfo[i].RoundRobinIndex = 0;
43          }          }
         for (uint i = 0; i < Event::destination_count; i++) {  
             pSynthesisEvents[i] = NULL; // we allocate when we retrieve the right Engine object  
         }  
44          InstrumentIdx  = -1;          InstrumentIdx  = -1;
45          InstrumentStat = -1;          InstrumentStat = -1;
46            pChannelLeft  = NULL;
47            pChannelRight = NULL;
48          AudioDeviceChannelLeft  = -1;          AudioDeviceChannelLeft  = -1;
49          AudioDeviceChannelRight = -1;          AudioDeviceChannelRight = -1;
50            pMidiInputPort = NULL;
51            midiChannel = midi_chan_all;
52          ResetControllers();          ResetControllers();
53            SoloMode       = false;
54            PortamentoMode = false;
55            PortamentoTime = CONFIG_PORTAMENTO_TIME_DEFAULT;
56      }      }
57    
58      EngineChannel::~EngineChannel() {      EngineChannel::~EngineChannel() {
# Line 58  namespace LinuxSampler { namespace gig { Line 61  namespace LinuxSampler { namespace gig {
61          if (pEventQueue) delete pEventQueue;          if (pEventQueue) delete pEventQueue;
62          if (pActiveKeys) delete pActiveKeys;          if (pActiveKeys) delete pActiveKeys;
63          if (pMIDIKeyInfo) delete[] pMIDIKeyInfo;          if (pMIDIKeyInfo) delete[] pMIDIKeyInfo;
64            RemoveAllFxSends();
65      }      }
66    
67      /**      /**
# Line 110  namespace LinuxSampler { namespace gig { Line 114  namespace LinuxSampler { namespace gig {
114              pMIDIKeyInfo[i].itSelf         = Pool<uint>::Iterator();              pMIDIKeyInfo[i].itSelf         = Pool<uint>::Iterator();
115              pMIDIKeyInfo[i].VoiceTheftsQueued = 0;              pMIDIKeyInfo[i].VoiceTheftsQueued = 0;
116          }          }
117            SoloKey       = -1;    // no solo key active yet
118            PortamentoPos = -1.0f; // no portamento active yet
119    
120          // reset all key groups          // reset all key groups
121          std::map<uint,uint*>::iterator iter = ActiveKeyGroups.begin();          std::map<uint,uint*>::iterator iter = ActiveKeyGroups.begin();
# Line 173  namespace LinuxSampler { namespace gig { Line 179  namespace LinuxSampler { namespace gig {
179    
180          // request gig instrument from instrument manager          // request gig instrument from instrument manager
181          try {          try {
182              instrument_id_t instrid;              InstrumentManager::instrument_id_t instrid;
183              instrid.FileName    = InstrumentFile;              instrid.FileName  = InstrumentFile;
184              instrid.iInstrument = InstrumentIdx;              instrid.Index     = InstrumentIdx;
185              pInstrument = Engine::instruments.Borrow(instrid, this);              pInstrument = Engine::instruments.Borrow(instrid, this);
186              if (!pInstrument) {              if (!pInstrument) {
187                  InstrumentStat = -1;                  InstrumentStat = -1;
# Line 186  namespace LinuxSampler { namespace gig { Line 192  namespace LinuxSampler { namespace gig {
192          catch (RIFF::Exception e) {          catch (RIFF::Exception e) {
193              InstrumentStat = -2;              InstrumentStat = -2;
194              String msg = "gig::Engine error: Failed to load instrument, cause: " + e.Message;              String msg = "gig::Engine error: Failed to load instrument, cause: " + e.Message;
195              throw LinuxSamplerException(msg);              throw Exception(msg);
196          }          }
197          catch (InstrumentResourceManagerException e) {          catch (InstrumentResourceManagerException e) {
198              InstrumentStat = -3;              InstrumentStat = -3;
199              String msg = "gig::Engine error: Failed to load instrument, cause: " + e.Message();              String msg = "gig::Engine error: Failed to load instrument, cause: " + e.Message();
200              throw LinuxSamplerException(msg);              throw Exception(msg);
201          }          }
202          catch (...) {          catch (...) {
203              InstrumentStat = -4;              InstrumentStat = -4;
204              throw LinuxSamplerException("gig::Engine error: Failed to load instrument, cause: Unknown exception while trying to parse gig file.");              throw Exception("gig::Engine error: Failed to load instrument, cause: Unknown exception while trying to parse gig file.");
205          }          }
206    
207          // rebuild ActiveKeyGroups map with key groups of current instrument          // rebuild ActiveKeyGroups map with key groups of current instrument
# Line 212  namespace LinuxSampler { namespace gig { Line 218  namespace LinuxSampler { namespace gig {
218          }          }
219          catch (AudioOutputException e) {          catch (AudioOutputException e) {
220              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();
221              throw LinuxSamplerException(msg);              throw Exception(msg);
222          }          }
223    
224          if (pEngine) pEngine->Enable();          if (pEngine) pEngine->Enable();
# Line 259  namespace LinuxSampler { namespace gig { Line 265  namespace LinuxSampler { namespace gig {
265          }          }
266          pEngine = Engine::AcquireEngine(this, pAudioOut);          pEngine = Engine::AcquireEngine(this, pAudioOut);
267          ResetInternal();          ResetInternal();
268          pEvents   = new RTList<Event>(pEngine->pEventPool);          pEvents = new RTList<Event>(pEngine->pEventPool);
         pCCEvents = new RTList<Event>(pEngine->pEventPool);  
         for (uint i = 0; i < Event::destination_count; i++) {  
             pSynthesisEvents[i] = new RTList<Event>(pEngine->pEventPool);  
         }  
269          for (uint i = 0; i < 128; i++) {          for (uint i = 0; i < 128; i++) {
270              pMIDIKeyInfo[i].pActiveVoices = new RTList<Voice>(pEngine->pVoicePool);              pMIDIKeyInfo[i].pActiveVoices = new RTList<Voice>(pEngine->pVoicePool);
271              pMIDIKeyInfo[i].pEvents       = new RTList<Event>(pEngine->pEventPool);              pMIDIKeyInfo[i].pEvents       = new RTList<Event>(pEngine->pEventPool);
272          }          }
273          AudioDeviceChannelLeft  = 0;          AudioDeviceChannelLeft  = 0;
274          AudioDeviceChannelRight = 1;          AudioDeviceChannelRight = 1;
275          pOutputLeft             = pAudioOut->Channel(0)->Buffer();          if (fxSends.empty()) { // render directly into the AudioDevice's output buffers
276          pOutputRight            = pAudioOut->Channel(1)->Buffer();              pChannelLeft  = pAudioOut->Channel(AudioDeviceChannelLeft);
277                pChannelRight = pAudioOut->Channel(AudioDeviceChannelRight);
278            } else { // use local buffers for rendering and copy later
279                // ensure the local buffers have the correct size
280                if (pChannelLeft)  delete pChannelLeft;
281                if (pChannelRight) delete pChannelRight;
282                pChannelLeft  = new AudioChannel(0, pAudioOut->MaxSamplesPerCycle());
283                pChannelRight = new AudioChannel(1, pAudioOut->MaxSamplesPerCycle());
284            }
285            MidiInputPort::AddSysexListener(pEngine);
286      }      }
287    
288      void EngineChannel::DisconnectAudioOutputDevice() {      void EngineChannel::DisconnectAudioOutputDevice() {
# Line 281  namespace LinuxSampler { namespace gig { Line 292  namespace LinuxSampler { namespace gig {
292                  delete pEvents;                  delete pEvents;
293                  pEvents = NULL;                  pEvents = NULL;
294              }              }
             if (pCCEvents) {  
                 delete pCCEvents;  
                 pCCEvents = NULL;  
             }  
295              for (uint i = 0; i < 128; i++) {              for (uint i = 0; i < 128; i++) {
296                  if (pMIDIKeyInfo[i].pActiveVoices) {                  if (pMIDIKeyInfo[i].pActiveVoices) {
297                      delete pMIDIKeyInfo[i].pActiveVoices;                      delete pMIDIKeyInfo[i].pActiveVoices;
# Line 295  namespace LinuxSampler { namespace gig { Line 302  namespace LinuxSampler { namespace gig {
302                      pMIDIKeyInfo[i].pEvents = NULL;                      pMIDIKeyInfo[i].pEvents = NULL;
303                  }                  }
304              }              }
             for (uint i = 0; i < Event::destination_count; i++) {  
                 if (pSynthesisEvents[i]) {  
                     delete pSynthesisEvents[i];  
                     pSynthesisEvents[i] = NULL;  
                 }  
             }  
305              Engine* oldEngine = pEngine;              Engine* oldEngine = pEngine;
306              AudioOutputDevice* oldAudioDevice = pEngine->pAudioOutputDevice;              AudioOutputDevice* oldAudioDevice = pEngine->pAudioOutputDevice;
307              pEngine = NULL;              pEngine = NULL;
308              Engine::FreeEngine(this, oldAudioDevice);              Engine::FreeEngine(this, oldAudioDevice);
309              AudioDeviceChannelLeft  = -1;              AudioDeviceChannelLeft  = -1;
310              AudioDeviceChannelRight = -1;              AudioDeviceChannelRight = -1;
311                if (!fxSends.empty()) { // free the local rendering buffers
312                    if (pChannelLeft)  delete pChannelLeft;
313                    if (pChannelRight) delete pChannelRight;
314                }
315                pChannelLeft  = NULL;
316                pChannelRight = NULL;
317          }          }
318      }      }
319    
320        AudioOutputDevice* EngineChannel::GetAudioOutputDevice() {
321            return (pEngine) ? pEngine->pAudioOutputDevice : NULL;
322        }
323    
324      void EngineChannel::SetOutputChannel(uint EngineAudioChannel, uint AudioDeviceChannel) {      void EngineChannel::SetOutputChannel(uint EngineAudioChannel, uint AudioDeviceChannel) {
325          if (!pEngine || !pEngine->pAudioOutputDevice) throw AudioOutputException("No audio output device connected yet.");          if (!pEngine || !pEngine->pAudioOutputDevice) throw AudioOutputException("No audio output device connected yet.");
326    
# Line 317  namespace LinuxSampler { namespace gig { Line 328  namespace LinuxSampler { namespace gig {
328          if (!pChannel) throw AudioOutputException("Invalid audio output device channel " + ToString(AudioDeviceChannel));          if (!pChannel) throw AudioOutputException("Invalid audio output device channel " + ToString(AudioDeviceChannel));
329          switch (EngineAudioChannel) {          switch (EngineAudioChannel) {
330              case 0: // left output channel              case 0: // left output channel
331                  pOutputLeft = pChannel->Buffer();                  if (fxSends.empty()) pChannelLeft = pChannel;
332                  AudioDeviceChannelLeft = AudioDeviceChannel;                  AudioDeviceChannelLeft = AudioDeviceChannel;
333                  break;                  break;
334              case 1: // right output channel              case 1: // right output channel
335                  pOutputRight = pChannel->Buffer();                  if (fxSends.empty()) pChannelRight = pChannel;
336                  AudioDeviceChannelRight = AudioDeviceChannel;                  AudioDeviceChannelRight = AudioDeviceChannel;
337                  break;                  break;
338              default:              default:
# Line 340  namespace LinuxSampler { namespace gig { Line 351  namespace LinuxSampler { namespace gig {
351          }          }
352      }      }
353    
354        void EngineChannel::Connect(MidiInputPort* pMidiPort, midi_chan_t MidiChannel) {
355            if (!pMidiPort || pMidiPort == this->pMidiInputPort) return;
356            DisconnectMidiInputPort();
357            this->pMidiInputPort = pMidiPort;
358            this->midiChannel    = MidiChannel;
359            pMidiPort->Connect(this, MidiChannel);
360        }
361    
362        void EngineChannel::DisconnectMidiInputPort() {
363            MidiInputPort* pOldPort = this->pMidiInputPort;
364            this->pMidiInputPort = NULL;
365            if (pOldPort) pOldPort->Disconnect(this);
366        }
367    
368        MidiInputPort* EngineChannel::GetMidiInputPort() {
369            return pMidiInputPort;
370        }
371    
372        midi_chan_t EngineChannel::MidiChannel() {
373            return midiChannel;
374        }
375    
376        FxSend* EngineChannel::AddFxSend(uint8_t MidiCtrl, String Name) throw (Exception) {
377            if (pEngine) pEngine->DisableAndLock();
378            FxSend* pFxSend = new FxSend(this, MidiCtrl, Name);
379            if (fxSends.empty()) {
380                if (pEngine && pEngine->pAudioOutputDevice) {
381                    AudioOutputDevice* pDevice = pEngine->pAudioOutputDevice;
382                    // create local render buffers
383                    pChannelLeft  = new AudioChannel(0, pDevice->MaxSamplesPerCycle());
384                    pChannelRight = new AudioChannel(1, pDevice->MaxSamplesPerCycle());
385                } else {
386                    // postpone local render buffer creation until audio device is assigned
387                    pChannelLeft  = NULL;
388                    pChannelRight = NULL;
389                }
390            }
391            fxSends.push_back(pFxSend);
392            if (pEngine) pEngine->Enable();
393            return pFxSend;
394        }
395    
396        FxSend* EngineChannel::GetFxSend(uint FxSendIndex) {
397            return (FxSendIndex < fxSends.size()) ? fxSends[FxSendIndex] : NULL;
398        }
399    
400        uint EngineChannel::GetFxSendCount() {
401            return fxSends.size();
402        }
403    
404        void EngineChannel::RemoveFxSend(FxSend* pFxSend) {
405            if (pEngine) pEngine->DisableAndLock();
406            for (
407                std::vector<FxSend*>::iterator iter = fxSends.begin();
408                iter != fxSends.end(); iter++
409            ) {
410                if (*iter == pFxSend) {
411                    delete pFxSend;
412                    fxSends.erase(iter);
413                    if (fxSends.empty()) {
414                        // destroy local render buffers
415                        if (pChannelLeft)  delete pChannelLeft;
416                        if (pChannelRight) delete pChannelRight;
417                        // fallback to render directly into AudioOutputDevice's buffers
418                        if (pEngine && pEngine->pAudioOutputDevice) {
419                            pChannelLeft  = pEngine->pAudioOutputDevice->Channel(AudioDeviceChannelLeft);
420                            pChannelRight = pEngine->pAudioOutputDevice->Channel(AudioDeviceChannelRight);
421                        } else { // we update the pointers later
422                            pChannelLeft  = NULL;
423                            pChannelRight = NULL;
424                        }
425                    }
426                    break;
427                }
428            }
429            if (pEngine) pEngine->Enable();
430        }
431    
432      /**      /**
433       *  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
434       *  voice for the given key.       *  voice for the given key. This method is meant for real time rendering,
435         *  that is an event will immediately be created with the current system
436         *  time as time stamp.
437       *       *
438       *  @param Key      - MIDI key number of the triggered key       *  @param Key      - MIDI key number of the triggered key
439       *  @param Velocity - MIDI velocity value of the triggered key       *  @param Velocity - MIDI velocity value of the triggered key
# Line 360  namespace LinuxSampler { namespace gig { Line 451  namespace LinuxSampler { namespace gig {
451      }      }
452    
453      /**      /**
454         *  Will be called by the MIDIIn Thread to let the audio thread trigger a new
455         *  voice for the given key. This method is meant for offline rendering
456         *  and / or for cases where the exact position of the event in the current
457         *  audio fragment is already known.
458         *
459         *  @param Key         - MIDI key number of the triggered key
460         *  @param Velocity    - MIDI velocity value of the triggered key
461         *  @param FragmentPos - sample point position in the current audio
462         *                       fragment to which this event belongs to
463         */
464        void EngineChannel::SendNoteOn(uint8_t Key, uint8_t Velocity, int32_t FragmentPos) {
465            if (FragmentPos < 0) {
466                dmsg(1,("EngineChannel::SendNoteOn(): negative FragmentPos! Seems MIDI driver is buggy!"));
467            }
468            else if (pEngine) {
469                Event event               = pEngine->pEventGenerator->CreateEvent(FragmentPos);
470                event.Type                = Event::type_note_on;
471                event.Param.Note.Key      = Key;
472                event.Param.Note.Velocity = Velocity;
473                event.pEngineChannel      = this;
474                if (this->pEventQueue->write_space() > 0) this->pEventQueue->push(&event);
475                else dmsg(1,("EngineChannel: Input event queue full!"));
476            }
477        }
478    
479        /**
480       *  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
481       *  voice(s) on the given key.       *  voice(s) on the given key. This method is meant for real time rendering,
482         *  that is an event will immediately be created with the current system
483         *  time as time stamp.
484       *       *
485       *  @param Key      - MIDI key number of the released key       *  @param Key      - MIDI key number of the released key
486       *  @param Velocity - MIDI release velocity value of the released key       *  @param Velocity - MIDI release velocity value of the released key
# Line 379  namespace LinuxSampler { namespace gig { Line 498  namespace LinuxSampler { namespace gig {
498      }      }
499    
500      /**      /**
501         *  Will be called by the MIDIIn Thread to signal the audio thread to release
502         *  voice(s) on the given key. This method is meant for offline rendering
503         *  and / or for cases where the exact position of the event in the current
504         *  audio fragment is already known.
505         *
506         *  @param Key         - MIDI key number of the released key
507         *  @param Velocity    - MIDI release velocity value of the released key
508         *  @param FragmentPos - sample point position in the current audio
509         *                       fragment to which this event belongs to
510         */
511        void EngineChannel::SendNoteOff(uint8_t Key, uint8_t Velocity, int32_t FragmentPos) {
512            if (FragmentPos < 0) {
513                dmsg(1,("EngineChannel::SendNoteOff(): negative FragmentPos! Seems MIDI driver is buggy!"));
514            }
515            else if (pEngine) {
516                Event event               = pEngine->pEventGenerator->CreateEvent(FragmentPos);
517                event.Type                = Event::type_note_off;
518                event.Param.Note.Key      = Key;
519                event.Param.Note.Velocity = Velocity;
520                event.pEngineChannel      = this;
521                if (this->pEventQueue->write_space() > 0) this->pEventQueue->push(&event);
522                else dmsg(1,("EngineChannel: Input event queue full!"));
523            }
524        }
525    
526        /**
527       *  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
528       *  the pitch value for all voices.       *  the pitch value for all voices. This method is meant for real time
529         *  rendering, that is an event will immediately be created with the
530         *  current system time as time stamp.
531       *       *
532       *  @param Pitch - MIDI pitch value (-8192 ... +8191)       *  @param Pitch - MIDI pitch value (-8192 ... +8191)
533       */       */
# Line 396  namespace LinuxSampler { namespace gig { Line 543  namespace LinuxSampler { namespace gig {
543      }      }
544    
545      /**      /**
546         *  Will be called by the MIDIIn Thread to signal the audio thread to change
547         *  the pitch value for all voices. This method is meant for offline
548         *  rendering and / or for cases where the exact position of the event in
549         *  the current audio fragment is already known.
550         *
551         *  @param Pitch       - MIDI pitch value (-8192 ... +8191)
552         *  @param FragmentPos - sample point position in the current audio
553         *                       fragment to which this event belongs to
554         */
555        void EngineChannel::SendPitchbend(int Pitch, int32_t FragmentPos) {
556            if (FragmentPos < 0) {
557                dmsg(1,("EngineChannel::SendPitchBend(): negative FragmentPos! Seems MIDI driver is buggy!"));
558            }
559            else if (pEngine) {
560                Event event             = pEngine->pEventGenerator->CreateEvent(FragmentPos);
561                event.Type              = Event::type_pitchbend;
562                event.Param.Pitch.Pitch = Pitch;
563                event.pEngineChannel    = this;
564                if (this->pEventQueue->write_space() > 0) this->pEventQueue->push(&event);
565                else dmsg(1,("EngineChannel: Input event queue full!"));
566            }
567        }
568    
569        /**
570       *  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
571       *  continuous controller value has changed.       *  continuous controller value has changed. This method is meant for real
572         *  time rendering, that is an event will immediately be created with the
573         *  current system time as time stamp.
574       *       *
575       *  @param Controller - MIDI controller number of the occured control change       *  @param Controller - MIDI controller number of the occured control change
576       *  @param Value      - value of the control change       *  @param Value      - value of the control change
# Line 414  namespace LinuxSampler { namespace gig { Line 587  namespace LinuxSampler { namespace gig {
587          }          }
588      }      }
589    
590        /**
591         *  Will be called by the MIDIIn Thread to signal the audio thread that a
592         *  continuous controller value has changed. This method is meant for
593         *  offline rendering and / or for cases where the exact position of the
594         *  event in the current audio fragment is already known.
595         *
596         *  @param Controller  - MIDI controller number of the occured control change
597         *  @param Value       - value of the control change
598         *  @param FragmentPos - sample point position in the current audio
599         *                       fragment to which this event belongs to
600         */
601        void EngineChannel::SendControlChange(uint8_t Controller, uint8_t Value, int32_t FragmentPos) {
602            if (FragmentPos < 0) {
603                dmsg(1,("EngineChannel::SendControlChange(): negative FragmentPos! Seems MIDI driver is buggy!"));
604            }
605            else if (pEngine) {
606                Event event               = pEngine->pEventGenerator->CreateEvent(FragmentPos);
607                event.Type                = Event::type_control_change;
608                event.Param.CC.Controller = Controller;
609                event.Param.CC.Value      = Value;
610                event.pEngineChannel      = this;
611                if (this->pEventQueue->write_space() > 0) this->pEventQueue->push(&event);
612                else dmsg(1,("EngineChannel: Input event queue full!"));
613            }
614        }
615    
616      void EngineChannel::ClearEventLists() {      void EngineChannel::ClearEventLists() {
617          pEvents->clear();          pEvents->clear();
         pCCEvents->clear();  
         for (uint i = 0; i < Event::destination_count; i++) {  
             pSynthesisEvents[i]->clear();  
         }  
618          // empty MIDI key specific event lists          // empty MIDI key specific event lists
619          {          {
620              RTList<uint>::Iterator iuiKey = pActiveKeys->first();              RTList<uint>::Iterator iuiKey = pActiveKeys->first();
# Line 433  namespace LinuxSampler { namespace gig { Line 628  namespace LinuxSampler { namespace gig {
628      void EngineChannel::ResetControllers() {      void EngineChannel::ResetControllers() {
629          Pitch          = 0;          Pitch          = 0;
630          SustainPedal   = false;          SustainPedal   = false;
631          GlobalVolume   = 1.0;          SostenutoPedal = false;
632            GlobalVolume   = 1.0f;
633            MidiVolume     = 1.0;
634          GlobalPanLeft  = 1.0f;          GlobalPanLeft  = 1.0f;
635          GlobalPanRight = 1.0f;          GlobalPanRight = 1.0f;
636          // set all MIDI controller values to zero          // set all MIDI controller values to zero
637          memset(ControllerTable, 0x00, 128);          memset(ControllerTable, 0x00, 129);
638      }      }
639    
640      /**      /**
# Line 454  namespace LinuxSampler { namespace gig { Line 651  namespace LinuxSampler { namespace gig {
651       *                  current audio cycle       *                  current audio cycle
652       */       */
653      void EngineChannel::ImportEvents(uint Samples) {      void EngineChannel::ImportEvents(uint Samples) {
654          RingBuffer<Event>::NonVolatileReader eventQueueReader = pEventQueue->get_non_volatile_reader();          RingBuffer<Event,false>::NonVolatileReader eventQueueReader = pEventQueue->get_non_volatile_reader();
655          Event* pEvent;          Event* pEvent;
656          while (true) {          while (true) {
657              // get next event from input event queue              // get next event from input event queue
# Line 476  namespace LinuxSampler { namespace gig { Line 673  namespace LinuxSampler { namespace gig {
673          eventQueueReader.free(); // free all copied events from input queue          eventQueueReader.free(); // free all copied events from input queue
674      }      }
675    
676        void EngineChannel::RemoveAllFxSends() {
677            if (pEngine) pEngine->DisableAndLock();
678            if (!fxSends.empty()) { // free local render buffers
679                if (pChannelLeft) {
680                    delete pChannelLeft;
681                    if (pEngine && pEngine->pAudioOutputDevice) {
682                        // fallback to render directly to the AudioOutputDevice's buffer
683                        pChannelLeft = pEngine->pAudioOutputDevice->Channel(AudioDeviceChannelLeft);
684                    } else pChannelLeft = NULL;
685                }
686                if (pChannelRight) {
687                    delete pChannelRight;
688                    if (pEngine && pEngine->pAudioOutputDevice) {
689                        // fallback to render directly to the AudioOutputDevice's buffer
690                        pChannelRight = pEngine->pAudioOutputDevice->Channel(AudioDeviceChannelRight);
691                    } else pChannelRight = NULL;
692                }
693            }
694            for (int i = 0; i < fxSends.size(); i++) delete fxSends[i];
695            fxSends.clear();
696            if (pEngine) pEngine->Enable();
697        }
698    
699      float EngineChannel::Volume() {      float EngineChannel::Volume() {
700          return GlobalVolume;          return GlobalVolume;
701      }      }

Legend:
Removed from v.670  
changed lines
  Added in v.1005

  ViewVC Help
Powered by ViewVC