/[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 1005 by schoenebeck, Fri Dec 29 20:06:14 2006 UTC revision 1212 by schoenebeck, Tue May 29 23:59:36 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 159  namespace LinuxSampler { namespace gig { Line 159  namespace LinuxSampler { namespace gig {
159       * This method will then actually start to load the instrument and block       * This method will then actually start to load the instrument and block
160       * the calling thread until loading was completed.       * the calling thread until loading was completed.
161       *       *
      * @returns detailed description of the method call result  
162       * @see PrepareLoadInstrument()       * @see PrepareLoadInstrument()
163       */       */
164      void EngineChannel::LoadInstrument() {      void EngineChannel::LoadInstrument() {
165            ::gig::Instrument* oldInstrument = pInstrument;
         if (pEngine) pEngine->DisableAndLock();  
   
         ResetInternal();  
166    
167          // free old instrument          // free old instrument
168          if (pInstrument) {          if (oldInstrument) {
169              // give old instrument back to instrument manager              if (pEngine) {
170              Engine::instruments.HandBack(pInstrument, this);                  // make sure we don't trigger any new notes with the
171                    // old instrument
172                    ::gig::DimensionRegion** dimRegionsInUse = pEngine->ChangeInstrument(this, 0);
173    
174                    // give old instrument back to instrument manager, but
175                    // keep the dimension regions and samples that are in
176                    // use
177                    Engine::instruments.HandBackInstrument(oldInstrument, this, dimRegionsInUse);
178                } else {
179                    Engine::instruments.HandBack(oldInstrument, this);
180                }
181          }          }
182    
183          // delete all key groups          // delete all key groups
184          ActiveKeyGroups.clear();          ActiveKeyGroups.clear();
185    
186          // request gig instrument from instrument manager          // request gig instrument from instrument manager
187            ::gig::Instrument* newInstrument;
188          try {          try {
189              InstrumentManager::instrument_id_t instrid;              InstrumentManager::instrument_id_t instrid;
190              instrid.FileName  = InstrumentFile;              instrid.FileName  = InstrumentFile;
191              instrid.Index     = InstrumentIdx;              instrid.Index     = InstrumentIdx;
192              pInstrument = Engine::instruments.Borrow(instrid, this);              newInstrument = Engine::instruments.Borrow(instrid, this);
193              if (!pInstrument) {              if (!newInstrument) {
194                  InstrumentStat = -1;                  throw InstrumentManagerException("resource was not created");
                 dmsg(1,("no instrument loaded!!!\n"));  
                 exit(EXIT_FAILURE);  
195              }              }
196          }          }
197          catch (RIFF::Exception e) {          catch (RIFF::Exception e) {
# Line 194  namespace LinuxSampler { namespace gig { Line 199  namespace LinuxSampler { namespace gig {
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 Exception(msg);              throw Exception(msg);
201          }          }
202          catch (InstrumentResourceManagerException e) {          catch (InstrumentManagerException e) {
203              InstrumentStat = -3;              InstrumentStat = -3;
204              String msg = "gig::Engine error: Failed to load instrument, cause: " + e.Message();              String msg = "gig::Engine error: Failed to load instrument, cause: " + e.Message();
205              throw Exception(msg);              throw Exception(msg);
# Line 205  namespace LinuxSampler { namespace gig { Line 210  namespace LinuxSampler { namespace gig {
210          }          }
211    
212          // rebuild ActiveKeyGroups map with key groups of current instrument          // rebuild ActiveKeyGroups map with key groups of current instrument
213          for (::gig::Region* pRegion = pInstrument->GetFirstRegion(); pRegion; pRegion = pInstrument->GetNextRegion())          for (::gig::Region* pRegion = newInstrument->GetFirstRegion(); pRegion; pRegion = newInstrument->GetNextRegion())
214              if (pRegion->KeyGroup) ActiveKeyGroups[pRegion->KeyGroup] = NULL;              if (pRegion->KeyGroup) ActiveKeyGroups[pRegion->KeyGroup] = NULL;
215    
216          InstrumentIdxName = pInstrument->pInfo->Name;          InstrumentIdxName = newInstrument->pInfo->Name;
217          InstrumentStat = 100;          InstrumentStat = 100;
218    
219          // inform audio driver for the need of two channels          if (pEngine) pEngine->ChangeInstrument(this, newInstrument);
220          try {          else pInstrument = newInstrument;
             if (pEngine && pEngine->pAudioOutputDevice)  
                 pEngine->pAudioOutputDevice->AcquireChannels(2); // gig Engine only stereo  
         }  
         catch (AudioOutputException e) {  
             String msg = "Audio output device unable to provide 2 audio channels, cause: " + e.Message();  
             throw Exception(msg);  
         }  
   
         if (pEngine) pEngine->Enable();  
221      }      }
222    
223      /**      /**
# Line 282  namespace LinuxSampler { namespace gig { Line 278  namespace LinuxSampler { namespace gig {
278              pChannelLeft  = new AudioChannel(0, pAudioOut->MaxSamplesPerCycle());              pChannelLeft  = new AudioChannel(0, pAudioOut->MaxSamplesPerCycle());
279              pChannelRight = new AudioChannel(1, pAudioOut->MaxSamplesPerCycle());              pChannelRight = new AudioChannel(1, pAudioOut->MaxSamplesPerCycle());
280          }          }
281            if (pEngine->EngineDisabled.GetUnsafe()) pEngine->Enable();
282          MidiInputPort::AddSysexListener(pEngine);          MidiInputPort::AddSysexListener(pEngine);
283      }      }
284    
# Line 390  namespace LinuxSampler { namespace gig { Line 387  namespace LinuxSampler { namespace gig {
387          }          }
388          fxSends.push_back(pFxSend);          fxSends.push_back(pFxSend);
389          if (pEngine) pEngine->Enable();          if (pEngine) pEngine->Enable();
390            fireFxSendCountChanged(iSamplerChannelIndex, GetFxSendCount());
391            
392          return pFxSend;          return pFxSend;
393      }      }
394    
# Line 427  namespace LinuxSampler { namespace gig { Line 426  namespace LinuxSampler { namespace gig {
426              }              }
427          }          }
428          if (pEngine) pEngine->Enable();          if (pEngine) pEngine->Enable();
429            fireFxSendCountChanged(iSamplerChannelIndex, GetFxSendCount());
430      }      }
431    
432      /**      /**
# Line 633  namespace LinuxSampler { namespace gig { Line 633  namespace LinuxSampler { namespace gig {
633          MidiVolume     = 1.0;          MidiVolume     = 1.0;
634          GlobalPanLeft  = 1.0f;          GlobalPanLeft  = 1.0f;
635          GlobalPanRight = 1.0f;          GlobalPanRight = 1.0f;
636            GlobalTranspose = 0;
637          // set all MIDI controller values to zero          // set all MIDI controller values to zero
638          memset(ControllerTable, 0x00, 129);          memset(ControllerTable, 0x00, 129);
639            // reset all FX Send levels
640            for (
641                std::vector<FxSend*>::iterator iter = fxSends.begin();
642                iter != fxSends.end(); iter++
643            ) {
644                (*iter)->Reset();
645            }
646      }      }
647    
648      /**      /**

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

  ViewVC Help
Powered by ViewVC