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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2018 by iliev, Tue Oct 27 19:04:57 2009 UTC revision 2086 by persson, Sun Apr 25 12:51:30 2010 UTC
# Line 2  Line 2 
2   *                                                                         *   *                                                                         *
3   *   LinuxSampler - modular, streaming capable sampler                     *   *   LinuxSampler - modular, streaming capable sampler                     *
4   *                                                                         *   *                                                                         *
5   *   Copyright (C) 2008-2009 Anders Dahnielson <anders@dahnielson.com>     *   *   Copyright (C) 2008 Anders Dahnielson <anders@dahnielson.com>          *
6   *   Copyright (C) 2009 Grigor Iliev                                       *   *   Copyright (C) 2009 - 2010 Anders Dahnielson and Grigor Iliev          *
7   *                                                                         *   *                                                                         *
8   *   This program is free software; you can redistribute it and/or modify  *   *   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  *   *   it under the terms of the GNU General Public License as published by  *
# Line 25  Line 25 
25    
26  #include <iostream>  #include <iostream>
27  #include <sstream>  #include <sstream>
28    #include <cctype>
29    #include <cstdio>
30    #include <cstring>
31    
32  #include "../../common/File.h"  #include "../../common/File.h"
33  #include "../../common/Path.h"  #include "../../common/Path.h"
# Line 33  Line 36 
36  namespace sfz  namespace sfz
37  {  {
38    
39      LinuxSampler::SampleFile* SampleManager::FindSample(std::string samplePath) {      Sample* SampleManager::FindSample(std::string samplePath) {
40          std::map<LinuxSampler::SampleFile*, std::set<Region*> >::iterator it = sampleMap.begin();          std::map<Sample*, std::set<Region*> >::iterator it = sampleMap.begin();
41          for (; it != sampleMap.end(); it++) {          for (; it != sampleMap.end(); it++) {
42              if (it->first->GetFile() == samplePath) return it->first;              if (it->first->GetFile() == samplePath) return it->first;
43          }          }
# Line 64  namespace sfz Line 67  namespace sfz
67      Definition::Definition() :      Definition::Definition() :
68          locc(128), hicc(128), start_locc(128), start_hicc(128), stop_locc(128),          locc(128), hicc(128), start_locc(128), start_hicc(128), stop_locc(128),
69          stop_hicc(128), on_locc(128), on_hicc(128), delay_oncc(128), delay_samples_oncc(128),          stop_hicc(128), on_locc(128), on_hicc(128), delay_oncc(128), delay_samples_oncc(128),
70          offset_oncc(128), amp_velcurve_(128), gain_oncc(128), xfin_locc(128), xfin_hicc(128),          offset_oncc(128), amp_velcurve(128), gain_oncc(128), xfin_locc(128), xfin_hicc(128),
71          xfout_locc(128), xfout_hicc(128), cutoff_oncc(128), cutoff2_oncc(128), cutoff_smoothcc(128),          xfout_locc(128), xfout_hicc(128), cutoff_oncc(128), cutoff2_oncc(128), cutoff_smoothcc(128),
72          cutoff2_smoothcc(128), cutoff_stepcc(128), cutoff2_stepcc(128), cutoff_curvecc(128),          cutoff2_smoothcc(128), cutoff_stepcc(128), cutoff2_stepcc(128), cutoff_curvecc(128),
73          cutoff2_curvecc(128), resonance_oncc(128), resonance2_oncc(128), resonance_smoothcc(128),          cutoff2_curvecc(128), resonance_oncc(128), resonance2_oncc(128), resonance_smoothcc(128),
# Line 86  namespace sfz Line 89  namespace sfz
89      Region::Region()      Region::Region()
90      {      {
91          pSample = NULL;          pSample = NULL;
92            seq_counter = 1;
93      }      }
94    
95      Region::~Region()      Region::~Region()
# Line 93  namespace sfz Line 97  namespace sfz
97          DestroySampleIfNotUsed();          DestroySampleIfNotUsed();
98      }      }
99    
100      LinuxSampler::SampleFile* Region::GetSample(bool create)      Sample* Region::GetSample(bool create)
101      {      {
102          if(pSample == NULL && create) {          if(pSample == NULL && create) {
103              LinuxSampler::SampleFile* sf = GetInstrument()->GetSampleManager()->FindSample(sample);              Sample* sf = GetInstrument()->GetSampleManager()->FindSample(sample);
104              if (sf != NULL) pSample = sf; // Reuse already created sample              if (sf != NULL) pSample = sf; // Reuse already created sample
105              else pSample = new LinuxSampler::SampleFile(sample);              else pSample = new Sample(sample);
106              GetInstrument()->GetSampleManager()->AddSampleConsumer(pSample, this);              GetInstrument()->GetSampleManager()->AddSampleConsumer(pSample, this);
107          }          }
108          return pSample;          return pSample;
# Line 118  namespace sfz Line 122  namespace sfz
122      Region::OnKey(uint8_t chan, uint8_t key, uint8_t vel,      Region::OnKey(uint8_t chan, uint8_t key, uint8_t vel,
123                int bend, uint8_t bpm, uint8_t chanaft, uint8_t polyaft,                int bend, uint8_t bpm, uint8_t chanaft, uint8_t polyaft,
124                uint8_t prog, float rand, trigger_t trig, uint8_t* cc,                uint8_t prog, float rand, trigger_t trig, uint8_t* cc,
125                float timer, uint8_t seq, bool* sw, uint8_t last_sw_key, uint8_t prev_sw_key)                float timer, bool* sw, uint8_t last_sw_key, uint8_t prev_sw_key)
126      {      {
127          // chan        (MIDI channel)          // chan        (MIDI channel)
128          // key         (MIDI note)          // key         (MIDI note)
# Line 134  namespace sfz Line 138  namespace sfz
138          // cc          (all 128 CC values)          // cc          (all 128 CC values)
139    
140          // timer       (time since previous region in the group was triggered)          // timer       (time since previous region in the group was triggered)
         // seq         (the state of the region sequence counter)  
141          // sw          (the state of region key switches, 128 possible values)          // sw          (the state of region key switches, 128 possible values)
142          // last_sw_key (the last key pressed in the key switch range)          // last_sw_key (the last key pressed in the key switch range)
143          // prev_sw_key (the previous note value)          // prev_sw_key (the previous note value)
# Line 144  namespace sfz Line 147  namespace sfz
147              key     >= lokey      &&  key     <= hikey      &&              key     >= lokey      &&  key     <= hikey      &&
148              vel     >= lovel      &&  vel     <= hivel      &&              vel     >= lovel      &&  vel     <= hivel      &&
149              bend    >= lobend     &&  bend    <= hibend     &&              bend    >= lobend     &&  bend    <= hibend     &&
150              bpm     >= lobpm      &&  bpm     <= hibpm      &&              bpm     >= lobpm      &&  bpm     <  hibpm      &&
151              chanaft >= lochanaft  &&  chanaft <= hichanaft  &&              chanaft >= lochanaft  &&  chanaft <= hichanaft  &&
152              polyaft >= lopolyaft  &&  polyaft <= hipolyaft  &&              polyaft >= lopolyaft  &&  polyaft <= hipolyaft  &&
153              prog    >= loprog     &&  prog    <= hiprog     &&              prog    >= loprog     &&  prog    <= hiprog     &&
154              rand    >= lorand     &&  rand    <= hirand     &&              rand    >= lorand     &&  rand    <  hirand     &&
155              timer   >= lotimer    &&  timer   <= hitimer    &&              timer   >= lotimer    &&  timer   <= hitimer    &&
             seq == seq_position   &&  
156    
157              ( (sw_lokey == -1 || sw_hikey == -1 || sw_last  == -1) ||              ( sw_last == -1 ||
158                ((sw_last >= sw_lokey && sw_last <= sw_hikey) ? (last_sw_key == sw_last) : true) ) &&                ((sw_last >= sw_lokey && sw_last <= sw_hikey) ? (last_sw_key == sw_last) : false) ) &&
159    
160              ( (sw_down  == -1 || sw_lokey == -1 || sw_hikey == -1) ||              ( sw_down == -1 ||
161                ((sw_down >= sw_lokey && sw_down <= sw_hikey) ? (sw[sw_down]) : true) )  &&                ((sw_down >= sw_lokey && (sw_hikey == -1 || sw_down <= sw_hikey)) ? (sw[sw_down]) : false) )  &&
162    
163              ( (sw_up    == -1 || sw_lokey == -1 || sw_hikey == -1) ||              ( sw_up   == -1 ||
164                ((sw_up   >= sw_lokey && sw_up   <= sw_hikey) ? (!sw[sw_up])  : true) )  &&                ((sw_up   >= sw_lokey && (sw_hikey == -1 || sw_up   <= sw_hikey)) ? (!sw[sw_up]) : true) )  &&
165    
166              ((sw_previous != -1) ? (prev_sw_key == sw_previous) : true)  &&              ( sw_previous == -1 ||
167               ((trigger && trig) != 0)                prev_sw_key == sw_previous )  &&
168    
169                ((trigger & trig) != 0)
170          );          );
171    
172          if (!is_triggered)          if (!is_triggered)
# Line 174  namespace sfz Line 178  namespace sfz
178                  return false;                  return false;
179          }          }
180    
181          return true;          // seq_position has to be checked last, so we know that we
182            // increment the right counter
183            is_triggered = (seq_counter == seq_position);
184            seq_counter = (seq_counter % seq_length) + 1;
185    
186            return is_triggered;
187      }      }
188    
189      bool      bool
190      Region::OnControl(uint8_t chan, uint8_t cont, uint8_t val,      Region::OnControl(uint8_t chan, uint8_t cont, uint8_t val,
191          int bend, uint8_t bpm, uint8_t chanaft, uint8_t polyaft,          int bend, uint8_t bpm, uint8_t chanaft, uint8_t polyaft,
192          uint8_t prog, float rand, trigger_t trig, uint8_t* cc,          uint8_t prog, float rand, trigger_t trig, uint8_t* cc,
193          float timer, uint8_t seq, bool* sw, uint8_t last_sw_key, uint8_t prev_sw_key)          float timer, bool* sw, uint8_t last_sw_key, uint8_t prev_sw_key)
194      {      {
195          // chan      (MIDI channel)          // chan      (MIDI channel)
196          // cont      (MIDI controller)          // cont      (MIDI controller)
# Line 197  namespace sfz Line 206  namespace sfz
206          // cc        (all CC values)          // cc        (all CC values)
207    
208          // timer       (time since previous region in the group was triggered)          // timer       (time since previous region in the group was triggered)
         // seq         (the state of the region sequence counter)  
209          // sw          (the state of region key switches, 128 possible values)          // sw          (the state of region key switches, 128 possible values)
210          // last_sw_key (the last key pressed in the key switch range)          // last_sw_key (the last key pressed in the key switch range)
211          // prev_sw_key (the previous note value)          // prev_sw_key (the previous note value)
# Line 207  namespace sfz Line 215  namespace sfz
215              ((val   >= on_locc[cont]    &&  val     <= on_hicc[cont])     ||              ((val   >= on_locc[cont]    &&  val     <= on_hicc[cont])     ||
216               (val   >= start_locc[cont] &&  val     <= start_hicc[cont])) &&               (val   >= start_locc[cont] &&  val     <= start_hicc[cont])) &&
217              bend    >= lobend           &&  bend    <= hibend             &&              bend    >= lobend           &&  bend    <= hibend             &&
218              bpm     >= lobpm            &&  bpm     <= hibpm              &&              bpm     >= lobpm            &&  bpm     <  hibpm              &&
219              chanaft >= lochanaft        &&  chanaft <= hichanaft          &&              chanaft >= lochanaft        &&  chanaft <= hichanaft          &&
220              polyaft >= lopolyaft        &&  polyaft <= hipolyaft          &&              polyaft >= lopolyaft        &&  polyaft <= hipolyaft          &&
221              prog    >= loprog           &&  prog    <= hiprog             &&              prog    >= loprog           &&  prog    <= hiprog             &&
222              rand    >= lorand           &&  rand    <= hirand             &&              rand    >= lorand           &&  rand    <  hirand             &&
223              timer   >= lotimer          &&  timer   <= hitimer            &&              timer   >= lotimer          &&  timer   <= hitimer            &&
             seq == seq_position   &&  
224    
225              ( (sw_lokey == -1 || sw_hikey == -1 || sw_last  == -1) ||              ( sw_last == -1 ||
226                ((sw_last >= sw_lokey && sw_last <= sw_hikey) ? (last_sw_key == sw_last) : true) ) &&                ((sw_last >= sw_lokey && sw_last <= sw_hikey) ? (last_sw_key == sw_last) : false) ) &&
227    
228              ( (sw_down  == -1 || sw_lokey == -1 || sw_hikey == -1) ||              ( sw_down == -1 ||
229                ((sw_down >= sw_lokey && sw_down <= sw_hikey) ? (sw[sw_down]) : true) )  &&                ((sw_down >= sw_lokey && (sw_hikey == -1 || sw_down <= sw_hikey)) ? (sw[sw_down]) : false) )  &&
230    
231              ( (sw_up    == -1 || sw_lokey == -1 || sw_hikey == -1) ||              ( sw_up   == -1 ||
232                ((sw_up   >= sw_lokey && sw_up   <= sw_hikey) ? (!sw[sw_up])  : true) )  &&                ((sw_up   >= sw_lokey && (sw_hikey == -1 || sw_up   <= sw_hikey)) ? (!sw[sw_up]) : true) )  &&
233    
234              ((sw_previous != -1) ? (prev_sw_key == sw_previous) : true)  &&              ( sw_previous == -1 ||
235               ((trigger && trig) != 0)                prev_sw_key == sw_previous )  &&
236    
237                ((trigger & trig) != 0)
238          );          );
239    
240          if (!is_triggered)          if (!is_triggered)
# Line 246  namespace sfz Line 255  namespace sfz
255          return new Articulation(); //todo: implement GetArticulation()          return new Articulation(); //todo: implement GetArticulation()
256      }      }
257    
258        bool Region::HasLoop() {
259            bool b = loop_mode == ::sfz::LOOP_CONTINUOUS || loop_mode == ::sfz::LOOP_SUSTAIN; // TODO: ONE_SHOT mode
260            return b && GetLoopStart() && GetLoopEnd() && GetLoopEnd() > GetLoopStart();
261        }
262    
263        uint Region::GetLoopStart() {
264            return (!loop_start) ? 0 : *loop_start; // TODO: use sample loop when loop_start not defined
265        }
266    
267        uint Region::GetLoopEnd() {
268            return (!loop_end) ? 0 : *loop_end; // TODO: use sample loop when loop_end not defined
269        }
270    
271        uint Region::GetLoopCount() {
272            return (!count) ? 0 : *count;
273        }
274    
275      /////////////////////////////////////////////////////////////      /////////////////////////////////////////////////////////////
276      // class Instrument      // class Instrument
277    
# Line 267  namespace sfz Line 293  namespace sfz
293          uint8_t chan, uint8_t key, uint8_t vel,          uint8_t chan, uint8_t key, uint8_t vel,
294          int bend, uint8_t bpm, uint8_t chanaft, uint8_t polyaft,          int bend, uint8_t bpm, uint8_t chanaft, uint8_t polyaft,
295          uint8_t prog, float rand, trigger_t trig, uint8_t* cc,          uint8_t prog, float rand, trigger_t trig, uint8_t* cc,
296          float timer, uint8_t seq, bool* sw, uint8_t last_sw_key, uint8_t prev_sw_key          float timer, bool* sw, uint8_t last_sw_key, uint8_t prev_sw_key
297      ) {      ) {
298          std::vector<Region*> v;          std::vector<Region*> v;
299          for (int i = 0; i < regions.size(); i++) {          for (int i = 0; i < regions.size(); i++) {
300              if (regions[i]->OnKey (              if (regions[i]->OnKey (
301                  chan, key, vel, bend, bpm, chanaft, polyaft, prog,                  chan, key, vel, bend, bpm, chanaft, polyaft, prog,
302                  rand, trig, cc, timer, seq, sw, last_sw_key, prev_sw_key)                  rand, trig, cc, timer, sw, last_sw_key, prev_sw_key)
303                      ) { v.push_back(regions[i]); }                      ) { v.push_back(regions[i]); }
304          }          }
305    
# Line 347  namespace sfz Line 373  namespace sfz
373    
374          trigger = TRIGGER_ATTACK;          trigger = TRIGGER_ATTACK;
375    
376          group.unset();          group = 0;
377          off_by.unset();          off_by.unset();
378          off_mode = OFF_FAST;          off_mode = OFF_FAST;
379    
# Line 449  namespace sfz Line 475  namespace sfz
475              offset_oncc[i].unset();              offset_oncc[i].unset();
476    
477              // amplifier              // amplifier
478              amp_velcurve_[i] = 0; //fixme: 20 log (127^2 / i^2)              amp_velcurve[i] = -1;
479              gain_oncc[i] = 0;              gain_oncc[i] = 0;
480              xfin_locc[i] = 0;              xfin_locc[i] = 0;
481              xfin_hicc[i] = 0;              xfin_hicc[i] = 0;
# Line 487  namespace sfz Line 513  namespace sfz
513              eq3_gain_oncc[i] = 0;              eq3_gain_oncc[i] = 0;
514          }          }
515    
516            eg.clear();
517    
518          // deprecated          // deprecated
519          ampeg_delay    = 0;          ampeg_delay    = 0;
520          ampeg_start    = 0; //in percentage          ampeg_start    = 0; //in percentage
# Line 511  namespace sfz Line 539  namespace sfz
539          pitcheg_decay    = 0;          pitcheg_decay    = 0;
540          pitcheg_sustain  = 100; // in percentage          pitcheg_sustain  = 100; // in percentage
541          pitcheg_release  = 0;          pitcheg_release  = 0;
542    
543            amplfo_delay     = 0;
544            amplfo_fade      = 0;
545            amplfo_freq      = 0;
546            amplfo_depth     = 0;
547    
548            fillfo_delay     = 0;
549            fillfo_fade      = 0;
550            fillfo_freq      = 0;
551            fillfo_depth     = 0;
552    
553            pitchlfo_delay   = 0;
554            pitchlfo_fade    = 0;
555            pitchlfo_freq    = 0;
556            pitchlfo_depth   = 0;
557      }      }
558    
559      Region*      Region*
# Line 596  namespace sfz Line 639  namespace sfz
639          region->amp_keytrack = amp_keytrack;          region->amp_keytrack = amp_keytrack;
640          region->amp_keycenter = amp_keycenter;          region->amp_keycenter = amp_keycenter;
641          region->amp_veltrack = amp_veltrack;          region->amp_veltrack = amp_veltrack;
642          region->amp_velcurve_ = amp_velcurve_;          region->amp_velcurve = amp_velcurve;
643          region->amp_random = amp_random;          region->amp_random = amp_random;
644          region->rt_decay = rt_decay;          region->rt_decay = rt_decay;
645          region->gain_oncc = gain_oncc;          region->gain_oncc = gain_oncc;
# Line 690  namespace sfz Line 733  namespace sfz
733          region->eq2_vel2gain = eq2_vel2gain;          region->eq2_vel2gain = eq2_vel2gain;
734          region->eq3_vel2gain = eq3_vel2gain;          region->eq3_vel2gain = eq3_vel2gain;
735    
736            // envelope generator
737            region->eg = eg;
738    
739          // deprecated          // deprecated
740          region->ampeg_delay    = ampeg_delay;          region->ampeg_delay    = ampeg_delay;
741          region->ampeg_start    = ampeg_start;          region->ampeg_start    = ampeg_start;
# Line 715  namespace sfz Line 761  namespace sfz
761          region->pitcheg_sustain  = pitcheg_sustain;          region->pitcheg_sustain  = pitcheg_sustain;
762          region->pitcheg_release  = pitcheg_release;          region->pitcheg_release  = pitcheg_release;
763    
764            region->amplfo_delay     = amplfo_delay;
765            region->amplfo_fade      = amplfo_fade;
766            region->amplfo_freq      = amplfo_freq;
767            region->amplfo_depth     = amplfo_depth;
768    
769            region->fillfo_delay     = fillfo_delay;
770            region->fillfo_fade      = fillfo_fade;
771            region->fillfo_freq      = fillfo_freq;
772            region->fillfo_depth     = fillfo_depth;
773    
774            region->pitchlfo_delay   = pitchlfo_delay;
775            region->pitchlfo_fade    = pitchlfo_fade;
776            region->pitchlfo_freq    = pitchlfo_freq;
777            region->pitchlfo_depth   = pitchlfo_depth;
778    
779          return region;          return region;
780      }      }
781    
# Line 729  namespace sfz Line 790  namespace sfz
790      {      {
791          _instrument = new Instrument(LinuxSampler::Path::getBaseName(file), pSampleManager);          _instrument = new Instrument(LinuxSampler::Path::getBaseName(file), pSampleManager);
792          _current_group = new Group();          _current_group = new Group();
793                  pCurDef = _current_group;          pCurDef = _current_group;
794          enum token_type_t { HEADER, OPCODE };          enum token_type_t { HEADER, OPCODE };
795          token_type_t token_type;          token_type_t token_type;
796          std::string token_string;          std::string token_string;
# Line 824  namespace sfz Line 885  namespace sfz
885    
886              // get keyswitches              // get keyswitches
887              low = pRegion->sw_lokey;              low = pRegion->sw_lokey;
888                if (low < 0) low = 0;
889              high = pRegion->sw_hikey;              high = pRegion->sw_hikey;
890              if(low == -1 && high == -1) {              if (high == -1) {
891                  // Key switches not defined, so nothing to do                  // Key switches not defined, so nothing to do
892              } else if(low >= 0 && low <= 127 && high >= 0 && high <= 127 && high >= low) {              } else if (low >= 0 && low <= 127 && high >= 0 && high <= 127 && high >= low) {
893                  for (int j = low; j <= high; j++) _instrument->KeySwitchBindings[j] = true;                  for (int j = low; j <= high; j++) _instrument->KeySwitchBindings[j] = true;
894              } else {              } else {
895                  std::cerr << "Invalid key switch range: " << low << " - " << high << std::endl;                  std::cerr << "Invalid key switch range: " << low << " - " << high << std::endl;
896              }              }
897    
898                // create velocity response curve
899                int prev = 0;
900                float prevvalue = 0;
901                for (int v = 0 ; v < 128 ; v++) {
902                    if (pRegion->amp_velcurve[v] >= 0) {
903                        float step = (pRegion->amp_velcurve[v] - prevvalue) / (v - prev);
904                        for ( ; prev < v ; prev++) {
905                            pRegion->amp_velcurve[prev] = prevvalue;
906                            prevvalue += step;
907                        }
908                    }
909                }
910                if (prev) {
911                    float step = (1 - prevvalue) / (127 - prev);
912                    for ( ; prev < 128 ; prev++) {
913                        pRegion->amp_velcurve[prev] = prevvalue;
914                        prevvalue += step;
915                    }
916                } else {
917                    // default curve
918                    for (int v = 0 ; v < 128 ; v++) {
919                        pRegion->amp_velcurve[v] = v * v / (127.0 * 127.0);
920                    }
921                }
922                // apply amp_veltrack
923                float offset = -pRegion->amp_veltrack;
924                if (offset <= 0) offset += 100;
925                for (int v = 0 ; v < 128 ; v++) {
926                    pRegion->amp_velcurve[v] =
927                        (offset + pRegion->amp_veltrack * pRegion->amp_velcurve[v]) / 100;
928                }
929          }          }
930      }      }
931    
# Line 854  namespace sfz Line 948  namespace sfz
948          {          {
949              _current_section = GROUP;              _current_section = GROUP;
950              _current_group->Reset();              _current_group->Reset();
951                          pCurDef = _current_group;              pCurDef = _current_group;
952          }          }
953          else if (token == "<region>")          else if (token == "<region>")
954          {          {
955              _current_section = REGION;              _current_section = REGION;
956              _current_region = _current_group->RegionFactory();              _current_region = _current_group->RegionFactory();
957                          pCurDef = _current_region;              pCurDef = _current_region;
958              _instrument->regions.push_back(_current_region);              _instrument->regions.push_back(_current_region);
959                          _current_region->SetInstrument(_instrument);              _current_region->SetInstrument(_instrument);
960          }          }
961          else if (token == "<control>")          else if (token == "<control>")
962          {          {
# Line 887  namespace sfz Line 981  namespace sfz
981          std::string::size_type delimiter_index = token.find('=');          std::string::size_type delimiter_index = token.find('=');
982          std::string key = token.substr(0, delimiter_index);          std::string key = token.substr(0, delimiter_index);
983          std::string value = token.substr(delimiter_index + 1);          std::string value = token.substr(delimiter_index + 1);
984            int x, y;
985    
986          // sample definition          // sample definition
987          if ("sample" == key)          if ("sample" == key)
# Line 933  namespace sfz Line 1028  namespace sfz
1028          // input controls          // input controls
1029          else if ("lochan" == key) pCurDef->lochan = ToInt(value);          else if ("lochan" == key) pCurDef->lochan = ToInt(value);
1030          else if ("hichan" == key) pCurDef->hichan = ToInt(value);          else if ("hichan" == key) pCurDef->hichan = ToInt(value);
1031          else if ("lokey"  == key) pCurDef->lokey  = ToInt(value) + note_offset + 12 * octave_offset;          else if ("lokey"  == key) pCurDef->lokey  = parseKey(value);
1032          else if ("hikey"  == key) pCurDef->hikey  = ToInt(value) + note_offset + 12 * octave_offset;          else if ("hikey"  == key) pCurDef->hikey  = parseKey(value);
1033          else if ("key" == key)          else if ("key" == key)
1034          {          {
1035              pCurDef->lokey = ToInt(value) + note_offset + 12 * octave_offset;              pCurDef->lokey = pCurDef->hikey = pCurDef->pitch_keycenter = parseKey(value);
             pCurDef->hikey = ToInt(value) + note_offset + 12 * octave_offset;  
1036          }          }
1037          else if ("lovel"  == key) pCurDef->lovel = ToInt(value);          else if ("lovel"  == key) pCurDef->lovel = ToInt(value);
1038          else if ("hivel"  == key) pCurDef->hivel = ToInt(value);          else if ("hivel"  == key) pCurDef->hivel = ToInt(value);
# Line 958  namespace sfz Line 1052  namespace sfz
1052          else if ("hitimer" == key) pCurDef->hitimer = ToFloat(value);          else if ("hitimer" == key) pCurDef->hitimer = ToFloat(value);
1053          else if ("seq_length"   == key) pCurDef->seq_length = ToInt(value);          else if ("seq_length"   == key) pCurDef->seq_length = ToInt(value);
1054          else if ("seq_position" == key) pCurDef->seq_position = ToInt(value);          else if ("seq_position" == key) pCurDef->seq_position = ToInt(value);
1055          else if ("sw_lokey" == key) pCurDef->sw_lokey = ToInt(value) + note_offset + 12 * octave_offset;          else if ("sw_lokey" == key) pCurDef->sw_lokey = parseKey(value);
1056          else if ("sw_hikey" == key) pCurDef->sw_hikey = ToInt(value) + note_offset + 12 * octave_offset;          else if ("sw_hikey" == key) pCurDef->sw_hikey = parseKey(value);
1057          else if ("sw_last"  == key) pCurDef->sw_last = ToInt(value) + note_offset + 12 * octave_offset;          else if ("sw_last"  == key) pCurDef->sw_last = parseKey(value);
1058          else if ("sw_down"  == key) pCurDef->sw_down = ToInt(value) + note_offset + 12 * octave_offset;          else if ("sw_down"  == key) pCurDef->sw_down = parseKey(value);
1059          else if ("sw_up"    == key) pCurDef->sw_up = ToInt(value) + note_offset + 12 * octave_offset;          else if ("sw_up"    == key) pCurDef->sw_up = parseKey(value);
1060          else if ("sw_previous" == key) pCurDef->sw_previous = ToInt(value) + note_offset + 12 * octave_offset;          else if ("sw_previous" == key) pCurDef->sw_previous = parseKey(value);
1061          else if ("sw_vel" == key)          else if ("sw_vel" == key)
1062          {          {
1063              if (value == "current") pCurDef->sw_vel = VEL_CURRENT;              if (value == "current") pCurDef->sw_vel = VEL_CURRENT;
# Line 977  namespace sfz Line 1071  namespace sfz
1071              else if (value == "legato")  pCurDef->trigger = TRIGGER_LEGATO;              else if (value == "legato")  pCurDef->trigger = TRIGGER_LEGATO;
1072          }          }
1073          else if ("group"  == key) pCurDef->group = ToInt(value);          else if ("group"  == key) pCurDef->group = ToInt(value);
1074          else if ("off_by" == key) pCurDef->off_by = ToInt(value);          else if ("off_by" == key || "offby" == key) pCurDef->off_by = ToInt(value);
1075          else if ("off_mode" == key)          else if ("off_mode" == key || "offmode" == key)
1076          {          {
1077              if (value == "fast")  _current_group->off_mode = OFF_FAST;              if (value == "fast")  _current_group->off_mode = OFF_FAST;
1078              else if (value == "normal") _current_group->off_mode = OFF_NORMAL;              else if (value == "normal") _current_group->off_mode = OFF_NORMAL;
1079          }          }
1080    
1081          // sample player          // sample player
1082          else if ("count" == key) pCurDef->count = ToInt(value);          else if ("count" == key) { pCurDef->count = ToInt(value); pCurDef->loop_mode = ONE_SHOT; }
1083          else if ("delay" == key) pCurDef->delay = ToFloat(value);          else if ("delay" == key) pCurDef->delay = ToFloat(value);
1084          else if ("delay_random"   == key) pCurDef->delay_random = ToFloat(value);          else if ("delay_random"   == key) pCurDef->delay_random = ToFloat(value);
1085          else if ("delay_beats"    == key) pCurDef->delay_beats = ToInt(value);          else if ("delay_beats"    == key) pCurDef->delay_beats = ToInt(value);
# Line 994  namespace sfz Line 1088  namespace sfz
1088          else if ("end"            == key) pCurDef->end = ToInt(value);          else if ("end"            == key) pCurDef->end = ToInt(value);
1089          else if ("loop_crossfade" == key) pCurDef->loop_crossfade = ToFloat(value);          else if ("loop_crossfade" == key) pCurDef->loop_crossfade = ToFloat(value);
1090          else if ("offset_random"  == key) pCurDef->offset_random = ToInt(value);          else if ("offset_random"  == key) pCurDef->offset_random = ToInt(value);
1091          else if ("loop_mode" == key)          else if ("loop_mode" == key || "loopmode" == key)
1092          {          {
1093              if (value == "no_loop") pCurDef->loop_mode = NO_LOOP;              if (value == "no_loop") pCurDef->loop_mode = NO_LOOP;
1094              else if (value == "one_shot") pCurDef->loop_mode = ONE_SHOT;              else if (value == "one_shot") pCurDef->loop_mode = ONE_SHOT;
1095              else if (value == "loop_continous") pCurDef->loop_mode = LOOP_CONTINOUS;              else if (value == "loop_continuous") pCurDef->loop_mode = LOOP_CONTINUOUS;
1096              else if (value == "loop_sustain") pCurDef->loop_mode = LOOP_SUSTAIN;              else if (value == "loop_sustain") pCurDef->loop_mode = LOOP_SUSTAIN;
1097          }          }
1098          else if ("loop_start" == key) pCurDef->loop_start = ToInt(value);          else if ("loop_start" == key) pCurDef->loop_start = ToInt(value);
1099            else if ("loopstart" == key) pCurDef->loop_start = ToInt(value); // nonstandard
1100          else if ("loop_end" == key) pCurDef->loop_end = ToInt(value);          else if ("loop_end" == key) pCurDef->loop_end = ToInt(value);
1101            else if ("loopend" == key) pCurDef->loop_end = ToInt(value); // nonstandard
1102          else if ("sync_beats" == key) pCurDef->sync_beats = ToInt(value);          else if ("sync_beats" == key) pCurDef->sync_beats = ToInt(value);
1103          else if ("sync_offset" == key) pCurDef->sync_offset = ToInt(value);          else if ("sync_offset" == key) pCurDef->sync_offset = ToInt(value);
1104    
# Line 1012  namespace sfz Line 1108  namespace sfz
1108          else if ("width"    == key) pCurDef->width = ToFloat(value);          else if ("width"    == key) pCurDef->width = ToFloat(value);
1109          else if ("position" == key) pCurDef->position = ToFloat(value);          else if ("position" == key) pCurDef->position = ToFloat(value);
1110          else if ("amp_keytrack"  == key) pCurDef->amp_keytrack = ToFloat(value);          else if ("amp_keytrack"  == key) pCurDef->amp_keytrack = ToFloat(value);
1111          else if ("amp_keycenter" == key) pCurDef->amp_keycenter = ToInt(value) + note_offset + 12 * octave_offset;          else if ("amp_keycenter" == key) pCurDef->amp_keycenter = parseKey(value);
1112          else if ("amp_veltrack"  == key) pCurDef->amp_veltrack = ToFloat(value);          else if ("amp_veltrack"  == key) pCurDef->amp_veltrack = ToFloat(value);
1113          else if ("amp_random"  == key) pCurDef->amp_random = ToFloat(value);          else if ("amp_random"  == key) pCurDef->amp_random = ToFloat(value);
1114          else if ("rt_decay"    == key) pCurDef->rt_decay = ToFloat(value);          else if ("rt_decay"    == key) pCurDef->rt_decay = ToFloat(value);
1115          else if ("xfin_lokey"  == key) pCurDef->xfin_lokey = ToInt(value) + note_offset + 12 * octave_offset;          else if ("xfin_lokey"  == key) pCurDef->xfin_lokey = parseKey(value);
1116          else if ("xfin_hikey"  == key) pCurDef->xfin_hikey = ToInt(value) + note_offset + 12 * octave_offset;          else if ("xfin_hikey"  == key) pCurDef->xfin_hikey = parseKey(value);
1117          else if ("xfout_lokey" == key) pCurDef->xfout_lokey = ToInt(value) + note_offset + 12 * octave_offset;          else if ("xfout_lokey" == key) pCurDef->xfout_lokey = parseKey(value);
1118          else if ("xfout_hikey" == key) pCurDef->xfout_hikey = ToInt(value) + note_offset + 12 * octave_offset;          else if ("xfout_hikey" == key) pCurDef->xfout_hikey = parseKey(value);
1119          else if ("xf_keycurve" == key)          else if ("xf_keycurve" == key)
1120          {          {
1121              if (value == "gain") pCurDef->xf_keycurve = GAIN;              if (value == "gain") pCurDef->xf_keycurve = GAIN;
# Line 1043  namespace sfz Line 1139  namespace sfz
1139          // pitch          // pitch
1140          else if ("transpose" == key) pCurDef->transpose = ToInt(value);          else if ("transpose" == key) pCurDef->transpose = ToInt(value);
1141          else if ("tune" == key) pCurDef->tune = ToInt(value);          else if ("tune" == key) pCurDef->tune = ToInt(value);
1142          else if ("pitch_keycenter" == key) pCurDef->pitch_keycenter = ToInt(value) + note_offset + 12 * octave_offset;          else if ("pitch_keycenter" == key) pCurDef->pitch_keycenter = parseKey(value);
1143          else if ("pitch_keytrack" == key) pCurDef->pitch_keytrack = ToInt(value);          else if ("pitch_keytrack" == key) pCurDef->pitch_keytrack = ToInt(value);
1144          else if ("pitch_veltrack" == key) pCurDef->pitch_veltrack = ToInt(value);          else if ("pitch_veltrack" == key) pCurDef->pitch_veltrack = ToInt(value);
1145          else if ("pitch_random" == key) pCurDef->pitch_random = ToInt(value);          else if ("pitch_random" == key) pCurDef->pitch_random = ToInt(value);
1146          else if ("bend_up" == key) pCurDef->bend_up = ToInt(value);          else if ("bend_up" == key || "bendup" == key) pCurDef->bend_up = ToInt(value);
1147          else if ("bend_down" == key) pCurDef->bend_down = ToInt(value);          else if ("bend_down" == key || "benddown" == key) pCurDef->bend_down = ToInt(value);
1148          else if ("bend_step" == key) pCurDef->bend_step = ToInt(value);          else if ("bend_step" == key) pCurDef->bend_step = ToInt(value);
1149    
1150          // filter          // filter
1151          else if ("fil_type" == key)          else if ("fil_type" == key || "filtype" == key)
1152          {          {
1153              if (value == "lpf_1p") pCurDef->fil_type = LPF_1P;              if (value == "lpf_1p") pCurDef->fil_type = LPF_1P;
1154              else if (value == "hpf_1p") pCurDef->fil_type = HPF_1P;              else if (value == "hpf_1p") pCurDef->fil_type = HPF_1P;
# Line 1096  namespace sfz Line 1192  namespace sfz
1192          else if ("resonance2" == key) pCurDef->resonance2 = ToFloat(value);          else if ("resonance2" == key) pCurDef->resonance2 = ToFloat(value);
1193          else if ("fil_keytrack"   == key) pCurDef->fil_keytrack = ToInt(value);          else if ("fil_keytrack"   == key) pCurDef->fil_keytrack = ToInt(value);
1194          else if ("fil2_keytrack"  == key) pCurDef->fil2_keytrack = ToInt(value);          else if ("fil2_keytrack"  == key) pCurDef->fil2_keytrack = ToInt(value);
1195          else if ("fil_keycenter"  == key) pCurDef->fil_keycenter = ToInt(value) + note_offset + 12 * octave_offset;          else if ("fil_keycenter"  == key) pCurDef->fil_keycenter = parseKey(value);
1196          else if ("fil2_keycenter" == key) pCurDef->fil2_keycenter = ToInt(value) + note_offset + 12 * octave_offset;          else if ("fil2_keycenter" == key) pCurDef->fil2_keycenter = parseKey(value);
1197          else if ("fil_veltrack"   == key) pCurDef->fil_veltrack = ToInt(value);          else if ("fil_veltrack"   == key) pCurDef->fil_veltrack = ToInt(value);
1198          else if ("fil2_veltrack"  == key) pCurDef->fil2_veltrack = ToInt(value);          else if ("fil2_veltrack"  == key) pCurDef->fil2_veltrack = ToInt(value);
1199          else if ("fil_random"     == key) pCurDef->fil_random = ToInt(value);          else if ("fil_random"     == key) pCurDef->fil_random = ToInt(value);
# Line 1120  namespace sfz Line 1216  namespace sfz
1216          else if ("eq2_vel2gain" == key) pCurDef->eq2_vel2gain = ToFloat(value);          else if ("eq2_vel2gain" == key) pCurDef->eq2_vel2gain = ToFloat(value);
1217          else if ("eq3_vel2gain" == key) pCurDef->eq3_vel2gain = ToFloat(value);          else if ("eq3_vel2gain" == key) pCurDef->eq3_vel2gain = ToFloat(value);
1218    
1219          //fixme: parse amp_velcurve_N          else if (sscanf(key.c_str(), "amp_velcurve_%d", &x)) {
1220                pCurDef->amp_velcurve[x] = ToFloat(value);
1221            }
1222    
1223          // CCs          // CCs
1224          else if (key.find("cc") != std::string::npos)          else if (key.find("cc") != std::string::npos)
# Line 1145  namespace sfz Line 1243  namespace sfz
1243              else if ("offset_on" == key_cc) pCurDef->offset_oncc[num_cc] = ToInt(value);              else if ("offset_on" == key_cc) pCurDef->offset_oncc[num_cc] = ToInt(value);
1244    
1245              // amplifier              // amplifier
1246              else if ("gain_on"  == key_cc) pCurDef->gain_oncc[num_cc]  = ToFloat(value);              else if ("gain_on"  == key_cc || "gain_" == key_cc) pCurDef->gain_oncc[num_cc]  = ToFloat(value);
1247              else if ("xfin_lo"  == key_cc) pCurDef->xfin_locc[num_cc]  = ToInt(value);              else if ("xfin_lo"  == key_cc) pCurDef->xfin_locc[num_cc]  = ToInt(value);
1248              else if ("xfin_hi"  == key_cc) pCurDef->xfin_hicc[num_cc]  = ToInt(value);              else if ("xfin_hi"  == key_cc) pCurDef->xfin_hicc[num_cc]  = ToInt(value);
1249              else if ("xfout_lo" == key_cc) pCurDef->xfout_locc[num_cc] = ToInt(value);              else if ("xfout_lo" == key_cc) pCurDef->xfout_locc[num_cc] = ToInt(value);
1250              else if ("xfout_hi" == key_cc) pCurDef->xfout_hicc[num_cc] = ToInt(value);              else if ("xfout_hi" == key_cc) pCurDef->xfout_hicc[num_cc] = ToInt(value);
1251    
1252              // filter              // filter
1253              else if ("cutoff_on"  == key_cc) pCurDef->cutoff_oncc[num_cc]  = ToInt(value);              else if ("cutoff_on"  == key_cc || "cutoff_" == key_cc) pCurDef->cutoff_oncc[num_cc]  = ToInt(value);
1254              else if ("cutoff2_on" == key_cc) pCurDef->cutoff2_oncc[num_cc] = ToInt(value);              else if ("cutoff2_on" == key_cc) pCurDef->cutoff2_oncc[num_cc] = ToInt(value);
1255              else if ("cutoff_smooth"  == key_cc) pCurDef->cutoff_smoothcc[num_cc]  = ToInt(value);              else if ("cutoff_smooth"  == key_cc) pCurDef->cutoff_smoothcc[num_cc]  = ToInt(value);
1256              else if ("cutoff2_smooth" == key_cc) pCurDef->cutoff2_smoothcc[num_cc] = ToInt(value);              else if ("cutoff2_smooth" == key_cc) pCurDef->cutoff2_smoothcc[num_cc] = ToInt(value);
# Line 1170  namespace sfz Line 1268  namespace sfz
1268              else if ("resonance2_curve" == key_cc) pCurDef->resonance2_curvecc[num_cc] = ToInt(value);              else if ("resonance2_curve" == key_cc) pCurDef->resonance2_curvecc[num_cc] = ToInt(value);
1269    
1270              // per voice equalizer              // per voice equalizer
1271              else if ("eq1_freq_on" == key_cc) pCurDef->eq1_freq_oncc[num_cc] = ToInt(value);              else if ("eq1_freq_on" == key_cc || "eq1_freq" == key_cc) pCurDef->eq1_freq_oncc[num_cc] = ToInt(value);
1272              else if ("eq2_freq_on" == key_cc) pCurDef->eq2_freq_oncc[num_cc] = ToInt(value);              else if ("eq2_freq_on" == key_cc || "eq2_freq" == key_cc) pCurDef->eq2_freq_oncc[num_cc] = ToInt(value);
1273              else if ("eq3_freq_on" == key_cc) pCurDef->eq3_freq_oncc[num_cc] = ToInt(value);              else if ("eq3_freq_on" == key_cc || "eq3_freq" == key_cc) pCurDef->eq3_freq_oncc[num_cc] = ToInt(value);
1274              else if ("eq1_bw_on" == key_cc) pCurDef->eq1_bw_oncc[num_cc] = ToInt(value);              else if ("eq1_bw_on" == key_cc || "eq1_bw" == key_cc) pCurDef->eq1_bw_oncc[num_cc] = ToInt(value);
1275              else if ("eq2_bw_on" == key_cc) pCurDef->eq2_bw_oncc[num_cc] = ToInt(value);              else if ("eq2_bw_on" == key_cc || "eq2_bw" == key_cc) pCurDef->eq2_bw_oncc[num_cc] = ToInt(value);
1276              else if ("eq3_bw_on" == key_cc) pCurDef->eq3_bw_oncc[num_cc] = ToInt(value);              else if ("eq3_bw_on" == key_cc || "eq3_bw" == key_cc) pCurDef->eq3_bw_oncc[num_cc] = ToInt(value);
1277              else if ("eq1_gain_on" == key_cc) pCurDef->eq1_gain_oncc[num_cc] = ToInt(value);              else if ("eq1_gain_on" == key_cc || "eq1_gain" == key_cc) pCurDef->eq1_gain_oncc[num_cc] = ToInt(value);
1278              else if ("eq2_gain_on" == key_cc) pCurDef->eq2_gain_oncc[num_cc] = ToInt(value);              else if ("eq2_gain_on" == key_cc || "eq2_gain" == key_cc) pCurDef->eq2_gain_oncc[num_cc] = ToInt(value);
1279              else if ("eq3_gain_on" == key_cc) pCurDef->eq3_gain_oncc[num_cc] = ToInt(value);              else if ("eq3_gain_on" == key_cc || "eq3_gain" == key_cc) pCurDef->eq3_gain_oncc[num_cc] = ToInt(value);
1280                else std::cerr << "The opcode '" << key << "' is unsupported by libsfz!" << std::endl;
1281            }
1282            // v2 envelope generators
1283            else if (sscanf(key.c_str(), "eg%d%n", &x, &y)) {
1284                const char* s = key.c_str() + y;
1285                if (sscanf(s, "_time%d", &y)) egnode(x, y).time = ToFloat(value);
1286                else if (sscanf(s, "_level%d", &y)) egnode(x, y).level = ToFloat(value);
1287                else if (sscanf(s, "_shape%d", &y)) egnode(x, y).shape = ToFloat(value);
1288                else if (sscanf(s, "_curve%d", &y)) egnode(x, y).curve = ToFloat(value);
1289                else if (strcmp(s, "_sustain") == 0) eg(x).sustain = ToInt(value);
1290                else if (strcmp(s, "_loop") == 0) eg(x).loop = ToInt(value);
1291                else if (strcmp(s, "_loop_count") == 0) eg(x).loop_count = ToInt(value);
1292                else if (strcmp(s, "_amplitude") == 0) eg(x).amplitude = ToFloat(value);
1293                else if (strcmp(s, "_cutoff") == 0) eg(x).cutoff = ToFloat(value);
1294              else std::cerr << "The opcode '" << key << "' is unsupported by libsfz!" << std::endl;              else std::cerr << "The opcode '" << key << "' is unsupported by libsfz!" << std::endl;
1295          }          }
1296          // Deprecated opcodes  
1297            // v1 envelope generators
1298          else if ("ampeg_delay"   == key) pCurDef->ampeg_delay = ToFloat(value);          else if ("ampeg_delay"   == key) pCurDef->ampeg_delay = ToFloat(value);
1299          else if ("ampeg_start"   == key) pCurDef->ampeg_start = ToFloat(value);          else if ("ampeg_start"   == key) pCurDef->ampeg_start = ToFloat(value);
1300          else if ("ampeg_attack"   == key) pCurDef->ampeg_attack = ToFloat(value);          else if ("ampeg_attack"   == key) pCurDef->ampeg_attack = ToFloat(value);
# Line 1203  namespace sfz Line 1316  namespace sfz
1316          else if ("pitcheg_decay"   == key) pCurDef->pitcheg_decay = ToFloat(value);          else if ("pitcheg_decay"   == key) pCurDef->pitcheg_decay = ToFloat(value);
1317          else if ("pitcheg_sustain"   == key) pCurDef->pitcheg_sustain = ToFloat(value);          else if ("pitcheg_sustain"   == key) pCurDef->pitcheg_sustain = ToFloat(value);
1318          else if ("pitcheg_release"   == key) pCurDef->pitcheg_release = ToFloat(value);          else if ("pitcheg_release"   == key) pCurDef->pitcheg_release = ToFloat(value);
1319    
1320            // v1 LFO
1321            else if ("amplfo_delay" == key) pCurDef->amplfo_delay = ToFloat(value);
1322            else if ("amplfo_fade" == key) pCurDef->amplfo_fade = ToFloat(value);
1323            else if ("amplfo_freq" == key) pCurDef->amplfo_freq = ToFloat(value);
1324            else if ("amplfo_depth" == key) pCurDef->amplfo_depth = ToFloat(value);
1325            else if ("fillfo_delay" == key) pCurDef->fillfo_delay = ToFloat(value);
1326            else if ("fillfo_fade" == key) pCurDef->fillfo_fade = ToFloat(value);
1327            else if ("fillfo_freq" == key) pCurDef->fillfo_freq = ToFloat(value);
1328            else if ("fillfo_depth" == key) pCurDef->fillfo_depth = ToFloat(value);
1329            else if ("pitchlfo_delay" == key) pCurDef->pitchlfo_delay = ToFloat(value);
1330            else if ("pitchlfo_fade" == key) pCurDef->pitchlfo_fade = ToFloat(value);
1331            else if ("pitchlfo_freq" == key) pCurDef->pitchlfo_freq = ToFloat(value);
1332            else if ("pitchlfo_depth" == key) pCurDef->pitchlfo_depth = ToInt(value);
1333    
1334          else {          else {
1335              std::cerr << "The opcode '" << key << "' is unsupported by libsfz!" << std::endl;              std::cerr << "The opcode '" << key << "' is unsupported by libsfz!" << std::endl;
1336          }          }
1337      }      }
1338    
1339        int File::parseKey(const std::string& s) {
1340            int i;
1341            std::istringstream iss(s);
1342            if (isdigit(iss.peek())) {
1343                iss >> i;
1344            } else {
1345                switch (tolower(iss.get())) {
1346                case 'c': i = 0; break;
1347                case 'd': i = 2; break;
1348                case 'e': i = 4; break;
1349                case 'f': i = 5; break;
1350                case 'g': i = 7; break;
1351                case 'a': i = 9; break;
1352                case 'b': i = 11; break;
1353                default:
1354                    std::cerr << "Not a note: " << s << std::endl;
1355                    return 0;
1356                }
1357                if (iss.peek() == '#') {
1358                    i++;
1359                    iss.get();
1360                } else if (tolower(iss.peek()) == 'b') {
1361                    i--;
1362                    iss.get();
1363                }
1364                int octave;
1365                if (!(iss >> octave)) {
1366                    std::cerr << "Not a note: " << s << std::endl;
1367                    return 0;
1368                }
1369                i += (octave + 1) * 12;
1370            }
1371            return i + note_offset + 12 * octave_offset;
1372        }
1373    
1374        EGNode::EGNode() : time(0), level(0), shape(0), curve(0) {
1375        }
1376    
1377        EG::EG() :
1378            sustain(0), loop(0), loop_count(0),
1379            amplitude(0), cutoff(0) {
1380        }
1381    
1382        EG& File::eg(int x) {
1383            while (pCurDef->eg.size() <= x) {
1384                pCurDef->eg.add(EG());
1385            }
1386            return pCurDef->eg[x];
1387        }
1388    
1389        EGNode& File::egnode(int x, int y) {
1390            EG& e = eg(x);
1391            while (e.node.size() <= y) {
1392                e.node.add(EGNode());
1393            }
1394            return e.node[y];
1395        }
1396    
1397  } // !namespace sfz  } // !namespace sfz

Legend:
Removed from v.2018  
changed lines
  Added in v.2086

  ViewVC Help
Powered by ViewVC