/[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 53 by schoenebeck, Mon Apr 26 17:15:51 2004 UTC revision 133 by capela, Fri Jun 18 14:29:02 2004 UTC
# Line 2  Line 2 
2   *                                                                         *   *                                                                         *
3   *   LinuxSampler - modular, streaming capable sampler                     *   *   LinuxSampler - modular, streaming capable sampler                     *
4   *                                                                         *   *                                                                         *
5   *   Copyright (C) 2003 by Benno Senoner and Christian Schoenebeck         *   *   Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck   *
6   *                                                                         *   *                                                                         *
7   *   This program is free software; you can redistribute it and/or modify  *   *   This program is free software; you can redistribute it and/or modify  *
8   *   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 59  namespace LinuxSampler { namespace gig { Line 59  namespace LinuxSampler { namespace gig {
59          pVoicePool->clear();          pVoicePool->clear();
60    
61          pSynthesisParameters[0] = NULL; // we allocate when an audio device is connected          pSynthesisParameters[0] = NULL; // we allocate when an audio device is connected
62            pBasicFilterParameters  = NULL;
63            pMainFilterParameters   = NULL;
64    
65            InstrumentIdx = -1;
66            InstrumentStat = -1;
67    
68          ResetInternal();          ResetInternal();
69      }      }
# Line 85  namespace LinuxSampler { namespace gig { Line 90  namespace LinuxSampler { namespace gig {
90          if (pVoicePool)  delete pVoicePool;          if (pVoicePool)  delete pVoicePool;
91          if (pActiveKeys) delete pActiveKeys;          if (pActiveKeys) delete pActiveKeys;
92          if (pEventGenerator) delete pEventGenerator;          if (pEventGenerator) delete pEventGenerator;
93            if (pMainFilterParameters) delete[] pMainFilterParameters;
94            if (pBasicFilterParameters) delete[] pBasicFilterParameters;
95          if (pSynthesisParameters[0]) delete[] pSynthesisParameters[0];          if (pSynthesisParameters[0]) delete[] pSynthesisParameters[0];
96      }      }
97    
98      void Engine::Enable() {      void Engine::Enable() {
99          dmsg(3,("gig::Engine: enabling\n"));          dmsg(3,("gig::Engine: enabling\n"));
100          EngineDisabled.PushAndUnlock(false, 2); // set condition object 'EngineDisabled' to false (wait max. 2s)          EngineDisabled.PushAndUnlock(false, 2); // set condition object 'EngineDisabled' to false (wait max. 2s)
101          dmsg(1,("gig::Engine: enabled (val=%d)\n", EngineDisabled.GetUnsafe()));          dmsg(3,("gig::Engine: enabled (val=%d)\n", EngineDisabled.GetUnsafe()));
102      }      }
103    
104      void Engine::Disable() {      void Engine::Disable() {
# Line 191  namespace LinuxSampler { namespace gig { Line 198  namespace LinuxSampler { namespace gig {
198              Instruments.HandBack(pInstrument, this);              Instruments.HandBack(pInstrument, this);
199          }          }
200    
201            InstrumentFile = FileName;
202            InstrumentIdx = Instrument;
203            InstrumentStat = 0;
204    
205          // request gig instrument from instrument manager          // request gig instrument from instrument manager
206          try {          try {
207              instrument_id_t instrid;              instrument_id_t instrid;
# Line 198  namespace LinuxSampler { namespace gig { Line 209  namespace LinuxSampler { namespace gig {
209              instrid.iInstrument = Instrument;              instrid.iInstrument = Instrument;
210              pInstrument = Instruments.Borrow(instrid, this);              pInstrument = Instruments.Borrow(instrid, this);
211              if (!pInstrument) {              if (!pInstrument) {
212                    InstrumentStat = -1;
213                  dmsg(1,("no instrument loaded!!!\n"));                  dmsg(1,("no instrument loaded!!!\n"));
214                  exit(EXIT_FAILURE);                  exit(EXIT_FAILURE);
215              }              }
216          }          }
217          catch (RIFF::Exception e) {          catch (RIFF::Exception e) {
218                InstrumentStat = -2;
219              String msg = "gig::Engine error: Failed to load instrument, cause: " + e.Message;              String msg = "gig::Engine error: Failed to load instrument, cause: " + e.Message;
220              throw LinuxSamplerException(msg);              throw LinuxSamplerException(msg);
221          }          }
222          catch (InstrumentResourceManagerException e) {          catch (InstrumentResourceManagerException e) {
223                InstrumentStat = -3;
224              String msg = "gig::Engine error: Failed to load instrument, cause: " + e.Message();              String msg = "gig::Engine error: Failed to load instrument, cause: " + e.Message();
225              throw LinuxSamplerException(msg);              throw LinuxSamplerException(msg);
226          }          }
227          catch (...) {          catch (...) {
228                InstrumentStat = -4;
229              throw LinuxSamplerException("gig::Engine error: Failed to load instrument, cause: Unknown exception while trying to parse gig file.");              throw LinuxSamplerException("gig::Engine error: Failed to load instrument, cause: Unknown exception while trying to parse gig file.");
230          }          }
231    
232            InstrumentStat = 100;
233    
234          // inform audio driver for the need of two channels          // inform audio driver for the need of two channels
235          try {          try {
236              if (pAudioOutputDevice) pAudioOutputDevice->AcquireChannels(2); // gig Engine only stereo              if (pAudioOutputDevice) pAudioOutputDevice->AcquireChannels(2); // gig Engine only stereo
# Line 289  namespace LinuxSampler { namespace gig { Line 306  namespace LinuxSampler { namespace gig {
306          for (int dst = 1; dst < Event::destination_count; dst++)          for (int dst = 1; dst < Event::destination_count; dst++)
307              pSynthesisParameters[dst] = pSynthesisParameters[dst - 1] + pAudioOut->MaxSamplesPerCycle();              pSynthesisParameters[dst] = pSynthesisParameters[dst - 1] + pAudioOut->MaxSamplesPerCycle();
308    
309            // (re)allocate biquad filter parameter sequence
310            if (pBasicFilterParameters) delete[] pBasicFilterParameters;
311            if (pMainFilterParameters)  delete[] pMainFilterParameters;
312            pBasicFilterParameters = new biquad_param_t[pAudioOut->MaxSamplesPerCycle()];
313            pMainFilterParameters  = new biquad_param_t[pAudioOut->MaxSamplesPerCycle()];
314    
315          dmsg(1,("Starting disk thread..."));          dmsg(1,("Starting disk thread..."));
316          pDiskThread->StartThread();          pDiskThread->StartThread();
317          dmsg(1,("OK\n"));          dmsg(1,("OK\n"));
# Line 635  namespace LinuxSampler { namespace gig { Line 658  namespace LinuxSampler { namespace gig {
658       */       */
659      void Engine::ResetSynthesisParameters(Event::destination_t dst, float val) {      void Engine::ResetSynthesisParameters(Event::destination_t dst, float val) {
660          int maxsamples = pAudioOutputDevice->MaxSamplesPerCycle();          int maxsamples = pAudioOutputDevice->MaxSamplesPerCycle();
661          for (int i = 0; i < maxsamples; i++) pSynthesisParameters[dst][i] = val;          float* m = &pSynthesisParameters[dst][0];
662            for (int i = 0; i < maxsamples; i += 4) {
663               m[i]   = val;
664               m[i+1] = val;
665               m[i+2] = val;
666               m[i+3] = val;
667            }
668      }      }
669    
670      float Engine::Volume() {      float Engine::Volume() {
# Line 674  namespace LinuxSampler { namespace gig { Line 703  namespace LinuxSampler { namespace gig {
703          return pDiskThread->GetBufferFillPercentage();          return pDiskThread->GetBufferFillPercentage();
704      }      }
705    
706        String Engine::EngineName() {
707            return "GigEngine";
708        }
709    
710        String Engine::InstrumentFileName() {
711            return InstrumentFile;
712        }
713    
714        int Engine::InstrumentIndex() {
715            return InstrumentIdx;
716        }
717    
718        int Engine::InstrumentStatus() {
719            return InstrumentStat;
720        }
721    
722      String Engine::Description() {      String Engine::Description() {
723          return "Gigasampler Engine";          return "Gigasampler Engine";
724      }      }
725    
726      String Engine::Version() {      String Engine::Version() {
727          return "0.0.1-0cvs20040423";          String s = "$Revision: 1.7 $";
728            return s.substr(11, s.size() - 13); // cut dollar signs, spaces and CVS macro keyword
729      }      }
730    
731  }} // namespace LinuxSampler::gig  }} // namespace LinuxSampler::gig

Legend:
Removed from v.53  
changed lines
  Added in v.133

  ViewVC Help
Powered by ViewVC