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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2018 - (show annotations) (download)
Tue Oct 27 19:04:57 2009 UTC (14 years, 5 months ago) by iliev
File size: 50192 byte(s)
* SFZ format engine: Implemented sfz version 1
   Filter EG, Amplifier EG and Pitch EG
* use SF2 file loader from libgig

1 /***************************************************************************
2 * *
3 * LinuxSampler - modular, streaming capable sampler *
4 * *
5 * Copyright (C) 2008-2009 Anders Dahnielson <anders@dahnielson.com> *
6 * Copyright (C) 2009 Grigor Iliev *
7 * *
8 * This program is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU General Public License as published by *
10 * the Free Software Foundation; either version 2 of the License, or *
11 * (at your option) any later version. *
12 * *
13 * This program is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU General Public License *
19 * along with this program; if not, write to the Free Software *
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
21 * MA 02111-1307 USA *
22 ***************************************************************************/
23
24 #include "sfz.h"
25
26 #include <iostream>
27 #include <sstream>
28
29 #include "../../common/File.h"
30 #include "../../common/Path.h"
31 #include "../../common/global_private.h"
32
33 namespace sfz
34 {
35
36 LinuxSampler::SampleFile* SampleManager::FindSample(std::string samplePath) {
37 std::map<LinuxSampler::SampleFile*, std::set<Region*> >::iterator it = sampleMap.begin();
38 for (; it != sampleMap.end(); it++) {
39 if (it->first->GetFile() == samplePath) return it->first;
40 }
41
42 return NULL;
43 }
44
45 /////////////////////////////////////////////////////////////
46 // class optional
47
48 const optional_base::nothing_t optional_base::nothing;
49
50 /////////////////////////////////////////////////////////////
51 // class Articulation
52
53 Articulation::Articulation()
54 {
55 }
56
57 Articulation::~Articulation()
58 {
59 }
60
61 /////////////////////////////////////////////////////////////
62 // class Definition
63
64 Definition::Definition() :
65 locc(128), hicc(128), start_locc(128), start_hicc(128), stop_locc(128),
66 stop_hicc(128), on_locc(128), on_hicc(128), delay_oncc(128), delay_samples_oncc(128),
67 offset_oncc(128), amp_velcurve_(128), gain_oncc(128), xfin_locc(128), xfin_hicc(128),
68 xfout_locc(128), xfout_hicc(128), cutoff_oncc(128), cutoff2_oncc(128), cutoff_smoothcc(128),
69 cutoff2_smoothcc(128), cutoff_stepcc(128), cutoff2_stepcc(128), cutoff_curvecc(128),
70 cutoff2_curvecc(128), resonance_oncc(128), resonance2_oncc(128), resonance_smoothcc(128),
71 resonance2_smoothcc(128), resonance_stepcc(128), resonance2_stepcc(128),
72 resonance_curvecc(128), resonance2_curvecc(128), eq1_freq_oncc(128), eq2_freq_oncc(128),
73 eq3_freq_oncc(128), eq1_bw_oncc(128), eq2_bw_oncc(128), eq3_bw_oncc(128),
74 eq1_gain_oncc(128), eq2_gain_oncc(128), eq3_gain_oncc(128)
75
76 {
77 }
78
79 Definition::~Definition()
80 {
81 }
82
83 /////////////////////////////////////////////////////////////
84 // class Region
85
86 Region::Region()
87 {
88 pSample = NULL;
89 }
90
91 Region::~Region()
92 {
93 DestroySampleIfNotUsed();
94 }
95
96 LinuxSampler::SampleFile* Region::GetSample(bool create)
97 {
98 if(pSample == NULL && create) {
99 LinuxSampler::SampleFile* sf = GetInstrument()->GetSampleManager()->FindSample(sample);
100 if (sf != NULL) pSample = sf; // Reuse already created sample
101 else pSample = new LinuxSampler::SampleFile(sample);
102 GetInstrument()->GetSampleManager()->AddSampleConsumer(pSample, this);
103 }
104 return pSample;
105 }
106
107 void Region::DestroySampleIfNotUsed() {
108 if (pSample == NULL) return;
109 GetInstrument()->GetSampleManager()->RemoveSampleConsumer(pSample, this);
110 if (!GetInstrument()->GetSampleManager()->HasSampleConsumers(pSample)) {
111 GetInstrument()->GetSampleManager()->RemoveSample(pSample);
112 delete pSample;
113 pSample = NULL;
114 }
115 }
116
117 bool
118 Region::OnKey(uint8_t chan, uint8_t key, uint8_t vel,
119 int bend, uint8_t bpm, uint8_t chanaft, uint8_t polyaft,
120 uint8_t prog, float rand, trigger_t trig, uint8_t* cc,
121 float timer, uint8_t seq, bool* sw, uint8_t last_sw_key, uint8_t prev_sw_key)
122 {
123 // chan (MIDI channel)
124 // key (MIDI note)
125 // vel (MIDI velocity)
126
127 // bend (MIDI pitch bend)
128 // bpm (host BPM)
129 // chanaft (MIDI channel pressure)
130 // polyaft (MIDI polyphonic aftertouch)
131 // prog (MIDI program change)
132 // rand (generated random number)
133 // trigger (how it was triggered)
134 // cc (all 128 CC values)
135
136 // timer (time since previous region in the group was triggered)
137 // seq (the state of the region sequence counter)
138 // sw (the state of region key switches, 128 possible values)
139 // last_sw_key (the last key pressed in the key switch range)
140 // prev_sw_key (the previous note value)
141
142 bool is_triggered (
143 chan >= lochan && chan <= hichan &&
144 key >= lokey && key <= hikey &&
145 vel >= lovel && vel <= hivel &&
146 bend >= lobend && bend <= hibend &&
147 bpm >= lobpm && bpm <= hibpm &&
148 chanaft >= lochanaft && chanaft <= hichanaft &&
149 polyaft >= lopolyaft && polyaft <= hipolyaft &&
150 prog >= loprog && prog <= hiprog &&
151 rand >= lorand && rand <= hirand &&
152 timer >= lotimer && timer <= hitimer &&
153 seq == seq_position &&
154
155 ( (sw_lokey == -1 || sw_hikey == -1 || sw_last == -1) ||
156 ((sw_last >= sw_lokey && sw_last <= sw_hikey) ? (last_sw_key == sw_last) : true) ) &&
157
158 ( (sw_down == -1 || sw_lokey == -1 || sw_hikey == -1) ||
159 ((sw_down >= sw_lokey && sw_down <= sw_hikey) ? (sw[sw_down]) : true) ) &&
160
161 ( (sw_up == -1 || sw_lokey == -1 || sw_hikey == -1) ||
162 ((sw_up >= sw_lokey && sw_up <= sw_hikey) ? (!sw[sw_up]) : true) ) &&
163
164 ((sw_previous != -1) ? (prev_sw_key == sw_previous) : true) &&
165 ((trigger && trig) != 0)
166 );
167
168 if (!is_triggered)
169 return false;
170
171 for (int i = 0; i < 128; ++i)
172 {
173 if (locc[i] != -1 && hicc[i] != -1 && !(cc[i] >= locc[i] && cc[i] <= hicc[i]))
174 return false;
175 }
176
177 return true;
178 }
179
180 bool
181 Region::OnControl(uint8_t chan, uint8_t cont, uint8_t val,
182 int bend, uint8_t bpm, uint8_t chanaft, uint8_t polyaft,
183 uint8_t prog, float rand, trigger_t trig, uint8_t* cc,
184 float timer, uint8_t seq, bool* sw, uint8_t last_sw_key, uint8_t prev_sw_key)
185 {
186 // chan (MIDI channel)
187 // cont (MIDI controller)
188 // val (MIDI controller value)
189
190 // bend (MIDI pitch bend)
191 // bpm (host BPM)
192 // chanaft (MIDI channel pressure)
193 // polyaft (MIDI polyphonic aftertouch)
194 // prog (MIDI program change)
195 // rand (generated random number)
196 // trigger (how it was triggered)
197 // cc (all CC values)
198
199 // timer (time since previous region in the group was triggered)
200 // seq (the state of the region sequence counter)
201 // sw (the state of region key switches, 128 possible values)
202 // last_sw_key (the last key pressed in the key switch range)
203 // prev_sw_key (the previous note value)
204
205 bool is_triggered = (
206 chan >= lochan && chan <= hichan &&
207 ((val >= on_locc[cont] && val <= on_hicc[cont]) ||
208 (val >= start_locc[cont] && val <= start_hicc[cont])) &&
209 bend >= lobend && bend <= hibend &&
210 bpm >= lobpm && bpm <= hibpm &&
211 chanaft >= lochanaft && chanaft <= hichanaft &&
212 polyaft >= lopolyaft && polyaft <= hipolyaft &&
213 prog >= loprog && prog <= hiprog &&
214 rand >= lorand && rand <= hirand &&
215 timer >= lotimer && timer <= hitimer &&
216 seq == seq_position &&
217
218 ( (sw_lokey == -1 || sw_hikey == -1 || sw_last == -1) ||
219 ((sw_last >= sw_lokey && sw_last <= sw_hikey) ? (last_sw_key == sw_last) : true) ) &&
220
221 ( (sw_down == -1 || sw_lokey == -1 || sw_hikey == -1) ||
222 ((sw_down >= sw_lokey && sw_down <= sw_hikey) ? (sw[sw_down]) : true) ) &&
223
224 ( (sw_up == -1 || sw_lokey == -1 || sw_hikey == -1) ||
225 ((sw_up >= sw_lokey && sw_up <= sw_hikey) ? (!sw[sw_up]) : true) ) &&
226
227 ((sw_previous != -1) ? (prev_sw_key == sw_previous) : true) &&
228 ((trigger && trig) != 0)
229 );
230
231 if (!is_triggered)
232 return false;
233
234 for (int i = 0; i < 128; ++i)
235 {
236 if (locc[i] != -1 && hicc[i] != -1 && !(cc[i] >= locc[i] && cc[i] <= hicc[i]))
237 return false;
238 }
239
240 return true;
241 }
242
243 Articulation*
244 Region::GetArticulation(int bend, uint8_t bpm, uint8_t chanaft, uint8_t polyaft, uint8_t* cc)
245 {
246 return new Articulation(); //todo: implement GetArticulation()
247 }
248
249 /////////////////////////////////////////////////////////////
250 // class Instrument
251
252 Instrument::Instrument(std::string name, SampleManager* pSampleManager) : KeyBindings(128, false), KeySwitchBindings(128, false)
253 {
254 this->name = name;
255 this->pSampleManager = pSampleManager ? pSampleManager : this;
256 }
257
258 Instrument::~Instrument()
259 {
260 for(int i = 0; i < regions.size(); i++) {
261 delete (regions[i]);
262 }
263 regions.clear();
264 }
265
266 std::vector<Region*> Instrument::GetRegionsOnKey (
267 uint8_t chan, uint8_t key, uint8_t vel,
268 int bend, uint8_t bpm, uint8_t chanaft, uint8_t polyaft,
269 uint8_t prog, float rand, trigger_t trig, uint8_t* cc,
270 float timer, uint8_t seq, bool* sw, uint8_t last_sw_key, uint8_t prev_sw_key
271 ) {
272 std::vector<Region*> v;
273 for (int i = 0; i < regions.size(); i++) {
274 if (regions[i]->OnKey (
275 chan, key, vel, bend, bpm, chanaft, polyaft, prog,
276 rand, trig, cc, timer, seq, sw, last_sw_key, prev_sw_key)
277 ) { v.push_back(regions[i]); }
278 }
279
280 return v;
281 }
282
283 bool Instrument::DestroyRegion(Region* pRegion) {
284 for (std::vector<Region*>::iterator it = regions.begin(); it != regions.end(); it++) {
285 if(*it == pRegion) {
286 regions.erase(it);
287 delete pRegion;
288 return true;
289 }
290 }
291
292 return false;
293 }
294
295 bool Instrument::HasKeyBinding(uint8_t key) {
296 if (key > 127) return false;
297 return KeyBindings[key];
298 }
299
300 bool Instrument::HasKeySwitchBinding(uint8_t key) {
301 if (key > 127) return false;
302 return KeySwitchBindings[key];
303 }
304
305 /////////////////////////////////////////////////////////////
306 // class Group
307
308 Group::Group() :
309 id(0)
310 {
311 Reset();
312 }
313
314 Group::~Group()
315 {
316 }
317
318 void
319 Group::Reset()
320 {
321 // This is where all the default values are set.
322
323 // sample definition default
324 sample = "";
325
326 // input control
327 lochan = 1; hichan = 16;
328 lokey = 0; hikey = 127;
329 lovel = 0; hivel = 127;
330 lobend = -8192; hibend = 8192;
331 lobpm = 0; hibpm = 500;
332 lochanaft = 0; hichanaft = 127;
333 lopolyaft = 0; hipolyaft = 127;
334 loprog = 0; hiprog = 127;
335 lorand = 0.0; hirand = 1.0;
336 lotimer = 0.0; hitimer = 0.0;
337
338 seq_length = 1;
339 seq_position = 1;
340
341 sw_lokey = -1; sw_hikey = -1;
342 sw_last = -1;
343 sw_down = -1;
344 sw_up = -1;
345 sw_previous = -1;
346 sw_vel = VEL_CURRENT;
347
348 trigger = TRIGGER_ATTACK;
349
350 group.unset();
351 off_by.unset();
352 off_mode = OFF_FAST;
353
354 // sample player
355 count.unset();
356 delay.unset(); delay_random.unset();
357 delay_beats.unset(); stop_beats.unset();
358 delay_samples.unset();
359 end.unset();
360 loop_crossfade.unset();
361 offset.unset(); offset_random.unset();
362 loop_mode = NO_LOOP;
363 loop_start.unset(); loop_end.unset();
364 sync_beats.unset(); sync_offset.unset();
365
366 // amplifier
367 volume = 0;
368 pan = 0;
369 width = 100;
370 position = 0;
371 amp_keytrack = 0;
372 amp_keycenter = 60;
373 amp_veltrack = 100;
374 amp_random = 0;
375 rt_decay = 0;
376 xfin_lokey = 0; xfin_hikey = 0;
377 xfout_lokey = 127; xfout_hikey = 127;
378 xf_keycurve = POWER;
379 xfin_lovel = 0; xfin_hivel = 0;
380 xfout_lovel = 127; xfout_hivel = 127;
381 xf_velcurve = POWER;
382 xf_cccurve = POWER;
383
384 // pitch
385 transpose = 0;
386 tune = 0;
387 pitch_keycenter = 60;
388 pitch_keytrack = 100;
389 pitch_veltrack = 0;
390 pitch_random = 0;
391 bend_up = 200;
392 bend_down = -200;
393 bend_step = 1;
394
395 // filter
396 fil_type = LPF_2P;
397 cutoff.unset();
398 cutoff_chanaft = 0;
399 cutoff_polyaft = 0;
400 resonance = 0;
401 fil_keytrack = 0;
402 fil_keycenter = 60;
403 fil_veltrack = 0;
404 fil_random = 0;
405
406 fil2_type = LPF_2P;
407 cutoff2.unset();
408 cutoff2_chanaft = 0;
409 cutoff2_polyaft = 0;
410 resonance2 = 0;
411 fil2_keytrack = 0;
412 fil2_keycenter = 60;
413 fil2_veltrack = 0;
414 fil2_random = 0;
415
416 // per voice equalizer
417 eq1_freq = 50;
418 eq2_freq = 500;
419 eq3_freq = 5000;
420 eq1_vel2freq = 0;
421 eq2_vel2freq = 0;
422 eq3_vel2freq = 0;
423 eq1_bw = 1;
424 eq2_bw = 1;
425 eq3_bw = 1;
426 eq1_gain = 0;
427 eq2_gain = 0;
428 eq3_gain = 0;
429 eq1_vel2gain = 0;
430 eq2_vel2gain = 0;
431 eq3_vel2gain = 0;
432
433 // CCs
434 for (int i = 0; i < 128; ++i)
435 {
436 // input control
437 locc[i] = 0;
438 hicc[i] = 127;
439 start_locc[i] = -1;
440 start_hicc[i] = -1;
441 stop_locc[i] = -1;
442 stop_hicc[i] = -1;
443 on_locc[i] = -1;
444 on_hicc[i] = -1;
445
446 // sample player
447 delay_oncc[i].unset();
448 delay_samples_oncc[i].unset();
449 offset_oncc[i].unset();
450
451 // amplifier
452 amp_velcurve_[i] = 0; //fixme: 20 log (127^2 / i^2)
453 gain_oncc[i] = 0;
454 xfin_locc[i] = 0;
455 xfin_hicc[i] = 0;
456 xfout_locc[i] = 127;
457 xfout_hicc[i] = 127;
458
459 // filter
460 cutoff_oncc[i] = 0;
461 cutoff_smoothcc[i] = 0;
462 cutoff_stepcc[i] = 0;
463 cutoff_curvecc[i] = 0;
464 resonance_oncc[i] = 0;
465 resonance_smoothcc[i] = 0;
466 resonance_stepcc[i] = 0;
467 resonance_curvecc[i] = 0;
468
469 cutoff2_oncc[i] = 0;
470 cutoff2_smoothcc[i] = 0;
471 cutoff2_stepcc[i] = 0;
472 cutoff2_curvecc[i] = 0;
473 resonance2_oncc[i] = 0;
474 resonance2_smoothcc[i] = 0;
475 resonance2_stepcc[i] = 0;
476 resonance2_curvecc[i] = 0;
477
478 // per voice equalizer
479 eq1_freq_oncc[i] = 0;
480 eq2_freq_oncc[i] = 0;
481 eq3_freq_oncc[i] = 0;
482 eq1_bw_oncc[i] = 0;
483 eq2_bw_oncc[i] = 0;
484 eq3_bw_oncc[i] = 0;
485 eq1_gain_oncc[i] = 0;
486 eq2_gain_oncc[i] = 0;
487 eq3_gain_oncc[i] = 0;
488 }
489
490 // deprecated
491 ampeg_delay = 0;
492 ampeg_start = 0; //in percentage
493 ampeg_attack = 0;
494 ampeg_hold = 0;
495 ampeg_decay = 0;
496 ampeg_sustain = 100; // in percentage
497 ampeg_release = 0;
498
499 fileg_delay = 0;
500 fileg_start = 0; //in percentage
501 fileg_attack = 0;
502 fileg_hold = 0;
503 fileg_decay = 0;
504 fileg_sustain = 100; // in percentage
505 fileg_release = 0;
506
507 pitcheg_delay = 0;
508 pitcheg_start = 0; //in percentage
509 pitcheg_attack = 0;
510 pitcheg_hold = 0;
511 pitcheg_decay = 0;
512 pitcheg_sustain = 100; // in percentage
513 pitcheg_release = 0;
514 }
515
516 Region*
517 Group::RegionFactory()
518 {
519 // This is where the current group setting are copied to the new region.
520
521 Region* region = new Region();
522
523 region->id = id++;
524
525 // sample definition
526 region->sample = sample;
527
528 // input control
529 region->lochan = lochan;
530 region->hichan = hichan;
531 region->lokey = lokey;
532 region->hikey = hikey;
533 region->lovel = lovel;
534 region->hivel = hivel;
535 region->locc = locc;
536 region->hicc = hicc;
537 region->lobend = lobend;
538 region->hibend = hibend;
539 region->lobpm = lobpm;
540 region->hibpm = hibpm;
541 region->lochanaft = lochanaft;
542 region->hichanaft = hichanaft;
543 region->lopolyaft = lopolyaft;
544 region->hipolyaft = hipolyaft;
545 region->loprog = loprog;
546 region->hiprog = hiprog;
547 region->lorand = lorand;
548 region->hirand = hirand;
549 region->lotimer = lotimer;
550 region->hitimer = hitimer;
551 region->seq_length = seq_length;
552 region->seq_position = seq_position;
553 region->start_locc = start_locc;
554 region->start_hicc = start_hicc;
555 region->stop_locc = stop_locc;
556 region->stop_hicc = stop_hicc;
557 region->sw_lokey = sw_lokey;
558 region->sw_hikey = sw_hikey;
559 region->sw_last = sw_last;
560 region->sw_down = sw_down;
561 region->sw_up = sw_up;
562 region->sw_previous = sw_previous;
563 region->sw_vel = sw_vel;
564 region->trigger = trigger;
565 region->group = group;
566 region->off_by = off_by;
567 region->off_mode = off_mode;
568 region->on_locc = on_locc;
569 region->on_hicc = on_hicc;
570
571 // sample player
572 region->count = count;
573 region->delay = delay;
574 region->delay_random = delay_random;
575 region->delay_oncc = delay_oncc;
576 region->delay_beats = delay_beats;
577 region->stop_beats = stop_beats;
578 region->delay_samples = delay_samples;
579 region->delay_samples_oncc = delay_samples_oncc;
580 region->end = end;
581 region->loop_crossfade = loop_crossfade;
582 region->offset = offset;
583 region->offset_random = offset_random;
584 region->offset_oncc = offset_oncc;
585 region->loop_mode = loop_mode;
586 region->loop_start = loop_start;
587 region->loop_end = loop_end;
588 region->sync_beats = sync_beats;
589 region->sync_offset = sync_offset;
590
591 // amplifier
592 region->volume = volume;
593 region->pan = pan;
594 region->width = width;
595 region->position = position;
596 region->amp_keytrack = amp_keytrack;
597 region->amp_keycenter = amp_keycenter;
598 region->amp_veltrack = amp_veltrack;
599 region->amp_velcurve_ = amp_velcurve_;
600 region->amp_random = amp_random;
601 region->rt_decay = rt_decay;
602 region->gain_oncc = gain_oncc;
603 region->xfin_lokey = xfin_lokey;
604 region->xfin_hikey = xfin_hikey;
605 region->xfout_lokey = xfout_lokey;
606 region->xfout_hikey = xfout_hikey;
607 region->xf_keycurve = xf_keycurve;
608 region->xfin_lovel = xfin_lovel;
609 region->xfin_hivel = xfin_lovel;
610 region->xfout_lovel = xfout_lovel;
611 region->xfout_hivel = xfout_hivel;
612 region->xf_velcurve = xf_velcurve;
613 region->xfin_locc = xfin_locc;
614 region->xfin_hicc = xfin_hicc;
615 region->xfout_locc = xfout_locc;
616 region->xfout_hicc = xfout_hicc;
617 region->xf_cccurve = xf_cccurve;
618
619 // pitch
620 region->transpose = transpose;
621 region->tune = tune;
622 region->pitch_keycenter = pitch_keycenter;
623 region->pitch_keytrack = pitch_keytrack;
624 region->pitch_veltrack = pitch_veltrack;
625 region->pitch_random = pitch_random;
626 region->bend_up = bend_up;
627 region->bend_down = bend_down;
628 region->bend_step = bend_step;
629
630 // filter
631 region->fil_type = fil_type;
632 region->cutoff = cutoff;
633 region->cutoff_oncc = cutoff_oncc;
634 region->cutoff_smoothcc = cutoff_smoothcc;
635 region->cutoff_stepcc = cutoff_stepcc;
636 region->cutoff_curvecc = cutoff_curvecc;
637 region->cutoff_chanaft = cutoff_chanaft;
638 region->cutoff_polyaft = cutoff_polyaft;
639 region->resonance = resonance;
640 region->resonance_oncc = resonance_oncc;
641 region->resonance_smoothcc = resonance_smoothcc;
642 region->resonance_stepcc = resonance_stepcc;
643 region->resonance_curvecc = resonance_curvecc;
644 region->fil_keytrack = fil_keytrack;
645 region->fil_keycenter = fil_keycenter;
646 region->fil_veltrack = fil_veltrack;
647 region->fil_random = fil_random;
648
649 region->fil2_type = fil2_type;
650 region->cutoff2 = cutoff2;
651 region->cutoff2_oncc = cutoff2_oncc;
652 region->cutoff2_smoothcc = cutoff2_smoothcc;
653 region->cutoff2_stepcc = cutoff2_stepcc;
654 region->cutoff2_curvecc = cutoff2_curvecc;
655 region->cutoff2_chanaft = cutoff2_chanaft;
656 region->cutoff2_polyaft = cutoff2_polyaft;
657 region->resonance2 = resonance2;
658 region->resonance2_oncc = resonance2_oncc;
659 region->resonance2_smoothcc = resonance2_smoothcc;
660 region->resonance2_stepcc = resonance2_stepcc;
661 region->resonance2_curvecc = resonance2_curvecc;
662 region->fil2_keytrack = fil2_keytrack;
663 region->fil2_keycenter = fil2_keycenter;
664 region->fil2_veltrack = fil2_veltrack;
665 region->fil2_random = fil2_random;
666
667 // per voice equalizer
668 region->eq1_freq = eq1_freq;
669 region->eq2_freq = eq2_freq;
670 region->eq3_freq = eq3_freq;
671 region->eq1_freq_oncc = eq1_freq_oncc;
672 region->eq2_freq_oncc = eq2_freq_oncc;
673 region->eq3_freq_oncc = eq3_freq_oncc;
674 region->eq1_vel2freq = eq1_vel2freq;
675 region->eq2_vel2freq = eq2_vel2freq;
676 region->eq3_vel2freq = eq3_vel2freq;
677 region->eq1_bw = eq1_bw;
678 region->eq2_bw = eq2_bw;
679 region->eq3_bw = eq3_bw;
680 region->eq1_bw_oncc = eq1_bw_oncc;
681 region->eq2_bw_oncc = eq2_bw_oncc;
682 region->eq3_bw_oncc = eq3_bw_oncc;
683 region->eq1_gain = eq1_gain;
684 region->eq2_gain = eq2_gain;
685 region->eq3_gain = eq3_gain;
686 region->eq1_gain_oncc = eq1_gain_oncc;
687 region->eq2_gain_oncc = eq2_gain_oncc;
688 region->eq3_gain_oncc = eq3_gain_oncc;
689 region->eq1_vel2gain = eq1_vel2gain;
690 region->eq2_vel2gain = eq2_vel2gain;
691 region->eq3_vel2gain = eq3_vel2gain;
692
693 // deprecated
694 region->ampeg_delay = ampeg_delay;
695 region->ampeg_start = ampeg_start;
696 region->ampeg_attack = ampeg_attack;
697 region->ampeg_hold = ampeg_hold;
698 region->ampeg_decay = ampeg_decay;
699 region->ampeg_sustain = ampeg_sustain;
700 region->ampeg_release = ampeg_release;
701
702 region->fileg_delay = fileg_delay;
703 region->fileg_start = fileg_start;
704 region->fileg_attack = fileg_attack;
705 region->fileg_hold = fileg_hold;
706 region->fileg_decay = fileg_decay;
707 region->fileg_sustain = fileg_sustain;
708 region->fileg_release = fileg_release;
709
710 region->pitcheg_delay = pitcheg_delay;
711 region->pitcheg_start = pitcheg_start;
712 region->pitcheg_attack = pitcheg_attack;
713 region->pitcheg_hold = pitcheg_hold;
714 region->pitcheg_decay = pitcheg_decay;
715 region->pitcheg_sustain = pitcheg_sustain;
716 region->pitcheg_release = pitcheg_release;
717
718 return region;
719 }
720
721 /////////////////////////////////////////////////////////////
722 // class File
723
724 File::File(std::string file, SampleManager* pSampleManager) :
725 _current_section(GROUP),
726 default_path(""),
727 octave_offset(0),
728 note_offset(0)
729 {
730 _instrument = new Instrument(LinuxSampler::Path::getBaseName(file), pSampleManager);
731 _current_group = new Group();
732 pCurDef = _current_group;
733 enum token_type_t { HEADER, OPCODE };
734 token_type_t token_type;
735 std::string token_string;
736
737 std::ifstream fs(file.c_str());
738 currentDir = LinuxSampler::Path::stripLastName(file);
739 std::string token;
740 std::string line;
741
742 while (std::getline(fs, line))
743 {
744 // COMMENT
745 std::string::size_type slash_index = line.find("//");
746 if (slash_index != std::string::npos)
747 line.resize(slash_index);
748
749 // DEFINITION
750 std::stringstream linestream(line);
751 while (linestream >> token)
752 {
753 if (token[0] == '<' and token[token.size()-1] == '>')
754 {
755 // HEAD
756 if (!token_string.empty())
757 {
758 switch (token_type)
759 {
760 case HEADER:
761 push_header(token_string);
762 break;
763 case OPCODE:
764 push_opcode(token_string);
765 break;
766 }
767 token_string.erase();
768 }
769 token_string.append(token);
770 token_type = HEADER;
771 }
772 else if (token.find('=') != std::string::npos)
773 {
774 // HEAD
775 if (!token_string.empty())
776 {
777 switch (token_type)
778 {
779 case HEADER:
780 push_header(token_string);
781 break;
782 case OPCODE:
783 push_opcode(token_string);
784 break;
785 }
786 token_string.erase();
787 }
788 token_string.append(token);
789 token_type = OPCODE;
790 }
791 else
792 {
793 // TAIL
794 token_string.append(" ");
795 token_string.append(token);
796 }
797 }
798
799 // EOL
800 if (!token_string.empty())
801 {
802 switch (token_type)
803 {
804 case HEADER:
805 push_header(token_string);
806 break;
807 case OPCODE:
808 push_opcode(token_string);
809 break;
810 }
811 token_string.erase();
812 }
813 }
814
815 for (int i = 0; i < _instrument->regions.size(); i++) {
816 ::sfz::Region* pRegion = _instrument->regions[i];
817 int low = pRegion->lokey;
818 int high = pRegion->hikey;
819 if (low < 0 || low > 127 || high < 0 || high > 127 || low > high) {
820 std::cerr << "Invalid key range: " << low << " - " << high << std::endl;
821 } else {
822 for (int j = low; j <= high; j++) _instrument->KeyBindings[j] = true;
823 }
824
825 // get keyswitches
826 low = pRegion->sw_lokey;
827 high = pRegion->sw_hikey;
828 if(low == -1 && high == -1) {
829 // Key switches not defined, so nothing to do
830 } else if(low >= 0 && low <= 127 && high >= 0 && high <= 127 && high >= low) {
831 for (int j = low; j <= high; j++) _instrument->KeySwitchBindings[j] = true;
832 } else {
833 std::cerr << "Invalid key switch range: " << low << " - " << high << std::endl;
834 }
835 }
836 }
837
838 File::~File()
839 {
840 delete _current_group;
841 delete _instrument;
842 }
843
844 Instrument*
845 File::GetInstrument()
846 {
847 return _instrument;
848 }
849
850 void
851 File::push_header(std::string token)
852 {
853 if (token == "<group>")
854 {
855 _current_section = GROUP;
856 _current_group->Reset();
857 pCurDef = _current_group;
858 }
859 else if (token == "<region>")
860 {
861 _current_section = REGION;
862 _current_region = _current_group->RegionFactory();
863 pCurDef = _current_region;
864 _instrument->regions.push_back(_current_region);
865 _current_region->SetInstrument(_instrument);
866 }
867 else if (token == "<control>")
868 {
869 _current_section = CONTROL;
870 default_path = "";
871 octave_offset = 0;
872 note_offset = 0;
873 }
874 else
875 {
876 _current_section = UNKNOWN;
877 std::cerr << "The header '" << token << "' is unsupported by libsfz!" << std::endl;
878 }
879 }
880
881 void
882 File::push_opcode(std::string token)
883 {
884 if (_current_section == UNKNOWN)
885 return;
886
887 std::string::size_type delimiter_index = token.find('=');
888 std::string key = token.substr(0, delimiter_index);
889 std::string value = token.substr(delimiter_index + 1);
890
891 // sample definition
892 if ("sample" == key)
893 {
894 std::string path = default_path + value;
895 #ifndef WIN32
896 for (int i = 0; i < path.length(); i++) if( path[i] == '\\') path[i] = '/';
897 #endif
898 path = currentDir + LinuxSampler::File::DirSeparator + path; // TODO: check for absolute path
899
900 if(pCurDef) pCurDef->sample = path;
901 return;
902 }
903
904 // control header directives
905 else if ("default_path" == key)
906 {
907 switch (_current_section)
908 {
909 case CONTROL:
910 default_path = value;
911 }
912 return;
913 }
914 else if ("octave_offset" == key)
915 {
916 switch (_current_section)
917 {
918 case CONTROL:
919 octave_offset = ToInt(value);
920 }
921 return;
922 }
923 else if ("note_offset" == key)
924 {
925 switch (_current_section)
926 {
927 case CONTROL:
928 note_offset = ToInt(value);
929 }
930 return;
931 }
932
933 // input controls
934 else if ("lochan" == key) pCurDef->lochan = ToInt(value);
935 else if ("hichan" == key) pCurDef->hichan = ToInt(value);
936 else if ("lokey" == key) pCurDef->lokey = ToInt(value) + note_offset + 12 * octave_offset;
937 else if ("hikey" == key) pCurDef->hikey = ToInt(value) + note_offset + 12 * octave_offset;
938 else if ("key" == key)
939 {
940 pCurDef->lokey = ToInt(value) + note_offset + 12 * octave_offset;
941 pCurDef->hikey = ToInt(value) + note_offset + 12 * octave_offset;
942 }
943 else if ("lovel" == key) pCurDef->lovel = ToInt(value);
944 else if ("hivel" == key) pCurDef->hivel = ToInt(value);
945 else if ("lobend" == key) pCurDef->lobend = ToInt(value);
946 else if ("hibend" == key) pCurDef->hibend = ToInt(value);
947 else if ("lobpm" == key) pCurDef->lobpm = ToInt(value);
948 else if ("hibpm" == key) pCurDef->hibpm = ToInt(value);
949 else if ("lochanaft" == key) pCurDef->lochanaft = ToInt(value);
950 else if ("hichanaft" == key) pCurDef->hichanaft = ToInt(value);
951 else if ("lopolyaft" == key) pCurDef->lopolyaft = ToInt(value);
952 else if ("hipolyaft" == key) pCurDef->hipolyaft = ToInt(value);
953 else if ("loprog" == key) pCurDef->loprog = ToInt(value);
954 else if ("hiprog" == key) pCurDef->hiprog = ToInt(value);
955 else if ("lorand" == key) pCurDef->lorand = ToFloat(value);
956 else if ("hirand" == key) pCurDef->hirand = ToFloat(value);
957 else if ("lotimer" == key) pCurDef->lotimer = ToFloat(value);
958 else if ("hitimer" == key) pCurDef->hitimer = ToFloat(value);
959 else if ("seq_length" == key) pCurDef->seq_length = ToInt(value);
960 else if ("seq_position" == key) pCurDef->seq_position = ToInt(value);
961 else if ("sw_lokey" == key) pCurDef->sw_lokey = ToInt(value) + note_offset + 12 * octave_offset;
962 else if ("sw_hikey" == key) pCurDef->sw_hikey = ToInt(value) + note_offset + 12 * octave_offset;
963 else if ("sw_last" == key) pCurDef->sw_last = ToInt(value) + note_offset + 12 * octave_offset;
964 else if ("sw_down" == key) pCurDef->sw_down = ToInt(value) + note_offset + 12 * octave_offset;
965 else if ("sw_up" == key) pCurDef->sw_up = ToInt(value) + note_offset + 12 * octave_offset;
966 else if ("sw_previous" == key) pCurDef->sw_previous = ToInt(value) + note_offset + 12 * octave_offset;
967 else if ("sw_vel" == key)
968 {
969 if (value == "current") pCurDef->sw_vel = VEL_CURRENT;
970 else if (value == "previous") pCurDef->sw_vel = VEL_PREVIOUS;
971 }
972 else if ("trigger" == key)
973 {
974 if (value == "attack") pCurDef->trigger = TRIGGER_ATTACK;
975 else if (value == "release") pCurDef->trigger = TRIGGER_RELEASE;
976 else if (value == "first") pCurDef->trigger = TRIGGER_FIRST;
977 else if (value == "legato") pCurDef->trigger = TRIGGER_LEGATO;
978 }
979 else if ("group" == key) pCurDef->group = ToInt(value);
980 else if ("off_by" == key) pCurDef->off_by = ToInt(value);
981 else if ("off_mode" == key)
982 {
983 if (value == "fast") _current_group->off_mode = OFF_FAST;
984 else if (value == "normal") _current_group->off_mode = OFF_NORMAL;
985 }
986
987 // sample player
988 else if ("count" == key) pCurDef->count = ToInt(value);
989 else if ("delay" == key) pCurDef->delay = ToFloat(value);
990 else if ("delay_random" == key) pCurDef->delay_random = ToFloat(value);
991 else if ("delay_beats" == key) pCurDef->delay_beats = ToInt(value);
992 else if ("stop_beats" == key) pCurDef->stop_beats = ToInt(value);
993 else if ("delay_samples" == key) pCurDef->delay_samples = ToInt(value);
994 else if ("end" == key) pCurDef->end = ToInt(value);
995 else if ("loop_crossfade" == key) pCurDef->loop_crossfade = ToFloat(value);
996 else if ("offset_random" == key) pCurDef->offset_random = ToInt(value);
997 else if ("loop_mode" == key)
998 {
999 if (value == "no_loop") pCurDef->loop_mode = NO_LOOP;
1000 else if (value == "one_shot") pCurDef->loop_mode = ONE_SHOT;
1001 else if (value == "loop_continous") pCurDef->loop_mode = LOOP_CONTINOUS;
1002 else if (value == "loop_sustain") pCurDef->loop_mode = LOOP_SUSTAIN;
1003 }
1004 else if ("loop_start" == key) pCurDef->loop_start = ToInt(value);
1005 else if ("loop_end" == key) pCurDef->loop_end = ToInt(value);
1006 else if ("sync_beats" == key) pCurDef->sync_beats = ToInt(value);
1007 else if ("sync_offset" == key) pCurDef->sync_offset = ToInt(value);
1008
1009 // amplifier
1010 else if ("volume" == key) pCurDef->volume = ToFloat(value);
1011 else if ("pan" == key) pCurDef->pan = ToFloat(value);
1012 else if ("width" == key) pCurDef->width = ToFloat(value);
1013 else if ("position" == key) pCurDef->position = ToFloat(value);
1014 else if ("amp_keytrack" == key) pCurDef->amp_keytrack = ToFloat(value);
1015 else if ("amp_keycenter" == key) pCurDef->amp_keycenter = ToInt(value) + note_offset + 12 * octave_offset;
1016 else if ("amp_veltrack" == key) pCurDef->amp_veltrack = ToFloat(value);
1017 else if ("amp_random" == key) pCurDef->amp_random = ToFloat(value);
1018 else if ("rt_decay" == key) pCurDef->rt_decay = ToFloat(value);
1019 else if ("xfin_lokey" == key) pCurDef->xfin_lokey = ToInt(value) + note_offset + 12 * octave_offset;
1020 else if ("xfin_hikey" == key) pCurDef->xfin_hikey = ToInt(value) + note_offset + 12 * octave_offset;
1021 else if ("xfout_lokey" == key) pCurDef->xfout_lokey = ToInt(value) + note_offset + 12 * octave_offset;
1022 else if ("xfout_hikey" == key) pCurDef->xfout_hikey = ToInt(value) + note_offset + 12 * octave_offset;
1023 else if ("xf_keycurve" == key)
1024 {
1025 if (value == "gain") pCurDef->xf_keycurve = GAIN;
1026 else if (value == "power") pCurDef->xf_keycurve = POWER;
1027 }
1028 else if ("xfin_lovel" == key) pCurDef->xfin_lovel = ToInt(value);
1029 else if ("xfin_hivel" == key) pCurDef->xfin_hivel = ToInt(value);
1030 else if ("xfout_lovel" == key) pCurDef->xfout_lovel = ToInt(value);
1031 else if ("xfout_hivel" == key) pCurDef->xfout_hivel = ToInt(value);
1032 else if ("xf_velcurve" == key)
1033 {
1034 if (value == "gain") pCurDef->xf_velcurve = GAIN;
1035 else if (value == "power") pCurDef->xf_velcurve = POWER;
1036 }
1037 else if ("xf_cccurve" == key)
1038 {
1039 if (value == "gain") pCurDef->xf_cccurve = GAIN;
1040 else if (value == "power") pCurDef->xf_cccurve = POWER;
1041 }
1042
1043 // pitch
1044 else if ("transpose" == key) pCurDef->transpose = ToInt(value);
1045 else if ("tune" == key) pCurDef->tune = ToInt(value);
1046 else if ("pitch_keycenter" == key) pCurDef->pitch_keycenter = ToInt(value) + note_offset + 12 * octave_offset;
1047 else if ("pitch_keytrack" == key) pCurDef->pitch_keytrack = ToInt(value);
1048 else if ("pitch_veltrack" == key) pCurDef->pitch_veltrack = ToInt(value);
1049 else if ("pitch_random" == key) pCurDef->pitch_random = ToInt(value);
1050 else if ("bend_up" == key) pCurDef->bend_up = ToInt(value);
1051 else if ("bend_down" == key) pCurDef->bend_down = ToInt(value);
1052 else if ("bend_step" == key) pCurDef->bend_step = ToInt(value);
1053
1054 // filter
1055 else if ("fil_type" == key)
1056 {
1057 if (value == "lpf_1p") pCurDef->fil_type = LPF_1P;
1058 else if (value == "hpf_1p") pCurDef->fil_type = HPF_1P;
1059 else if (value == "bpf_1p") pCurDef->fil_type = BPF_1P;
1060 else if (value == "brf_1p") pCurDef->fil_type = BRF_1P;
1061 else if (value == "apf_1p") pCurDef->fil_type = APF_1P;
1062 else if (value == "lpf_2p") pCurDef->fil_type = LPF_2P;
1063 else if (value == "hpf_2p") pCurDef->fil_type = HPF_2P;
1064 else if (value == "bpf_2p") pCurDef->fil_type = BPF_2P;
1065 else if (value == "brf_2p") pCurDef->fil_type = BRF_2P;
1066 else if (value == "pkf_2p") pCurDef->fil_type = PKF_2P;
1067 else if (value == "lpf_4p") pCurDef->fil_type = LPF_4P;
1068 else if (value == "hpf_4p") pCurDef->fil_type = HPF_4P;
1069 else if (value == "lpf_6p") pCurDef->fil_type = LPF_6P;
1070 else if (value == "hpf_6p") pCurDef->fil_type = HPF_6P;
1071 }
1072 else if ("fil2_type" == key)
1073 {
1074 if (value == "lpf_1p") pCurDef->fil2_type = LPF_1P;
1075 else if (value == "hpf_1p") pCurDef->fil2_type = HPF_1P;
1076 else if (value == "bpf_1p") pCurDef->fil2_type = BPF_1P;
1077 else if (value == "brf_1p") pCurDef->fil2_type = BRF_1P;
1078 else if (value == "apf_1p") pCurDef->fil2_type = APF_1P;
1079 else if (value == "lpf_2p") pCurDef->fil2_type = LPF_2P;
1080 else if (value == "hpf_2p") pCurDef->fil2_type = HPF_2P;
1081 else if (value == "bpf_2p") pCurDef->fil2_type = BPF_2P;
1082 else if (value == "brf_2p") pCurDef->fil2_type = BRF_2P;
1083 else if (value == "pkf_2p") pCurDef->fil2_type = PKF_2P;
1084 else if (value == "lpf_4p") pCurDef->fil2_type = LPF_4P;
1085 else if (value == "hpf_4p") pCurDef->fil2_type = HPF_4P;
1086 else if (value == "lpf_6p") pCurDef->fil2_type = LPF_6P;
1087 else if (value == "hpf_6p") pCurDef->fil2_type = HPF_6P;
1088 }
1089 else if ("cutoff" == key) pCurDef->cutoff = ToFloat(value);
1090 else if ("cutoff2" == key) pCurDef->cutoff2 = ToFloat(value);
1091 else if ("cutoff_chanaft" == key) pCurDef->cutoff_chanaft = ToInt(value);
1092 else if ("cutoff2_chanaft" == key) pCurDef->cutoff2_chanaft = ToInt(value);
1093 else if ("cutoff_polyaft" == key) pCurDef->cutoff_polyaft = ToInt(value);
1094 else if ("cutoff2_polyaft" == key) pCurDef->cutoff2_polyaft = ToInt(value);
1095 else if ("resonance" == key) pCurDef->resonance = ToFloat(value);
1096 else if ("resonance2" == key) pCurDef->resonance2 = ToFloat(value);
1097 else if ("fil_keytrack" == key) pCurDef->fil_keytrack = ToInt(value);
1098 else if ("fil2_keytrack" == key) pCurDef->fil2_keytrack = ToInt(value);
1099 else if ("fil_keycenter" == key) pCurDef->fil_keycenter = ToInt(value) + note_offset + 12 * octave_offset;
1100 else if ("fil2_keycenter" == key) pCurDef->fil2_keycenter = ToInt(value) + note_offset + 12 * octave_offset;
1101 else if ("fil_veltrack" == key) pCurDef->fil_veltrack = ToInt(value);
1102 else if ("fil2_veltrack" == key) pCurDef->fil2_veltrack = ToInt(value);
1103 else if ("fil_random" == key) pCurDef->fil_random = ToInt(value);
1104 else if ("fil2_random" == key) pCurDef->fil2_random = ToInt(value);
1105
1106 // per voice equalizer
1107 else if ("eq1_freq" == key) pCurDef->eq1_freq = ToFloat(value);
1108 else if ("eq2_freq" == key) pCurDef->eq2_freq = ToFloat(value);
1109 else if ("eq3_freq" == key) pCurDef->eq3_freq = ToFloat(value);
1110 else if ("eq1_vel2freq" == key) pCurDef->eq1_vel2freq = ToFloat(value);
1111 else if ("eq2_vel2freq" == key) pCurDef->eq2_vel2freq = ToFloat(value);
1112 else if ("eq3_vel2freq" == key) pCurDef->eq3_vel2freq = ToFloat(value);
1113 else if ("eq1_bw" == key) pCurDef->eq1_bw = ToFloat(value);
1114 else if ("eq2_bw" == key) pCurDef->eq2_bw = ToFloat(value);
1115 else if ("eq3_bw" == key) pCurDef->eq3_bw = ToFloat(value);
1116 else if ("eq1_gain" == key) pCurDef->eq1_gain = ToFloat(value);
1117 else if ("eq2_gain" == key) pCurDef->eq2_gain = ToFloat(value);
1118 else if ("eq3_gain" == key) pCurDef->eq3_gain = ToFloat(value);
1119 else if ("eq1_vel2gain" == key) pCurDef->eq1_vel2gain = ToFloat(value);
1120 else if ("eq2_vel2gain" == key) pCurDef->eq2_vel2gain = ToFloat(value);
1121 else if ("eq3_vel2gain" == key) pCurDef->eq3_vel2gain = ToFloat(value);
1122
1123 //fixme: parse amp_velcurve_N
1124
1125 // CCs
1126 else if (key.find("cc") != std::string::npos)
1127 {
1128 std::string::size_type delimiter_index = key.find("cc");
1129 std::string key_cc = key.substr(0, delimiter_index);
1130 int num_cc = ToInt(key.substr(delimiter_index + 2));
1131
1132 // input controls
1133 if ("lo" == key_cc) pCurDef->locc[num_cc] = ToInt(value);
1134 else if ("hi" == key_cc) pCurDef->hicc[num_cc] = ToInt(value);
1135 else if ("start_lo" == key_cc) pCurDef->start_locc[num_cc] = ToInt(value);
1136 else if ("start_hi" == key_cc) pCurDef->start_hicc[num_cc] = ToInt(value);
1137 else if ("stop_lo" == key_cc) pCurDef->stop_locc[num_cc] = ToInt(value);
1138 else if ("stop_hi" == key_cc) pCurDef->stop_hicc[num_cc] = ToInt(value);
1139 else if ("on_lo" == key_cc) pCurDef->on_locc[num_cc] = ToInt(value);
1140 else if ("on_hi" == key_cc) pCurDef->on_hicc[num_cc] = ToInt(value);
1141
1142 // sample player
1143 else if ("delay_on" == key_cc) pCurDef->delay_oncc[num_cc] = ToFloat(value);
1144 else if ("delay_samples_on" == key_cc) pCurDef->delay_samples_oncc[num_cc] = ToInt(value);
1145 else if ("offset_on" == key_cc) pCurDef->offset_oncc[num_cc] = ToInt(value);
1146
1147 // amplifier
1148 else if ("gain_on" == key_cc) pCurDef->gain_oncc[num_cc] = ToFloat(value);
1149 else if ("xfin_lo" == key_cc) pCurDef->xfin_locc[num_cc] = ToInt(value);
1150 else if ("xfin_hi" == key_cc) pCurDef->xfin_hicc[num_cc] = ToInt(value);
1151 else if ("xfout_lo" == key_cc) pCurDef->xfout_locc[num_cc] = ToInt(value);
1152 else if ("xfout_hi" == key_cc) pCurDef->xfout_hicc[num_cc] = ToInt(value);
1153
1154 // filter
1155 else if ("cutoff_on" == key_cc) pCurDef->cutoff_oncc[num_cc] = ToInt(value);
1156 else if ("cutoff2_on" == key_cc) pCurDef->cutoff2_oncc[num_cc] = ToInt(value);
1157 else if ("cutoff_smooth" == key_cc) pCurDef->cutoff_smoothcc[num_cc] = ToInt(value);
1158 else if ("cutoff2_smooth" == key_cc) pCurDef->cutoff2_smoothcc[num_cc] = ToInt(value);
1159 else if ("cutoff_step" == key_cc) pCurDef->cutoff_stepcc[num_cc] = ToInt(value);
1160 else if ("cutoff2_step" == key_cc) pCurDef->cutoff2_stepcc[num_cc] = ToInt(value);
1161 else if ("cutoff_curve" == key_cc) pCurDef->cutoff_curvecc[num_cc] = ToInt(value);
1162 else if ("cutoff2_curve" == key_cc) pCurDef->cutoff2_curvecc[num_cc] = ToInt(value);
1163 else if ("resonance_on" == key_cc) pCurDef->resonance_oncc[num_cc] = ToInt(value);
1164 else if ("resonance2_on" == key_cc) pCurDef->resonance2_oncc[num_cc] = ToInt(value);
1165 else if ("resonance_smooth" == key_cc) pCurDef->resonance_smoothcc[num_cc] = ToInt(value);
1166 else if ("resonance2_smooth" == key_cc) pCurDef->resonance2_smoothcc[num_cc] = ToInt(value);
1167 else if ("resonance_step" == key_cc) pCurDef->resonance_stepcc[num_cc] = ToInt(value);
1168 else if ("resonance2_step" == key_cc) pCurDef->resonance2_stepcc[num_cc] = ToInt(value);
1169 else if ("resonance_curve" == key_cc) pCurDef->resonance_curvecc[num_cc] = ToInt(value);
1170 else if ("resonance2_curve" == key_cc) pCurDef->resonance2_curvecc[num_cc] = ToInt(value);
1171
1172 // per voice equalizer
1173 else if ("eq1_freq_on" == key_cc) pCurDef->eq1_freq_oncc[num_cc] = ToInt(value);
1174 else if ("eq2_freq_on" == key_cc) pCurDef->eq2_freq_oncc[num_cc] = ToInt(value);
1175 else if ("eq3_freq_on" == key_cc) pCurDef->eq3_freq_oncc[num_cc] = ToInt(value);
1176 else if ("eq1_bw_on" == key_cc) pCurDef->eq1_bw_oncc[num_cc] = ToInt(value);
1177 else if ("eq2_bw_on" == key_cc) pCurDef->eq2_bw_oncc[num_cc] = ToInt(value);
1178 else if ("eq3_bw_on" == key_cc) pCurDef->eq3_bw_oncc[num_cc] = ToInt(value);
1179 else if ("eq1_gain_on" == key_cc) pCurDef->eq1_gain_oncc[num_cc] = ToInt(value);
1180 else if ("eq2_gain_on" == key_cc) pCurDef->eq2_gain_oncc[num_cc] = ToInt(value);
1181 else if ("eq3_gain_on" == key_cc) pCurDef->eq3_gain_oncc[num_cc] = ToInt(value);
1182 else std::cerr << "The opcode '" << key << "' is unsupported by libsfz!" << std::endl;
1183 }
1184 // Deprecated opcodes
1185 else if ("ampeg_delay" == key) pCurDef->ampeg_delay = ToFloat(value);
1186 else if ("ampeg_start" == key) pCurDef->ampeg_start = ToFloat(value);
1187 else if ("ampeg_attack" == key) pCurDef->ampeg_attack = ToFloat(value);
1188 else if ("ampeg_hold" == key) pCurDef->ampeg_hold = ToFloat(value);
1189 else if ("ampeg_decay" == key) pCurDef->ampeg_decay = ToFloat(value);
1190 else if ("ampeg_sustain" == key) pCurDef->ampeg_sustain = ToFloat(value);
1191 else if ("ampeg_release" == key) pCurDef->ampeg_release = ToFloat(value);
1192 else if ("fileg_delay" == key) pCurDef->fileg_delay = ToFloat(value);
1193 else if ("fileg_start" == key) pCurDef->fileg_start = ToFloat(value);
1194 else if ("fileg_attack" == key) pCurDef->fileg_attack = ToFloat(value);
1195 else if ("fileg_hold" == key) pCurDef->fileg_hold = ToFloat(value);
1196 else if ("fileg_decay" == key) pCurDef->fileg_decay = ToFloat(value);
1197 else if ("fileg_sustain" == key) pCurDef->fileg_sustain = ToFloat(value);
1198 else if ("fileg_release" == key) pCurDef->fileg_release = ToFloat(value);
1199 else if ("pitcheg_delay" == key) pCurDef->pitcheg_delay = ToFloat(value);
1200 else if ("pitcheg_start" == key) pCurDef->pitcheg_start = ToFloat(value);
1201 else if ("pitcheg_attack" == key) pCurDef->pitcheg_attack = ToFloat(value);
1202 else if ("pitcheg_hold" == key) pCurDef->pitcheg_hold = ToFloat(value);
1203 else if ("pitcheg_decay" == key) pCurDef->pitcheg_decay = ToFloat(value);
1204 else if ("pitcheg_sustain" == key) pCurDef->pitcheg_sustain = ToFloat(value);
1205 else if ("pitcheg_release" == key) pCurDef->pitcheg_release = ToFloat(value);
1206 else {
1207 std::cerr << "The opcode '" << key << "' is unsupported by libsfz!" << std::endl;
1208 }
1209 }
1210
1211 } // !namespace sfz

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC