134 |
dmsg(1,("voice::trigger: !pInstrument\n")); |
dmsg(1,("voice::trigger: !pInstrument\n")); |
135 |
exit(EXIT_FAILURE); |
exit(EXIT_FAILURE); |
136 |
} |
} |
137 |
if (itNoteOnEvent->FragmentPos() > pEngine->MaxSamplesPerCycle) { // FIXME: should be removed before the final release (purpose: just a sanity check for debugging) |
#if CONFIG_DEVMODE |
138 |
|
if (itNoteOnEvent->FragmentPos() > pEngine->MaxSamplesPerCycle) { // just a sanity check for debugging |
139 |
dmsg(1,("Voice::Trigger(): ERROR, TriggerDelay > Totalsamples\n")); |
dmsg(1,("Voice::Trigger(): ERROR, TriggerDelay > Totalsamples\n")); |
140 |
} |
} |
141 |
|
#endif // CONFIG_DEVMODE |
142 |
|
|
143 |
Type = type_normal; |
Type = type_normal; |
144 |
MIDIKey = itNoteOnEvent->Param.Note.Key; |
MIDIKey = itNoteOnEvent->Param.Note.Key; |
145 |
pRegion = pInstrument->GetRegion(MIDIKey); |
pRegion = pInstrument->GetRegion(MIDIKey); |
146 |
PlaybackState = playback_state_ram; // we always start playback from RAM cache and switch then to disk if needed |
PlaybackState = playback_state_init; // mark voice as triggered, but no audio rendered yet |
147 |
Delay = itNoteOnEvent->FragmentPos(); |
Delay = itNoteOnEvent->FragmentPos(); |
148 |
itTriggerEvent = itNoteOnEvent; |
itTriggerEvent = itNoteOnEvent; |
149 |
itKillEvent = Pool<Event>::Iterator(); |
itKillEvent = Pool<Event>::Iterator(); |
333 |
this->PitchBend = RTMath::CentsToFreqRatio(((double) PitchBend / 8192.0) * 200.0); // pitchbend wheel +-2 semitones = 200 cents |
this->PitchBend = RTMath::CentsToFreqRatio(((double) PitchBend / 8192.0) * 200.0); // pitchbend wheel +-2 semitones = 200 cents |
334 |
} |
} |
335 |
|
|
336 |
Volume = pDimRgn->GetVelocityAttenuation(itNoteOnEvent->Param.Note.Velocity) / 32768.0f; // we downscale by 32768 to convert from int16 value range to DSP value range (which is -1.0..1.0) |
const double velocityAttenuation = pDimRgn->GetVelocityAttenuation(itNoteOnEvent->Param.Note.Velocity); |
337 |
|
|
338 |
|
Volume = velocityAttenuation / 32768.0f; // we downscale by 32768 to convert from int16 value range to DSP value range (which is -1.0..1.0) |
339 |
|
|
340 |
Volume *= pDimRgn->SampleAttenuation; |
Volume *= pDimRgn->SampleAttenuation; |
341 |
|
|
342 |
|
// the length of the decay and release curves are dependent on the velocity |
343 |
|
const double velrelease = 1 / pDimRgn->GetVelocityRelease(itNoteOnEvent->Param.Note.Velocity); |
344 |
|
|
345 |
// setup EG 1 (VCA EG) |
// setup EG 1 (VCA EG) |
346 |
{ |
{ |
347 |
// get current value of EG1 controller |
// get current value of EG1 controller |
371 |
pDimRgn->EG1Attack + eg1attack, |
pDimRgn->EG1Attack + eg1attack, |
372 |
pDimRgn->EG1Hold, |
pDimRgn->EG1Hold, |
373 |
pSample->LoopStart, |
pSample->LoopStart, |
374 |
pDimRgn->EG1Decay1 + eg1decay, |
(pDimRgn->EG1Decay1 + eg1decay) * velrelease, |
375 |
pDimRgn->EG1Decay2 + eg1decay, |
(pDimRgn->EG1Decay2 + eg1decay) * velrelease, |
376 |
pDimRgn->EG1InfiniteSustain, |
pDimRgn->EG1InfiniteSustain, |
377 |
pDimRgn->EG1Sustain, |
pDimRgn->EG1Sustain, |
378 |
pDimRgn->EG1Release + eg1release, |
(pDimRgn->EG1Release + eg1release) * velrelease, |
379 |
// the SSE synthesis implementation requires |
// the SSE synthesis implementation requires |
380 |
// the vca start to be 16 byte aligned |
// the vca start to be 16 byte aligned |
381 |
SYNTHESIS_MODE_GET_IMPLEMENTATION(SynthesisMode) ? |
SYNTHESIS_MODE_GET_IMPLEMENTATION(SynthesisMode) ? |
382 |
Delay & 0xfffffffc : Delay); |
Delay & 0xfffffffc : Delay, |
383 |
|
velocityAttenuation); |
384 |
} |
} |
385 |
|
|
386 |
|
|
413 |
pDimRgn->EG2Attack + eg2attack, |
pDimRgn->EG2Attack + eg2attack, |
414 |
false, |
false, |
415 |
pSample->LoopStart, |
pSample->LoopStart, |
416 |
pDimRgn->EG2Decay1 + eg2decay, |
(pDimRgn->EG2Decay1 + eg2decay) * velrelease, |
417 |
pDimRgn->EG2Decay2 + eg2decay, |
(pDimRgn->EG2Decay2 + eg2decay) * velrelease, |
418 |
pDimRgn->EG2InfiniteSustain, |
pDimRgn->EG2InfiniteSustain, |
419 |
pDimRgn->EG2Sustain, |
pDimRgn->EG2Sustain, |
420 |
pDimRgn->EG2Release + eg2release, |
(pDimRgn->EG2Release + eg2release) * velrelease, |
421 |
Delay); |
Delay, |
422 |
|
velocityAttenuation); |
423 |
} |
} |
424 |
|
|
425 |
|
|
695 |
|
|
696 |
switch (this->PlaybackState) { |
switch (this->PlaybackState) { |
697 |
|
|
698 |
|
case playback_state_init: |
699 |
|
this->PlaybackState = playback_state_ram; // we always start playback from RAM cache and switch then to disk if needed |
700 |
|
// no break - continue with playback_state_ram |
701 |
|
|
702 |
case playback_state_ram: { |
case playback_state_ram: { |
703 |
if (RAMLoop) SYNTHESIS_MODE_SET_LOOP(SynthesisMode, true); // enable looping |
if (RAMLoop) SYNTHESIS_MODE_SET_LOOP(SynthesisMode, true); // enable looping |
704 |
|
|