/[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 1038 by persson, Sat Feb 3 15:33:00 2007 UTC
# Line 163  namespace LinuxSampler { namespace gig { Line 163  namespace LinuxSampler { namespace gig {
163       * @see PrepareLoadInstrument()       * @see PrepareLoadInstrument()
164       */       */
165      void EngineChannel::LoadInstrument() {      void EngineChannel::LoadInstrument() {
166            ::gig::Instrument* oldInstrument = pInstrument;
         if (pEngine) pEngine->DisableAndLock();  
   
         ResetInternal();  
167    
168          // free old instrument          // free old instrument
169          if (pInstrument) {          if (oldInstrument) {
170              // give old instrument back to instrument manager              if (pEngine) {
171              Engine::instruments.HandBack(pInstrument, this);                  // make sure we don't trigger any new notes with the
172                    // old instrument
173                    ::gig::DimensionRegion** dimRegionsInUse = pEngine->ChangeInstrument(this, 0);
174    
175                    // give old instrument back to instrument manager, but
176                    // keep the dimension regions and samples that are in
177                    // use
178                    Engine::instruments.HandBackInstrument(oldInstrument, this, dimRegionsInUse);
179                } else {
180                    Engine::instruments.HandBack(oldInstrument, this);
181                }
182          }          }
183    
184          // delete all key groups          // delete all key groups
185          ActiveKeyGroups.clear();          ActiveKeyGroups.clear();
186    
187          // request gig instrument from instrument manager          // request gig instrument from instrument manager
188            ::gig::Instrument* newInstrument;
189          try {          try {
190              InstrumentManager::instrument_id_t instrid;              InstrumentManager::instrument_id_t instrid;
191              instrid.FileName  = InstrumentFile;              instrid.FileName  = InstrumentFile;
192              instrid.Index     = InstrumentIdx;              instrid.Index     = InstrumentIdx;
193              pInstrument = Engine::instruments.Borrow(instrid, this);              newInstrument = Engine::instruments.Borrow(instrid, this);
194              if (!pInstrument) {              if (!newInstrument) {
195                  InstrumentStat = -1;                  InstrumentStat = -1;
196                  dmsg(1,("no instrument loaded!!!\n"));                  dmsg(1,("no instrument loaded!!!\n"));
197                  exit(EXIT_FAILURE);                  exit(EXIT_FAILURE);
# Line 205  namespace LinuxSampler { namespace gig { Line 213  namespace LinuxSampler { namespace gig {
213          }          }
214    
215          // rebuild ActiveKeyGroups map with key groups of current instrument          // rebuild ActiveKeyGroups map with key groups of current instrument
216          for (::gig::Region* pRegion = pInstrument->GetFirstRegion(); pRegion; pRegion = pInstrument->GetNextRegion())          for (::gig::Region* pRegion = newInstrument->GetFirstRegion(); pRegion; pRegion = newInstrument->GetNextRegion())
217              if (pRegion->KeyGroup) ActiveKeyGroups[pRegion->KeyGroup] = NULL;              if (pRegion->KeyGroup) ActiveKeyGroups[pRegion->KeyGroup] = NULL;
218    
219          InstrumentIdxName = pInstrument->pInfo->Name;          InstrumentIdxName = newInstrument->pInfo->Name;
220          InstrumentStat = 100;          InstrumentStat = 100;
221    
222          // inform audio driver for the need of two channels          if (pEngine) pEngine->ChangeInstrument(this, newInstrument);
223          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();  
224      }      }
225    
226      /**      /**
# Line 282  namespace LinuxSampler { namespace gig { Line 281  namespace LinuxSampler { namespace gig {
281              pChannelLeft  = new AudioChannel(0, pAudioOut->MaxSamplesPerCycle());              pChannelLeft  = new AudioChannel(0, pAudioOut->MaxSamplesPerCycle());
282              pChannelRight = new AudioChannel(1, pAudioOut->MaxSamplesPerCycle());              pChannelRight = new AudioChannel(1, pAudioOut->MaxSamplesPerCycle());
283          }          }
284            pEngine->Enable();
285          MidiInputPort::AddSysexListener(pEngine);          MidiInputPort::AddSysexListener(pEngine);
286      }      }
287    

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

  ViewVC Help
Powered by ViewVC