1 |
/*************************************************************************** |
2 |
* * |
3 |
* LinuxSampler - modular, streaming capable sampler * |
4 |
* * |
5 |
* Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * |
6 |
* Copyright (C) 2005 - 2008 Christian Schoenebeck * |
7 |
* Copyright (C) 2009 - 2010 Christian Schoenebeck and Grigor Iliev * |
8 |
* * |
9 |
* 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 * |
11 |
* the Free Software Foundation; either version 2 of the License, or * |
12 |
* (at your option) any later version. * |
13 |
* * |
14 |
* This program is distributed in the hope that it will be useful, * |
15 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
17 |
* GNU General Public License for more details. * |
18 |
* * |
19 |
* You should have received a copy of the GNU General Public License * |
20 |
* along with this program; if not, write to the Free Software * |
21 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, * |
22 |
* MA 02111-1307 USA * |
23 |
***************************************************************************/ |
24 |
|
25 |
#include "Voice.h" |
26 |
|
27 |
#include "Engine.h" |
28 |
#include "EngineChannel.h" |
29 |
|
30 |
#define LN_10_DIV_20 0.115129254649702 |
31 |
|
32 |
namespace LinuxSampler { namespace sfz { |
33 |
|
34 |
Voice::Voice() { |
35 |
pEngine = NULL; |
36 |
} |
37 |
|
38 |
Voice::~Voice() { |
39 |
|
40 |
} |
41 |
|
42 |
EngineChannel* Voice::GetSfzEngineChannel() { |
43 |
return static_cast<EngineChannel*>(pEngineChannel); |
44 |
} |
45 |
|
46 |
void Voice::SetEngine(LinuxSampler::Engine* pEngine) { |
47 |
Engine* engine = static_cast<Engine*>(pEngine); |
48 |
this->pEngine = engine; |
49 |
this->pDiskThread = engine->pDiskThread; |
50 |
dmsg(6,("Voice::SetEngine()\n")); |
51 |
} |
52 |
|
53 |
Voice::SampleInfo Voice::GetSampleInfo() { |
54 |
SampleInfo si; |
55 |
si.SampleRate = pSample->GetSampleRate(); |
56 |
si.ChannelCount = pSample->GetChannelCount(); |
57 |
si.FrameSize = pSample->GetFrameSize(); |
58 |
si.BitDepth = (pSample->GetFrameSize() / pSample->GetChannelCount()) * 8; |
59 |
si.TotalFrameCount = pSample->GetTotalFrameCount(); |
60 |
|
61 |
si.HasLoops = pRegion->HasLoop(); |
62 |
si.LoopStart = pRegion->GetLoopStart(); |
63 |
si.LoopLength = pRegion->GetLoopEnd() - pRegion->GetLoopStart(); |
64 |
si.LoopPlayCount = pRegion->GetLoopCount(); |
65 |
si.Unpitched = pRegion->pitch_keytrack == 0; |
66 |
return si; |
67 |
} |
68 |
|
69 |
Voice::RegionInfo Voice::GetRegionInfo() { |
70 |
RegionInfo ri; |
71 |
ri.UnityNote = pRegion->pitch_keycenter; |
72 |
ri.FineTune = pRegion->tune + pRegion->transpose * 100; |
73 |
ri.Pan = int(pRegion->pan * 0.63); // convert from -100..100 to -64..63 |
74 |
ri.SampleStartOffset = 0; // TODO: |
75 |
|
76 |
ri.EG1PreAttack = pRegion->ampeg_start * 10; |
77 |
ri.EG1Attack = pRegion->ampeg_attack; |
78 |
ri.EG1Hold = pRegion->ampeg_hold; |
79 |
ri.EG1Decay1 = pRegion->ampeg_decay; |
80 |
ri.EG1Decay2 = pRegion->ampeg_decay; |
81 |
ri.EG1Sustain = pRegion->ampeg_sustain * 10; |
82 |
ri.EG1InfiniteSustain = true; |
83 |
ri.EG1Release = pRegion->ampeg_release; |
84 |
|
85 |
ri.EG2PreAttack = pRegion->fileg_start * 10; |
86 |
ri.EG2Attack = pRegion->fileg_attack; |
87 |
//ri.EG2Hold = pRegion->fileg_hold; // TODO: |
88 |
ri.EG2Decay1 = pRegion->fileg_decay; |
89 |
ri.EG2Decay2 = pRegion->fileg_decay; |
90 |
ri.EG2Sustain = pRegion->fileg_sustain * 10; |
91 |
ri.EG2InfiniteSustain = true; |
92 |
ri.EG2Release = pRegion->fileg_release; |
93 |
|
94 |
ri.EG3Attack = pRegion->pitcheg_attack; |
95 |
ri.EG3Depth = 0; // TODO: |
96 |
ri.VCFEnabled = false; // TODO: |
97 |
ri.VCFType = ::gig::vcf_type_lowpass; // TODO: |
98 |
ri.VCFResonance = 0; // TODO: |
99 |
|
100 |
// rt_decay is in dB. Precalculate a suitable value for exp in |
101 |
// GetReleaseTriggerAttenuation: -ln(10) / 20 * rt_decay |
102 |
ri.ReleaseTriggerDecay = -LN_10_DIV_20 * pRegion->rt_decay; |
103 |
|
104 |
return ri; |
105 |
} |
106 |
|
107 |
Voice::InstrumentInfo Voice::GetInstrumentInfo() { |
108 |
InstrumentInfo ii; |
109 |
ii.FineTune = 0; // TODO: |
110 |
ii.PitchbendRange = 2; // TODO: |
111 |
|
112 |
return ii; |
113 |
} |
114 |
|
115 |
double Voice::GetSampleAttenuation() { |
116 |
return exp(LN_10_DIV_20 * pRegion->volume); |
117 |
} |
118 |
|
119 |
double Voice::GetVelocityAttenuation(uint8_t MIDIKeyVelocity) { |
120 |
return pRegion->amp_velcurve[MIDIKeyVelocity]; |
121 |
} |
122 |
|
123 |
double Voice::GetVelocityRelease(uint8_t MIDIKeyVelocity) { |
124 |
return 0.9; // TODO: |
125 |
} |
126 |
|
127 |
void Voice::ProcessCCEvent(RTList<Event>::Iterator& itEvent) { |
128 |
/*if (itEvent->Type == Event::type_control_change && itEvent->Param.CC.Controller) { // if (valid) MIDI control change event |
129 |
if (pRegion->AttenuationController.type == ::gig::attenuation_ctrl_t::type_controlchange && |
130 |
itEvent->Param.CC.Controller == pRegion->AttenuationController.controller_number) { |
131 |
CrossfadeSmoother.update(AbstractEngine::CrossfadeCurve[CrossfadeAttenuation(itEvent->Param.CC.Value)]); |
132 |
} |
133 |
}*/ // TODO: ^^^ |
134 |
} |
135 |
|
136 |
void Voice::ProcessCutoffEvent(RTList<Event>::Iterator& itEvent) { |
137 |
/*int ccvalue = itEvent->Param.CC.Value; |
138 |
if (VCFCutoffCtrl.value == ccvalue) return; |
139 |
VCFCutoffCtrl.value == ccvalue; |
140 |
if (pRegion->VCFCutoffControllerInvert) ccvalue = 127 - ccvalue; |
141 |
if (ccvalue < pRegion->VCFVelocityScale) ccvalue = pRegion->VCFVelocityScale; |
142 |
float cutoff = CutoffBase * float(ccvalue); |
143 |
if (cutoff > 127.0f) cutoff = 127.0f; |
144 |
|
145 |
VCFCutoffCtrl.fvalue = cutoff; // needed for initialization of fFinalCutoff next time |
146 |
fFinalCutoff = cutoff;*/ // TODO: ^^^ |
147 |
} |
148 |
|
149 |
double Voice::CalculateCrossfadeVolume(uint8_t MIDIKeyVelocity) { |
150 |
/*float crossfadeVolume; |
151 |
switch (pRegion->AttenuationController.type) { |
152 |
case ::gig::attenuation_ctrl_t::type_channelaftertouch: |
153 |
crossfadeVolume = Engine::CrossfadeCurve[CrossfadeAttenuation(GetSfzEngineChannel()->ControllerTable[128])]; |
154 |
break; |
155 |
case ::gig::attenuation_ctrl_t::type_velocity: |
156 |
crossfadeVolume = Engine::CrossfadeCurve[CrossfadeAttenuation(MIDIKeyVelocity)]; |
157 |
break; |
158 |
case ::gig::attenuation_ctrl_t::type_controlchange: //FIXME: currently not sample accurate |
159 |
crossfadeVolume = Engine::CrossfadeCurve[CrossfadeAttenuation(GetSfzEngineChannel()->ControllerTable[pRegion->AttenuationController.controller_number])]; |
160 |
break; |
161 |
case ::gig::attenuation_ctrl_t::type_none: // no crossfade defined |
162 |
default: |
163 |
crossfadeVolume = 1.0f; |
164 |
} |
165 |
|
166 |
return crossfadeVolume;*/ // TODO: ^^^ |
167 |
return 1.0f; |
168 |
} |
169 |
|
170 |
double Voice::GetEG1ControllerValue(uint8_t MIDIKeyVelocity) { |
171 |
/*double eg1controllervalue = 0; |
172 |
switch (pRegion->EG1Controller.type) { |
173 |
case ::gig::eg1_ctrl_t::type_none: // no controller defined |
174 |
eg1controllervalue = 0; |
175 |
break; |
176 |
case ::gig::eg1_ctrl_t::type_channelaftertouch: |
177 |
eg1controllervalue = GetSfzEngineChannel()->ControllerTable[128]; |
178 |
break; |
179 |
case ::gig::eg1_ctrl_t::type_velocity: |
180 |
eg1controllervalue = MIDIKeyVelocity; |
181 |
break; |
182 |
case ::gig::eg1_ctrl_t::type_controlchange: // MIDI control change controller |
183 |
eg1controllervalue = GetSfzEngineChannel()->ControllerTable[pRegion->EG1Controller.controller_number]; |
184 |
break; |
185 |
} |
186 |
if (pRegion->EG1ControllerInvert) eg1controllervalue = 127 - eg1controllervalue; |
187 |
|
188 |
return eg1controllervalue;*/ // TODO: ^^^ |
189 |
return 0; |
190 |
} |
191 |
|
192 |
Voice::EGInfo Voice::CalculateEG1ControllerInfluence(double eg1ControllerValue) { |
193 |
/*EGInfo eg; |
194 |
// (eg1attack is different from the others) |
195 |
eg.Attack = (pRegion->EG1ControllerAttackInfluence) ? |
196 |
1 + 0.031 * (double) (pRegion->EG1ControllerAttackInfluence == 1 ? |
197 |
1 : 1 << pRegion->EG1ControllerAttackInfluence) * eg1ControllerValue : 1.0; |
198 |
eg.Decay = (pRegion->EG1ControllerDecayInfluence) ? 1 + 0.00775 * (double) (1 << pRegion->EG1ControllerDecayInfluence) * eg1ControllerValue : 1.0; |
199 |
eg.Release = (pRegion->EG1ControllerReleaseInfluence) ? 1 + 0.00775 * (double) (1 << pRegion->EG1ControllerReleaseInfluence) * eg1ControllerValue : 1.0; |
200 |
|
201 |
return eg;*/ // TODO: ^^^ |
202 |
EGInfo eg; |
203 |
eg.Attack = 1.0; |
204 |
eg.Decay = 1.0; |
205 |
eg.Release = 1.0; |
206 |
return eg; |
207 |
} |
208 |
|
209 |
void Voice::TriggerEG1(const EGInfo& egInfo, double velrelease, double velocityAttenuation, uint sampleRate, uint8_t velocity) { |
210 |
|
211 |
// TODO: controller modulation |
212 |
|
213 |
// first check if there is a v2 EG for amplitude |
214 |
for (int i = 0 ; i < pRegion->eg.size() ; i++) { |
215 |
if (pRegion->eg[i].amplitude > 0) { |
216 |
// TODO: actually use the value of the amplitude parameter |
217 |
pEG1 = &EG1; |
218 |
EG1.trigger(pRegion->eg[i], sampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE, velocity); |
219 |
return; |
220 |
} |
221 |
} |
222 |
|
223 |
// otherwise use the v1 EGADSR |
224 |
pEG1 = &EGADSR1; |
225 |
EGADSR1.trigger(uint(RgnInfo.EG1PreAttack), |
226 |
RgnInfo.EG1Attack, |
227 |
RgnInfo.EG1Hold, |
228 |
RgnInfo.EG1Decay1, |
229 |
uint(RgnInfo.EG1Sustain), |
230 |
RgnInfo.EG1Release, |
231 |
sampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE); |
232 |
} |
233 |
|
234 |
double Voice::GetEG2ControllerValue(uint8_t MIDIKeyVelocity) { |
235 |
/*double eg2controllervalue = 0; |
236 |
switch (pRegion->EG2Controller.type) { |
237 |
case ::gig::eg2_ctrl_t::type_none: // no controller defined |
238 |
eg2controllervalue = 0; |
239 |
break; |
240 |
case ::gig::eg2_ctrl_t::type_channelaftertouch: |
241 |
eg2controllervalue = GetSfzEngineChannel()->ControllerTable[128]; |
242 |
break; |
243 |
case ::gig::eg2_ctrl_t::type_velocity: |
244 |
eg2controllervalue = MIDIKeyVelocity; |
245 |
break; |
246 |
case ::gig::eg2_ctrl_t::type_controlchange: // MIDI control change controller |
247 |
eg2controllervalue = GetSfzEngineChannel()->ControllerTable[pRegion->EG2Controller.controller_number]; |
248 |
break; |
249 |
} |
250 |
if (pRegion->EG2ControllerInvert) eg2controllervalue = 127 - eg2controllervalue; |
251 |
|
252 |
return eg2controllervalue;*/ // TODO: ^^^ |
253 |
return 0; |
254 |
} |
255 |
|
256 |
Voice::EGInfo Voice::CalculateEG2ControllerInfluence(double eg2ControllerValue) { |
257 |
/*EGInfo eg; |
258 |
eg.Attack = (pRegion->EG2ControllerAttackInfluence) ? 1 + 0.00775 * (double) (1 << pRegion->EG2ControllerAttackInfluence) * eg2ControllerValue : 1.0; |
259 |
eg.Decay = (pRegion->EG2ControllerDecayInfluence) ? 1 + 0.00775 * (double) (1 << pRegion->EG2ControllerDecayInfluence) * eg2ControllerValue : 1.0; |
260 |
eg.Release = (pRegion->EG2ControllerReleaseInfluence) ? 1 + 0.00775 * (double) (1 << pRegion->EG2ControllerReleaseInfluence) * eg2ControllerValue : 1.0; |
261 |
|
262 |
return eg;*/ // TODO: ^^^ |
263 |
EGInfo eg; |
264 |
eg.Attack = 1.0; |
265 |
eg.Decay = 1.0; |
266 |
eg.Release = 1.0; |
267 |
return eg; |
268 |
} |
269 |
|
270 |
void Voice::InitLFO1() { |
271 |
/*uint16_t lfo1_internal_depth; |
272 |
switch (pRegion->LFO1Controller) { |
273 |
case ::gig::lfo1_ctrl_internal: |
274 |
lfo1_internal_depth = pRegion->LFO1InternalDepth; |
275 |
pLFO1->ExtController = 0; // no external controller |
276 |
bLFO1Enabled = (lfo1_internal_depth > 0); |
277 |
break; |
278 |
case ::gig::lfo1_ctrl_modwheel: |
279 |
lfo1_internal_depth = 0; |
280 |
pLFO1->ExtController = 1; // MIDI controller 1 |
281 |
bLFO1Enabled = (pRegion->LFO1ControlDepth > 0); |
282 |
break; |
283 |
case ::gig::lfo1_ctrl_breath: |
284 |
lfo1_internal_depth = 0; |
285 |
pLFO1->ExtController = 2; // MIDI controller 2 |
286 |
bLFO1Enabled = (pRegion->LFO1ControlDepth > 0); |
287 |
break; |
288 |
case ::gig::lfo1_ctrl_internal_modwheel: |
289 |
lfo1_internal_depth = pRegion->LFO1InternalDepth; |
290 |
pLFO1->ExtController = 1; // MIDI controller 1 |
291 |
bLFO1Enabled = (lfo1_internal_depth > 0 || pRegion->LFO1ControlDepth > 0); |
292 |
break; |
293 |
case ::gig::lfo1_ctrl_internal_breath: |
294 |
lfo1_internal_depth = pRegion->LFO1InternalDepth; |
295 |
pLFO1->ExtController = 2; // MIDI controller 2 |
296 |
bLFO1Enabled = (lfo1_internal_depth > 0 || pRegion->LFO1ControlDepth > 0); |
297 |
break; |
298 |
default: |
299 |
lfo1_internal_depth = 0; |
300 |
pLFO1->ExtController = 0; // no external controller |
301 |
bLFO1Enabled = false; |
302 |
} |
303 |
if (bLFO1Enabled) { |
304 |
pLFO1->trigger(pRegion->LFO1Frequency, |
305 |
start_level_min, |
306 |
lfo1_internal_depth, |
307 |
pRegion->LFO1ControlDepth, |
308 |
pRegion->LFO1FlipPhase, |
309 |
pEngine->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE); |
310 |
pLFO1->update(pLFO1->ExtController ? GetSfzEngineChannel()->ControllerTable[pLFO1->ExtController] : 0); |
311 |
}*/ // TODO: ^^^ |
312 |
bLFO1Enabled = false; |
313 |
} |
314 |
|
315 |
void Voice::InitLFO2() { |
316 |
/*uint16_t lfo2_internal_depth; |
317 |
switch (pRegion->LFO2Controller) { |
318 |
case ::gig::lfo2_ctrl_internal: |
319 |
lfo2_internal_depth = pRegion->LFO2InternalDepth; |
320 |
pLFO2->ExtController = 0; // no external controller |
321 |
bLFO2Enabled = (lfo2_internal_depth > 0); |
322 |
break; |
323 |
case ::gig::lfo2_ctrl_modwheel: |
324 |
lfo2_internal_depth = 0; |
325 |
pLFO2->ExtController = 1; // MIDI controller 1 |
326 |
bLFO2Enabled = (pRegion->LFO2ControlDepth > 0); |
327 |
break; |
328 |
case ::gig::lfo2_ctrl_foot: |
329 |
lfo2_internal_depth = 0; |
330 |
pLFO2->ExtController = 4; // MIDI controller 4 |
331 |
bLFO2Enabled = (pRegion->LFO2ControlDepth > 0); |
332 |
break; |
333 |
case ::gig::lfo2_ctrl_internal_modwheel: |
334 |
lfo2_internal_depth = pRegion->LFO2InternalDepth; |
335 |
pLFO2->ExtController = 1; // MIDI controller 1 |
336 |
bLFO2Enabled = (lfo2_internal_depth > 0 || pRegion->LFO2ControlDepth > 0); |
337 |
break; |
338 |
case ::gig::lfo2_ctrl_internal_foot: |
339 |
lfo2_internal_depth = pRegion->LFO2InternalDepth; |
340 |
pLFO2->ExtController = 4; // MIDI controller 4 |
341 |
bLFO2Enabled = (lfo2_internal_depth > 0 || pRegion->LFO2ControlDepth > 0); |
342 |
break; |
343 |
default: |
344 |
lfo2_internal_depth = 0; |
345 |
pLFO2->ExtController = 0; // no external controller |
346 |
bLFO2Enabled = false; |
347 |
} |
348 |
if (bLFO2Enabled) { |
349 |
pLFO2->trigger(pRegion->LFO2Frequency, |
350 |
start_level_max, |
351 |
lfo2_internal_depth, |
352 |
pRegion->LFO2ControlDepth, |
353 |
pRegion->LFO2FlipPhase, |
354 |
pEngine->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE); |
355 |
pLFO2->update(pLFO2->ExtController ? GetSfzEngineChannel()->ControllerTable[pLFO2->ExtController] : 0); |
356 |
}*/ // TODO: ^^^ |
357 |
bLFO2Enabled = false; |
358 |
} |
359 |
|
360 |
void Voice::InitLFO3() { |
361 |
/*uint16_t lfo3_internal_depth; |
362 |
switch (pRegion->LFO3Controller) { |
363 |
case ::gig::lfo3_ctrl_internal: |
364 |
lfo3_internal_depth = pRegion->LFO3InternalDepth; |
365 |
pLFO3->ExtController = 0; // no external controller |
366 |
bLFO3Enabled = (lfo3_internal_depth > 0); |
367 |
break; |
368 |
case ::gig::lfo3_ctrl_modwheel: |
369 |
lfo3_internal_depth = 0; |
370 |
pLFO3->ExtController = 1; // MIDI controller 1 |
371 |
bLFO3Enabled = (pRegion->LFO3ControlDepth > 0); |
372 |
break; |
373 |
case ::gig::lfo3_ctrl_aftertouch: |
374 |
lfo3_internal_depth = 0; |
375 |
pLFO3->ExtController = 128; |
376 |
bLFO3Enabled = true; |
377 |
break; |
378 |
case ::gig::lfo3_ctrl_internal_modwheel: |
379 |
lfo3_internal_depth = pRegion->LFO3InternalDepth; |
380 |
pLFO3->ExtController = 1; // MIDI controller 1 |
381 |
bLFO3Enabled = (lfo3_internal_depth > 0 || pRegion->LFO3ControlDepth > 0); |
382 |
break; |
383 |
case ::gig::lfo3_ctrl_internal_aftertouch: |
384 |
lfo3_internal_depth = pRegion->LFO3InternalDepth; |
385 |
pLFO1->ExtController = 128; |
386 |
bLFO3Enabled = (lfo3_internal_depth > 0 || pRegion->LFO3ControlDepth > 0); |
387 |
break; |
388 |
default: |
389 |
lfo3_internal_depth = 0; |
390 |
pLFO3->ExtController = 0; // no external controller |
391 |
bLFO3Enabled = false; |
392 |
} |
393 |
if (bLFO3Enabled) { |
394 |
pLFO3->trigger(pRegion->LFO3Frequency, |
395 |
start_level_mid, |
396 |
lfo3_internal_depth, |
397 |
pRegion->LFO3ControlDepth, |
398 |
false, |
399 |
pEngine->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE); |
400 |
pLFO3->update(pLFO3->ExtController ? GetSfzEngineChannel()->ControllerTable[pLFO3->ExtController] : 0); |
401 |
}*/ // TODO: ^^^ |
402 |
bLFO3Enabled = false; |
403 |
} |
404 |
|
405 |
float Voice::CalculateCutoffBase(uint8_t MIDIKeyVelocity) { |
406 |
/*float cutoff = pRegion->GetVelocityCutoff(MIDIKeyVelocity); |
407 |
if (pRegion->VCFKeyboardTracking) { |
408 |
cutoff *= exp((MIDIKeyVelocity - pRegion->VCFKeyboardTrackingBreakpoint) * 0.057762265f); // (ln(2) / 12) |
409 |
} |
410 |
return cutoff;*/ // TODO: ^^^ |
411 |
return 1.0f; |
412 |
} |
413 |
|
414 |
float Voice::CalculateFinalCutoff(float cutoffBase) { |
415 |
/*int cvalue; |
416 |
if (VCFCutoffCtrl.controller) { |
417 |
cvalue = GetSfzEngineChannel()->ControllerTable[VCFCutoffCtrl.controller]; |
418 |
if (pRegion->VCFCutoffControllerInvert) cvalue = 127 - cvalue; |
419 |
// VCFVelocityScale in this case means Minimum cutoff |
420 |
if (cvalue < pRegion->VCFVelocityScale) cvalue = pRegion->VCFVelocityScale; |
421 |
} |
422 |
else { |
423 |
cvalue = pRegion->VCFCutoff; |
424 |
} |
425 |
float fco = cutoffBase * float(cvalue); |
426 |
if (fco > 127.0f) fco = 127.0f; |
427 |
|
428 |
return fco;*/ // TODO: ^^^ |
429 |
return 127.0f; |
430 |
} |
431 |
|
432 |
uint8_t Voice::GetVCFCutoffCtrl() { |
433 |
/*uint8_t ctrl; |
434 |
switch (pRegion->VCFCutoffController) { |
435 |
case ::gig::vcf_cutoff_ctrl_modwheel: |
436 |
ctrl = 1; |
437 |
break; |
438 |
case ::gig::vcf_cutoff_ctrl_effect1: |
439 |
ctrl = 12; |
440 |
break; |
441 |
case ::gig::vcf_cutoff_ctrl_effect2: |
442 |
ctrl = 13; |
443 |
break; |
444 |
case ::gig::vcf_cutoff_ctrl_breath: |
445 |
ctrl = 2; |
446 |
break; |
447 |
case ::gig::vcf_cutoff_ctrl_foot: |
448 |
ctrl = 4; |
449 |
break; |
450 |
case ::gig::vcf_cutoff_ctrl_sustainpedal: |
451 |
ctrl = 64; |
452 |
break; |
453 |
case ::gig::vcf_cutoff_ctrl_softpedal: |
454 |
ctrl = 67; |
455 |
break; |
456 |
case ::gig::vcf_cutoff_ctrl_genpurpose7: |
457 |
ctrl = 82; |
458 |
break; |
459 |
case ::gig::vcf_cutoff_ctrl_genpurpose8: |
460 |
ctrl = 83; |
461 |
break; |
462 |
case ::gig::vcf_cutoff_ctrl_aftertouch: |
463 |
ctrl = 128; |
464 |
break; |
465 |
case ::gig::vcf_cutoff_ctrl_none: |
466 |
default: |
467 |
ctrl = 0; |
468 |
break; |
469 |
} |
470 |
|
471 |
return ctrl;*/ // TODO: ^^^ |
472 |
return 0; |
473 |
} |
474 |
|
475 |
uint8_t Voice::GetVCFResonanceCtrl() { |
476 |
/*uint8_t ctrl; |
477 |
switch (pRegion->VCFResonanceController) { |
478 |
case ::gig::vcf_res_ctrl_genpurpose3: |
479 |
ctrl = 18; |
480 |
break; |
481 |
case ::gig::vcf_res_ctrl_genpurpose4: |
482 |
ctrl = 19; |
483 |
break; |
484 |
case ::gig::vcf_res_ctrl_genpurpose5: |
485 |
ctrl = 80; |
486 |
break; |
487 |
case ::gig::vcf_res_ctrl_genpurpose6: |
488 |
ctrl = 81; |
489 |
break; |
490 |
case ::gig::vcf_res_ctrl_none: |
491 |
default: |
492 |
ctrl = 0; |
493 |
} |
494 |
|
495 |
return ctrl;*/ // TODO: ^^^ |
496 |
return 0; |
497 |
} |
498 |
|
499 |
float Voice::GetReleaseTriggerAttenuation(float noteLength) { |
500 |
// pow(10, -rt_decay * noteLength / 20): |
501 |
return expf(RgnInfo.ReleaseTriggerDecay * noteLength); |
502 |
} |
503 |
|
504 |
void Voice::ProcessGroupEvent(RTList<Event>::Iterator& itEvent) { |
505 |
dmsg(4,("Voice %x processGroupEvents event type=%d", this, itEvent->Type)); |
506 |
if (itEvent->Param.Note.Key != MIDIKey) { |
507 |
dmsg(4,("Voice %x - kill", this)); |
508 |
if (pRegion->off_mode == ::sfz::OFF_NORMAL) { |
509 |
// turn off the voice by entering release envelope stage |
510 |
EnterReleaseStage(); |
511 |
} else { |
512 |
// kill the voice fast |
513 |
pEG1->enterFadeOutStage(); |
514 |
} |
515 |
} |
516 |
} |
517 |
|
518 |
}} // namespace LinuxSampler::sfz |