/[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 351 by schoenebeck, Tue Jan 25 22:11:43 2005 UTC revision 361 by schoenebeck, Wed Feb 9 01:22:18 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 166  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 352  namespace LinuxSampler { namespace gig { Line 358  namespace LinuxSampler { namespace gig {
358    
359          // (re)allocate synthesis parameter matrix          // (re)allocate synthesis parameter matrix
360          if (pSynthesisParameters[0]) free(pSynthesisParameters[0]);          if (pSynthesisParameters[0]) free(pSynthesisParameters[0]);
361    
362            #if defined(__APPLE__)
363            pSynthesisParameters[0] = (float *) malloc(Event::destination_count * sizeof(float) * pAudioOut->MaxSamplesPerCycle());
364            #else
365          pSynthesisParameters[0] = (float *) memalign(16,(Event::destination_count * sizeof(float) * pAudioOut->MaxSamplesPerCycle()));          pSynthesisParameters[0] = (float *) memalign(16,(Event::destination_count * sizeof(float) * pAudioOut->MaxSamplesPerCycle()));
366            #endif
367          for (int dst = 1; dst < Event::destination_count; dst++)          for (int dst = 1; dst < Event::destination_count; dst++)
368              pSynthesisParameters[dst] = pSynthesisParameters[dst - 1] + pAudioOut->MaxSamplesPerCycle();              pSynthesisParameters[dst] = pSynthesisParameters[dst - 1] + pAudioOut->MaxSamplesPerCycle();
369    
# Line 662  namespace LinuxSampler { namespace gig { Line 673  namespace LinuxSampler { namespace gig {
673       *  @param itNoteOnEvent - key, velocity and time stamp of the event       *  @param itNoteOnEvent - key, velocity and time stamp of the event
674       */       */
675      void Engine::ProcessNoteOn(Pool<Event>::Iterator& itNoteOnEvent) {      void Engine::ProcessNoteOn(Pool<Event>::Iterator& itNoteOnEvent) {
676          midi_key_info_t* pKey = &pMIDIKeyInfo[itNoteOnEvent->Param.Note.Key];  
677            const int key = itNoteOnEvent->Param.Note.Key;
678    
679            // Change key dimension value if key is in keyswitching area
680            if (key >= pInstrument->DimensionKeyRange.low && key <= pInstrument->DimensionKeyRange.high)
681                CurrentKeyDimension = ((key - pInstrument->DimensionKeyRange.low) * 128) /
682                    (pInstrument->DimensionKeyRange.high - pInstrument->DimensionKeyRange.low + 1);
683    
684            midi_key_info_t* pKey = &pMIDIKeyInfo[key];
685    
686          pKey->KeyPressed = true; // the MIDI key was now pressed down          pKey->KeyPressed = true; // the MIDI key was now pressed down
687    
# Line 736  namespace LinuxSampler { namespace gig { Line 755  namespace LinuxSampler { namespace gig {
755       *                               when there is no free voice       *                               when there is no free voice
756       *                               (optional, default = true)       *                               (optional, default = true)
757       *  @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
758       *           if an error occured while trying to trigger the new voice       *           if the voice wasn't triggered (for example when no region is
759         *           defined for the given key).
760       */       */
761      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) {
762          midi_key_info_t* pKey = &pMIDIKeyInfo[itNoteOnEvent->Param.Note.Key];          midi_key_info_t* pKey = &pMIDIKeyInfo[itNoteOnEvent->Param.Note.Key];
# Line 746  namespace LinuxSampler { namespace gig { Line 766  namespace LinuxSampler { namespace gig {
766          if (itNewVoice) {          if (itNewVoice) {
767              // launch the new voice              // launch the new voice
768              if (itNewVoice->Trigger(itNoteOnEvent, this->Pitch, this->pInstrument, iLayer, ReleaseTriggerVoice, VoiceStealing) < 0) {              if (itNewVoice->Trigger(itNoteOnEvent, this->Pitch, this->pInstrument, iLayer, ReleaseTriggerVoice, VoiceStealing) < 0) {
769                  dmsg(1,("Triggering new voice failed!\n"));                  dmsg(4,("Voice not triggered\n"));
770                  pKey->pActiveVoices->free(itNewVoice);                  pKey->pActiveVoices->free(itNewVoice);
771              }              }
772              else { // on success              else { // on success
# Line 1174  namespace LinuxSampler { namespace gig { Line 1194  namespace LinuxSampler { namespace gig {
1194      }      }
1195    
1196      String Engine::Version() {      String Engine::Version() {
1197          String s = "$Revision: 1.21 $";          String s = "$Revision: 1.23 $";
1198          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
1199      }      }
1200    

Legend:
Removed from v.351  
changed lines
  Added in v.361

  ViewVC Help
Powered by ViewVC