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 - 2008 Christian Schoenebeck * |
* Copyright (C) 2005 - 2008 Christian Schoenebeck * |
7 |
* Copyright (C) 2009 - 2010 Christian Schoenebeck and Grigor Iliev * |
* Copyright (C) 2009 - 2011 Christian Schoenebeck and Grigor Iliev * |
8 |
* * |
* * |
9 |
* This program is free software; you can redistribute it and/or modify * |
* This program is free software; you can redistribute it and/or modify * |
10 |
* 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 * |
35 |
Voice::Voice() { |
Voice::Voice() { |
36 |
pEngine = NULL; |
pEngine = NULL; |
37 |
pEG1 = &EG1; |
pEG1 = &EG1; |
38 |
|
pEG2 = &EG2; |
39 |
} |
} |
40 |
|
|
41 |
Voice::~Voice() { |
Voice::~Voice() { |
96 |
ri.EG3Attack = pRegion->EG3Attack; |
ri.EG3Attack = pRegion->EG3Attack; |
97 |
ri.EG3Depth = pRegion->EG3Depth; |
ri.EG3Depth = pRegion->EG3Depth; |
98 |
ri.VCFEnabled = pRegion->VCFEnabled; |
ri.VCFEnabled = pRegion->VCFEnabled; |
99 |
ri.VCFType = pRegion->VCFType; |
ri.VCFType = Filter::vcf_type_t(pRegion->VCFType); |
100 |
ri.VCFResonance = pRegion->VCFResonance; |
ri.VCFResonance = pRegion->VCFResonance; |
101 |
|
|
102 |
ri.ReleaseTriggerDecay = 0.01053 * (256 >> pRegion->ReleaseTriggerDecay); |
ri.ReleaseTriggerDecay = 0.01053 * (256 >> pRegion->ReleaseTriggerDecay); |
136 |
void Voice::ProcessCutoffEvent(RTList<Event>::Iterator& itEvent) { |
void Voice::ProcessCutoffEvent(RTList<Event>::Iterator& itEvent) { |
137 |
int ccvalue = itEvent->Param.CC.Value; |
int ccvalue = itEvent->Param.CC.Value; |
138 |
if (VCFCutoffCtrl.value == ccvalue) return; |
if (VCFCutoffCtrl.value == ccvalue) return; |
139 |
VCFCutoffCtrl.value == ccvalue; |
VCFCutoffCtrl.value = ccvalue; |
140 |
if (pRegion->VCFCutoffControllerInvert) ccvalue = 127 - ccvalue; |
if (pRegion->VCFCutoffControllerInvert) ccvalue = 127 - ccvalue; |
141 |
if (ccvalue < pRegion->VCFVelocityScale) ccvalue = pRegion->VCFVelocityScale; |
if (ccvalue < pRegion->VCFVelocityScale) ccvalue = pRegion->VCFVelocityScale; |
142 |
float cutoff = CutoffBase * float(ccvalue); |
float cutoff = CutoffBase * float(ccvalue); |
342 |
break; |
break; |
343 |
case ::gig::lfo3_ctrl_internal_aftertouch: |
case ::gig::lfo3_ctrl_internal_aftertouch: |
344 |
lfo3_internal_depth = pRegion->LFO3InternalDepth; |
lfo3_internal_depth = pRegion->LFO3InternalDepth; |
345 |
pLFO1->ExtController = 128; |
pLFO3->ExtController = 128; |
346 |
bLFO3Enabled = (lfo3_internal_depth > 0 || pRegion->LFO3ControlDepth > 0); |
bLFO3Enabled = (lfo3_internal_depth > 0 || pRegion->LFO3ControlDepth > 0); |
347 |
break; |
break; |
348 |
default: |
default: |
364 |
float Voice::CalculateCutoffBase(uint8_t MIDIKeyVelocity) { |
float Voice::CalculateCutoffBase(uint8_t MIDIKeyVelocity) { |
365 |
float cutoff = pRegion->GetVelocityCutoff(MIDIKeyVelocity); |
float cutoff = pRegion->GetVelocityCutoff(MIDIKeyVelocity); |
366 |
if (pRegion->VCFKeyboardTracking) { |
if (pRegion->VCFKeyboardTracking) { |
367 |
cutoff *= exp((MIDIKeyVelocity - pRegion->VCFKeyboardTrackingBreakpoint) * 0.057762265f); // (ln(2) / 12) |
cutoff *= RTMath::CentsToFreqRatioUnlimited((MIDIKey - pRegion->VCFKeyboardTrackingBreakpoint) * 100); |
368 |
} |
} |
369 |
return cutoff; |
return cutoff; |
370 |
} |
} |
463 |
velocityAttenuation, |
velocityAttenuation, |
464 |
sampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE); |
sampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE); |
465 |
} |
} |
466 |
|
|
467 |
|
void Voice::TriggerEG2(const EGInfo& egInfo, double velrelease, double velocityAttenuation, uint sampleRate, uint8_t velocity) { |
468 |
|
EG2.trigger(uint(RgnInfo.EG2PreAttack), |
469 |
|
RgnInfo.EG2Attack * egInfo.Attack, |
470 |
|
false, |
471 |
|
RgnInfo.EG2Decay1 * egInfo.Decay * velrelease, |
472 |
|
RgnInfo.EG2Decay2 * egInfo.Decay * velrelease, |
473 |
|
RgnInfo.EG2InfiniteSustain, |
474 |
|
uint(RgnInfo.EG2Sustain), |
475 |
|
RgnInfo.EG2Release * egInfo.Release * velrelease, |
476 |
|
velocityAttenuation, |
477 |
|
sampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE); |
478 |
|
} |
479 |
|
|
480 |
void Voice::ProcessGroupEvent(RTList<Event>::Iterator& itEvent) { |
void Voice::ProcessGroupEvent(RTList<Event>::Iterator& itEvent) { |
481 |
dmsg(4,("Voice %x processGroupEvents event type=%d", this, itEvent->Type)); |
dmsg(4,("Voice %x processGroupEvents event type=%d", this, itEvent->Type)); |