/[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 354 by schoenebeck, Sat Jan 29 15:17:59 2005 UTC revision 392 by schoenebeck, Sat Feb 19 02:40:24 2005 UTC
# Line 26  Line 26 
26  #include "EGADSR.h"  #include "EGADSR.h"
27    
28  #include "Engine.h"  #include "Engine.h"
29  #include <malloc.h>  
30    #if defined(__APPLE__)
31    # include <stdlib.h>
32    #else
33    # include <malloc.h>
34    #endif
35    
36  namespace LinuxSampler { namespace gig {  namespace LinuxSampler { namespace gig {
37    
# Line 210  namespace LinuxSampler { namespace gig { Line 215  namespace LinuxSampler { namespace gig {
215      }      }
216    
217      /**      /**
218       *  Load an instrument from a .gig file.       * More or less a workaround to set the instrument name, index and load
219         * status variable to zero percent immediately, that is without blocking
220         * the calling thread. It might be used in future for other preparations
221         * as well though.
222         *
223         * @param FileName   - file name of the Gigasampler instrument file
224         * @param Instrument - index of the instrument in the .gig file
225         * @see LoadInstrument()
226         */
227        void Engine::PrepareLoadInstrument(const char* FileName, uint Instrument) {
228            InstrumentFile = FileName;
229            InstrumentIdx  = Instrument;
230            InstrumentStat = 0;
231        }
232    
233        /**
234         * Load an instrument from a .gig file. PrepareLoadInstrument() has to
235         * be called first to provide the information which instrument to load.
236         * This method will then actually start to load the instrument and block
237         * the calling thread until loading was completed.
238       *       *
239       *  @param FileName   - file name of the Gigasampler instrument file       * @returns detailed description of the method call result
240       *  @param Instrument - index of the instrument in the .gig file       * @see PrepareLoadInstrument()
      *  @throws LinuxSamplerException  on error  
      *  @returns          detailed description of the method call result  
241       */       */
242      void Engine::LoadInstrument(const char* FileName, uint Instrument) {      void Engine::LoadInstrument() {
243    
244          DisableAndLock();          DisableAndLock();
245    
# Line 229  namespace LinuxSampler { namespace gig { Line 251  namespace LinuxSampler { namespace gig {
251              Instruments.HandBack(pInstrument, this);              Instruments.HandBack(pInstrument, this);
252          }          }
253    
         InstrumentFile = FileName;  
         InstrumentIdx = Instrument;  
         InstrumentStat = 0;  
   
254          // delete all key groups          // delete all key groups
255          ActiveKeyGroups.clear();          ActiveKeyGroups.clear();
256    
257          // request gig instrument from instrument manager          // request gig instrument from instrument manager
258          try {          try {
259              instrument_id_t instrid;              instrument_id_t instrid;
260              instrid.FileName    = FileName;              instrid.FileName    = InstrumentFile;
261              instrid.iInstrument = Instrument;              instrid.iInstrument = InstrumentIdx;
262              pInstrument = Instruments.Borrow(instrid, this);              pInstrument = Instruments.Borrow(instrid, this);
263              if (!pInstrument) {              if (!pInstrument) {
264                  InstrumentStat = -1;                  InstrumentStat = -1;
# Line 267  namespace LinuxSampler { namespace gig { Line 285  namespace LinuxSampler { namespace gig {
285          for (::gig::Region* pRegion = pInstrument->GetFirstRegion(); pRegion; pRegion = pInstrument->GetNextRegion())          for (::gig::Region* pRegion = pInstrument->GetFirstRegion(); pRegion; pRegion = pInstrument->GetNextRegion())
286              if (pRegion->KeyGroup) ActiveKeyGroups[pRegion->KeyGroup] = NULL;              if (pRegion->KeyGroup) ActiveKeyGroups[pRegion->KeyGroup] = NULL;
287    
288            InstrumentIdxName = pInstrument->pInfo->Name;
289          InstrumentStat = 100;          InstrumentStat = 100;
290    
291          // inform audio driver for the need of two channels          // inform audio driver for the need of two channels
# Line 353  namespace LinuxSampler { namespace gig { Line 372  namespace LinuxSampler { namespace gig {
372    
373          // (re)allocate synthesis parameter matrix          // (re)allocate synthesis parameter matrix
374          if (pSynthesisParameters[0]) free(pSynthesisParameters[0]);          if (pSynthesisParameters[0]) free(pSynthesisParameters[0]);
375    
376            #if defined(__APPLE__)
377            pSynthesisParameters[0] = (float *) malloc(Event::destination_count * sizeof(float) * pAudioOut->MaxSamplesPerCycle());
378            #else
379          pSynthesisParameters[0] = (float *) memalign(16,(Event::destination_count * sizeof(float) * pAudioOut->MaxSamplesPerCycle()));          pSynthesisParameters[0] = (float *) memalign(16,(Event::destination_count * sizeof(float) * pAudioOut->MaxSamplesPerCycle()));
380            #endif
381          for (int dst = 1; dst < Event::destination_count; dst++)          for (int dst = 1; dst < Event::destination_count; dst++)
382              pSynthesisParameters[dst] = pSynthesisParameters[dst - 1] + pAudioOut->MaxSamplesPerCycle();              pSynthesisParameters[dst] = pSynthesisParameters[dst - 1] + pAudioOut->MaxSamplesPerCycle();
383    
# Line 1171  namespace LinuxSampler { namespace gig { Line 1195  namespace LinuxSampler { namespace gig {
1195          return InstrumentFile;          return InstrumentFile;
1196      }      }
1197    
1198        String Engine::InstrumentName() {
1199            return InstrumentIdxName;
1200        }
1201    
1202      int Engine::InstrumentIndex() {      int Engine::InstrumentIndex() {
1203          return InstrumentIdx;          return InstrumentIdx;
1204      }      }
# Line 1184  namespace LinuxSampler { namespace gig { Line 1212  namespace LinuxSampler { namespace gig {
1212      }      }
1213    
1214      String Engine::Version() {      String Engine::Version() {
1215          String s = "$Revision: 1.22 $";          String s = "$Revision: 1.25 $";
1216          return s.substr(11, s.size() - 13); // cut dollar signs, spaces and CVS macro keyword          return s.substr(11, s.size() - 13); // cut dollar signs, spaces and CVS macro keyword
1217      }      }
1218    

Legend:
Removed from v.354  
changed lines
  Added in v.392

  ViewVC Help
Powered by ViewVC