/[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 319 by schoenebeck, Mon Dec 13 00:46:42 2004 UTC revision 376 by senkov, Sat Feb 12 23:48:50 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 77  namespace LinuxSampler { namespace gig { Line 82  namespace LinuxSampler { namespace gig {
82    
83      Engine::~Engine() {      Engine::~Engine() {
84          if (pDiskThread) {          if (pDiskThread) {
85                dmsg(1,("Stopping disk thread..."));
86              pDiskThread->StopThread();              pDiskThread->StopThread();
87              delete pDiskThread;              delete pDiskThread;
88                dmsg(1,("OK\n"));
89          }          }
90    
91            if (pInstrument) Instruments.HandBack(pInstrument, this);
92    
93          if (pGig)  delete pGig;          if (pGig)  delete pGig;
94          if (pRIFF) delete pRIFF;          if (pRIFF) delete pRIFF;
95          for (uint i = 0; i < 128; i++) {          for (uint i = 0; i < 128; i++) {
# Line 89  namespace LinuxSampler { namespace gig { Line 99  namespace LinuxSampler { namespace gig {
99          for (uint i = 0; i < Event::destination_count; i++) {          for (uint i = 0; i < Event::destination_count; i++) {
100              if (pSynthesisEvents[i]) delete pSynthesisEvents[i];              if (pSynthesisEvents[i]) delete pSynthesisEvents[i];
101          }          }
         delete[] pSynthesisEvents;  
102          if (pEvents)     delete pEvents;          if (pEvents)     delete pEvents;
103          if (pCCEvents)   delete pCCEvents;          if (pCCEvents)   delete pCCEvents;
104          if (pEventQueue) delete pEventQueue;          if (pEventQueue) delete pEventQueue;
105          if (pEventPool)  delete pEventPool;          if (pEventPool)  delete pEventPool;
106          if (pVoicePool)  delete pVoicePool;          if (pVoicePool) {
107                    pVoicePool->clear();
108                    delete pVoicePool;
109            }
110          if (pActiveKeys) delete pActiveKeys;          if (pActiveKeys) delete pActiveKeys;
111          if (pSysexBuffer) delete pSysexBuffer;          if (pSysexBuffer) delete pSysexBuffer;
112          if (pEventGenerator) delete pEventGenerator;          if (pEventGenerator) delete pEventGenerator;
# Line 159  namespace LinuxSampler { namespace gig { Line 171  namespace LinuxSampler { namespace gig {
171          ActiveVoiceCount    = 0;          ActiveVoiceCount    = 0;
172          ActiveVoiceCountMax = 0;          ActiveVoiceCountMax = 0;
173          GlobalVolume        = 1.0;          GlobalVolume        = 1.0;
174            CurrentKeyDimension = 0;
175    
176          // reset voice stealing parameters          // reset voice stealing parameters
177          itLastStolenVoice = RTList<Voice>::Iterator();          itLastStolenVoice = RTList<Voice>::Iterator();
# Line 259  namespace LinuxSampler { namespace gig { Line 272  namespace LinuxSampler { namespace gig {
272          for (::gig::Region* pRegion = pInstrument->GetFirstRegion(); pRegion; pRegion = pInstrument->GetNextRegion())          for (::gig::Region* pRegion = pInstrument->GetFirstRegion(); pRegion; pRegion = pInstrument->GetNextRegion())
273              if (pRegion->KeyGroup) ActiveKeyGroups[pRegion->KeyGroup] = NULL;              if (pRegion->KeyGroup) ActiveKeyGroups[pRegion->KeyGroup] = NULL;
274    
275            InstrumentIdxName = pInstrument->pInfo->Name;
276          InstrumentStat = 100;          InstrumentStat = 100;
277    
278          // inform audio driver for the need of two channels          // inform audio driver for the need of two channels
# Line 322  namespace LinuxSampler { namespace gig { Line 336  namespace LinuxSampler { namespace gig {
336    
337          // (re)create disk thread          // (re)create disk thread
338          if (this->pDiskThread) {          if (this->pDiskThread) {
339                dmsg(1,("Stopping disk thread..."));
340              this->pDiskThread->StopThread();              this->pDiskThread->StopThread();
341              delete this->pDiskThread;              delete this->pDiskThread;
342                dmsg(1,("OK\n"));
343          }          }
344          this->pDiskThread = new DiskThread(((pAudioOut->MaxSamplesPerCycle() << MAX_PITCH) << 1) + 6); //FIXME: assuming stereo          this->pDiskThread = new DiskThread(((pAudioOut->MaxSamplesPerCycle() << MAX_PITCH) << 1) + 6); //FIXME: assuming stereo
345          if (!pDiskThread) {          if (!pDiskThread) {
# Line 343  namespace LinuxSampler { namespace gig { Line 359  namespace LinuxSampler { namespace gig {
359    
360          // (re)allocate synthesis parameter matrix          // (re)allocate synthesis parameter matrix
361          if (pSynthesisParameters[0]) free(pSynthesisParameters[0]);          if (pSynthesisParameters[0]) free(pSynthesisParameters[0]);
362    
363            #if defined(__APPLE__)
364            pSynthesisParameters[0] = (float *) malloc(Event::destination_count * sizeof(float) * pAudioOut->MaxSamplesPerCycle());
365            #else
366          pSynthesisParameters[0] = (float *) memalign(16,(Event::destination_count * sizeof(float) * pAudioOut->MaxSamplesPerCycle()));          pSynthesisParameters[0] = (float *) memalign(16,(Event::destination_count * sizeof(float) * pAudioOut->MaxSamplesPerCycle()));
367            #endif
368          for (int dst = 1; dst < Event::destination_count; dst++)          for (int dst = 1; dst < Event::destination_count; dst++)
369              pSynthesisParameters[dst] = pSynthesisParameters[dst - 1] + pAudioOut->MaxSamplesPerCycle();              pSynthesisParameters[dst] = pSynthesisParameters[dst - 1] + pAudioOut->MaxSamplesPerCycle();
370    
# Line 653  namespace LinuxSampler { namespace gig { Line 674  namespace LinuxSampler { namespace gig {
674       *  @param itNoteOnEvent - key, velocity and time stamp of the event       *  @param itNoteOnEvent - key, velocity and time stamp of the event
675       */       */
676      void Engine::ProcessNoteOn(Pool<Event>::Iterator& itNoteOnEvent) {      void Engine::ProcessNoteOn(Pool<Event>::Iterator& itNoteOnEvent) {
677          midi_key_info_t* pKey = &pMIDIKeyInfo[itNoteOnEvent->Param.Note.Key];  
678            const int key = itNoteOnEvent->Param.Note.Key;
679    
680            // Change key dimension value if key is in keyswitching area
681            if (key >= pInstrument->DimensionKeyRange.low && key <= pInstrument->DimensionKeyRange.high)
682                CurrentKeyDimension = ((key - pInstrument->DimensionKeyRange.low) * 128) /
683                    (pInstrument->DimensionKeyRange.high - pInstrument->DimensionKeyRange.low + 1);
684    
685            midi_key_info_t* pKey = &pMIDIKeyInfo[key];
686    
687          pKey->KeyPressed = true; // the MIDI key was now pressed down          pKey->KeyPressed = true; // the MIDI key was now pressed down
688    
# Line 727  namespace LinuxSampler { namespace gig { Line 756  namespace LinuxSampler { namespace gig {
756       *                               when there is no free voice       *                               when there is no free voice
757       *                               (optional, default = true)       *                               (optional, default = true)
758       *  @returns pointer to new voice or NULL if there was no free voice or       *  @returns pointer to new voice or NULL if there was no free voice or
759       *           if an error occured while trying to trigger the new voice       *           if the voice wasn't triggered (for example when no region is
760         *           defined for the given key).
761       */       */
762      Pool<Voice>::Iterator Engine::LaunchVoice(Pool<Event>::Iterator& itNoteOnEvent, int iLayer, bool ReleaseTriggerVoice, bool VoiceStealing) {      Pool<Voice>::Iterator Engine::LaunchVoice(Pool<Event>::Iterator& itNoteOnEvent, int iLayer, bool ReleaseTriggerVoice, bool VoiceStealing) {
763          midi_key_info_t* pKey = &pMIDIKeyInfo[itNoteOnEvent->Param.Note.Key];          midi_key_info_t* pKey = &pMIDIKeyInfo[itNoteOnEvent->Param.Note.Key];
# Line 737  namespace LinuxSampler { namespace gig { Line 767  namespace LinuxSampler { namespace gig {
767          if (itNewVoice) {          if (itNewVoice) {
768              // launch the new voice              // launch the new voice
769              if (itNewVoice->Trigger(itNoteOnEvent, this->Pitch, this->pInstrument, iLayer, ReleaseTriggerVoice, VoiceStealing) < 0) {              if (itNewVoice->Trigger(itNoteOnEvent, this->Pitch, this->pInstrument, iLayer, ReleaseTriggerVoice, VoiceStealing) < 0) {
770                  dmsg(1,("Triggering new voice failed!\n"));                  dmsg(4,("Voice not triggered\n"));
771                  pKey->pActiveVoices->free(itNewVoice);                  pKey->pActiveVoices->free(itNewVoice);
772              }              }
773              else { // on success              else { // on success
# Line 1152  namespace LinuxSampler { namespace gig { Line 1182  namespace LinuxSampler { namespace gig {
1182          return InstrumentFile;          return InstrumentFile;
1183      }      }
1184    
1185        String Engine::InstrumentName() {
1186            return InstrumentIdxName;
1187        }
1188    
1189      int Engine::InstrumentIndex() {      int Engine::InstrumentIndex() {
1190          return InstrumentIdx;          return InstrumentIdx;
1191      }      }
# Line 1165  namespace LinuxSampler { namespace gig { Line 1199  namespace LinuxSampler { namespace gig {
1199      }      }
1200    
1201      String Engine::Version() {      String Engine::Version() {
1202          String s = "$Revision: 1.19 $";          String s = "$Revision: 1.24 $";
1203          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
1204      }      }
1205    

Legend:
Removed from v.319  
changed lines
  Added in v.376

  ViewVC Help
Powered by ViewVC