/[svn]/linuxsampler/trunk/src/engines/gig/Voice.cpp
ViewVC logotype

Diff of /linuxsampler/trunk/src/engines/gig/Voice.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1862 by persson, Wed Mar 11 19:03:37 2009 UTC revision 2012 by iliev, Fri Oct 23 17:53:17 2009 UTC
# Line 24  Line 24 
24  #include "../../common/Features.h"  #include "../../common/Features.h"
25  #include "Synthesizer.h"  #include "Synthesizer.h"
26  #include "Profiler.h"  #include "Profiler.h"
27    #include "Engine.h"
28    #include "EngineChannel.h"
29    
30  #include "Voice.h"  #include "Voice.h"
31    
# Line 56  namespace LinuxSampler { namespace gig { Line 58  namespace LinuxSampler { namespace gig {
58          if (pLFO3) delete pLFO3;          if (pLFO3) delete pLFO3;
59      }      }
60    
61      void Voice::SetEngine(Engine* pEngine) {      void Voice::SetEngine(LinuxSampler::Engine* pEngine) {
62          this->pEngine     = pEngine;          Engine* engine = static_cast<Engine*>(pEngine);
63          this->pDiskThread = pEngine->pDiskThread;          this->pEngine     = engine;
64            this->pDiskThread = engine->pDiskThread;
65          dmsg(6,("Voice::SetEngine()\n"));          dmsg(6,("Voice::SetEngine()\n"));
66      }      }
67    
# Line 156  namespace LinuxSampler { namespace gig { Line 159  namespace LinuxSampler { namespace gig {
159          const DLS::sample_loop_t& loopinfo = pDimRgn->pSampleLoops[0];          const DLS::sample_loop_t& loopinfo = pDimRgn->pSampleLoops[0];
160    
161          if (DiskVoice) { // voice to be streamed from disk          if (DiskVoice) { // voice to be streamed from disk
162              MaxRAMPos = cachedsamples - (pEngine->MaxSamplesPerCycle << CONFIG_MAX_PITCH) / pSample->Channels; //TODO: this calculation is too pessimistic and may better be moved to Render() method, so it calculates MaxRAMPos dependent to the current demand of sample points to be rendered (e.g. in case of JACK)              if (cachedsamples > (pEngine->MaxSamplesPerCycle << CONFIG_MAX_PITCH)) {
163                    MaxRAMPos = cachedsamples - (pEngine->MaxSamplesPerCycle << CONFIG_MAX_PITCH) / pSample->Channels; //TODO: this calculation is too pessimistic and may better be moved to Render() method, so it calculates MaxRAMPos dependent to the current demand of sample points to be rendered (e.g. in case of JACK)
164                } else {
165                    // The cache is too small to fit a max sample buffer.
166                    // Setting MaxRAMPos to 0 will probably cause a click
167                    // in the audio, but it's better than not handling
168                    // this case at all, which would have caused the
169                    // unsigned MaxRAMPos to be set to a negative number.
170                    MaxRAMPos = 0;
171                }
172    
173              // check if there's a loop defined which completely fits into the cached (RAM) part of the sample              // check if there's a loop defined which completely fits into the cached (RAM) part of the sample
174              RAMLoop = (pDimRgn->SampleLoops && (loopinfo.LoopStart + loopinfo.LoopLength) <= MaxRAMPos);              RAMLoop = (pDimRgn->SampleLoops && (loopinfo.LoopStart + loopinfo.LoopLength) <= MaxRAMPos);
# Line 191  namespace LinuxSampler { namespace gig { Line 203  namespace LinuxSampler { namespace gig {
203              if (pDimRgn->PitchTrack && (MIDIKey - (int) pDimRgn->UnityNote) < 40) pitchbasecents += (MIDIKey - (int) pDimRgn->UnityNote) * 100;              if (pDimRgn->PitchTrack && (MIDIKey - (int) pDimRgn->UnityNote) < 40) pitchbasecents += (MIDIKey - (int) pDimRgn->UnityNote) * 100;
204    
205              this->PitchBase = RTMath::CentsToFreqRatioUnlimited(pitchbasecents) * (double(pSample->SamplesPerSecond) / double(pEngine->SampleRate));              this->PitchBase = RTMath::CentsToFreqRatioUnlimited(pitchbasecents) * (double(pSample->SamplesPerSecond) / double(pEngine->SampleRate));
206              this->PitchBend = RTMath::CentsToFreqRatio(PitchBend / 8192.0 * 100.0 * pEngineChannel->pInstrument->PitchbendRange);              this->PitchBendRange = 1.0 / 8192.0 * 100.0 * pEngineChannel->pInstrument->PitchbendRange;
207                this->PitchBend = RTMath::CentsToFreqRatio(PitchBend * PitchBendRange);
208          }          }
209    
210          // the length of the decay and release curves are dependent on the velocity          // the length of the decay and release curves are dependent on the velocity
# Line 737  namespace LinuxSampler { namespace gig { Line 750  namespace LinuxSampler { namespace gig {
750      }      }
751    
752      void Voice::processPitchEvent(RTList<Event>::Iterator& itEvent) {      void Voice::processPitchEvent(RTList<Event>::Iterator& itEvent) {
753          PitchBend = RTMath::CentsToFreqRatio(itEvent->Param.Pitch.Pitch / 8192.0 * 100.0 * pEngineChannel->pInstrument->PitchbendRange);          PitchBend = RTMath::CentsToFreqRatio(itEvent->Param.Pitch.Pitch * PitchBendRange);
754      }      }
755    
756      void Voice::processCutoffEvent(RTList<Event>::Iterator& itEvent) {      void Voice::processCutoffEvent(RTList<Event>::Iterator& itEvent) {

Legend:
Removed from v.1862  
changed lines
  Added in v.2012

  ViewVC Help
Powered by ViewVC