/[svn]/linuxsampler/trunk/src/engines/sfz/SfzSignalUnitRack.cpp
ViewVC logotype

Contents of /linuxsampler/trunk/src/engines/sfz/SfzSignalUnitRack.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2233 - (show annotations) (download)
Mon Aug 8 18:46:19 2011 UTC (9 years ago) by iliev
File size: 24647 byte(s)
* sfz engine: implemented opcodes fillfo_depthccN, amplfo_depthccN,
  lfoN_volume, lfoN_volume_onccX, lfoN_volume_smoothccX,
  lfoN_freq_smoothccX, lfoN_pitch_smoothccX, lfoN_pan_onccX,
  lfoN_pan_smoothccX, lfoN_cutoff_onccX, lfoN_cutoff_smoothccX,
  lfoN_resonance_onccX, lfoN_resonance_smoothccX, lfoN_delay_onccX

1 /***************************************************************************
2 * *
3 * LinuxSampler - modular, streaming capable sampler *
4 * *
5 * Copyright (C) 2011 Grigor Iliev *
6 * *
7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * This program is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU General Public License *
18 * along with this program; if not, write to the Free Software *
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
20 * MA 02111-1307 USA *
21 ***************************************************************************/
22
23 #include "SfzSignalUnitRack.h"
24 #include "Voice.h"
25 #include <SF.h>
26
27 namespace LinuxSampler { namespace sfz {
28
29 SfzSignalUnit::SfzSignalUnit(SfzSignalUnitRack* rack): SignalUnit(rack), pVoice(rack->pVoice) {
30
31 }
32
33 double SfzSignalUnit::GetSampleRate() {
34 return pVoice->GetSampleRate() / CONFIG_DEFAULT_SUBFRAGMENT_SIZE;
35 }
36
37 float SfzSignalUnit::GetInfluence(ArrayList< ::sfz::CC>& cc) {
38 float f = 0;
39 for (int i = 0; i < cc.size(); i++) {
40 int val = pVoice->GetControllerValue(cc[i].Controller);
41 f += (val / 127.0f) * cc[i].Influence;
42 }
43 return f;
44 }
45
46
47 void EGv2Unit::Trigger() {
48 egInfo = *pEGInfo;
49 for (int i = 0; i < egInfo.node.size(); i++) {
50 float f = GetInfluence(egInfo.node[i].level_oncc);
51 egInfo.node[i].level = std::min(egInfo.node[i].level + f, 1.0f);
52
53 f = GetInfluence(egInfo.node[i].time_oncc);
54 egInfo.node[i].time = std::min(egInfo.node[i].time + f, 100.0f);
55 }
56 EG.trigger(egInfo, GetSampleRate(), pVoice->MIDIVelocity);
57 }
58
59
60 void PitchEGUnit::Trigger() {
61 ::sfz::Region* const pRegion = pVoice->pRegion;
62 depth = pRegion->pitcheg_depth;
63
64 // the length of the decay and release curves are dependent on the velocity
65 const double velrelease = 1 / pVoice->GetVelocityRelease(pVoice->MIDIVelocity);
66
67 // set the delay trigger
68 uiDelayTrigger = (pRegion->pitcheg_delay + pRegion->pitcheg_vel2delay * velrelease) * GetSampleRate();
69
70 EG.trigger(uint(pRegion->pitcheg_start * 10),
71 std::max(0.0, pRegion->pitcheg_attack + pRegion->pitcheg_vel2attack * velrelease),
72 std::max(0.0, pRegion->pitcheg_hold + pRegion->pitcheg_vel2hold * velrelease),
73 std::max(0.0, pRegion->pitcheg_decay + pRegion->pitcheg_vel2decay * velrelease),
74 uint(std::min(std::max(0.0, 10 * (pRegion->pitcheg_sustain + pRegion->pitcheg_vel2sustain * velrelease)), 1000.0)),
75 std::max(0.0, pRegion->pitcheg_release + pRegion->pitcheg_vel2release * velrelease),
76 GetSampleRate());
77 }
78
79
80 void FilEGUnit::Trigger() {
81 ::sfz::Region* const pRegion = pVoice->pRegion;
82 depth = pRegion->fileg_depth;
83
84 // the length of the decay and release curves are dependent on the velocity
85 const double velrelease = 1 / pVoice->GetVelocityRelease(pVoice->MIDIVelocity);
86
87 // set the delay trigger
88 uiDelayTrigger = (pRegion->fileg_delay + pRegion->fileg_vel2delay * velrelease) * GetSampleRate();
89
90 EG.trigger(uint(pRegion->fileg_start * 10),
91 std::max(0.0, pRegion->fileg_attack + pRegion->fileg_vel2attack * velrelease),
92 std::max(0.0, pRegion->fileg_hold + pRegion->fileg_vel2hold * velrelease),
93 std::max(0.0, pRegion->fileg_decay + pRegion->fileg_vel2decay * velrelease),
94 uint(std::min(std::max(0.0, 10 * (pRegion->fileg_sustain + pRegion->fileg_vel2sustain * velrelease)), 1000.0)),
95 std::max(0.0, pRegion->fileg_release + pRegion->fileg_vel2release * velrelease),
96 GetSampleRate());
97 }
98
99
100 void AmpEGUnit::Trigger() {
101 ::sfz::Region* const pRegion = pVoice->pRegion;
102
103 // the length of the decay and release curves are dependent on the velocity
104 const double velrelease = 1 / pVoice->GetVelocityRelease(pVoice->MIDIVelocity);
105
106 // set the delay trigger
107 float delay = pRegion->ampeg_delay + pRegion->ampeg_vel2delay * velrelease;
108 delay += GetInfluence(pRegion->ampeg_delaycc);
109 uiDelayTrigger = std::max(0.0f, delay) * GetSampleRate();
110
111 float start = (pRegion->ampeg_start + GetInfluence(pRegion->ampeg_startcc)) * 10;
112
113 float attack = pRegion->ampeg_attack + pRegion->ampeg_vel2attack * velrelease;
114 attack = std::max(0.0f, attack + GetInfluence(pRegion->ampeg_attackcc));
115
116 float hold = pRegion->ampeg_hold + pRegion->ampeg_vel2hold * velrelease;
117 hold = std::max(0.0f, hold + GetInfluence(pRegion->ampeg_holdcc));
118
119 float decay = pRegion->ampeg_decay + pRegion->ampeg_vel2decay * velrelease;
120 decay = std::max(0.0f, decay + GetInfluence(pRegion->ampeg_decaycc));
121
122 float sustain = pRegion->ampeg_sustain + pRegion->ampeg_vel2sustain * velrelease;
123 sustain = 10 * (sustain + GetInfluence(pRegion->ampeg_sustaincc));
124
125 float release = pRegion->ampeg_release + pRegion->ampeg_vel2release * velrelease;
126 release = std::max(0.0f, release + GetInfluence(pRegion->ampeg_releasecc));
127
128 EG.trigger (
129 uint(std::min(std::max(0.0f, start), 1000.0f)), attack, hold, decay,
130 uint(std::min(std::max(0.0f, sustain), 1000.0f)), release, GetSampleRate()
131 );
132 }
133
134
135 LFOUnit::LFOUnit(SfzSignalUnitRack* rack)
136 : SfzSignalUnit(rack), pLfoInfo(NULL), pLFO(NULL),
137 suFadeEG(rack), suFreqOnCC(rack, this), suDepthOnCC(rack)
138 { }
139
140 LFOUnit::LFOUnit(const LFOUnit& Unit)
141 : SfzSignalUnit(Unit), suFadeEG(static_cast<SfzSignalUnitRack*>(Unit.pRack)),
142 suFreqOnCC(static_cast<SfzSignalUnitRack*>(Unit.pRack), this),
143 suDepthOnCC(static_cast<SfzSignalUnitRack*>(Unit.pRack))
144 {
145 Copy(Unit);
146 }
147
148 void LFOUnit::Increment() {
149 if (DelayStage()) return;
150
151 SignalUnit::Increment();
152
153 Level = pLFO->Render();
154 if (suFadeEG.Active()) Level *= suFadeEG.GetLevel();
155 }
156
157 void LFOUnit::Trigger() {
158 //reset
159 Level = 0;
160
161 // set the delay trigger
162 uiDelayTrigger = (pLfoInfo->delay + GetInfluence(pLfoInfo->delay_oncc)) * GetSampleRate();
163 if(pLfoInfo->fade != 0 || !pLfoInfo->fade_oncc.empty()) {
164 float f = pLfoInfo->fade;
165 f += GetInfluence(pLfoInfo->fade_oncc);
166
167 if (f != 0) {
168 suFadeEG.uiDelayTrigger = pLfoInfo->delay * GetSampleRate();
169 suFadeEG.EG.trigger(0, f, 0, 0, 1000, 0, GetSampleRate());
170 }
171 }
172 }
173
174 void LFOUnit::ValueChanged(CCSignalUnit* pUnit) {
175 pLFO->SetFrequency(std::max(0.0f, suFreqOnCC.GetLevel() + pLfoInfo->freq), GetSampleRate());
176 }
177
178
179 void LFOv1Unit::Trigger() {
180 LFOUnit::Trigger();
181
182 lfo.trigger (
183 pLfoInfo->freq + suFreqOnCC.GetLevel(),
184 start_level_mid,
185 1, 0, false, GetSampleRate()
186 );
187 lfo.update(0);
188 }
189
190
191 LFOv2Unit::LFOv2Unit(SfzSignalUnitRack* rack)
192 : LFOUnit(rack), lfos(8), lfo0(1200.0f), lfo1(1200.0f), lfo2(1200.0f),
193 lfo3(1200.0f), lfo4(1200.0f), lfo5(1200.0f), lfo6(1200.0f), lfo7(1200.0f),
194 suVolOnCC(rack), suPitchOnCC(rack), suPanOnCC(rack), suCutoffOnCC(rack), suResOnCC(rack)
195 {
196 lfos.add(&lfo0);
197 lfos.add(&lfo1);
198 lfos.add(&lfo2);
199 lfos.add(&lfo3);
200 lfos.add(&lfo4);
201 lfos.add(&lfo5);
202 lfos.add(&lfo6);
203 lfos.add(&lfo7);
204 }
205
206 void LFOv2Unit::Trigger() {
207 LFOUnit::Trigger();
208
209 if (pLfoInfo->wave < 0 || pLfoInfo->wave >= lfos.size()) pLFO = &lfo0;
210 else pLFO = lfos[pLfoInfo->wave];
211
212 pLFO->Trigger (
213 pLfoInfo->freq + suFreqOnCC.GetLevel(),
214 start_level_mid,
215 1, 0, false, GetSampleRate()
216 );
217 pLFO->Update(0);
218
219 float phase = pLfoInfo->phase + GetInfluence(pLfoInfo->phase_oncc);
220 if (phase != 0) pLFO->SetPhase(phase);
221 }
222
223 void AmpLFOUnit::Trigger() {
224 ::sfz::Region* const pRegion = pVoice->pRegion;
225 pLfoInfo->delay = pRegion->amplfo_delay;
226 pLfoInfo->freq = pRegion->amplfo_freq;
227 pLfoInfo->fade = pRegion->amplfo_fade;
228 pLfoInfo->volume = pRegion->amplfo_depth;
229
230 LFOv1Unit::Trigger();
231 }
232
233 void PitchLFOUnit::Trigger() {
234 ::sfz::Region* const pRegion = pVoice->pRegion;
235 pLfoInfo->delay = pRegion->pitchlfo_delay;
236 pLfoInfo->freq = pRegion->pitchlfo_freq;
237 pLfoInfo->fade = pRegion->pitchlfo_fade;
238 pLfoInfo->pitch = pRegion->pitchlfo_depth;
239
240 LFOv1Unit::Trigger();
241 }
242
243 void FilLFOUnit::Trigger() {
244 ::sfz::Region* const pRegion = pVoice->pRegion;
245 pLfoInfo->delay = pRegion->fillfo_delay;
246 pLfoInfo->freq = pRegion->fillfo_freq;
247 pLfoInfo->fade = pRegion->fillfo_fade;
248 pLfoInfo->cutoff = pRegion->fillfo_depth;
249
250 LFOv1Unit::Trigger();
251 }
252
253 CCUnit::CCUnit(SfzSignalUnitRack* rack, Listener* l): CCSignalUnit(rack, l) {
254 pVoice = NULL;
255 }
256
257 void CCUnit::Trigger() {
258 for (int i = 0; i < Ctrls.size(); i++) {
259 Ctrls[i].Value = pVoice->GetControllerValue(Ctrls[i].Controller);
260 if (Ctrls[i].pSmoother != NULL) Ctrls[i].pSmoother->setValue(Ctrls[i].Value);
261 }
262 CCSignalUnit::Trigger();
263 }
264
265 void CCUnit::SetCCs(::sfz::Array<int>& cc) {
266 RemoveAllCCs();
267 for (int i = 0; i < 128; i++) {
268 if (cc[i] != 0) AddCC(i, cc[i]);
269 }
270 }
271
272 void CCUnit::SetCCs(ArrayList< ::sfz::CC>& cc) {
273 RemoveAllCCs();
274 for (int i = 0; i < cc.size(); i++) {
275 if (cc[i].Influence != 0) {
276 short int curve = cc[i].Curve;
277 if (curve >= GetCurveCount()) curve = -1;
278 AddSmoothCC(cc[i].Controller, cc[i].Influence, curve, cc[i].Smooth);
279 }
280 }
281 }
282
283 void CCUnit::AddSmoothCC(uint8_t Controller, float Influence, short int Curve, float Smooth) {
284 AddCC(Controller, Influence, Curve);
285 }
286
287 int CCUnit::GetCurveCount() {
288 return pVoice->pRegion->GetInstrument()->curves.size();
289 }
290
291 ::sfz::Curve* CCUnit::GetCurve(int idx) {
292 return &pVoice->pRegion->GetInstrument()->curves[idx];
293 }
294
295 double CCUnit::GetSampleRate() {
296 return pVoice->GetSampleRate() / CONFIG_DEFAULT_SUBFRAGMENT_SIZE;
297 }
298
299 void SmoothCCUnit::AddSmoothCC(uint8_t Controller, float Influence, short int Curve, float Smooth) {
300 if (Smooth > 0) {
301 Smoothers[Controller].trigger(Smooth / 1000.0f, GetSampleRate());
302 AddCC(Controller, Influence, Curve, &Smoothers[Controller]);
303 } else {
304 AddCC(Controller, Influence, Curve);
305 }
306 }
307
308
309 EndpointUnit::EndpointUnit(SfzSignalUnitRack* rack): EndpointSignalUnit(rack) {
310
311 }
312
313 SfzSignalUnitRack* const EndpointUnit::GetRack() {
314 return static_cast<SfzSignalUnitRack* const>(pRack);
315 }
316
317 void EndpointUnit::Trigger() {
318
319 }
320
321 bool EndpointUnit::Active() {
322 if (GetRack()->suVolEG.Active()) return true;
323
324 bool b = false;
325 for (int i = 0; i < GetRack()->volEGs.size(); i++) {
326 if (GetRack()->volEGs[i]->Active()) { b = true; break; }
327 }
328
329 return b;
330 }
331
332 float EndpointUnit::GetVolume() {
333 float vol = GetRack()->suVolEG.Active() ? GetRack()->suVolEG.GetLevel() : 0;
334
335 for (int i = 0; i < GetRack()->volEGs.size(); i++) {
336 EGv2Unit* eg = GetRack()->volEGs[i];
337 if (!eg->Active()) continue;
338 vol += eg->GetLevel() * (eg->pEGInfo->amplitude / 100.0f);
339
340 }
341
342 AmpLFOUnit* u = &(GetRack()->suAmpLFO);
343 CCSignalUnit* u2 = &(GetRack()->suAmpLFO.suDepthOnCC);
344 float f = u2->Active() ? u2->GetLevel() : 0;
345 vol *= u->Active() ? ::sf2::ToRatio((u->GetLevel() * (u->pLfoInfo->volume + f) * 10.0)) : 1;
346
347 vol *= ::sf2::ToRatio(GetRack()->suVolOnCC.GetLevel() * 10.0);
348
349 for (int i = 0; i < GetRack()->volLFOs.size(); i++) {
350 LFOv2Unit* lfo = GetRack()->volLFOs[i];
351 if (!lfo->Active()) continue;
352
353 float f = lfo->suVolOnCC.Active() ? lfo->suVolOnCC.GetLevel() : 0;
354 vol *= ::sf2::ToRatio(lfo->GetLevel() * (lfo->pLfoInfo->volume + f) * 10.0);
355 }
356
357 return vol;
358 }
359
360 float EndpointUnit::GetFilterCutoff() {
361 float val;
362
363 FilLFOUnit* u = &(GetRack()->suFilLFO);
364 CCSignalUnit* u1 = &(GetRack()->suFilLFO.suDepthOnCC);
365 float f = u1->Active() ? u1->GetLevel() : 0;
366 val = u->Active() ? RTMath::CentsToFreqRatioUnlimited(u->GetLevel() * (u->pLfoInfo->cutoff + f)) : 1;
367
368 FilEGUnit* u2 = &(GetRack()->suFilEG);
369 val *= u2->Active() ? RTMath::CentsToFreqRatioUnlimited(u2->GetLevel() * u2->depth) : 1;
370
371 for (int i = 0; i < GetRack()->filLFOs.size(); i++) {
372 LFOv2Unit* lfo = GetRack()->filLFOs[i];
373 if (!lfo->Active()) continue;
374
375 float f = lfo->suCutoffOnCC.Active() ? lfo->suCutoffOnCC.GetLevel() : 0;
376 f = lfo->GetLevel() * (lfo->pLfoInfo->cutoff + f);
377 val *= RTMath::CentsToFreqRatioUnlimited(f);
378 }
379
380 return val;
381 }
382
383 float EndpointUnit::GetPitch() {
384 double p;
385 EGv1Unit* u = &(GetRack()->suPitchEG);
386 p = u->Active() ? RTMath::CentsToFreqRatioUnlimited(u->GetLevel() * u->depth) : 1;
387
388 PitchLFOUnit* u2 = &(GetRack()->suPitchLFO);
389 CCSignalUnit* u3 = &(GetRack()->suPitchLFO.suDepthOnCC);
390 float f = u3->Active() ? u3->GetLevel() : 0;
391 p *= u2->Active() ? RTMath::CentsToFreqRatioUnlimited(u2->GetLevel() * (u2->pLfoInfo->pitch + f)) : 1;
392
393 for (int i = 0; i < GetRack()->pitchLFOs.size(); i++) {
394 LFOv2Unit* lfo = GetRack()->pitchLFOs[i];
395 if (!lfo->Active()) continue;
396
397 float f = lfo->suPitchOnCC.Active() ? lfo->suPitchOnCC.GetLevel() : 0;
398 p *= RTMath::CentsToFreqRatioUnlimited(lfo->GetLevel() * (lfo->pLfoInfo->pitch + f));
399 }
400
401 return p;
402 }
403
404 float EndpointUnit::GetResonance() {
405 float val = 0;
406
407 for (int i = 0; i < GetRack()->resLFOs.size(); i++) {
408 LFOv2Unit* lfo = GetRack()->resLFOs[i];
409 if (!lfo->Active()) continue;
410
411 float f = lfo->suResOnCC.Active() ? lfo->suResOnCC.GetLevel() : 0;
412 val += lfo->GetLevel() * (lfo->pLfoInfo->resonance + f);
413 }
414
415 return val;
416 }
417
418 float EndpointUnit::GetPan() {
419 float pan = 0;
420
421 for (int i = 0; i < GetRack()->panLFOs.size(); i++) {
422 LFOv2Unit* lfo = GetRack()->panLFOs[i];
423 if (!lfo->Active()) continue;
424
425 float f = lfo->suPanOnCC.Active() ? lfo->suPanOnCC.GetLevel() : 0;
426 pan += lfo->GetLevel() * (lfo->pLfoInfo->pan + f);
427 }
428
429 if(pan < -100) return -100;
430 if(pan > 100) return 100;
431
432 return pan;
433 }
434
435
436 SfzSignalUnitRack::SfzSignalUnitRack(Voice* voice)
437 : SignalUnitRack(MaxUnitCount), pVoice(voice), suEndpoint(this), suVolEG(this), suFilEG(this), suPitchEG(this),
438 EGs(maxEgCount), volEGs(maxEgCount), pitchEGs(maxEgCount), suVolOnCC(this),
439 suAmpLFO(this), suPitchLFO(this), suFilLFO(this),
440 LFOs(maxLfoCount), volLFOs(maxLfoCount), pitchLFOs(maxLfoCount),
441 filLFOs(maxLfoCount), resLFOs(maxLfoCount), panLFOs(maxLfoCount)
442 {
443 suEndpoint.pVoice = suVolEG.pVoice = suFilEG.pVoice = suPitchEG.pVoice = voice;
444 suAmpLFO.pVoice = suPitchLFO.pVoice = suFilLFO.pVoice = suVolOnCC.pVoice = voice;
445 suPitchLFO.suDepthOnCC.pVoice = suPitchLFO.suFadeEG.pVoice = suPitchLFO.suFreqOnCC.pVoice = voice;
446 suFilLFO.suFadeEG.pVoice = suFilLFO.suDepthOnCC.pVoice = suFilLFO.suFreqOnCC.pVoice = voice;
447 suAmpLFO.suFadeEG.pVoice = suAmpLFO.suDepthOnCC.pVoice = suAmpLFO.suFreqOnCC.pVoice = voice;
448
449 for (int i = 0; i < EGs.capacity(); i++) {
450 EGs[i] = new EGv2Unit(this);
451 EGs[i]->pVoice = voice;
452 }
453
454 for (int i = 0; i < LFOs.capacity(); i++) {
455 LFOs[i] = new LFOv2Unit(this);
456 LFOs[i]->pVoice = voice;
457 LFOs[i]->suFadeEG.pVoice = voice;
458 LFOs[i]->suVolOnCC.pVoice = voice;
459 LFOs[i]->suPitchOnCC.pVoice = voice;
460 LFOs[i]->suFreqOnCC.pVoice = voice;
461 LFOs[i]->suPanOnCC.pVoice = voice;
462 LFOs[i]->suCutoffOnCC.pVoice = voice;
463 LFOs[i]->suResOnCC.pVoice = voice;
464 }
465 }
466
467 SfzSignalUnitRack::~SfzSignalUnitRack() {
468 for (int i = 0; i < EGs.capacity(); i++) {
469 delete EGs[i]; EGs[i] = NULL;
470 }
471
472 for (int i = 0; i < LFOs.capacity(); i++) {
473 delete LFOs[i]; LFOs[i] = NULL;
474 }
475 }
476
477 void SfzSignalUnitRack::Trigger() {
478 EGs.clear();
479 volEGs.clear();
480 pitchEGs.clear();
481
482 LFOs.clear();
483 volLFOs.clear();
484 pitchLFOs.clear();
485 filLFOs.clear();
486 resLFOs.clear();
487 panLFOs.clear();
488
489 ::sfz::Region* const pRegion = pVoice->pRegion;
490
491 suVolOnCC.SetCCs(pRegion->volume_oncc);
492
493 for (int i = 0; i < pRegion->eg.size(); i++) {
494 if (pRegion->eg[i].node.size() == 0) continue;
495
496 if(EGs.size() < EGs.capacity()) {
497 EGv2Unit eg(this);
498 eg.pEGInfo = &(pRegion->eg[i]);
499 EGs.increment()->Copy(eg);
500 } else { std::cerr << "Maximum number of EGs reached!" << std::endl; break; }
501
502 if (pRegion->eg[i].amplitude > 0) {
503 if(volEGs.size() < volEGs.capacity()) volEGs.add(EGs[EGs.size() - 1]);
504 else std::cerr << "Maximum number of EGs reached!" << std::endl;
505 }
506 }
507
508 if (pRegion->ampeg_sustain == -1) {
509 if (volEGs.size() > 0) pRegion->ampeg_sustain = 0;
510 else pRegion->ampeg_sustain = 100;
511 }
512
513 // LFO
514 for (int i = 0; i < pRegion->lfos.size(); i++) {
515 if (pRegion->lfos[i].freq == -1) continue; // Not initialized
516
517 if(LFOs.size() < LFOs.capacity()) {
518 LFOv2Unit lfo(this);
519 lfo.pLfoInfo = &(pRegion->lfos[i]);
520 LFOs.increment()->Copy(lfo);
521 LFOs[LFOs.size() - 1]->suVolOnCC.SetCCs(pRegion->lfos[i].volume_oncc);
522 LFOs[LFOs.size() - 1]->suPitchOnCC.SetCCs(pRegion->lfos[i].pitch_oncc);
523 LFOs[LFOs.size() - 1]->suFreqOnCC.SetCCs(pRegion->lfos[i].freq_oncc);
524 LFOs[LFOs.size() - 1]->suPanOnCC.SetCCs(pRegion->lfos[i].pan_oncc);
525 LFOs[LFOs.size() - 1]->suCutoffOnCC.SetCCs(pRegion->lfos[i].cutoff_oncc);
526 LFOs[LFOs.size() - 1]->suResOnCC.SetCCs(pRegion->lfos[i].resonance_oncc);
527 } else { std::cerr << "Maximum number of LFOs reached!" << std::endl; break; }
528
529 if (pRegion->lfos[i].volume != 0 || !pRegion->lfos[i].volume_oncc.empty()) {
530 if(volLFOs.size() < volLFOs.capacity()) volLFOs.add(LFOs[LFOs.size() - 1]);
531 else std::cerr << "Maximum number of LFOs reached!" << std::endl;
532 }
533
534 if (pRegion->lfos[i].pitch != 0 || !pRegion->lfos[i].pitch_oncc.empty()) {
535 if(pitchLFOs.size() < pitchLFOs.capacity()) pitchLFOs.add(LFOs[LFOs.size() - 1]);
536 else std::cerr << "Maximum number of LFOs reached!" << std::endl;
537 }
538
539 if (pRegion->lfos[i].cutoff != 0 || !pRegion->lfos[i].cutoff_oncc.empty()) {
540 if(filLFOs.size() < filLFOs.capacity()) filLFOs.add(LFOs[LFOs.size() - 1]);
541 else std::cerr << "Maximum number of LFOs reached!" << std::endl;
542 }
543
544 if (pRegion->lfos[i].resonance != 0 || !pRegion->lfos[i].resonance_oncc.empty()) {
545 if(resLFOs.size() < resLFOs.capacity()) resLFOs.add(LFOs[LFOs.size() - 1]);
546 else std::cerr << "Maximum number of LFOs reached!" << std::endl;
547 }
548
549 if (pRegion->lfos[i].pan != 0 || !pRegion->lfos[i].pan_oncc.empty()) {
550 if(panLFOs.size() < panLFOs.capacity()) panLFOs.add(LFOs[LFOs.size() - 1]);
551 else std::cerr << "Maximum number of LFOs reached!" << std::endl;
552 }
553 }
554
555 suPitchLFO.suDepthOnCC.SetCCs(pRegion->pitchlfo_depthcc);
556 suPitchLFO.suFreqOnCC.SetCCs(pRegion->pitchlfo_freqcc);
557
558 suFilLFO.suDepthOnCC.SetCCs(pRegion->fillfo_depthcc);
559 suFilLFO.suFreqOnCC.SetCCs(pRegion->fillfo_freqcc);
560
561 suAmpLFO.suDepthOnCC.SetCCs(pRegion->amplfo_depthcc);
562 suAmpLFO.suFreqOnCC.SetCCs(pRegion->amplfo_freqcc);
563
564 Units.clear();
565
566 Units.add(&suVolOnCC);
567
568 Units.add(&suVolEG);
569 Units.add(&suFilEG);
570 Units.add(&suPitchEG);
571
572 Units.add(&suPitchLFO.suFreqOnCC); // Don't change order! (should be triggered before the LFO)
573 Units.add(&suPitchLFO);
574 Units.add(&suPitchLFO.suDepthOnCC);
575 Units.add(&suPitchLFO.suFadeEG);
576
577 Units.add(&suAmpLFO.suFreqOnCC); // Don't change order! (should be triggered before the LFO)
578 Units.add(&suAmpLFO.suDepthOnCC);
579 Units.add(&suAmpLFO);
580 Units.add(&suAmpLFO.suFadeEG);
581
582 Units.add(&suFilLFO.suFreqOnCC); // Don't change order! (should be triggered before the LFO)
583 Units.add(&suFilLFO.suDepthOnCC);
584 Units.add(&suFilLFO);
585 Units.add(&suFilLFO.suFadeEG);
586
587 for (int i = 0; i < EGs.size(); i++) {
588 Units.add(EGs[i]);
589 }
590
591 for (int i = 0; i < LFOs.size(); i++) {
592 Units.add(&(LFOs[i]->suFreqOnCC)); // Don't change order! (should be triggered before the LFO)
593 Units.add(LFOs[i]);
594 Units.add(&(LFOs[i]->suFadeEG));
595 Units.add(&(LFOs[i]->suVolOnCC));
596 Units.add(&(LFOs[i]->suPitchOnCC));
597 Units.add(&(LFOs[i]->suPanOnCC));
598 Units.add(&(LFOs[i]->suCutoffOnCC));
599 Units.add(&(LFOs[i]->suResOnCC));
600 }
601
602 Units.add(&suEndpoint);
603
604 SignalUnitRack::Trigger();
605 }
606
607 EndpointSignalUnit* SfzSignalUnitRack::GetEndpointUnit() {
608 return &suEndpoint;
609 }
610
611 void SfzSignalUnitRack::EnterFadeOutStage() {
612 suVolEG.EG.enterFadeOutStage();
613
614 for (int i = 0; i < volEGs.size(); i++) {
615 volEGs[i]->EG.enterFadeOutStage();
616 }
617 }
618
619 }} // namespace LinuxSampler::sfz

  ViewVC Help
Powered by ViewVC