/[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 783 by persson, Sun Oct 2 14:40:52 2005 UTC revision 2012 by iliev, Fri Oct 23 17:53:17 2009 UTC
# Line 3  Line 3 
3   *   LinuxSampler - modular, streaming capable sampler                     *   *   LinuxSampler - modular, streaming capable sampler                     *
4   *                                                                         *   *                                                                         *
5   *   Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck   *   *   Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck   *
6   *   Copyright (C) 2005 Christian Schoenebeck                              *   *   Copyright (C) 2005 - 2009 Christian Schoenebeck                       *
7   *                                                                         *   *                                                                         *
8   *   This program is free software; you can redistribute it and/or modify  *   *   This program is free software; you can redistribute it and/or modify  *
9   *   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 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    
32  namespace LinuxSampler { namespace gig {  namespace LinuxSampler { namespace gig {
33    
     const float Voice::FILTER_CUTOFF_COEFF(CalculateFilterCutoffCoeff());  
   
     float Voice::CalculateFilterCutoffCoeff() {  
         return log(CONFIG_FILTER_CUTOFF_MAX / CONFIG_FILTER_CUTOFF_MIN);  
     }  
   
34      Voice::Voice() {      Voice::Voice() {
35          pEngine     = NULL;          pEngine     = NULL;
36          pDiskThread = NULL;          pDiskThread = NULL;
# Line 44  namespace LinuxSampler { namespace gig { Line 40  namespace LinuxSampler { namespace gig {
40          pLFO3 = new LFOSigned(1200.0f); // pitch EG (-1200..+1200 range)          pLFO3 = new LFOSigned(1200.0f); // pitch EG (-1200..+1200 range)
41          KeyGroup = 0;          KeyGroup = 0;
42          SynthesisMode = 0; // set all mode bits to 0 first          SynthesisMode = 0; // set all mode bits to 0 first
43          // select synthesis implementation (currently either pure C++ or MMX+SSE(1))          // select synthesis implementation (asm core is not supported ATM)
44          #if CONFIG_ASM && ARCH_X86          #if 0 // CONFIG_ASM && ARCH_X86
45          SYNTHESIS_MODE_SET_IMPLEMENTATION(SynthesisMode, Features::supportsMMX() && Features::supportsSSE());          SYNTHESIS_MODE_SET_IMPLEMENTATION(SynthesisMode, Features::supportsMMX() && Features::supportsSSE());
46          #else          #else
47          SYNTHESIS_MODE_SET_IMPLEMENTATION(SynthesisMode, false);          SYNTHESIS_MODE_SET_IMPLEMENTATION(SynthesisMode, false);
# Line 62  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 85  namespace LinuxSampler { namespace gig { Line 82  namespace LinuxSampler { namespace gig {
82      int Voice::Trigger(EngineChannel* pEngineChannel, Pool<Event>::Iterator& itNoteOnEvent, int PitchBend, ::gig::DimensionRegion* pDimRgn, type_t VoiceType, int iKeyGroup) {      int Voice::Trigger(EngineChannel* pEngineChannel, Pool<Event>::Iterator& itNoteOnEvent, int PitchBend, ::gig::DimensionRegion* pDimRgn, type_t VoiceType, int iKeyGroup) {
83          this->pEngineChannel = pEngineChannel;          this->pEngineChannel = pEngineChannel;
84          this->pDimRgn        = pDimRgn;          this->pDimRgn        = pDimRgn;
85            Orphan = false;
86    
87          #if CONFIG_DEVMODE          #if CONFIG_DEVMODE
88          if (itNoteOnEvent->FragmentPos() > pEngine->MaxSamplesPerCycle) { // just a sanity check for debugging          if (itNoteOnEvent->FragmentPos() > pEngine->MaxSamplesPerCycle) { // just a sanity check for debugging
# Line 104  namespace LinuxSampler { namespace gig { Line 102  namespace LinuxSampler { namespace gig {
102          // calculate volume          // calculate volume
103          const double velocityAttenuation = pDimRgn->GetVelocityAttenuation(itNoteOnEvent->Param.Note.Velocity);          const double velocityAttenuation = pDimRgn->GetVelocityAttenuation(itNoteOnEvent->Param.Note.Velocity);
104    
105          Volume = velocityAttenuation / 32768.0f; // we downscale by 32768 to convert from int16 value range to DSP value range (which is -1.0..1.0)          // For 16 bit samples, we downscale by 32768 to convert from
106            // int16 value range to DSP value range (which is
107            // -1.0..1.0). For 24 bit, we downscale from int32.
108            float volume = velocityAttenuation / (pSample->BitDepth == 16 ? 32768.0f : 32768.0f * 65536.0f);
109    
110          Volume *= pDimRgn->SampleAttenuation;          volume *= pDimRgn->SampleAttenuation * pEngineChannel->GlobalVolume * GLOBAL_VOLUME;
111    
112          // the volume of release triggered samples depends on note length          // the volume of release triggered samples depends on note length
113          if (Type == type_release_trigger) {          if (Type == type_release_trigger) {
# Line 114  namespace LinuxSampler { namespace gig { Line 115  namespace LinuxSampler { namespace gig {
115                                       pEngineChannel->pMIDIKeyInfo[MIDIKey].NoteOnTime) / pEngine->SampleRate;                                       pEngineChannel->pMIDIKeyInfo[MIDIKey].NoteOnTime) / pEngine->SampleRate;
116              float attenuation = 1 - 0.01053 * (256 >> pDimRgn->ReleaseTriggerDecay) * noteLength;              float attenuation = 1 - 0.01053 * (256 >> pDimRgn->ReleaseTriggerDecay) * noteLength;
117              if (attenuation <= 0) return -1;              if (attenuation <= 0) return -1;
118              Volume *= attenuation;              volume *= attenuation;
119          }          }
120    
121          // select channel mode (mono or stereo)          // select channel mode (mono or stereo)
122          SYNTHESIS_MODE_SET_CHANNELS(SynthesisMode, pSample->Channels == 2);          SYNTHESIS_MODE_SET_CHANNELS(SynthesisMode, pSample->Channels == 2);
123            // select bit depth (16 or 24)
124            SYNTHESIS_MODE_SET_BITDEPTH24(SynthesisMode, pSample->BitDepth == 24);
125    
126          // get starting crossfade volume level          // get starting crossfade volume level
127            float crossfadeVolume;
128          switch (pDimRgn->AttenuationController.type) {          switch (pDimRgn->AttenuationController.type) {
129              case ::gig::attenuation_ctrl_t::type_channelaftertouch:              case ::gig::attenuation_ctrl_t::type_channelaftertouch:
130                  CrossfadeVolume = 1.0f; //TODO: aftertouch not supported yet                  crossfadeVolume = Engine::CrossfadeCurve[CrossfadeAttenuation(pEngineChannel->ControllerTable[128])];
131                  break;                  break;
132              case ::gig::attenuation_ctrl_t::type_velocity:              case ::gig::attenuation_ctrl_t::type_velocity:
133                  CrossfadeVolume = CrossfadeAttenuation(itNoteOnEvent->Param.Note.Velocity);                  crossfadeVolume = Engine::CrossfadeCurve[CrossfadeAttenuation(itNoteOnEvent->Param.Note.Velocity)];
134                  break;                  break;
135              case ::gig::attenuation_ctrl_t::type_controlchange: //FIXME: currently not sample accurate              case ::gig::attenuation_ctrl_t::type_controlchange: //FIXME: currently not sample accurate
136                  CrossfadeVolume = CrossfadeAttenuation(pEngineChannel->ControllerTable[pDimRgn->AttenuationController.controller_number]);                  crossfadeVolume = Engine::CrossfadeCurve[CrossfadeAttenuation(pEngineChannel->ControllerTable[pDimRgn->AttenuationController.controller_number])];
137                  break;                  break;
138              case ::gig::attenuation_ctrl_t::type_none: // no crossfade defined              case ::gig::attenuation_ctrl_t::type_none: // no crossfade defined
139              default:              default:
140                  CrossfadeVolume = 1.0f;                  crossfadeVolume = 1.0f;
141          }          }
142    
143          PanLeft  = 1.0f - float(RTMath::Max(pDimRgn->Pan, 0)) /  63.0f;          VolumeLeft  = volume * Engine::PanCurve[64 - pDimRgn->Pan];
144          PanRight = 1.0f - float(RTMath::Min(pDimRgn->Pan, 0)) / -64.0f;          VolumeRight = volume * Engine::PanCurve[64 + pDimRgn->Pan];
145    
146            float subfragmentRate = pEngine->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE;
147            CrossfadeSmoother.trigger(crossfadeVolume, subfragmentRate);
148            VolumeSmoother.trigger(pEngineChannel->MidiVolume, subfragmentRate);
149            PanLeftSmoother.trigger(pEngineChannel->GlobalPanLeft, subfragmentRate);
150            PanRightSmoother.trigger(pEngineChannel->GlobalPanRight, subfragmentRate);
151    
152          finalSynthesisParameters.dPos = pDimRgn->SampleStartOffset; // offset where we should start playback of sample (0 - 2000 sample points)          finalSynthesisParameters.dPos = pDimRgn->SampleStartOffset; // offset where we should start playback of sample (0 - 2000 sample points)
153          Pos = pDimRgn->SampleStartOffset;          Pos = pDimRgn->SampleStartOffset;
# Line 146  namespace LinuxSampler { namespace gig { Line 156  namespace LinuxSampler { namespace gig {
156          long cachedsamples = pSample->GetCache().Size / pSample->FrameSize;          long cachedsamples = pSample->GetCache().Size / pSample->FrameSize;
157          DiskVoice          = cachedsamples < pSample->SamplesTotal;          DiskVoice          = cachedsamples < pSample->SamplesTotal;
158    
159            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              if (pSample->Loops && pSample->LoopEnd <= MaxRAMPos) {              RAMLoop = (pDimRgn->SampleLoops && (loopinfo.LoopStart + loopinfo.LoopLength) <= MaxRAMPos);
                 RAMLoop            = true;  
                 loop.uiTotalCycles = pSample->LoopPlayCount;  
                 loop.uiCyclesLeft  = pSample->LoopPlayCount;  
                 loop.uiStart       = pSample->LoopStart;  
                 loop.uiEnd         = pSample->LoopEnd;  
                 loop.uiSize        = pSample->LoopSize;  
             }  
             else RAMLoop = false;  
175    
176              if (pDiskThread->OrderNewStream(&DiskStreamRef, pSample, MaxRAMPos, !RAMLoop) < 0) {              if (pDiskThread->OrderNewStream(&DiskStreamRef, pDimRgn, MaxRAMPos, !RAMLoop) < 0) {
177                  dmsg(1,("Disk stream order failed!\n"));                  dmsg(1,("Disk stream order failed!\n"));
178                  KillImmediately();                  KillImmediately();
179                  return -1;                  return -1;
# Line 169  namespace LinuxSampler { namespace gig { Line 182  namespace LinuxSampler { namespace gig {
182          }          }
183          else { // RAM only voice          else { // RAM only voice
184              MaxRAMPos = cachedsamples;              MaxRAMPos = cachedsamples;
185              if (pSample->Loops) {              RAMLoop = (pDimRgn->SampleLoops != 0);
                 RAMLoop           = true;  
                 loop.uiCyclesLeft = pSample->LoopPlayCount;  
             }  
             else RAMLoop = false;  
186              dmsg(4,("RAM only voice launched (Looping: %s)\n", (RAMLoop) ? "yes" : "no"));              dmsg(4,("RAM only voice launched (Looping: %s)\n", (RAMLoop) ? "yes" : "no"));
187          }          }
188            if (RAMLoop) {
189                loop.uiTotalCycles = pSample->LoopPlayCount;
190                loop.uiCyclesLeft  = pSample->LoopPlayCount;
191                loop.uiStart       = loopinfo.LoopStart;
192                loop.uiEnd         = loopinfo.LoopStart + loopinfo.LoopLength;
193                loop.uiSize        = loopinfo.LoopLength;
194            }
195    
196          // calculate initial pitch value          // calculate initial pitch value
197          {          {
198              double pitchbasecents = pDimRgn->FineTune + (int) pEngine->ScaleTuning[MIDIKey % 12];              double pitchbasecents = pEngineChannel->pInstrument->FineTune + pDimRgn->FineTune + pEngine->ScaleTuning[MIDIKey % 12];
199              if (pDimRgn->PitchTrack) pitchbasecents += (MIDIKey - (int) pDimRgn->UnityNote) * 100;  
200              this->PitchBase = RTMath::CentsToFreqRatio(pitchbasecents) * (double(pSample->SamplesPerSecond) / double(pEngine->SampleRate));              // GSt behaviour: maximum transpose up is 40 semitones. If
201              this->PitchBend = RTMath::CentsToFreqRatio(((double) PitchBend / 8192.0) * 200.0); // pitchbend wheel +-2 semitones = 200 cents              // MIDI key is more than 40 semitones above unity note,
202                // the transpose is not done.
203                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));
206                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 198  namespace LinuxSampler { namespace gig { Line 219  namespace LinuxSampler { namespace gig {
219                      eg1controllervalue = 0;                      eg1controllervalue = 0;
220                      break;                      break;
221                  case ::gig::eg1_ctrl_t::type_channelaftertouch:                  case ::gig::eg1_ctrl_t::type_channelaftertouch:
222                      eg1controllervalue = 0; // TODO: aftertouch not yet supported                      eg1controllervalue = pEngineChannel->ControllerTable[128];
223                      break;                      break;
224                  case ::gig::eg1_ctrl_t::type_velocity:                  case ::gig::eg1_ctrl_t::type_velocity:
225                      eg1controllervalue = itNoteOnEvent->Param.Note.Velocity;                      eg1controllervalue = itNoteOnEvent->Param.Note.Velocity;
# Line 229  namespace LinuxSampler { namespace gig { Line 250  namespace LinuxSampler { namespace gig {
250                          pEngine->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE);                          pEngine->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE);
251          }          }
252    
253    #ifdef CONFIG_INTERPOLATE_VOLUME
254            // setup initial volume in synthesis parameters
255    #ifdef CONFIG_PROCESS_MUTED_CHANNELS
256            if (pEngineChannel->GetMute()) {
257                finalSynthesisParameters.fFinalVolumeLeft  = 0;
258                finalSynthesisParameters.fFinalVolumeRight = 0;
259            }
260            else
261    #else
262            {
263                float finalVolume = pEngineChannel->MidiVolume * crossfadeVolume * EG1.getLevel();
264    
265                finalSynthesisParameters.fFinalVolumeLeft  = finalVolume * VolumeLeft  * pEngineChannel->GlobalPanLeft;
266                finalSynthesisParameters.fFinalVolumeRight = finalVolume * VolumeRight * pEngineChannel->GlobalPanRight;
267            }
268    #endif
269    #endif
270    
271          // setup EG 2 (VCF Cutoff EG)          // setup EG 2 (VCF Cutoff EG)
272          {          {
# Line 239  namespace LinuxSampler { namespace gig { Line 277  namespace LinuxSampler { namespace gig {
277                      eg2controllervalue = 0;                      eg2controllervalue = 0;
278                      break;                      break;
279                  case ::gig::eg2_ctrl_t::type_channelaftertouch:                  case ::gig::eg2_ctrl_t::type_channelaftertouch:
280                      eg2controllervalue = 0; // TODO: aftertouch not yet supported                      eg2controllervalue = pEngineChannel->ControllerTable[128];
281                      break;                      break;
282                  case ::gig::eg2_ctrl_t::type_velocity:                  case ::gig::eg2_ctrl_t::type_velocity:
283                      eg2controllervalue = itNoteOnEvent->Param.Note.Velocity;                      eg2controllervalue = itNoteOnEvent->Param.Note.Velocity;
# Line 270  namespace LinuxSampler { namespace gig { Line 308  namespace LinuxSampler { namespace gig {
308    
309          // setup EG 3 (VCO EG)          // setup EG 3 (VCO EG)
310          {          {
311            double eg3depth = RTMath::CentsToFreqRatio(pDimRgn->EG3Depth);              // if portamento mode is on, we dedicate EG3 purely for portamento, otherwise if portamento is off we do as told by the patch
312            EG3.trigger(eg3depth, pDimRgn->EG3Attack, pEngine->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE);              bool  bPortamento = pEngineChannel->PortamentoMode && pEngineChannel->PortamentoPos >= 0.0f;
313                float eg3depth = (bPortamento)
314                                     ? RTMath::CentsToFreqRatio((pEngineChannel->PortamentoPos - (float) MIDIKey) * 100)
315                                     : RTMath::CentsToFreqRatio(pDimRgn->EG3Depth);
316                float eg3time = (bPortamento)
317                                    ? pEngineChannel->PortamentoTime
318                                    : pDimRgn->EG3Attack;
319                EG3.trigger(eg3depth, eg3time, pEngine->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE);
320                dmsg(5,("PortamentoPos=%f, depth=%f, time=%f\n", pEngineChannel->PortamentoPos, eg3depth, eg3time));
321          }          }
322    
323    
# Line 309  namespace LinuxSampler { namespace gig { Line 355  namespace LinuxSampler { namespace gig {
355                      pLFO1->ExtController = 0; // no external controller                      pLFO1->ExtController = 0; // no external controller
356                      bLFO1Enabled         = false;                      bLFO1Enabled         = false;
357              }              }
358              if (bLFO1Enabled) pLFO1->trigger(pDimRgn->LFO1Frequency,              if (bLFO1Enabled) {
359                                               start_level_max,                  pLFO1->trigger(pDimRgn->LFO1Frequency,
360                                               lfo1_internal_depth,                                 start_level_min,
361                                               pDimRgn->LFO1ControlDepth,                                 lfo1_internal_depth,
362                                               pDimRgn->LFO1FlipPhase,                                 pDimRgn->LFO1ControlDepth,
363                                               pEngine->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE);                                 pDimRgn->LFO1FlipPhase,
364                                   pEngine->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE);
365                    pLFO1->update(pLFO1->ExtController ? pEngineChannel->ControllerTable[pLFO1->ExtController] : 0);
366                }
367          }          }
368    
369    
# Line 352  namespace LinuxSampler { namespace gig { Line 401  namespace LinuxSampler { namespace gig {
401                      pLFO2->ExtController = 0; // no external controller                      pLFO2->ExtController = 0; // no external controller
402                      bLFO2Enabled         = false;                      bLFO2Enabled         = false;
403              }              }
404              if (bLFO2Enabled) pLFO2->trigger(pDimRgn->LFO2Frequency,              if (bLFO2Enabled) {
405                                               start_level_max,                  pLFO2->trigger(pDimRgn->LFO2Frequency,
406                                               lfo2_internal_depth,                                 start_level_max,
407                                               pDimRgn->LFO2ControlDepth,                                 lfo2_internal_depth,
408                                               pDimRgn->LFO2FlipPhase,                                 pDimRgn->LFO2ControlDepth,
409                                               pEngine->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE);                                 pDimRgn->LFO2FlipPhase,
410                                   pEngine->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE);
411                    pLFO2->update(pLFO2->ExtController ? pEngineChannel->ControllerTable[pLFO2->ExtController] : 0);
412                }
413          }          }
414    
415    
# Line 377  namespace LinuxSampler { namespace gig { Line 429  namespace LinuxSampler { namespace gig {
429                      break;                      break;
430                  case ::gig::lfo3_ctrl_aftertouch:                  case ::gig::lfo3_ctrl_aftertouch:
431                      lfo3_internal_depth  = 0;                      lfo3_internal_depth  = 0;
432                      pLFO3->ExtController = 0; // TODO: aftertouch not implemented yet                      pLFO3->ExtController = 128;
433                      bLFO3Enabled         = false; // see TODO comment in line above                      bLFO3Enabled         = true;
434                      break;                      break;
435                  case ::gig::lfo3_ctrl_internal_modwheel:                  case ::gig::lfo3_ctrl_internal_modwheel:
436                      lfo3_internal_depth  = pDimRgn->LFO3InternalDepth;                      lfo3_internal_depth  = pDimRgn->LFO3InternalDepth;
# Line 387  namespace LinuxSampler { namespace gig { Line 439  namespace LinuxSampler { namespace gig {
439                      break;                      break;
440                  case ::gig::lfo3_ctrl_internal_aftertouch:                  case ::gig::lfo3_ctrl_internal_aftertouch:
441                      lfo3_internal_depth  = pDimRgn->LFO3InternalDepth;                      lfo3_internal_depth  = pDimRgn->LFO3InternalDepth;
442                      pLFO1->ExtController = 0; // TODO: aftertouch not implemented yet                      pLFO1->ExtController = 128;
443                      bLFO3Enabled         = (lfo3_internal_depth > 0 /*|| pDimRgn->LFO3ControlDepth > 0*/); // see TODO comment in line above                      bLFO3Enabled         = (lfo3_internal_depth > 0 || pDimRgn->LFO3ControlDepth > 0);
444                      break;                      break;
445                  default:                  default:
446                      lfo3_internal_depth  = 0;                      lfo3_internal_depth  = 0;
447                      pLFO3->ExtController = 0; // no external controller                      pLFO3->ExtController = 0; // no external controller
448                      bLFO3Enabled         = false;                      bLFO3Enabled         = false;
449              }              }
450              if (bLFO3Enabled) pLFO3->trigger(pDimRgn->LFO3Frequency,              if (bLFO3Enabled) {
451                                               start_level_mid,                  pLFO3->trigger(pDimRgn->LFO3Frequency,
452                                               lfo3_internal_depth,                                 start_level_mid,
453                                               pDimRgn->LFO3ControlDepth,                                 lfo3_internal_depth,
454                                               false,                                 pDimRgn->LFO3ControlDepth,
455                                               pEngine->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE);                                 false,
456                                   pEngine->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE);
457                    pLFO3->update(pLFO3->ExtController ? pEngineChannel->ControllerTable[pLFO3->ExtController] : 0);
458                }
459          }          }
460    
461    
# Line 442  namespace LinuxSampler { namespace gig { Line 497  namespace LinuxSampler { namespace gig {
497                  case ::gig::vcf_cutoff_ctrl_genpurpose8:                  case ::gig::vcf_cutoff_ctrl_genpurpose8:
498                      VCFCutoffCtrl.controller = 83;                      VCFCutoffCtrl.controller = 83;
499                      break;                      break;
500                  case ::gig::vcf_cutoff_ctrl_aftertouch: //TODO: not implemented yet                  case ::gig::vcf_cutoff_ctrl_aftertouch:
501                        VCFCutoffCtrl.controller = 128;
502                        break;
503                  case ::gig::vcf_cutoff_ctrl_none:                  case ::gig::vcf_cutoff_ctrl_none:
504                  default:                  default:
505                      VCFCutoffCtrl.controller = 0;                      VCFCutoffCtrl.controller = 0;
# Line 476  namespace LinuxSampler { namespace gig { Line 533  namespace LinuxSampler { namespace gig {
533              finalSynthesisParameters.filterLeft.SetType(pDimRgn->VCFType);              finalSynthesisParameters.filterLeft.SetType(pDimRgn->VCFType);
534              finalSynthesisParameters.filterRight.SetType(pDimRgn->VCFType);              finalSynthesisParameters.filterRight.SetType(pDimRgn->VCFType);
535              #else // override filter type              #else // override filter type
536              FilterLeft.SetType(CONFIG_OVERRIDE_FILTER_TYPE);              finalSynthesisParameters.filterLeft.SetType(CONFIG_OVERRIDE_FILTER_TYPE);
537              FilterRight.SetType(CONFIG_OVERRIDE_FILTER_TYPE);              finalSynthesisParameters.filterRight.SetType(CONFIG_OVERRIDE_FILTER_TYPE);
538              #endif // CONFIG_OVERRIDE_FILTER_TYPE              #endif // CONFIG_OVERRIDE_FILTER_TYPE
539    
540              VCFCutoffCtrl.value    = pEngineChannel->ControllerTable[VCFCutoffCtrl.controller];              VCFCutoffCtrl.value    = pEngineChannel->ControllerTable[VCFCutoffCtrl.controller];
# Line 494  namespace LinuxSampler { namespace gig { Line 551  namespace LinuxSampler { namespace gig {
551              if (VCFCutoffCtrl.controller) {              if (VCFCutoffCtrl.controller) {
552                  cvalue = pEngineChannel->ControllerTable[VCFCutoffCtrl.controller];                  cvalue = pEngineChannel->ControllerTable[VCFCutoffCtrl.controller];
553                  if (pDimRgn->VCFCutoffControllerInvert) cvalue = 127 - cvalue;                  if (pDimRgn->VCFCutoffControllerInvert) cvalue = 127 - cvalue;
554                    // VCFVelocityScale in this case means Minimum cutoff
555                  if (cvalue < pDimRgn->VCFVelocityScale) cvalue = pDimRgn->VCFVelocityScale;                  if (cvalue < pDimRgn->VCFVelocityScale) cvalue = pDimRgn->VCFVelocityScale;
556              }              }
557              else {              else {
558                  cvalue = pDimRgn->VCFCutoff;                  cvalue = pDimRgn->VCFCutoff;
559              }              }
560              cutoff *= float(cvalue) * 0.00787402f; // (1 / 127)              cutoff *= float(cvalue);
561              if (cutoff > 1.0) cutoff = 1.0;              if (cutoff > 127.0f) cutoff = 127.0f;
             cutoff = exp(cutoff * FILTER_CUTOFF_COEFF) * CONFIG_FILTER_CUTOFF_MIN;  
562    
563              // calculate resonance              // calculate resonance
564              float resonance = (float) VCFResonanceCtrl.value * 0.00787f;   // 0.0..1.0              float resonance = (float) (VCFResonanceCtrl.controller ? VCFResonanceCtrl.value : pDimRgn->VCFResonance);
             if (pDimRgn->VCFKeyboardTracking) {  
                 resonance += (float) (itNoteOnEvent->Param.Note.Key - pDimRgn->VCFKeyboardTrackingBreakpoint) * 0.00787f;  
             }  
             Constrain(resonance, 0.0, 1.0); // correct resonance if outside allowed value range (0.0..1.0)  
565    
566              VCFCutoffCtrl.fvalue    = cutoff - CONFIG_FILTER_CUTOFF_MIN;              VCFCutoffCtrl.fvalue    = cutoff;
567              VCFResonanceCtrl.fvalue = resonance;              VCFResonanceCtrl.fvalue = resonance;
568          }          }
569          else {          else {
# Line 587  namespace LinuxSampler { namespace gig { Line 640  namespace LinuxSampler { namespace gig {
640                          }                          }
641                      }                      }
642    
643                      sample_t* ptr = DiskStreamRef.pStream->GetReadPtr(); // get the current read_ptr within the ringbuffer where we read the samples from                      sample_t* ptr = (sample_t*)DiskStreamRef.pStream->GetReadPtr(); // get the current read_ptr within the ringbuffer where we read the samples from
644    
645                      // render current audio fragment                      // render current audio fragment
646                      Synthesize(Samples, ptr, Delay);                      Synthesize(Samples, ptr, Delay);
# Line 640  namespace LinuxSampler { namespace gig { Line 693  namespace LinuxSampler { namespace gig {
693       * for the given time.       * for the given time.
694       *       *
695       * @param itEvent - iterator pointing to the next event to be processed       * @param itEvent - iterator pointing to the next event to be processed
696       * @param End     - youngest time stamp where processing should be stopped       * @param End     - youngest time stamp where processing should be stopped
697       */       */
698      void Voice::processTransitionEvents(RTList<Event>::Iterator& itEvent, uint End) {      void Voice::processTransitionEvents(RTList<Event>::Iterator& itEvent, uint End) {
699          for (; itEvent && itEvent->FragmentPos() <= End; ++itEvent) {          for (; itEvent && itEvent->FragmentPos() <= End; ++itEvent) {
# Line 659  namespace LinuxSampler { namespace gig { Line 712  namespace LinuxSampler { namespace gig {
712       * the given time.       * the given time.
713       *       *
714       * @param itEvent - iterator pointing to the next event to be processed       * @param itEvent - iterator pointing to the next event to be processed
715       * @param End     - youngest time stamp where processing should be stopped       * @param End     - youngest time stamp where processing should be stopped
716       */       */
717      void Voice::processCCEvents(RTList<Event>::Iterator& itEvent, uint End) {      void Voice::processCCEvents(RTList<Event>::Iterator& itEvent, uint End) {
718          for (; itEvent && itEvent->FragmentPos() <= End; ++itEvent) {          for (; itEvent && itEvent->FragmentPos() <= End; ++itEvent) {
# Line 682  namespace LinuxSampler { namespace gig { Line 735  namespace LinuxSampler { namespace gig {
735                  }                  }
736                  if (pDimRgn->AttenuationController.type == ::gig::attenuation_ctrl_t::type_controlchange &&                  if (pDimRgn->AttenuationController.type == ::gig::attenuation_ctrl_t::type_controlchange &&
737                      itEvent->Param.CC.Controller == pDimRgn->AttenuationController.controller_number) {                      itEvent->Param.CC.Controller == pDimRgn->AttenuationController.controller_number) {
738                      processCrossFadeEvent(itEvent);                      CrossfadeSmoother.update(Engine::CrossfadeCurve[CrossfadeAttenuation(itEvent->Param.CC.Value)]);
739                    }
740                    if (itEvent->Param.CC.Controller == 7) { // volume
741                        VolumeSmoother.update(Engine::VolumeCurve[itEvent->Param.CC.Value]);
742                    } else if (itEvent->Param.CC.Controller == 10) { // panpot
743                        PanLeftSmoother.update(Engine::PanCurve[128 - itEvent->Param.CC.Value]);
744                        PanRightSmoother.update(Engine::PanCurve[itEvent->Param.CC.Value]);
745                  }                  }
746              } else if (itEvent->Type == Event::type_pitchbend) { // if pitch bend event              } else if (itEvent->Type == Event::type_pitchbend) { // if pitch bend event
747                  processPitchEvent(itEvent);                  processPitchEvent(itEvent);
# Line 691  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          const float pitch = RTMath::CentsToFreqRatio(((double) itEvent->Param.Pitch.Pitch / 8192.0) * 200.0); // +-two semitones = +-200 cents          PitchBend = RTMath::CentsToFreqRatio(itEvent->Param.Pitch.Pitch * PitchBendRange);
         finalSynthesisParameters.fFinalPitch *= pitch;  
         PitchBend = pitch;  
     }  
   
     void Voice::processCrossFadeEvent(RTList<Event>::Iterator& itEvent) {  
         CrossfadeVolume = CrossfadeAttenuation(itEvent->Param.CC.Value);  
         #if CONFIG_PROCESS_MUTED_CHANNELS  
         const float effectiveVolume = CrossfadeVolume * Volume * (pEngineChannel->GetMute() ? 0 : pEngineChannel->GlobalVolume);  
         #else  
         const float effectiveVolume = CrossfadeVolume * Volume * pEngineChannel->GlobalVolume;  
         #endif  
         fFinalVolume = effectiveVolume;  
754      }      }
755    
756      void Voice::processCutoffEvent(RTList<Event>::Iterator& itEvent) {      void Voice::processCutoffEvent(RTList<Event>::Iterator& itEvent) {
# Line 712  namespace LinuxSampler { namespace gig { Line 759  namespace LinuxSampler { namespace gig {
759          VCFCutoffCtrl.value == ccvalue;          VCFCutoffCtrl.value == ccvalue;
760          if (pDimRgn->VCFCutoffControllerInvert)  ccvalue = 127 - ccvalue;          if (pDimRgn->VCFCutoffControllerInvert)  ccvalue = 127 - ccvalue;
761          if (ccvalue < pDimRgn->VCFVelocityScale) ccvalue = pDimRgn->VCFVelocityScale;          if (ccvalue < pDimRgn->VCFVelocityScale) ccvalue = pDimRgn->VCFVelocityScale;
762          float cutoff = CutoffBase * float(ccvalue) * 0.00787402f; // (1 / 127)          float cutoff = CutoffBase * float(ccvalue);
763          if (cutoff > 1.0) cutoff = 1.0;          if (cutoff > 127.0f) cutoff = 127.0f;
764          cutoff = exp(cutoff * FILTER_CUTOFF_COEFF) * CONFIG_FILTER_CUTOFF_MIN - CONFIG_FILTER_CUTOFF_MIN;  
765          VCFCutoffCtrl.fvalue = cutoff; // needed for initialization of fFinalCutoff next time          VCFCutoffCtrl.fvalue = cutoff; // needed for initialization of fFinalCutoff next time
766          fFinalCutoff = cutoff;          fFinalCutoff = cutoff;
767      }      }
# Line 723  namespace LinuxSampler { namespace gig { Line 770  namespace LinuxSampler { namespace gig {
770          // convert absolute controller value to differential          // convert absolute controller value to differential
771          const int ctrldelta = itEvent->Param.CC.Value - VCFResonanceCtrl.value;          const int ctrldelta = itEvent->Param.CC.Value - VCFResonanceCtrl.value;
772          VCFResonanceCtrl.value = itEvent->Param.CC.Value;          VCFResonanceCtrl.value = itEvent->Param.CC.Value;
773          const float resonancedelta = (float) ctrldelta * 0.00787f; // 0.0..1.0          const float resonancedelta = (float) ctrldelta;
774          fFinalResonance += resonancedelta;          fFinalResonance += resonancedelta;
775          // needed for initialization of parameter          // needed for initialization of parameter
776          VCFResonanceCtrl.fvalue = itEvent->Param.CC.Value * 0.00787f;          VCFResonanceCtrl.fvalue = itEvent->Param.CC.Value;
777      }      }
778    
779      /**      /**
# Line 738  namespace LinuxSampler { namespace gig { Line 785  namespace LinuxSampler { namespace gig {
785       *  @param Skip    - number of sample points to skip in output buffer       *  @param Skip    - number of sample points to skip in output buffer
786       */       */
787      void Voice::Synthesize(uint Samples, sample_t* pSrc, uint Skip) {      void Voice::Synthesize(uint Samples, sample_t* pSrc, uint Skip) {
788          finalSynthesisParameters.pOutLeft  = &pEngineChannel->pOutputLeft[Skip];          finalSynthesisParameters.pOutLeft  = &pEngineChannel->pChannelLeft->Buffer()[Skip];
789          finalSynthesisParameters.pOutRight = &pEngineChannel->pOutputRight[Skip];          finalSynthesisParameters.pOutRight = &pEngineChannel->pChannelRight->Buffer()[Skip];
790          finalSynthesisParameters.pSrc      = pSrc;          finalSynthesisParameters.pSrc      = pSrc;
791    
792          RTList<Event>::Iterator itCCEvent = pEngineChannel->pEvents->first();          RTList<Event>::Iterator itCCEvent = pEngineChannel->pEvents->first();
793          RTList<Event>::Iterator itNoteEvent = pEngineChannel->pMIDIKeyInfo[MIDIKey].pEvents->first();          RTList<Event>::Iterator itNoteEvent = pEngineChannel->pMIDIKeyInfo[MIDIKey].pEvents->first();
794    
795          if (Skip) { // skip events that happened before this voice was triggered          if (itTriggerEvent) { // skip events that happened before this voice was triggered
796              while (itCCEvent && itCCEvent->FragmentPos() <= Skip) ++itCCEvent;              while (itCCEvent && itCCEvent->FragmentPos() <= Skip) ++itCCEvent;
797              while (itNoteEvent && itNoteEvent->FragmentPos() <= Skip) ++itNoteEvent;              // we can't simply compare the timestamp here, because note events
798                // might happen on the same time stamp, so we have to deal on the
799                // actual sequence the note events arrived instead (see bug #112)
800                for (; itNoteEvent; ++itNoteEvent) {
801                    if (itTriggerEvent == itNoteEvent) {
802                        ++itNoteEvent;
803                        break;
804                    }
805                }
806            }
807    
808            uint killPos;
809            if (itKillEvent) {
810                int maxFadeOutPos = Samples - pEngine->MinFadeOutSamples;
811                if (maxFadeOutPos < 0) {
812                    // There's not enough space in buffer to do a fade out
813                    // from max volume (this can only happen for audio
814                    // drivers that use Samples < MaxSamplesPerCycle).
815                    // End the EG1 here, at pos 0, with a shorter max fade
816                    // out time.
817                    EG1.enterFadeOutStage(Samples / CONFIG_DEFAULT_SUBFRAGMENT_SIZE);
818                    itKillEvent = Pool<Event>::Iterator();
819                } else {
820                    killPos = RTMath::Min(itKillEvent->FragmentPos(), maxFadeOutPos);
821                }
822          }          }
823    
824          uint i = Skip;          uint i = Skip;
# Line 755  namespace LinuxSampler { namespace gig { Line 826  namespace LinuxSampler { namespace gig {
826              int iSubFragmentEnd = RTMath::Min(i + CONFIG_DEFAULT_SUBFRAGMENT_SIZE, Samples);              int iSubFragmentEnd = RTMath::Min(i + CONFIG_DEFAULT_SUBFRAGMENT_SIZE, Samples);
827    
828              // initialize all final synthesis parameters              // initialize all final synthesis parameters
             finalSynthesisParameters.fFinalPitch = PitchBase * PitchBend;  
             #if CONFIG_PROCESS_MUTED_CHANNELS  
             fFinalVolume = this->Volume * this->CrossfadeVolume * (pEngineChannel->GetMute() ? 0 : pEngineChannel->GlobalVolume);  
             #else  
             fFinalVolume = this->Volume * this->CrossfadeVolume * pEngineChannel->GlobalVolume;  
             #endif  
829              fFinalCutoff    = VCFCutoffCtrl.fvalue;              fFinalCutoff    = VCFCutoffCtrl.fvalue;
830              fFinalResonance = VCFResonanceCtrl.fvalue;              fFinalResonance = VCFResonanceCtrl.fvalue;
831    
832              // process MIDI control change and pitchbend events for this subfragment              // process MIDI control change and pitchbend events for this subfragment
833              processCCEvents(itCCEvent, iSubFragmentEnd);              processCCEvents(itCCEvent, iSubFragmentEnd);
834    
835                finalSynthesisParameters.fFinalPitch = PitchBase * PitchBend;
836                float fFinalVolume = VolumeSmoother.render() * CrossfadeSmoother.render();
837    #ifdef CONFIG_PROCESS_MUTED_CHANNELS
838                if (pEngineChannel->GetMute()) fFinalVolume = 0;
839    #endif
840    
841              // process transition events (note on, note off & sustain pedal)              // process transition events (note on, note off & sustain pedal)
842              processTransitionEvents(itNoteEvent, iSubFragmentEnd);              processTransitionEvents(itNoteEvent, iSubFragmentEnd);
843    
844                // if the voice was killed in this subfragment, or if the
845                // filter EG is finished, switch EG1 to fade out stage
846                if ((itKillEvent && killPos <= iSubFragmentEnd) ||
847                    (SYNTHESIS_MODE_GET_FILTER(SynthesisMode) &&
848                     EG2.getSegmentType() == EGADSR::segment_end)) {
849                    EG1.enterFadeOutStage();
850                    itKillEvent = Pool<Event>::Iterator();
851                }
852    
853              // process envelope generators              // process envelope generators
854              switch (EG1.getSegmentType()) {              switch (EG1.getSegmentType()) {
855                  case EGADSR::segment_lin:                  case EGADSR::segment_lin:
# Line 793  namespace LinuxSampler { namespace gig { Line 873  namespace LinuxSampler { namespace gig {
873                      fFinalCutoff *= EG2.getLevel();                      fFinalCutoff *= EG2.getLevel();
874                      break; // noop                      break; // noop
875              }              }
876              if (EG3.active()) finalSynthesisParameters.fFinalPitch *= RTMath::CentsToFreqRatio(EG3.render());              if (EG3.active()) finalSynthesisParameters.fFinalPitch *= EG3.render();
877    
878              // process low frequency oscillators              // process low frequency oscillators
879              if (bLFO1Enabled) fFinalVolume *= pLFO1->render();              if (bLFO1Enabled) fFinalVolume *= (1.0f - pLFO1->render());
880              if (bLFO2Enabled) fFinalCutoff *= pLFO2->render();              if (bLFO2Enabled) fFinalCutoff *= pLFO2->render();
881              if (bLFO3Enabled) finalSynthesisParameters.fFinalPitch *= RTMath::CentsToFreqRatio(pLFO3->render());              if (bLFO3Enabled) finalSynthesisParameters.fFinalPitch *= RTMath::CentsToFreqRatio(pLFO3->render());
882    
883                // limit the pitch so we don't read outside the buffer
884                finalSynthesisParameters.fFinalPitch = RTMath::Min(finalSynthesisParameters.fFinalPitch, float(1 << CONFIG_MAX_PITCH));
885    
886              // if filter enabled then update filter coefficients              // if filter enabled then update filter coefficients
887              if (SYNTHESIS_MODE_GET_FILTER(SynthesisMode)) {              if (SYNTHESIS_MODE_GET_FILTER(SynthesisMode)) {
888                  finalSynthesisParameters.filterLeft.SetParameters(fFinalCutoff, fFinalResonance, pEngine->SampleRate);                  finalSynthesisParameters.filterLeft.SetParameters(fFinalCutoff, fFinalResonance, pEngine->SampleRate);
# Line 814  namespace LinuxSampler { namespace gig { Line 897  namespace LinuxSampler { namespace gig {
897              SYNTHESIS_MODE_SET_INTERPOLATE(SynthesisMode, bResamplingRequired);              SYNTHESIS_MODE_SET_INTERPOLATE(SynthesisMode, bResamplingRequired);
898    
899              // prepare final synthesis parameters structure              // prepare final synthesis parameters structure
             finalSynthesisParameters.fFinalVolumeLeft  = fFinalVolume * PanLeft;  
             finalSynthesisParameters.fFinalVolumeRight = fFinalVolume * PanRight;  
900              finalSynthesisParameters.uiToGo            = iSubFragmentEnd - i;              finalSynthesisParameters.uiToGo            = iSubFragmentEnd - i;
901    #ifdef CONFIG_INTERPOLATE_VOLUME
902                finalSynthesisParameters.fFinalVolumeDeltaLeft  =
903                    (fFinalVolume * VolumeLeft  * PanLeftSmoother.render() -
904                     finalSynthesisParameters.fFinalVolumeLeft) / finalSynthesisParameters.uiToGo;
905                finalSynthesisParameters.fFinalVolumeDeltaRight =
906                    (fFinalVolume * VolumeRight * PanRightSmoother.render() -
907                     finalSynthesisParameters.fFinalVolumeRight) / finalSynthesisParameters.uiToGo;
908    #else
909                finalSynthesisParameters.fFinalVolumeLeft  =
910                    fFinalVolume * VolumeLeft  * PanLeftSmoother.render();
911                finalSynthesisParameters.fFinalVolumeRight =
912                    fFinalVolume * VolumeRight * PanRightSmoother.render();
913    #endif
914              // render audio for one subfragment              // render audio for one subfragment
915              RunSynthesisFunction(SynthesisMode, &finalSynthesisParameters, &loop);              RunSynthesisFunction(SynthesisMode, &finalSynthesisParameters, &loop);
916    
917                // stop the rendering if volume EG is finished
918                if (EG1.getSegmentType() == EGADSR::segment_end) break;
919    
920              const double newPos = Pos + (iSubFragmentEnd - i) * finalSynthesisParameters.fFinalPitch;              const double newPos = Pos + (iSubFragmentEnd - i) * finalSynthesisParameters.fFinalPitch;
921    
922              // increment envelopes' positions              // increment envelopes' positions
923              if (EG1.active()) {              if (EG1.active()) {
924    
925                  // if sample has a loop and loop start has been reached in this subfragment, send a special event to EG1 to let it finish the attack hold stage                  // if sample has a loop and loop start has been reached in this subfragment, send a special event to EG1 to let it finish the attack hold stage
926                  if (pSample->Loops && Pos <= pSample->LoopStart && pSample->LoopStart < newPos) {                  if (pDimRgn->SampleLoops && Pos <= pDimRgn->pSampleLoops[0].LoopStart && pDimRgn->pSampleLoops[0].LoopStart < newPos) {
927                      EG1.update(EGADSR::event_hold_end, pEngine->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE);                      EG1.update(EGADSR::event_hold_end, pEngine->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE);
928                  }                  }
929    
# Line 846  namespace LinuxSampler { namespace gig { Line 942  namespace LinuxSampler { namespace gig {
942          }          }
943      }      }
944    
945        /** @brief Update current portamento position.
946         *
947         * Will be called when portamento mode is enabled to get the final
948         * portamento position of this active voice from where the next voice(s)
949         * might continue to slide on.
950         *
951         * @param itNoteOffEvent - event which causes this voice to die soon
952         */
953        void Voice::UpdatePortamentoPos(Pool<Event>::Iterator& itNoteOffEvent) {
954            const float fFinalEG3Level = EG3.level(itNoteOffEvent->FragmentPos());
955            pEngineChannel->PortamentoPos = (float) MIDIKey + RTMath::FreqRatioToCents(fFinalEG3Level) * 0.01f;
956        }
957    
958      /**      /**
959       *  Immediately kill the voice. This method should not be used to kill       *  Immediately kill the voice. This method should not be used to kill
960       *  a normal, active voice, because it doesn't take care of things like       *  a normal, active voice, because it doesn't take care of things like
961       *  fading down the volume level to avoid clicks and regular processing       *  fading down the volume level to avoid clicks and regular processing
962       *  until the kill event actually occured!       *  until the kill event actually occured!
963       *       *
964       *  @see Kill()       * If it's necessary to know when the voice's disk stream was actually
965         * deleted, then one can set the optional @a bRequestNotification
966         * parameter and this method will then return the handle of the disk
967         * stream (unique identifier) and one can use this handle to poll the
968         * disk thread if this stream has been deleted. In any case this method
969         * will return immediately and will not block until the stream actually
970         * was deleted.
971         *
972         * @param bRequestNotification - (optional) whether the disk thread shall
973         *                                provide a notification once it deleted
974         *                               the respective disk stream
975         *                               (default=false)
976         * @returns handle to the voice's disk stream or @c Stream::INVALID_HANDLE
977         *          if the voice did not use a disk stream at all
978         * @see Kill()
979       */       */
980      void Voice::KillImmediately() {      Stream::Handle Voice::KillImmediately(bool bRequestNotification) {
981            Stream::Handle hStream = Stream::INVALID_HANDLE;
982          if (DiskVoice && DiskStreamRef.State != Stream::state_unused) {          if (DiskVoice && DiskStreamRef.State != Stream::state_unused) {
983              pDiskThread->OrderDeletionOfStream(&DiskStreamRef);              pDiskThread->OrderDeletionOfStream(&DiskStreamRef, bRequestNotification);
984                hStream = DiskStreamRef.hStream;
985          }          }
986          Reset();          Reset();
987            return hStream;
988      }      }
989    
990      /**      /**

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

  ViewVC Help
Powered by ViewVC