1 |
iliev |
2218 |
/*************************************************************************** |
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 |
iliev |
2221 |
#include <SF.h> |
26 |
iliev |
2218 |
|
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 |
|
|
|
38 |
|
|
void EGv1Unit::Trigger() { |
39 |
|
|
::sfz::Region* const pRegion = pVoice->pRegion; |
40 |
iliev |
2220 |
|
41 |
iliev |
2218 |
// the length of the decay and release curves are dependent on the velocity |
42 |
|
|
const double velrelease = 1 / pVoice->GetVelocityRelease(pVoice->MIDIVelocity); |
43 |
|
|
|
44 |
iliev |
2220 |
// set the delay trigger |
45 |
|
|
uiDelayTrigger = (pRegion->ampeg_delay + pRegion->ampeg_vel2delay * velrelease) * GetSampleRate(); |
46 |
|
|
|
47 |
iliev |
2218 |
EG.trigger(uint(pRegion->ampeg_start * 10), |
48 |
|
|
std::max(0.0, pRegion->ampeg_attack + pRegion->ampeg_vel2attack * velrelease), |
49 |
|
|
std::max(0.0, pRegion->ampeg_hold + pRegion->ampeg_vel2hold * velrelease), |
50 |
|
|
std::max(0.0, pRegion->ampeg_decay + pRegion->ampeg_vel2decay * velrelease), |
51 |
|
|
uint(std::min(std::max(0.0, 10 * (pRegion->ampeg_sustain + pRegion->ampeg_vel2sustain * velrelease)), 1000.0)), |
52 |
|
|
std::max(0.0, pRegion->ampeg_release + pRegion->ampeg_vel2release * velrelease), |
53 |
|
|
GetSampleRate()); |
54 |
|
|
} |
55 |
|
|
|
56 |
iliev |
2220 |
|
57 |
iliev |
2218 |
void EGv2Unit::Trigger() { |
58 |
|
|
EG.trigger(*pEGInfo, GetSampleRate(), pVoice->MIDIVelocity); |
59 |
|
|
} |
60 |
iliev |
2219 |
|
61 |
iliev |
2220 |
|
62 |
|
|
void PitchEGUnit::Trigger() { |
63 |
|
|
::sfz::Region* const pRegion = pVoice->pRegion; |
64 |
|
|
depth = pRegion->pitcheg_depth; |
65 |
|
|
|
66 |
|
|
// the length of the decay and release curves are dependent on the velocity |
67 |
|
|
const double velrelease = 1 / pVoice->GetVelocityRelease(pVoice->MIDIVelocity); |
68 |
iliev |
2218 |
|
69 |
iliev |
2220 |
// set the delay trigger |
70 |
|
|
uiDelayTrigger = (pRegion->pitcheg_delay + pRegion->pitcheg_vel2delay * velrelease) * GetSampleRate(); |
71 |
|
|
|
72 |
|
|
EG.trigger(uint(pRegion->pitcheg_start * 10), |
73 |
|
|
std::max(0.0, pRegion->pitcheg_attack + pRegion->pitcheg_vel2attack * velrelease), |
74 |
|
|
std::max(0.0, pRegion->pitcheg_hold + pRegion->pitcheg_vel2hold * velrelease), |
75 |
|
|
std::max(0.0, pRegion->pitcheg_decay + pRegion->pitcheg_vel2decay * velrelease), |
76 |
|
|
uint(std::min(std::max(0.0, 10 * (pRegion->pitcheg_sustain + pRegion->pitcheg_vel2sustain * velrelease)), 1000.0)), |
77 |
|
|
std::max(0.0, pRegion->pitcheg_release + pRegion->pitcheg_vel2release * velrelease), |
78 |
|
|
GetSampleRate()); |
79 |
|
|
} |
80 |
|
|
|
81 |
iliev |
2222 |
|
82 |
|
|
void FilEGUnit::Trigger() { |
83 |
|
|
::sfz::Region* const pRegion = pVoice->pRegion; |
84 |
|
|
depth = pRegion->fileg_depth; |
85 |
|
|
|
86 |
|
|
// the length of the decay and release curves are dependent on the velocity |
87 |
|
|
const double velrelease = 1 / pVoice->GetVelocityRelease(pVoice->MIDIVelocity); |
88 |
iliev |
2220 |
|
89 |
iliev |
2222 |
// set the delay trigger |
90 |
|
|
uiDelayTrigger = (pRegion->fileg_delay + pRegion->fileg_vel2delay * velrelease) * GetSampleRate(); |
91 |
|
|
|
92 |
|
|
EG.trigger(uint(pRegion->fileg_start * 10), |
93 |
|
|
std::max(0.0, pRegion->fileg_attack + pRegion->fileg_vel2attack * velrelease), |
94 |
|
|
std::max(0.0, pRegion->fileg_hold + pRegion->fileg_vel2hold * velrelease), |
95 |
|
|
std::max(0.0, pRegion->fileg_decay + pRegion->fileg_vel2decay * velrelease), |
96 |
|
|
uint(std::min(std::max(0.0, 10 * (pRegion->fileg_sustain + pRegion->fileg_vel2sustain * velrelease)), 1000.0)), |
97 |
|
|
std::max(0.0, pRegion->fileg_release + pRegion->fileg_vel2release * velrelease), |
98 |
|
|
GetSampleRate()); |
99 |
|
|
} |
100 |
|
|
|
101 |
|
|
|
102 |
iliev |
2219 |
void LFOUnit::Increment() { |
103 |
|
|
if (DelayStage()) return; |
104 |
|
|
|
105 |
|
|
SignalUnit::Increment(); |
106 |
|
|
|
107 |
iliev |
2223 |
Level = pLFO->Render(); |
108 |
iliev |
2219 |
} |
109 |
|
|
|
110 |
|
|
void LFOUnit::Trigger() { |
111 |
|
|
//reset |
112 |
|
|
Level = 0; |
113 |
|
|
|
114 |
|
|
// set the delay trigger |
115 |
iliev |
2220 |
uiDelayTrigger = pLfoInfo->delay * GetSampleRate(); |
116 |
iliev |
2219 |
} |
117 |
|
|
|
118 |
iliev |
2221 |
void LFOv1Unit::Trigger() { |
119 |
|
|
LFOUnit::Trigger(); |
120 |
|
|
|
121 |
|
|
lfo.trigger ( |
122 |
|
|
pLfoInfo->freq, |
123 |
|
|
start_level_mid, |
124 |
|
|
1, 0, false, GetSampleRate() |
125 |
|
|
); |
126 |
|
|
lfo.update(0); |
127 |
|
|
} |
128 |
|
|
|
129 |
iliev |
2223 |
|
130 |
|
|
LFOv2Unit::LFOv2Unit(SfzSignalUnitRack* rack) |
131 |
|
|
: LFOUnit(rack), lfos(8), lfo0(1200.0f), lfo1(1200.0f), lfo2(1200.0f), |
132 |
iliev |
2225 |
lfo3(1200.0f), lfo4(1200.0f), lfo5(1200.0f), lfo6(1200.0f), lfo7(1200.0f), |
133 |
|
|
suPitchOnCC(rack) |
134 |
iliev |
2223 |
{ |
135 |
|
|
lfos.add(&lfo0); |
136 |
|
|
lfos.add(&lfo1); |
137 |
|
|
lfos.add(&lfo2); |
138 |
|
|
lfos.add(&lfo3); |
139 |
|
|
lfos.add(&lfo4); |
140 |
|
|
lfos.add(&lfo5); |
141 |
|
|
lfos.add(&lfo6); |
142 |
|
|
lfos.add(&lfo7); |
143 |
|
|
} |
144 |
|
|
|
145 |
iliev |
2219 |
void LFOv2Unit::Trigger() { |
146 |
|
|
LFOUnit::Trigger(); |
147 |
|
|
|
148 |
iliev |
2223 |
if (pLfoInfo->wave < 0 || pLfoInfo->wave >= lfos.size()) pLFO = &lfo0; |
149 |
|
|
else pLFO = lfos[pLfoInfo->wave]; |
150 |
|
|
|
151 |
|
|
pLFO->Trigger ( |
152 |
iliev |
2219 |
pLfoInfo->freq, |
153 |
|
|
start_level_mid, |
154 |
|
|
1, 0, false, GetSampleRate() |
155 |
|
|
); |
156 |
iliev |
2223 |
pLFO->Update(0); |
157 |
iliev |
2225 |
|
158 |
|
|
float phase = pLfoInfo->phase; |
159 |
|
|
for (int i = 0; i < pLfoInfo->phase_oncc.size(); i++) { |
160 |
|
|
int val = pVoice->GetControllerValue(pLfoInfo->phase_oncc[i].Controller); |
161 |
|
|
phase += (val / 127.0f) * pLfoInfo->phase_oncc[i].Influence; |
162 |
|
|
} |
163 |
|
|
if (phase != 0) pLFO->SetPhase(phase); |
164 |
iliev |
2219 |
} |
165 |
iliev |
2221 |
|
166 |
|
|
void AmpLFOUnit::Trigger() { |
167 |
|
|
::sfz::Region* const pRegion = pVoice->pRegion; |
168 |
|
|
pLfoInfo->delay = pRegion->amplfo_delay; |
169 |
|
|
pLfoInfo->freq = pRegion->amplfo_freq; |
170 |
|
|
pLfoInfo->volume = pRegion->amplfo_depth; |
171 |
|
|
|
172 |
|
|
LFOv1Unit::Trigger(); |
173 |
|
|
} |
174 |
|
|
|
175 |
|
|
void PitchLFOUnit::Trigger() { |
176 |
|
|
::sfz::Region* const pRegion = pVoice->pRegion; |
177 |
|
|
pLfoInfo->delay = pRegion->pitchlfo_delay; |
178 |
|
|
pLfoInfo->freq = pRegion->pitchlfo_freq; |
179 |
|
|
pLfoInfo->pitch = pRegion->pitchlfo_depth; |
180 |
|
|
|
181 |
|
|
LFOv1Unit::Trigger(); |
182 |
|
|
} |
183 |
|
|
|
184 |
|
|
void FilLFOUnit::Trigger() { |
185 |
|
|
::sfz::Region* const pRegion = pVoice->pRegion; |
186 |
|
|
pLfoInfo->delay = pRegion->fillfo_delay; |
187 |
|
|
pLfoInfo->freq = pRegion->fillfo_freq; |
188 |
|
|
pLfoInfo->cutoff = pRegion->fillfo_depth; |
189 |
|
|
|
190 |
|
|
LFOv1Unit::Trigger(); |
191 |
|
|
} |
192 |
iliev |
2224 |
|
193 |
|
|
CCUnit::CCUnit(SfzSignalUnitRack* rack): CCSignalUnit(rack) { } |
194 |
|
|
|
195 |
|
|
void CCUnit::Trigger() { |
196 |
|
|
for (int i = 0; i < Ctrls.size(); i++) { |
197 |
|
|
Ctrls[i].Value = pVoice->GetControllerValue(Ctrls[i].Controller); |
198 |
|
|
} |
199 |
|
|
CCSignalUnit::Trigger(); |
200 |
|
|
} |
201 |
|
|
|
202 |
|
|
void CCUnit::SetCCs(::sfz::Array<int>& cc) { |
203 |
|
|
RemoveAllCCs(); |
204 |
|
|
for (int i = 0; i < 128; i++) { |
205 |
|
|
if (cc[i] != 0) AddCC(i, cc[i]); |
206 |
|
|
} |
207 |
|
|
} |
208 |
iliev |
2225 |
|
209 |
|
|
void CCUnit::SetCCs(ArrayList< ::sfz::CC>& cc) { |
210 |
|
|
RemoveAllCCs(); |
211 |
|
|
for (int i = 0; i < cc.size(); i++) { |
212 |
|
|
if (cc[i].Influence != 0) AddCC(cc[i].Controller, cc[i].Influence); |
213 |
|
|
} |
214 |
|
|
} |
215 |
iliev |
2218 |
|
216 |
iliev |
2219 |
|
217 |
iliev |
2218 |
EndpointUnit::EndpointUnit(SfzSignalUnitRack* rack): EndpointSignalUnit(rack) { |
218 |
|
|
|
219 |
|
|
} |
220 |
|
|
|
221 |
|
|
SfzSignalUnitRack* const EndpointUnit::GetRack() { |
222 |
|
|
return static_cast<SfzSignalUnitRack* const>(pRack); |
223 |
|
|
} |
224 |
|
|
|
225 |
|
|
void EndpointUnit::Trigger() { |
226 |
|
|
|
227 |
|
|
} |
228 |
|
|
|
229 |
|
|
bool EndpointUnit::Active() { |
230 |
|
|
if (GetRack()->suVolEG.Active()) return true; |
231 |
|
|
|
232 |
|
|
bool b = false; |
233 |
|
|
for (int i = 0; i < GetRack()->volEGs.size(); i++) { |
234 |
|
|
if (GetRack()->volEGs[i]->Active()) { b = true; break; } |
235 |
|
|
} |
236 |
|
|
|
237 |
|
|
return b; |
238 |
|
|
} |
239 |
|
|
|
240 |
|
|
float EndpointUnit::GetVolume() { |
241 |
|
|
float vol = GetRack()->suVolEG.Active() ? GetRack()->suVolEG.GetLevel() : 0; |
242 |
|
|
|
243 |
|
|
for (int i = 0; i < GetRack()->volEGs.size(); i++) { |
244 |
|
|
EGv2Unit* eg = GetRack()->volEGs[i]; |
245 |
|
|
if (!eg->Active()) continue; |
246 |
|
|
vol += eg->GetLevel() * (eg->pEGInfo->amplitude / 100.0f); |
247 |
|
|
} |
248 |
|
|
|
249 |
iliev |
2221 |
AmpLFOUnit* u = &(GetRack()->suAmpLFO); |
250 |
|
|
vol *= u->Active() ? ::sf2::ToRatio((u->GetLevel() * u->pLfoInfo->volume) * 10.0) : 1; |
251 |
|
|
|
252 |
iliev |
2218 |
return vol; |
253 |
|
|
} |
254 |
|
|
|
255 |
|
|
float EndpointUnit::GetFilterCutoff() { |
256 |
iliev |
2221 |
float val; |
257 |
iliev |
2219 |
|
258 |
iliev |
2221 |
FilLFOUnit* u = &(GetRack()->suFilLFO); |
259 |
|
|
val = u->Active() ? RTMath::CentsToFreqRatioUnlimited(u->GetLevel() * u->pLfoInfo->cutoff) : 1; |
260 |
|
|
|
261 |
iliev |
2222 |
FilEGUnit* u2 = &(GetRack()->suFilEG); |
262 |
|
|
val *= u2->Active() ? RTMath::CentsToFreqRatioUnlimited(u2->GetLevel() * u2->depth) : 1; |
263 |
|
|
|
264 |
iliev |
2219 |
for (int i = 0; i < GetRack()->filLFOs.size(); i++) { |
265 |
|
|
LFOv2Unit* lfo = GetRack()->filLFOs[i]; |
266 |
|
|
if (!lfo->Active()) continue; |
267 |
|
|
|
268 |
|
|
float f = lfo->GetLevel() * lfo->pLfoInfo->cutoff; |
269 |
|
|
val *= RTMath::CentsToFreqRatioUnlimited(f); |
270 |
|
|
} |
271 |
|
|
|
272 |
|
|
return val; |
273 |
iliev |
2218 |
} |
274 |
|
|
|
275 |
|
|
float EndpointUnit::GetPitch() { |
276 |
iliev |
2221 |
double p; |
277 |
iliev |
2220 |
EGv1Unit* u = &(GetRack()->suPitchEG); |
278 |
iliev |
2221 |
p = u->Active() ? RTMath::CentsToFreqRatioUnlimited(u->GetLevel() * u->depth) : 1; |
279 |
|
|
|
280 |
|
|
PitchLFOUnit* u2 = &(GetRack()->suPitchLFO); |
281 |
iliev |
2224 |
CCSignalUnit* u3 = &(GetRack()->suPitchLFO.suDepthCC); |
282 |
|
|
float f = u3->Active() ? u3->GetLevel() : 0; |
283 |
|
|
p *= u2->Active() ? RTMath::CentsToFreqRatioUnlimited(u2->GetLevel() * (u2->pLfoInfo->pitch + f)) : 1; |
284 |
iliev |
2225 |
|
285 |
|
|
for (int i = 0; i < GetRack()->pitchLFOs.size(); i++) { |
286 |
|
|
LFOv2Unit* lfo = GetRack()->pitchLFOs[i]; |
287 |
|
|
if (!lfo->Active()) continue; |
288 |
|
|
|
289 |
|
|
float f = lfo->suPitchOnCC.Active() ? lfo->suPitchOnCC.GetLevel() : 0; |
290 |
|
|
p *= RTMath::CentsToFreqRatioUnlimited(lfo->GetLevel() * (lfo->pLfoInfo->pitch + f)); |
291 |
|
|
} |
292 |
|
|
|
293 |
iliev |
2221 |
return p; |
294 |
iliev |
2218 |
} |
295 |
|
|
|
296 |
|
|
float EndpointUnit::GetResonance() { |
297 |
iliev |
2219 |
float val = 0; |
298 |
|
|
|
299 |
|
|
for (int i = 0; i < GetRack()->resLFOs.size(); i++) { |
300 |
|
|
LFOv2Unit* lfo = GetRack()->resLFOs[i]; |
301 |
|
|
if (!lfo->Active()) continue; |
302 |
|
|
|
303 |
|
|
val += lfo->GetLevel() * lfo->pLfoInfo->resonance; |
304 |
|
|
} |
305 |
|
|
|
306 |
|
|
return val; |
307 |
iliev |
2218 |
} |
308 |
|
|
|
309 |
iliev |
2219 |
float EndpointUnit::GetPan() { |
310 |
|
|
float pan = 0; |
311 |
|
|
|
312 |
|
|
for (int i = 0; i < GetRack()->panLFOs.size(); i++) { |
313 |
|
|
LFOv2Unit* lfo = GetRack()->panLFOs[i]; |
314 |
|
|
if (!lfo->Active()) continue; |
315 |
|
|
|
316 |
|
|
pan += lfo->GetLevel() * lfo->pLfoInfo->pan; |
317 |
|
|
} |
318 |
|
|
|
319 |
|
|
if(pan < -100) return -100; |
320 |
|
|
if(pan > 100) return 100; |
321 |
|
|
|
322 |
|
|
return pan; |
323 |
|
|
} |
324 |
iliev |
2218 |
|
325 |
iliev |
2219 |
|
326 |
iliev |
2218 |
SfzSignalUnitRack::SfzSignalUnitRack(Voice* voice) |
327 |
iliev |
2222 |
: SignalUnitRack(MaxUnitCount), pVoice(voice), suEndpoint(this), suVolEG(this), suFilEG(this), suPitchEG(this), |
328 |
iliev |
2219 |
EGs(maxEgCount), volEGs(maxEgCount), pitchEGs(maxEgCount), |
329 |
iliev |
2221 |
suAmpLFO(this), suPitchLFO(this), suFilLFO(this), |
330 |
iliev |
2225 |
LFOs(maxLfoCount), pitchLFOs(maxLfoCount), filLFOs(maxLfoCount), resLFOs(maxLfoCount), panLFOs(maxLfoCount) |
331 |
iliev |
2218 |
{ |
332 |
iliev |
2222 |
suEndpoint.pVoice = suVolEG.pVoice = suFilEG.pVoice = suPitchEG.pVoice = voice; |
333 |
iliev |
2221 |
suAmpLFO.pVoice = suPitchLFO.pVoice = suFilLFO.pVoice = voice; |
334 |
iliev |
2224 |
suPitchLFO.suDepthCC.pVoice = voice; |
335 |
iliev |
2218 |
|
336 |
|
|
for (int i = 0; i < EGs.capacity(); i++) { |
337 |
|
|
EGs[i] = new EGv2Unit(this); |
338 |
|
|
EGs[i]->pVoice = voice; |
339 |
|
|
} |
340 |
iliev |
2219 |
|
341 |
|
|
for (int i = 0; i < LFOs.capacity(); i++) { |
342 |
|
|
LFOs[i] = new LFOv2Unit(this); |
343 |
|
|
LFOs[i]->pVoice = voice; |
344 |
iliev |
2225 |
LFOs[i]->suPitchOnCC.pVoice = voice; |
345 |
iliev |
2219 |
} |
346 |
iliev |
2218 |
} |
347 |
|
|
|
348 |
|
|
SfzSignalUnitRack::~SfzSignalUnitRack() { |
349 |
iliev |
2219 |
for (int i = 0; i < EGs.capacity(); i++) { |
350 |
iliev |
2218 |
delete EGs[i]; EGs[i] = NULL; |
351 |
|
|
} |
352 |
iliev |
2219 |
|
353 |
|
|
for (int i = 0; i < LFOs.capacity(); i++) { |
354 |
|
|
delete LFOs[i]; LFOs[i] = NULL; |
355 |
|
|
} |
356 |
iliev |
2218 |
} |
357 |
|
|
|
358 |
|
|
void SfzSignalUnitRack::Trigger() { |
359 |
|
|
EGs.clear(); |
360 |
|
|
volEGs.clear(); |
361 |
|
|
pitchEGs.clear(); |
362 |
|
|
|
363 |
iliev |
2219 |
LFOs.clear(); |
364 |
iliev |
2225 |
pitchLFOs.clear(); |
365 |
iliev |
2219 |
filLFOs.clear(); |
366 |
|
|
resLFOs.clear(); |
367 |
|
|
panLFOs.clear(); |
368 |
|
|
|
369 |
iliev |
2218 |
::sfz::Region* const pRegion = pVoice->pRegion; |
370 |
|
|
|
371 |
iliev |
2219 |
for (int i = 0; i < pRegion->eg.size(); i++) { |
372 |
iliev |
2218 |
if (pRegion->eg[i].node.size() == 0) continue; |
373 |
|
|
|
374 |
|
|
if(EGs.size() < EGs.capacity()) { |
375 |
|
|
EGv2Unit eg(this); |
376 |
|
|
eg.pEGInfo = &(pRegion->eg[i]); |
377 |
|
|
EGs.increment()->Copy(eg); |
378 |
|
|
} else { std::cerr << "Maximum number of EGs reached!" << std::endl; break; } |
379 |
|
|
|
380 |
|
|
if (pRegion->eg[i].amplitude > 0) { |
381 |
|
|
if(volEGs.size() < volEGs.capacity()) volEGs.add(EGs[EGs.size() - 1]); |
382 |
|
|
else std::cerr << "Maximum number of EGs reached!" << std::endl; |
383 |
|
|
} |
384 |
|
|
} |
385 |
|
|
|
386 |
|
|
if (pRegion->ampeg_sustain == -1) { |
387 |
|
|
if (volEGs.size() > 0) pRegion->ampeg_sustain = 0; |
388 |
|
|
else pRegion->ampeg_sustain = 100; |
389 |
|
|
} |
390 |
|
|
|
391 |
iliev |
2219 |
// LFO |
392 |
|
|
for (int i = 0; i < pRegion->lfos.size(); i++) { |
393 |
|
|
if (pRegion->lfos[i].freq == -1) continue; // Not initialized |
394 |
|
|
|
395 |
|
|
if(LFOs.size() < LFOs.capacity()) { |
396 |
|
|
LFOv2Unit lfo(this); |
397 |
|
|
lfo.pLfoInfo = &(pRegion->lfos[i]); |
398 |
|
|
LFOs.increment()->Copy(lfo); |
399 |
iliev |
2225 |
LFOs[LFOs.size() - 1]->suPitchOnCC.SetCCs(pRegion->lfos[i].pitch_oncc); |
400 |
iliev |
2219 |
} else { std::cerr << "Maximum number of LFOs reached!" << std::endl; break; } |
401 |
|
|
|
402 |
iliev |
2225 |
if (pRegion->lfos[i].pitch != 0 || !pRegion->lfos[i].pitch_oncc.empty()) { |
403 |
|
|
if(pitchLFOs.size() < pitchLFOs.capacity()) pitchLFOs.add(LFOs[LFOs.size() - 1]); |
404 |
|
|
else std::cerr << "Maximum number of LFOs reached!" << std::endl; |
405 |
|
|
} |
406 |
|
|
|
407 |
iliev |
2219 |
if (pRegion->lfos[i].cutoff != 0) { |
408 |
|
|
if(filLFOs.size() < filLFOs.capacity()) filLFOs.add(LFOs[LFOs.size() - 1]); |
409 |
|
|
else std::cerr << "Maximum number of LFOs reached!" << std::endl; |
410 |
|
|
} |
411 |
|
|
|
412 |
|
|
if (pRegion->lfos[i].resonance != 0) { |
413 |
|
|
if(resLFOs.size() < resLFOs.capacity()) resLFOs.add(LFOs[LFOs.size() - 1]); |
414 |
|
|
else std::cerr << "Maximum number of LFOs reached!" << std::endl; |
415 |
|
|
} |
416 |
|
|
|
417 |
|
|
if (pRegion->lfos[i].pan != 0) { |
418 |
|
|
if(panLFOs.size() < panLFOs.capacity()) panLFOs.add(LFOs[LFOs.size() - 1]); |
419 |
|
|
else std::cerr << "Maximum number of LFOs reached!" << std::endl; |
420 |
|
|
} |
421 |
|
|
} |
422 |
|
|
|
423 |
iliev |
2224 |
suPitchLFO.suDepthCC.SetCCs(pRegion->pitchlfo_depthcc); |
424 |
|
|
|
425 |
iliev |
2218 |
Units.clear(); |
426 |
|
|
|
427 |
|
|
Units.add(&suVolEG); |
428 |
iliev |
2222 |
Units.add(&suFilEG); |
429 |
iliev |
2220 |
Units.add(&suPitchEG); |
430 |
iliev |
2221 |
Units.add(&suPitchLFO); |
431 |
iliev |
2224 |
Units.add(&suPitchLFO.suDepthCC); |
432 |
iliev |
2221 |
Units.add(&suAmpLFO); |
433 |
|
|
Units.add(&suFilLFO); |
434 |
iliev |
2218 |
|
435 |
iliev |
2219 |
for (int i = 0; i < EGs.size(); i++) { |
436 |
iliev |
2218 |
Units.add(EGs[i]); |
437 |
|
|
} |
438 |
|
|
|
439 |
iliev |
2219 |
for (int i = 0; i < LFOs.size(); i++) { |
440 |
|
|
Units.add(LFOs[i]); |
441 |
iliev |
2225 |
Units.add(&(LFOs[i]->suPitchOnCC)); |
442 |
iliev |
2219 |
} |
443 |
|
|
|
444 |
iliev |
2218 |
Units.add(&suEndpoint); |
445 |
|
|
|
446 |
|
|
SignalUnitRack::Trigger(); |
447 |
|
|
} |
448 |
|
|
|
449 |
|
|
EndpointSignalUnit* SfzSignalUnitRack::GetEndpointUnit() { |
450 |
|
|
return &suEndpoint; |
451 |
|
|
} |
452 |
|
|
|
453 |
|
|
void SfzSignalUnitRack::EnterFadeOutStage() { |
454 |
|
|
suVolEG.EG.enterFadeOutStage(); |
455 |
|
|
|
456 |
|
|
for (int i = 0; i < volEGs.size(); i++) { |
457 |
|
|
volEGs[i]->EG.enterFadeOutStage(); |
458 |
|
|
} |
459 |
|
|
} |
460 |
|
|
|
461 |
|
|
}} // namespace LinuxSampler::sfz |