/[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 2012 - (show annotations) (download)
Fri Oct 23 17:53:17 2009 UTC (9 years, 8 months ago) by iliev
File size: 46659 byte(s)
* Refactoring: moved the independent code from
  the Gigasampler format engine to base classes
* SFZ format engine: experimental code (not usable yet)
* SoundFont format engine: experimental code (not usable yet)
* Fixed crash which may occur when MIDI key + transpose is out of range

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
491 Region*
492 Group::RegionFactory()
493 {
494 // This is where the current group setting are copied to the new region.
495
496 Region* region = new Region();
497
498 region->id = id++;
499
500 // sample definition
501 region->sample = sample;
502
503 // input control
504 region->lochan = lochan;
505 region->hichan = hichan;
506 region->lokey = lokey;
507 region->hikey = hikey;
508 region->lovel = lovel;
509 region->hivel = hivel;
510 region->locc = locc;
511 region->hicc = hicc;
512 region->lobend = lobend;
513 region->hibend = hibend;
514 region->lobpm = lobpm;
515 region->hibpm = hibpm;
516 region->lochanaft = lochanaft;
517 region->hichanaft = hichanaft;
518 region->lopolyaft = lopolyaft;
519 region->hipolyaft = hipolyaft;
520 region->loprog = loprog;
521 region->hiprog = hiprog;
522 region->lorand = lorand;
523 region->hirand = hirand;
524 region->lotimer = lotimer;
525 region->hitimer = hitimer;
526 region->seq_length = seq_length;
527 region->seq_position = seq_position;
528 region->start_locc = start_locc;
529 region->start_hicc = start_hicc;
530 region->stop_locc = stop_locc;
531 region->stop_hicc = stop_hicc;
532 region->sw_lokey = sw_lokey;
533 region->sw_hikey = sw_hikey;
534 region->sw_last = sw_last;
535 region->sw_down = sw_down;
536 region->sw_up = sw_up;
537 region->sw_previous = sw_previous;
538 region->sw_vel = sw_vel;
539 region->trigger = trigger;
540 region->group = group;
541 region->off_by = off_by;
542 region->off_mode = off_mode;
543 region->on_locc = on_locc;
544 region->on_hicc = on_hicc;
545
546 // sample player
547 region->count = count;
548 region->delay = delay;
549 region->delay_random = delay_random;
550 region->delay_oncc = delay_oncc;
551 region->delay_beats = delay_beats;
552 region->stop_beats = stop_beats;
553 region->delay_samples = delay_samples;
554 region->delay_samples_oncc = delay_samples_oncc;
555 region->end = end;
556 region->loop_crossfade = loop_crossfade;
557 region->offset = offset;
558 region->offset_random = offset_random;
559 region->offset_oncc = offset_oncc;
560 region->loop_mode = loop_mode;
561 region->loop_start = loop_start;
562 region->loop_end = loop_end;
563 region->sync_beats = sync_beats;
564 region->sync_offset = sync_offset;
565
566 // amplifier
567 region->volume = volume;
568 region->pan = pan;
569 region->width = width;
570 region->position = position;
571 region->amp_keytrack = amp_keytrack;
572 region->amp_keycenter = amp_keycenter;
573 region->amp_veltrack = amp_veltrack;
574 region->amp_velcurve_ = amp_velcurve_;
575 region->amp_random = amp_random;
576 region->rt_decay = rt_decay;
577 region->gain_oncc = gain_oncc;
578 region->xfin_lokey = xfin_lokey;
579 region->xfin_hikey = xfin_hikey;
580 region->xfout_lokey = xfout_lokey;
581 region->xfout_hikey = xfout_hikey;
582 region->xf_keycurve = xf_keycurve;
583 region->xfin_lovel = xfin_lovel;
584 region->xfin_hivel = xfin_lovel;
585 region->xfout_lovel = xfout_lovel;
586 region->xfout_hivel = xfout_hivel;
587 region->xf_velcurve = xf_velcurve;
588 region->xfin_locc = xfin_locc;
589 region->xfin_hicc = xfin_hicc;
590 region->xfout_locc = xfout_locc;
591 region->xfout_hicc = xfout_hicc;
592 region->xf_cccurve = xf_cccurve;
593
594 // pitch
595 region->transpose = transpose;
596 region->tune = tune;
597 region->pitch_keycenter = pitch_keycenter;
598 region->pitch_keytrack = pitch_keytrack;
599 region->pitch_veltrack = pitch_veltrack;
600 region->pitch_random = pitch_random;
601 region->bend_up = bend_up;
602 region->bend_down = bend_down;
603 region->bend_step = bend_step;
604
605 // filter
606 region->fil_type = fil_type;
607 region->cutoff = cutoff;
608 region->cutoff_oncc = cutoff_oncc;
609 region->cutoff_smoothcc = cutoff_smoothcc;
610 region->cutoff_stepcc = cutoff_stepcc;
611 region->cutoff_curvecc = cutoff_curvecc;
612 region->cutoff_chanaft = cutoff_chanaft;
613 region->cutoff_polyaft = cutoff_polyaft;
614 region->resonance = resonance;
615 region->resonance_oncc = resonance_oncc;
616 region->resonance_smoothcc = resonance_smoothcc;
617 region->resonance_stepcc = resonance_stepcc;
618 region->resonance_curvecc = resonance_curvecc;
619 region->fil_keytrack = fil_keytrack;
620 region->fil_keycenter = fil_keycenter;
621 region->fil_veltrack = fil_veltrack;
622 region->fil_random = fil_random;
623
624 region->fil2_type = fil2_type;
625 region->cutoff2 = cutoff2;
626 region->cutoff2_oncc = cutoff2_oncc;
627 region->cutoff2_smoothcc = cutoff2_smoothcc;
628 region->cutoff2_stepcc = cutoff2_stepcc;
629 region->cutoff2_curvecc = cutoff2_curvecc;
630 region->cutoff2_chanaft = cutoff2_chanaft;
631 region->cutoff2_polyaft = cutoff2_polyaft;
632 region->resonance2 = resonance2;
633 region->resonance2_oncc = resonance2_oncc;
634 region->resonance2_smoothcc = resonance2_smoothcc;
635 region->resonance2_stepcc = resonance2_stepcc;
636 region->resonance2_curvecc = resonance2_curvecc;
637 region->fil2_keytrack = fil2_keytrack;
638 region->fil2_keycenter = fil2_keycenter;
639 region->fil2_veltrack = fil2_veltrack;
640 region->fil2_random = fil2_random;
641
642 // per voice equalizer
643 region->eq1_freq = eq1_freq;
644 region->eq2_freq = eq2_freq;
645 region->eq3_freq = eq3_freq;
646 region->eq1_freq_oncc = eq1_freq_oncc;
647 region->eq2_freq_oncc = eq2_freq_oncc;
648 region->eq3_freq_oncc = eq3_freq_oncc;
649 region->eq1_vel2freq = eq1_vel2freq;
650 region->eq2_vel2freq = eq2_vel2freq;
651 region->eq3_vel2freq = eq3_vel2freq;
652 region->eq1_bw = eq1_bw;
653 region->eq2_bw = eq2_bw;
654 region->eq3_bw = eq3_bw;
655 region->eq1_bw_oncc = eq1_bw_oncc;
656 region->eq2_bw_oncc = eq2_bw_oncc;
657 region->eq3_bw_oncc = eq3_bw_oncc;
658 region->eq1_gain = eq1_gain;
659 region->eq2_gain = eq2_gain;
660 region->eq3_gain = eq3_gain;
661 region->eq1_gain_oncc = eq1_gain_oncc;
662 region->eq2_gain_oncc = eq2_gain_oncc;
663 region->eq3_gain_oncc = eq3_gain_oncc;
664 region->eq1_vel2gain = eq1_vel2gain;
665 region->eq2_vel2gain = eq2_vel2gain;
666 region->eq3_vel2gain = eq3_vel2gain;
667
668 return region;
669 }
670
671 /////////////////////////////////////////////////////////////
672 // class File
673
674 File::File(std::string file, SampleManager* pSampleManager) :
675 _current_section(GROUP),
676 default_path(""),
677 octave_offset(0),
678 note_offset(0)
679 {
680 _instrument = new Instrument(LinuxSampler::Path::getBaseName(file), pSampleManager);
681 _current_group = new Group();
682 pCurDef = _current_group;
683 enum token_type_t { HEADER, OPCODE };
684 token_type_t token_type;
685 std::string token_string;
686
687 std::ifstream fs(file.c_str());
688 currentDir = LinuxSampler::Path::stripLastName(file);
689 std::string token;
690 std::string line;
691
692 while (std::getline(fs, line))
693 {
694 // COMMENT
695 std::string::size_type slash_index = line.find("//");
696 if (slash_index != std::string::npos)
697 line.resize(slash_index);
698
699 // DEFINITION
700 std::stringstream linestream(line);
701 while (linestream >> token)
702 {
703 if (token[0] == '<' and token[token.size()-1] == '>')
704 {
705 // HEAD
706 if (!token_string.empty())
707 {
708 switch (token_type)
709 {
710 case HEADER:
711 push_header(token_string);
712 break;
713 case OPCODE:
714 push_opcode(token_string);
715 break;
716 }
717 token_string.erase();
718 }
719 token_string.append(token);
720 token_type = HEADER;
721 }
722 else if (token.find('=') != std::string::npos)
723 {
724 // HEAD
725 if (!token_string.empty())
726 {
727 switch (token_type)
728 {
729 case HEADER:
730 push_header(token_string);
731 break;
732 case OPCODE:
733 push_opcode(token_string);
734 break;
735 }
736 token_string.erase();
737 }
738 token_string.append(token);
739 token_type = OPCODE;
740 }
741 else
742 {
743 // TAIL
744 token_string.append(" ");
745 token_string.append(token);
746 }
747 }
748
749 // EOL
750 if (!token_string.empty())
751 {
752 switch (token_type)
753 {
754 case HEADER:
755 push_header(token_string);
756 break;
757 case OPCODE:
758 push_opcode(token_string);
759 break;
760 }
761 token_string.erase();
762 }
763 }
764
765 for (int i = 0; i < _instrument->regions.size(); i++) {
766 ::sfz::Region* pRegion = _instrument->regions[i];
767 int low = pRegion->lokey;
768 int high = pRegion->hikey;
769 if (low < 0 || low > 127 || high < 0 || high > 127 || low > high) {
770 std::cerr << "Invalid key range: " << low << " - " << high << std::endl;
771 } else {
772 for (int j = low; j <= high; j++) _instrument->KeyBindings[j] = true;
773 }
774
775 // get keyswitches
776 low = pRegion->sw_lokey;
777 high = pRegion->sw_hikey;
778 if(low == -1 && high == -1) {
779 // Key switches not defined, so nothing to do
780 } else if(low >= 0 && low <= 127 && high >= 0 && high <= 127 && high >= low) {
781 for (int j = low; j <= high; j++) _instrument->KeySwitchBindings[j] = true;
782 } else {
783 std::cerr << "Invalid key switch range: " << low << " - " << high << std::endl;
784 }
785 }
786 }
787
788 File::~File()
789 {
790 delete _current_group;
791 delete _instrument;
792 }
793
794 Instrument*
795 File::GetInstrument()
796 {
797 return _instrument;
798 }
799
800 void
801 File::push_header(std::string token)
802 {
803 if (token == "<group>")
804 {
805 _current_section = GROUP;
806 _current_group->Reset();
807 pCurDef = _current_group;
808 }
809 else if (token == "<region>")
810 {
811 _current_section = REGION;
812 _current_region = _current_group->RegionFactory();
813 pCurDef = _current_region;
814 _instrument->regions.push_back(_current_region);
815 _current_region->SetInstrument(_instrument);
816 }
817 else if (token == "<control>")
818 {
819 _current_section = CONTROL;
820 default_path = "";
821 octave_offset = 0;
822 note_offset = 0;
823 }
824 else
825 {
826 _current_section = UNKNOWN;
827 std::cerr << "The header '" << token << "' is unsupported by libsfz!" << std::endl;
828 }
829 }
830
831 void
832 File::push_opcode(std::string token)
833 {
834 if (_current_section == UNKNOWN)
835 return;
836
837 std::string::size_type delimiter_index = token.find('=');
838 std::string key = token.substr(0, delimiter_index);
839 std::string value = token.substr(delimiter_index + 1);
840
841 // sample definition
842 if ("sample" == key)
843 {
844 std::string path = default_path + value;
845 #ifndef WIN32
846 for (int i = 0; i < path.length(); i++) if( path[i] == '\\') path[i] = '/';
847 #endif
848 path = currentDir + LinuxSampler::File::DirSeparator + path; // TODO: check for absolute path
849
850 if(pCurDef) pCurDef->sample = path;
851 return;
852 }
853
854 // control header directives
855 else if ("default_path" == key)
856 {
857 switch (_current_section)
858 {
859 case CONTROL:
860 default_path = value;
861 }
862 return;
863 }
864 else if ("octave_offset" == key)
865 {
866 switch (_current_section)
867 {
868 case CONTROL:
869 octave_offset = ToInt(value);
870 }
871 return;
872 }
873 else if ("note_offset" == key)
874 {
875 switch (_current_section)
876 {
877 case CONTROL:
878 note_offset = ToInt(value);
879 }
880 return;
881 }
882
883 // input controls
884 else if ("lochan" == key) pCurDef->lochan = ToInt(value);
885 else if ("hichan" == key) pCurDef->hichan = ToInt(value);
886 else if ("lokey" == key) pCurDef->lokey = ToInt(value) + note_offset + 12 * octave_offset;
887 else if ("hikey" == key) pCurDef->hikey = ToInt(value) + note_offset + 12 * octave_offset;
888 else if ("key" == key)
889 {
890 pCurDef->lokey = ToInt(value) + note_offset + 12 * octave_offset;
891 pCurDef->hikey = ToInt(value) + note_offset + 12 * octave_offset;
892 }
893 else if ("lovel" == key) pCurDef->lovel = ToInt(value);
894 else if ("hivel" == key) pCurDef->hivel = ToInt(value);
895 else if ("lobend" == key) pCurDef->lobend = ToInt(value);
896 else if ("hibend" == key) pCurDef->hibend = ToInt(value);
897 else if ("lobpm" == key) pCurDef->lobpm = ToInt(value);
898 else if ("hibpm" == key) pCurDef->hibpm = ToInt(value);
899 else if ("lochanaft" == key) pCurDef->lochanaft = ToInt(value);
900 else if ("hichanaft" == key) pCurDef->hichanaft = ToInt(value);
901 else if ("lopolyaft" == key) pCurDef->lopolyaft = ToInt(value);
902 else if ("hipolyaft" == key) pCurDef->hipolyaft = ToInt(value);
903 else if ("loprog" == key) pCurDef->loprog = ToInt(value);
904 else if ("hiprog" == key) pCurDef->hiprog = ToInt(value);
905 else if ("lorand" == key) pCurDef->lorand = ToFloat(value);
906 else if ("hirand" == key) pCurDef->hirand = ToFloat(value);
907 else if ("lotimer" == key) pCurDef->lotimer = ToFloat(value);
908 else if ("hitimer" == key) pCurDef->hitimer = ToFloat(value);
909 else if ("seq_length" == key) pCurDef->seq_length = ToInt(value);
910 else if ("seq_position" == key) pCurDef->seq_position = ToInt(value);
911 else if ("sw_lokey" == key) pCurDef->sw_lokey = ToInt(value) + note_offset + 12 * octave_offset;
912 else if ("sw_hikey" == key) pCurDef->sw_hikey = ToInt(value) + note_offset + 12 * octave_offset;
913 else if ("sw_last" == key) pCurDef->sw_last = ToInt(value) + note_offset + 12 * octave_offset;
914 else if ("sw_down" == key) pCurDef->sw_down = ToInt(value) + note_offset + 12 * octave_offset;
915 else if ("sw_up" == key) pCurDef->sw_up = ToInt(value) + note_offset + 12 * octave_offset;
916 else if ("sw_previous" == key) pCurDef->sw_previous = ToInt(value) + note_offset + 12 * octave_offset;
917 else if ("sw_vel" == key)
918 {
919 if (value == "current") pCurDef->sw_vel = VEL_CURRENT;
920 else if (value == "previous") pCurDef->sw_vel = VEL_PREVIOUS;
921 }
922 else if ("trigger" == key)
923 {
924 if (value == "attack") pCurDef->trigger = TRIGGER_ATTACK;
925 else if (value == "release") pCurDef->trigger = TRIGGER_RELEASE;
926 else if (value == "first") pCurDef->trigger = TRIGGER_FIRST;
927 else if (value == "legato") pCurDef->trigger = TRIGGER_LEGATO;
928 }
929 else if ("group" == key) pCurDef->group = ToInt(value);
930 else if ("off_by" == key) pCurDef->off_by = ToInt(value);
931 else if ("off_mode" == key)
932 {
933 if (value == "fast") _current_group->off_mode = OFF_FAST;
934 else if (value == "normal") _current_group->off_mode = OFF_NORMAL;
935 }
936
937 // sample player
938 else if ("count" == key) pCurDef->count = ToInt(value);
939 else if ("delay" == key) pCurDef->delay = ToFloat(value);
940 else if ("delay_random" == key) pCurDef->delay_random = ToFloat(value);
941 else if ("delay_beats" == key) pCurDef->delay_beats = ToInt(value);
942 else if ("stop_beats" == key) pCurDef->stop_beats = ToInt(value);
943 else if ("delay_samples" == key) pCurDef->delay_samples = ToInt(value);
944 else if ("end" == key) pCurDef->end = ToInt(value);
945 else if ("loop_crossfade" == key) pCurDef->loop_crossfade = ToFloat(value);
946 else if ("offset_random" == key) pCurDef->offset_random = ToInt(value);
947 else if ("loop_mode" == key)
948 {
949 if (value == "no_loop") pCurDef->loop_mode = NO_LOOP;
950 else if (value == "one_shot") pCurDef->loop_mode = ONE_SHOT;
951 else if (value == "loop_continous") pCurDef->loop_mode = LOOP_CONTINOUS;
952 else if (value == "loop_sustain") pCurDef->loop_mode = LOOP_SUSTAIN;
953 }
954 else if ("loop_start" == key) pCurDef->loop_start = ToInt(value);
955 else if ("loop_end" == key) pCurDef->loop_end = ToInt(value);
956 else if ("sync_beats" == key) pCurDef->sync_beats = ToInt(value);
957 else if ("sync_offset" == key) pCurDef->sync_offset = ToInt(value);
958
959 // amplifier
960 else if ("volume" == key) pCurDef->volume = ToFloat(value);
961 else if ("pan" == key) pCurDef->pan = ToFloat(value);
962 else if ("width" == key) pCurDef->width = ToFloat(value);
963 else if ("position" == key) pCurDef->position = ToFloat(value);
964 else if ("amp_keytrack" == key) pCurDef->amp_keytrack = ToFloat(value);
965 else if ("amp_keycenter" == key) pCurDef->amp_keycenter = ToInt(value) + note_offset + 12 * octave_offset;
966 else if ("amp_veltrack" == key) pCurDef->amp_veltrack = ToFloat(value);
967 else if ("amp_random" == key) pCurDef->amp_random = ToFloat(value);
968 else if ("rt_decay" == key) pCurDef->rt_decay = ToFloat(value);
969 else if ("xfin_lokey" == key) pCurDef->xfin_lokey = ToInt(value) + note_offset + 12 * octave_offset;
970 else if ("xfin_hikey" == key) pCurDef->xfin_hikey = ToInt(value) + note_offset + 12 * octave_offset;
971 else if ("xfout_lokey" == key) pCurDef->xfout_lokey = ToInt(value) + note_offset + 12 * octave_offset;
972 else if ("xfout_hikey" == key) pCurDef->xfout_hikey = ToInt(value) + note_offset + 12 * octave_offset;
973 else if ("xf_keycurve" == key)
974 {
975 if (value == "gain") pCurDef->xf_keycurve = GAIN;
976 else if (value == "power") pCurDef->xf_keycurve = POWER;
977 }
978 else if ("xfin_lovel" == key) pCurDef->xfin_lovel = ToInt(value);
979 else if ("xfin_hivel" == key) pCurDef->xfin_hivel = ToInt(value);
980 else if ("xfout_lovel" == key) pCurDef->xfout_lovel = ToInt(value);
981 else if ("xfout_hivel" == key) pCurDef->xfout_hivel = ToInt(value);
982 else if ("xf_velcurve" == key)
983 {
984 if (value == "gain") pCurDef->xf_velcurve = GAIN;
985 else if (value == "power") pCurDef->xf_velcurve = POWER;
986 }
987 else if ("xf_cccurve" == key)
988 {
989 if (value == "gain") pCurDef->xf_cccurve = GAIN;
990 else if (value == "power") pCurDef->xf_cccurve = POWER;
991 }
992
993 // pitch
994 else if ("transpose" == key) pCurDef->transpose = ToInt(value);
995 else if ("tune" == key) pCurDef->tune = ToInt(value);
996 else if ("pitch_keycenter" == key) pCurDef->pitch_keycenter = ToInt(value) + note_offset + 12 * octave_offset;
997 else if ("pitch_keytrack" == key) pCurDef->pitch_keytrack = ToInt(value);
998 else if ("pitch_veltrack" == key) pCurDef->pitch_veltrack = ToInt(value);
999 else if ("pitch_random" == key) pCurDef->pitch_random = ToInt(value);
1000 else if ("bend_up" == key) pCurDef->bend_up = ToInt(value);
1001 else if ("bend_down" == key) pCurDef->bend_down = ToInt(value);
1002 else if ("bend_step" == key) pCurDef->bend_step = ToInt(value);
1003
1004 // filter
1005 else if ("fil_type" == key)
1006 {
1007 if (value == "lpf_1p") pCurDef->fil_type = LPF_1P;
1008 else if (value == "hpf_1p") pCurDef->fil_type = HPF_1P;
1009 else if (value == "bpf_1p") pCurDef->fil_type = BPF_1P;
1010 else if (value == "brf_1p") pCurDef->fil_type = BRF_1P;
1011 else if (value == "apf_1p") pCurDef->fil_type = APF_1P;
1012 else if (value == "lpf_2p") pCurDef->fil_type = LPF_2P;
1013 else if (value == "hpf_2p") pCurDef->fil_type = HPF_2P;
1014 else if (value == "bpf_2p") pCurDef->fil_type = BPF_2P;
1015 else if (value == "brf_2p") pCurDef->fil_type = BRF_2P;
1016 else if (value == "pkf_2p") pCurDef->fil_type = PKF_2P;
1017 else if (value == "lpf_4p") pCurDef->fil_type = LPF_4P;
1018 else if (value == "hpf_4p") pCurDef->fil_type = HPF_4P;
1019 else if (value == "lpf_6p") pCurDef->fil_type = LPF_6P;
1020 else if (value == "hpf_6p") pCurDef->fil_type = HPF_6P;
1021 }
1022 else if ("fil2_type" == key)
1023 {
1024 if (value == "lpf_1p") pCurDef->fil2_type = LPF_1P;
1025 else if (value == "hpf_1p") pCurDef->fil2_type = HPF_1P;
1026 else if (value == "bpf_1p") pCurDef->fil2_type = BPF_1P;
1027 else if (value == "brf_1p") pCurDef->fil2_type = BRF_1P;
1028 else if (value == "apf_1p") pCurDef->fil2_type = APF_1P;
1029 else if (value == "lpf_2p") pCurDef->fil2_type = LPF_2P;
1030 else if (value == "hpf_2p") pCurDef->fil2_type = HPF_2P;
1031 else if (value == "bpf_2p") pCurDef->fil2_type = BPF_2P;
1032 else if (value == "brf_2p") pCurDef->fil2_type = BRF_2P;
1033 else if (value == "pkf_2p") pCurDef->fil2_type = PKF_2P;
1034 else if (value == "lpf_4p") pCurDef->fil2_type = LPF_4P;
1035 else if (value == "hpf_4p") pCurDef->fil2_type = HPF_4P;
1036 else if (value == "lpf_6p") pCurDef->fil2_type = LPF_6P;
1037 else if (value == "hpf_6p") pCurDef->fil2_type = HPF_6P;
1038 }
1039 else if ("cutoff" == key) pCurDef->cutoff = ToFloat(value);
1040 else if ("cutoff2" == key) pCurDef->cutoff2 = ToFloat(value);
1041 else if ("cutoff_chanaft" == key) pCurDef->cutoff_chanaft = ToInt(value);
1042 else if ("cutoff2_chanaft" == key) pCurDef->cutoff2_chanaft = ToInt(value);
1043 else if ("cutoff_polyaft" == key) pCurDef->cutoff_polyaft = ToInt(value);
1044 else if ("cutoff2_polyaft" == key) pCurDef->cutoff2_polyaft = ToInt(value);
1045 else if ("resonance" == key) pCurDef->resonance = ToFloat(value);
1046 else if ("resonance2" == key) pCurDef->resonance2 = ToFloat(value);
1047 else if ("fil_keytrack" == key) pCurDef->fil_keytrack = ToInt(value);
1048 else if ("fil2_keytrack" == key) pCurDef->fil2_keytrack = ToInt(value);
1049 else if ("fil_keycenter" == key) pCurDef->fil_keycenter = ToInt(value) + note_offset + 12 * octave_offset;
1050 else if ("fil2_keycenter" == key) pCurDef->fil2_keycenter = ToInt(value) + note_offset + 12 * octave_offset;
1051 else if ("fil_veltrack" == key) pCurDef->fil_veltrack = ToInt(value);
1052 else if ("fil2_veltrack" == key) pCurDef->fil2_veltrack = ToInt(value);
1053 else if ("fil_random" == key) pCurDef->fil_random = ToInt(value);
1054 else if ("fil2_random" == key) pCurDef->fil2_random = ToInt(value);
1055
1056 // per voice equalizer
1057 else if ("eq1_freq" == key) pCurDef->eq1_freq = ToFloat(value);
1058 else if ("eq2_freq" == key) pCurDef->eq2_freq = ToFloat(value);
1059 else if ("eq3_freq" == key) pCurDef->eq3_freq = ToFloat(value);
1060 else if ("eq1_vel2freq" == key) pCurDef->eq1_vel2freq = ToFloat(value);
1061 else if ("eq2_vel2freq" == key) pCurDef->eq2_vel2freq = ToFloat(value);
1062 else if ("eq3_vel2freq" == key) pCurDef->eq3_vel2freq = ToFloat(value);
1063 else if ("eq1_bw" == key) pCurDef->eq1_bw = ToFloat(value);
1064 else if ("eq2_bw" == key) pCurDef->eq2_bw = ToFloat(value);
1065 else if ("eq3_bw" == key) pCurDef->eq3_bw = ToFloat(value);
1066 else if ("eq1_gain" == key) pCurDef->eq1_gain = ToFloat(value);
1067 else if ("eq2_gain" == key) pCurDef->eq2_gain = ToFloat(value);
1068 else if ("eq3_gain" == key) pCurDef->eq3_gain = ToFloat(value);
1069 else if ("eq1_vel2gain" == key) pCurDef->eq1_vel2gain = ToFloat(value);
1070 else if ("eq2_vel2gain" == key) pCurDef->eq2_vel2gain = ToFloat(value);
1071 else if ("eq3_vel2gain" == key) pCurDef->eq3_vel2gain = ToFloat(value);
1072
1073 //fixme: parse amp_velcurve_N
1074
1075 // CCs
1076 else if (key.find("cc") != std::string::npos)
1077 {
1078 std::string::size_type delimiter_index = key.find("cc");
1079 std::string key_cc = key.substr(0, delimiter_index);
1080 int num_cc = ToInt(key.substr(delimiter_index + 2));
1081
1082 // input controls
1083 if ("lo" == key_cc) pCurDef->locc[num_cc] = ToInt(value);
1084 else if ("hi" == key_cc) pCurDef->hicc[num_cc] = ToInt(value);
1085 else if ("start_lo" == key_cc) pCurDef->start_locc[num_cc] = ToInt(value);
1086 else if ("start_hi" == key_cc) pCurDef->start_hicc[num_cc] = ToInt(value);
1087 else if ("stop_lo" == key_cc) pCurDef->stop_locc[num_cc] = ToInt(value);
1088 else if ("stop_hi" == key_cc) pCurDef->stop_hicc[num_cc] = ToInt(value);
1089 else if ("on_lo" == key_cc) pCurDef->on_locc[num_cc] = ToInt(value);
1090 else if ("on_hi" == key_cc) pCurDef->on_hicc[num_cc] = ToInt(value);
1091
1092 // sample player
1093 else if ("delay_on" == key_cc) pCurDef->delay_oncc[num_cc] = ToFloat(value);
1094 else if ("delay_samples_on" == key_cc) pCurDef->delay_samples_oncc[num_cc] = ToInt(value);
1095 else if ("offset_on" == key_cc) pCurDef->offset_oncc[num_cc] = ToInt(value);
1096
1097 // amplifier
1098 else if ("gain_on" == key_cc) pCurDef->gain_oncc[num_cc] = ToFloat(value);
1099 else if ("xfin_lo" == key_cc) pCurDef->xfin_locc[num_cc] = ToInt(value);
1100 else if ("xfin_hi" == key_cc) pCurDef->xfin_hicc[num_cc] = ToInt(value);
1101 else if ("xfout_lo" == key_cc) pCurDef->xfout_locc[num_cc] = ToInt(value);
1102 else if ("xfout_hi" == key_cc) pCurDef->xfout_hicc[num_cc] = ToInt(value);
1103
1104 // filter
1105 else if ("cutoff_on" == key_cc) pCurDef->cutoff_oncc[num_cc] = ToInt(value);
1106 else if ("cutoff2_on" == key_cc) pCurDef->cutoff2_oncc[num_cc] = ToInt(value);
1107 else if ("cutoff_smooth" == key_cc) pCurDef->cutoff_smoothcc[num_cc] = ToInt(value);
1108 else if ("cutoff2_smooth" == key_cc) pCurDef->cutoff2_smoothcc[num_cc] = ToInt(value);
1109 else if ("cutoff_step" == key_cc) pCurDef->cutoff_stepcc[num_cc] = ToInt(value);
1110 else if ("cutoff2_step" == key_cc) pCurDef->cutoff2_stepcc[num_cc] = ToInt(value);
1111 else if ("cutoff_curve" == key_cc) pCurDef->cutoff_curvecc[num_cc] = ToInt(value);
1112 else if ("cutoff2_curve" == key_cc) pCurDef->cutoff2_curvecc[num_cc] = ToInt(value);
1113 else if ("resonance_on" == key_cc) pCurDef->resonance_oncc[num_cc] = ToInt(value);
1114 else if ("resonance2_on" == key_cc) pCurDef->resonance2_oncc[num_cc] = ToInt(value);
1115 else if ("resonance_smooth" == key_cc) pCurDef->resonance_smoothcc[num_cc] = ToInt(value);
1116 else if ("resonance2_smooth" == key_cc) pCurDef->resonance2_smoothcc[num_cc] = ToInt(value);
1117 else if ("resonance_step" == key_cc) pCurDef->resonance_stepcc[num_cc] = ToInt(value);
1118 else if ("resonance2_step" == key_cc) pCurDef->resonance2_stepcc[num_cc] = ToInt(value);
1119 else if ("resonance_curve" == key_cc) pCurDef->resonance_curvecc[num_cc] = ToInt(value);
1120 else if ("resonance2_curve" == key_cc) pCurDef->resonance2_curvecc[num_cc] = ToInt(value);
1121
1122 // per voice equalizer
1123 else if ("eq1_freq_on" == key_cc) pCurDef->eq1_freq_oncc[num_cc] = ToInt(value);
1124 else if ("eq2_freq_on" == key_cc) pCurDef->eq2_freq_oncc[num_cc] = ToInt(value);
1125 else if ("eq3_freq_on" == key_cc) pCurDef->eq3_freq_oncc[num_cc] = ToInt(value);
1126 else if ("eq1_bw_on" == key_cc) pCurDef->eq1_bw_oncc[num_cc] = ToInt(value);
1127 else if ("eq2_bw_on" == key_cc) pCurDef->eq2_bw_oncc[num_cc] = ToInt(value);
1128 else if ("eq3_bw_on" == key_cc) pCurDef->eq3_bw_oncc[num_cc] = ToInt(value);
1129 else if ("eq1_gain_on" == key_cc) pCurDef->eq1_gain_oncc[num_cc] = ToInt(value);
1130 else if ("eq2_gain_on" == key_cc) pCurDef->eq2_gain_oncc[num_cc] = ToInt(value);
1131 else if ("eq3_gain_on" == key_cc) pCurDef->eq3_gain_oncc[num_cc] = ToInt(value);
1132 else std::cerr << "The opcode '" << key << "' is unsupported by libsfz!" << std::endl;
1133 } else {
1134 std::cerr << "The opcode '" << key << "' is unsupported by libsfz!" << std::endl;
1135 }
1136 }
1137
1138 } // !namespace sfz

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC