/[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 2222 by iliev, Thu Jul 28 18:24:12 2011 UTC revision 2232 by iliev, Mon Aug 8 13:40:04 2011 UTC
# Line 198  namespace sfz Line 198  namespace sfz
198          this->name = name;          this->name = name;
199          this->pSampleManager = pSampleManager ? pSampleManager : this;          this->pSampleManager = pSampleManager ? pSampleManager : this;
200          pLookupTable = 0;          pLookupTable = 0;
201            
202            // The first 6 curves are defined internally (actually 7 with the one at index 0)
203            Curve c;
204            for (int i = 0; i < 128; i++) c.v[i] = i / 127.0f;
205            curves.add(c); curves.add(c); curves.add(c); curves.add(c);
206            curves.add(c); curves.add(c); curves.add(c);
207            ///////
208      }      }
209    
210      Instrument::~Instrument()      Instrument::~Instrument()
# Line 315  namespace sfz Line 322  namespace sfz
322    
323          // amplifier          // amplifier
324          volume = 0;          volume = 0;
325            volume_oncc.clear();
326            volume_curvecc.clear();
327            volume_smoothcc.clear();
328          pan = 0;          pan = 0;
329          width = 100;          width = 100;
330          position = 0;          position = 0;
# Line 435  namespace sfz Line 445  namespace sfz
445              eq1_gain_oncc.set(i, 0);              eq1_gain_oncc.set(i, 0);
446              eq2_gain_oncc.set(i, 0);              eq2_gain_oncc.set(i, 0);
447              eq3_gain_oncc.set(i, 0);              eq3_gain_oncc.set(i, 0);
448                
449                pitchlfo_depthcc.set(i, 0);
450          }          }
451          cutoff_cc = 0;          cutoff_cc = 0;
452    
453          eg.clear();          eg.clear();
454            lfos.clear();
455    
456          // deprecated          // deprecated
457          ampeg_delay    = 0;          ampeg_delay    = 0;
# Line 455  namespace sfz Line 468  namespace sfz
468          ampeg_vel2decay   = 0;          ampeg_vel2decay   = 0;
469          ampeg_vel2sustain = 0;          ampeg_vel2sustain = 0;
470          ampeg_vel2release = 0;          ampeg_vel2release = 0;
471            
472            ampeg_delaycc.clear();
473            ampeg_startcc.clear();
474            ampeg_attackcc.clear();
475            ampeg_holdcc.clear();
476            ampeg_decaycc.clear();
477            ampeg_sustaincc.clear();
478            ampeg_releasecc.clear();
479    
480          fileg_delay    = 0;          fileg_delay    = 0;
481          fileg_start    = 0; //in percentage          fileg_start    = 0; //in percentage
# Line 490  namespace sfz Line 511  namespace sfz
511    
512          amplfo_delay     = 0;          amplfo_delay     = 0;
513          amplfo_fade      = 0;          amplfo_fade      = 0;
514          amplfo_freq      = 0;          amplfo_freq      = -1; /* -1 is used to determine whether the LFO was initialized */
515          amplfo_depth     = 0;          amplfo_depth     = 0;
516            amplfo_freqcc.clear();
517    
518          fillfo_delay     = 0;          fillfo_delay     = 0;
519          fillfo_fade      = 0;          fillfo_fade      = 0;
520          fillfo_freq      = 0;          fillfo_freq      = -1; /* -1 is used to determine whether the LFO was initialized */
521          fillfo_depth     = 0;          fillfo_depth     = 0;
522            fillfo_freqcc.clear();
523    
524          pitchlfo_delay   = 0;          pitchlfo_delay   = 0;
525          pitchlfo_fade    = 0;          pitchlfo_fade    = 0;
526          pitchlfo_freq    = 0;          pitchlfo_freq    = -1; /* -1 is used to determine whether the LFO was initialized */
527          pitchlfo_depth   = 0;          pitchlfo_depth   = 0;
528            pitchlfo_freqcc.clear();
529      }      }
530    
531      Region*      Region*
# Line 581  namespace sfz Line 605  namespace sfz
605    
606          // amplifier          // amplifier
607          region->volume = volume;          region->volume = volume;
608            region->volume_oncc = volume_oncc;
609            region->volume_curvecc = volume_curvecc;
610            region->volume_smoothcc = volume_smoothcc;
611          region->pan = pan;          region->pan = pan;
612          region->width = width;          region->width = width;
613          region->position = position;          region->position = position;
# Line 700  namespace sfz Line 727  namespace sfz
727          region->ampeg_vel2decay   = ampeg_vel2decay;          region->ampeg_vel2decay   = ampeg_vel2decay;
728          region->ampeg_vel2sustain = ampeg_vel2sustain;          region->ampeg_vel2sustain = ampeg_vel2sustain;
729          region->ampeg_vel2release = ampeg_vel2release;          region->ampeg_vel2release = ampeg_vel2release;
730            
731            region->ampeg_delaycc   = ampeg_delaycc;
732            region->ampeg_startcc   = ampeg_startcc;
733            region->ampeg_attackcc  = ampeg_attackcc;
734            region->ampeg_holdcc    = ampeg_holdcc;
735            region->ampeg_decaycc   = ampeg_decaycc;
736            region->ampeg_sustaincc = ampeg_sustaincc;
737            region->ampeg_releasecc = ampeg_releasecc;
738    
739          region->fileg_delay    = fileg_delay;          region->fileg_delay    = fileg_delay;
740          region->fileg_start    = fileg_start;          region->fileg_start    = fileg_start;
# Line 737  namespace sfz Line 772  namespace sfz
772          region->amplfo_fade      = amplfo_fade;          region->amplfo_fade      = amplfo_fade;
773          region->amplfo_freq      = amplfo_freq;          region->amplfo_freq      = amplfo_freq;
774          region->amplfo_depth     = amplfo_depth;          region->amplfo_depth     = amplfo_depth;
775            
776            region->amplfo_freqcc    = amplfo_freqcc;
777    
778          region->fillfo_delay     = fillfo_delay;          region->fillfo_delay     = fillfo_delay;
779          region->fillfo_fade      = fillfo_fade;          region->fillfo_fade      = fillfo_fade;
780          region->fillfo_freq      = fillfo_freq;          region->fillfo_freq      = fillfo_freq;
781          region->fillfo_depth     = fillfo_depth;          region->fillfo_depth     = fillfo_depth;
782            
783            region->fillfo_freqcc    = fillfo_freqcc;
784    
785          region->pitchlfo_delay   = pitchlfo_delay;          region->pitchlfo_delay   = pitchlfo_delay;
786          region->pitchlfo_fade    = pitchlfo_fade;          region->pitchlfo_fade    = pitchlfo_fade;
787          region->pitchlfo_freq    = pitchlfo_freq;          region->pitchlfo_freq    = pitchlfo_freq;
788          region->pitchlfo_depth   = pitchlfo_depth;          region->pitchlfo_depth   = pitchlfo_depth;
789            
790            region->pitchlfo_depthcc = pitchlfo_depthcc;
791            region->pitchlfo_freqcc  = pitchlfo_freqcc;
792            
793            region->eg = eg;
794            region->lfos = lfos;
795    
796          return region;          return region;
797      }      }
# Line 919  namespace sfz Line 964  namespace sfz
964          for (int i = 0 ; i < 128 ; i++) {          for (int i = 0 ; i < 128 ; i++) {
965              _instrument->pLookupTableCC[i] = new LookupTable(_instrument, i);              _instrument->pLookupTableCC[i] = new LookupTable(_instrument, i);
966          }          }
967            
968            for (int k = 0; k < _instrument->regions.size(); k++) {
969                Region* r = _instrument->regions[k];
970                
971                copyCurves(r->volume_curvecc, r->volume_oncc);
972                copySmoothValues(r->volume_smoothcc, r->volume_oncc);
973                
974                r->volume_curvecc.clear();
975                r->volume_smoothcc.clear();
976            }
977      }      }
978    
979      File::~File()      File::~File()
# Line 932  namespace sfz Line 987  namespace sfz
987      {      {
988          return _instrument;          return _instrument;
989      }      }
990        
991        void File::copyCurves(LinuxSampler::ArrayList<CC>& curves, LinuxSampler::ArrayList<CC>& dest) {
992            for (int i = 0; i < curves.size(); i++) {
993                for (int j = 0; j < dest.size(); j++) {
994                    if (curves[i].Controller == dest[j].Controller) {
995                        dest[j].Curve = curves[i].Curve;
996                    }
997                }
998            }
999        }
1000        
1001        void File::copySmoothValues(LinuxSampler::ArrayList<CC>& smooths, LinuxSampler::ArrayList<CC>& dest) {
1002            for (int i = 0; i < smooths.size(); i++) {
1003                for (int j = 0; j < dest.size(); j++) {
1004                    if (smooths[i].Controller == dest[j].Controller) {
1005                        dest[j].Smooth = smooths[i].Smooth;
1006                    }
1007                }
1008            }
1009        }
1010    
1011      void      void
1012      File::push_header(std::string token)      File::push_header(std::string token)
# Line 957  namespace sfz Line 1032  namespace sfz
1032              octave_offset = 0;              octave_offset = 0;
1033              note_offset = 0;              note_offset = 0;
1034          }          }
1035            else if (token == "<curve>")
1036            {
1037                _current_section = CURVE;
1038                _instrument->curves.add(Curve());
1039                _current_curve = &_instrument->curves[_instrument->curves.size() - 1];
1040            }
1041          else          else
1042          {          {
1043              _current_section = UNKNOWN;              _current_section = UNKNOWN;
# Line 973  namespace sfz Line 1054  namespace sfz
1054          std::string::size_type delimiter_index = token.find('=');          std::string::size_type delimiter_index = token.find('=');
1055          std::string key = token.substr(0, delimiter_index);          std::string key = token.substr(0, delimiter_index);
1056          std::string value = token.substr(delimiter_index + 1);          std::string value = token.substr(delimiter_index + 1);
1057          int x, y;          int x, y, z;
1058            
1059            if (_current_section == CURVE) {
1060                if (sscanf(key.c_str(), "v%d", &x)) {
1061                    if (x < 0 || x > 127) {
1062                        std::cerr << "Invalid curve index: " << x << std::endl;
1063                    }
1064                    _current_curve->v[x] = check(key, 0.0f, 1.0f, ToFloat(value));
1065                } else {
1066                    std::cerr << "The opcode '" << key << "' in section <curve> is unsupported by libsfz!" << std::endl;
1067                }
1068                
1069                return;
1070            }
1071    
1072          // sample definition          // sample definition
1073          if ("sample" == key)          if ("sample" == key)
# Line 1104  namespace sfz Line 1198  namespace sfz
1198          else if ("amp_keycenter" == key) pCurDef->amp_keycenter = parseKey(value);          else if ("amp_keycenter" == key) pCurDef->amp_keycenter = parseKey(value);
1199          else if ("amp_veltrack"  == key) pCurDef->amp_veltrack = ToFloat(value);          else if ("amp_veltrack"  == key) pCurDef->amp_veltrack = ToFloat(value);
1200          else if ("amp_random"  == key) pCurDef->amp_random = ToFloat(value);          else if ("amp_random"  == key) pCurDef->amp_random = ToFloat(value);
1201          else if ("rt_decay"    == key) pCurDef->rt_decay = ToFloat(value);          else if ("rt_decay" == key || "rtdecay" == key) pCurDef->rt_decay = ToFloat(value);
1202          else if ("xfin_lokey"  == key) pCurDef->xfin_lokey = parseKey(value);          else if ("xfin_lokey"  == key) pCurDef->xfin_lokey = parseKey(value);
1203          else if ("xfin_hikey"  == key) pCurDef->xfin_hikey = parseKey(value);          else if ("xfin_hikey"  == key) pCurDef->xfin_hikey = parseKey(value);
1204          else if ("xfout_lokey" == key) pCurDef->xfout_lokey = parseKey(value);          else if ("xfout_lokey" == key) pCurDef->xfout_lokey = parseKey(value);
# Line 1138  namespace sfz Line 1232  namespace sfz
1232          else if ("pitch_random" == key) pCurDef->pitch_random = ToInt(value);          else if ("pitch_random" == key) pCurDef->pitch_random = ToInt(value);
1233          else if ("bend_up" == key || "bendup" == key) pCurDef->bend_up = ToInt(value);          else if ("bend_up" == key || "bendup" == key) pCurDef->bend_up = ToInt(value);
1234          else if ("bend_down" == key || "benddown" == key) pCurDef->bend_down = ToInt(value);          else if ("bend_down" == key || "benddown" == key) pCurDef->bend_down = ToInt(value);
1235          else if ("bend_step" == key) pCurDef->bend_step = ToInt(value);          else if ("bend_step" == key || "bendstep" == key) pCurDef->bend_step = ToInt(value);
1236    
1237          // filter          // filter
1238          else if ("fil_type" == key || "filtype" == key)          else if ("fil_type" == key || "filtype" == key)
# Line 1212  namespace sfz Line 1306  namespace sfz
1306          else if (sscanf(key.c_str(), "amp_velcurve_%d", &x)) {          else if (sscanf(key.c_str(), "amp_velcurve_%d", &x)) {
1307              pCurDef->amp_velcurve.set(x, ToFloat(value));              pCurDef->amp_velcurve.set(x, ToFloat(value));
1308          }          }
1309            
         // CCs  
         else if (key.find("cc") != std::string::npos)  
         {  
             std::string::size_type delimiter_index = key.find("cc");  
             std::string key_cc = key.substr(0, delimiter_index);  
             int num_cc = ToInt(key.substr(delimiter_index + 2));  
   
             // input controls  
             if ("lo" == key_cc) pCurDef->locc.set(num_cc, ToInt(value));  
             else if ("hi" == key_cc) pCurDef->hicc.set(num_cc, ToInt(value));  
             else if ("start_lo" == key_cc) pCurDef->start_locc.set(num_cc, ToInt(value));  
             else if ("start_hi" == key_cc) pCurDef->start_hicc.set(num_cc, ToInt(value));  
             else if ("stop_lo" == key_cc) pCurDef->stop_locc.set(num_cc, ToInt(value));  
             else if ("stop_hi" == key_cc) pCurDef->stop_hicc.set(num_cc, ToInt(value));  
             else if ("on_lo" == key_cc) pCurDef->on_locc.set(num_cc, ToInt(value));  
             else if ("on_hi" == key_cc) pCurDef->on_hicc.set(num_cc, ToInt(value));  
   
             // sample player  
             else if ("delay_on" == key_cc) pCurDef->delay_oncc.set(num_cc, ToFloat(value));  
             else if ("delay_samples_on" == key_cc) pCurDef->delay_samples_oncc.set(num_cc, ToInt(value));  
             else if ("offset_on" == key_cc) pCurDef->offset_oncc.set(num_cc, ToInt(value));  
   
             // amplifier  
             else if ("gain_on"  == key_cc || "gain_" == key_cc) pCurDef->gain_oncc.set(num_cc, ToFloat(value));  
             else if ("xfin_lo"  == key_cc) pCurDef->xfin_locc.set(num_cc, ToInt(value));  
             else if ("xfin_hi"  == key_cc) pCurDef->xfin_hicc.set(num_cc, ToInt(value));  
             else if ("xfout_lo" == key_cc) pCurDef->xfout_locc.set(num_cc, ToInt(value));  
             else if ("xfout_hi" == key_cc) pCurDef->xfout_hicc.set(num_cc, ToInt(value));  
   
             // filter  
             else if ("cutoff_on"  == key_cc || "cutoff_" == key_cc) {  
                 pCurDef->cutoff_oncc.set(num_cc, ToInt(value));  
                 pCurDef->cutoff_cc = num_cc;  
             } else if ("cutoff2_on" == key_cc) pCurDef->cutoff2_oncc.set(num_cc, ToInt(value));  
             else if ("cutoff_smooth"  == key_cc) pCurDef->cutoff_smoothcc.set(num_cc, ToInt(value));  
             else if ("cutoff2_smooth" == key_cc) pCurDef->cutoff2_smoothcc.set(num_cc, ToInt(value));  
             else if ("cutoff_step"  == key_cc) pCurDef->cutoff_stepcc.set(num_cc, ToInt(value));  
             else if ("cutoff2_step" == key_cc) pCurDef->cutoff2_stepcc.set(num_cc, ToInt(value));  
             else if ("cutoff_curve" == key_cc) pCurDef->cutoff_curvecc.set(num_cc, ToInt(value));  
             else if ("cutoff2_curve" == key_cc) pCurDef->cutoff2_curvecc.set(num_cc, ToInt(value));  
             else if ("resonance_on" == key_cc) pCurDef->resonance_oncc.set(num_cc, ToInt(value));  
             else if ("resonance2_on" == key_cc) pCurDef->resonance2_oncc.set(num_cc, ToInt(value));  
             else if ("resonance_smooth" == key_cc) pCurDef->resonance_smoothcc.set(num_cc, ToInt(value));  
             else if ("resonance2_smooth" == key_cc) pCurDef->resonance2_smoothcc.set(num_cc, ToInt(value));  
             else if ("resonance_step" == key_cc) pCurDef->resonance_stepcc.set(num_cc, ToInt(value));  
             else if ("resonance2_step" == key_cc) pCurDef->resonance2_stepcc.set(num_cc, ToInt(value));  
             else if ("resonance_curve" == key_cc) pCurDef->resonance_curvecc.set(num_cc, ToInt(value));  
             else if ("resonance2_curve" == key_cc) pCurDef->resonance2_curvecc.set(num_cc, ToInt(value));  
   
             // per voice equalizer  
             else if ("eq1_freq_on" == key_cc || "eq1_freq" == key_cc) pCurDef->eq1_freq_oncc.set(num_cc, ToInt(value));  
             else if ("eq2_freq_on" == key_cc || "eq2_freq" == key_cc) pCurDef->eq2_freq_oncc.set(num_cc, ToInt(value));  
             else if ("eq3_freq_on" == key_cc || "eq3_freq" == key_cc) pCurDef->eq3_freq_oncc.set(num_cc, ToInt(value));  
             else if ("eq1_bw_on" == key_cc || "eq1_bw" == key_cc) pCurDef->eq1_bw_oncc.set(num_cc, ToInt(value));  
             else if ("eq2_bw_on" == key_cc || "eq2_bw" == key_cc) pCurDef->eq2_bw_oncc.set(num_cc, ToInt(value));  
             else if ("eq3_bw_on" == key_cc || "eq3_bw" == key_cc) pCurDef->eq3_bw_oncc.set(num_cc, ToInt(value));  
             else if ("eq1_gain_on" == key_cc || "eq1_gain" == key_cc) pCurDef->eq1_gain_oncc.set(num_cc, ToInt(value));  
             else if ("eq2_gain_on" == key_cc || "eq2_gain" == key_cc) pCurDef->eq2_gain_oncc.set(num_cc, ToInt(value));  
             else if ("eq3_gain_on" == key_cc || "eq3_gain" == key_cc) pCurDef->eq3_gain_oncc.set(num_cc, ToInt(value));  
             else std::cerr << "The opcode '" << key << "' is unsupported by libsfz!" << std::endl;  
         }  
1310          // v2 envelope generators          // v2 envelope generators
1311          else if (sscanf(key.c_str(), "eg%d%n", &x, &y)) {          else if (sscanf(key.c_str(), "eg%d%n", &x, &y)) {
1312              const char* s = key.c_str() + y;              const char* s = key.c_str() + y;
1313              if (sscanf(s, "_time%d", &y)) egnode(x, y).time = ToFloat(value);              if (sscanf(s, "_time%d%n", &y, &z)) {
1314              else if (sscanf(s, "_level%d", &y)) egnode(x, y).level = ToFloat(value);                  const char* s2 = s + z;
1315                    if (strcmp(s2, "") == 0) egnode(x, y).time = check(key, 0.0f, 100.0f, ToFloat(value));
1316                    else if (sscanf(s2, "_oncc%d", &z)) egnode(x, y).time_oncc.add( CC(z, check(key, 0.0f, 100.0f, ToFloat(value))) );
1317                } else if (sscanf(s, "_level%d%n", &y, &z)) {
1318                    const char* s2 = s + z;
1319                    if (strcmp(s2, "") == 0) egnode(x, y).level = check(key, 0.0f, 1.0f, ToFloat(value));
1320                    else if (sscanf(s2, "_oncc%d", &z)) egnode(x, y).level_oncc.add( CC(z, check(key, 0.0f, 1.0f, ToFloat(value))) );
1321                }
1322              else if (sscanf(s, "_shape%d", &y)) egnode(x, y).shape = ToFloat(value);              else if (sscanf(s, "_shape%d", &y)) egnode(x, y).shape = ToFloat(value);
1323              else if (sscanf(s, "_curve%d", &y)) egnode(x, y).curve = ToFloat(value);              else if (sscanf(s, "_curve%d", &y)) egnode(x, y).curve = ToFloat(value);
1324              else if (strcmp(s, "_sustain") == 0) eg(x).sustain = ToInt(value);              else if (strcmp(s, "_sustain") == 0) eg(x).sustain = ToInt(value);
# Line 1351  namespace sfz Line 1391  namespace sfz
1391          else if (sscanf(key.c_str(), "lfo%d%n", &x, &y)) {          else if (sscanf(key.c_str(), "lfo%d%n", &x, &y)) {
1392              const char* s = key.c_str() + y;              const char* s = key.c_str() + y;
1393              if (strcmp(s, "_freq") == 0) lfo(x).freq = check(key, 0.0f, 20.0f, ToFloat(value));              if (strcmp(s, "_freq") == 0) lfo(x).freq = check(key, 0.0f, 20.0f, ToFloat(value));
1394                else if (sscanf(s, "_freq_oncc%d", &y)) lfo(x).freq_oncc.add( CC(y, check(key, 0.0f, 20.0f, ToFloat(value))) );
1395              else if (strcmp(s, "_wave") == 0) lfo(x).wave = ToInt(value);              else if (strcmp(s, "_wave") == 0) lfo(x).wave = ToInt(value);
1396              else if (strcmp(s, "_delay") == 0) lfo(x).delay = check(key, 0.0f, 100.0f, ToFloat(value));              else if (strcmp(s, "_delay") == 0) lfo(x).delay = check(key, 0.0f, 100.0f, ToFloat(value));
1397                else if (strcmp(s, "_fade") == 0) lfo(x).fade = check(key, 0.0f, 100.0f, ToFloat(value));
1398                else if (sscanf(s, "_fade_oncc%d", &y)) lfo(x).fade_oncc.add( CC(y, check(key, 0.0f, 100.0f, ToFloat(value))) );
1399                else if (strcmp(s, "_phase") == 0) lfo(x).phase = check(key, 0.0f, 360.0f, ToFloat(value));
1400                else if (sscanf(s, "_phase_oncc%d", &y)) lfo(x).phase_oncc.add( CC(y, check(key, 0.0f, 360.0f, ToFloat(value))) );
1401              else if (strcmp(s, "_volume") == 0) lfo(x).volume = check(key, -144.0f, 6.0f, ToFloat(value));              else if (strcmp(s, "_volume") == 0) lfo(x).volume = check(key, -144.0f, 6.0f, ToFloat(value));
1402              else if (strcmp(s, "_pitch") == 0) lfo(x).pitch = check(key, -9600, 9600, ToInt(value));              else if (strcmp(s, "_pitch") == 0) lfo(x).pitch = check(key, -9600, 9600, ToInt(value));
1403                else if (sscanf(s, "_pitch_oncc%d", &y)) lfo(x).pitch_oncc.add( CC(y, check(key, -9600, 9600, ToInt(value))) );
1404              else if (strcmp(s, "_cutoff") == 0) lfo(x).cutoff = check(key, -9600, 9600, ToInt(value));              else if (strcmp(s, "_cutoff") == 0) lfo(x).cutoff = check(key, -9600, 9600, ToInt(value));
1405              else if (strcmp(s, "_resonance") == 0) lfo(x).resonance = check(key, 0.0f, 40.0f, ToFloat(value));              else if (strcmp(s, "_resonance") == 0) lfo(x).resonance = check(key, 0.0f, 40.0f, ToFloat(value));
1406              else if (strcmp(s, "_pan") == 0) lfo(x).pan = check(key, -100.0f, 100.0f, ToFloat(value));              else if (strcmp(s, "_pan") == 0) lfo(x).pan = check(key, -100.0f, 100.0f, ToFloat(value));
1407              else std::cerr << "The opcode '" << key << "' is unsupported by libsfz!" << std::endl;              else std::cerr << "The opcode '" << key << "' is unsupported by libsfz!" << std::endl;
1408          }          }
1409            
1410            // CCs
1411            else if (key.find("cc") != std::string::npos)
1412            {
1413                std::string::size_type delimiter_index = key.find("cc");
1414                std::string key_cc = key.substr(0, delimiter_index);
1415                int num_cc = ToInt(key.substr(delimiter_index + 2));
1416    
1417                // input controls
1418                if ("lo" == key_cc) pCurDef->locc.set(num_cc, ToInt(value));
1419                else if ("hi" == key_cc) pCurDef->hicc.set(num_cc, ToInt(value));
1420                else if ("start_lo" == key_cc) pCurDef->start_locc.set(num_cc, ToInt(value));
1421                else if ("start_hi" == key_cc) pCurDef->start_hicc.set(num_cc, ToInt(value));
1422                else if ("stop_lo" == key_cc) pCurDef->stop_locc.set(num_cc, ToInt(value));
1423                else if ("stop_hi" == key_cc) pCurDef->stop_hicc.set(num_cc, ToInt(value));
1424                else if ("on_lo" == key_cc) pCurDef->on_locc.set(num_cc, ToInt(value));
1425                else if ("on_hi" == key_cc) pCurDef->on_hicc.set(num_cc, ToInt(value));
1426    
1427                // sample player
1428                else if ("delay_on" == key_cc) pCurDef->delay_oncc.set(num_cc, ToFloat(value));
1429                else if ("delay_samples_on" == key_cc) pCurDef->delay_samples_oncc.set(num_cc, ToInt(value));
1430                else if ("offset_on" == key_cc) pCurDef->offset_oncc.set(num_cc, ToInt(value));
1431    
1432                // amplifier
1433                else if ("gain_on"  == key_cc || "gain_" == key_cc) pCurDef->gain_oncc.set(num_cc, ToFloat(value));
1434                else if ("xfin_lo"  == key_cc) pCurDef->xfin_locc.set(num_cc, ToInt(value));
1435                else if ("xfin_hi"  == key_cc) pCurDef->xfin_hicc.set(num_cc, ToInt(value));
1436                else if ("xfout_lo" == key_cc) pCurDef->xfout_locc.set(num_cc, ToInt(value));
1437                else if ("xfout_hi" == key_cc) pCurDef->xfout_hicc.set(num_cc, ToInt(value));
1438    
1439                // filter
1440                else if ("cutoff_on"  == key_cc || "cutoff_" == key_cc) {
1441                    pCurDef->cutoff_oncc.set(num_cc, ToInt(value));
1442                    pCurDef->cutoff_cc = num_cc;
1443                } else if ("cutoff2_on" == key_cc) pCurDef->cutoff2_oncc.set(num_cc, ToInt(value));
1444                else if ("cutoff_smooth"  == key_cc) pCurDef->cutoff_smoothcc.set(num_cc, ToInt(value));
1445                else if ("cutoff2_smooth" == key_cc) pCurDef->cutoff2_smoothcc.set(num_cc, ToInt(value));
1446                else if ("cutoff_step"  == key_cc) pCurDef->cutoff_stepcc.set(num_cc, ToInt(value));
1447                else if ("cutoff2_step" == key_cc) pCurDef->cutoff2_stepcc.set(num_cc, ToInt(value));
1448                else if ("cutoff_curve" == key_cc) pCurDef->cutoff_curvecc.set(num_cc, ToInt(value));
1449                else if ("cutoff2_curve" == key_cc) pCurDef->cutoff2_curvecc.set(num_cc, ToInt(value));
1450                else if ("resonance_on" == key_cc) pCurDef->resonance_oncc.set(num_cc, ToInt(value));
1451                else if ("resonance2_on" == key_cc) pCurDef->resonance2_oncc.set(num_cc, ToInt(value));
1452                else if ("resonance_smooth" == key_cc) pCurDef->resonance_smoothcc.set(num_cc, ToInt(value));
1453                else if ("resonance2_smooth" == key_cc) pCurDef->resonance2_smoothcc.set(num_cc, ToInt(value));
1454                else if ("resonance_step" == key_cc) pCurDef->resonance_stepcc.set(num_cc, ToInt(value));
1455                else if ("resonance2_step" == key_cc) pCurDef->resonance2_stepcc.set(num_cc, ToInt(value));
1456                else if ("resonance_curve" == key_cc) pCurDef->resonance_curvecc.set(num_cc, ToInt(value));
1457                else if ("resonance2_curve" == key_cc) pCurDef->resonance2_curvecc.set(num_cc, ToInt(value));
1458    
1459                // per voice equalizer
1460                else if ("eq1_freq_on" == key_cc || "eq1_freq" == key_cc) pCurDef->eq1_freq_oncc.set(num_cc, ToInt(value));
1461                else if ("eq2_freq_on" == key_cc || "eq2_freq" == key_cc) pCurDef->eq2_freq_oncc.set(num_cc, ToInt(value));
1462                else if ("eq3_freq_on" == key_cc || "eq3_freq" == key_cc) pCurDef->eq3_freq_oncc.set(num_cc, ToInt(value));
1463                else if ("eq1_bw_on" == key_cc || "eq1_bw" == key_cc) pCurDef->eq1_bw_oncc.set(num_cc, ToInt(value));
1464                else if ("eq2_bw_on" == key_cc || "eq2_bw" == key_cc) pCurDef->eq2_bw_oncc.set(num_cc, ToInt(value));
1465                else if ("eq3_bw_on" == key_cc || "eq3_bw" == key_cc) pCurDef->eq3_bw_oncc.set(num_cc, ToInt(value));
1466                else if ("eq1_gain_on" == key_cc || "eq1_gain" == key_cc) pCurDef->eq1_gain_oncc.set(num_cc, ToInt(value));
1467                else if ("eq2_gain_on" == key_cc || "eq2_gain" == key_cc) pCurDef->eq2_gain_oncc.set(num_cc, ToInt(value));
1468                else if ("eq3_gain_on" == key_cc || "eq3_gain" == key_cc) pCurDef->eq3_gain_oncc.set(num_cc, ToInt(value));
1469                
1470                else if ("ampeg_delay"   == key_cc) pCurDef->ampeg_delaycc.add( CC(num_cc, check(key, -100.0f, 100.0f, ToFloat(value))) );
1471                else if ("ampeg_start"   == key_cc) pCurDef->ampeg_startcc.add( CC(num_cc, check(key, -100.0f, 100.0f, ToFloat(value))) );
1472                else if ("ampeg_attack"  == key_cc) pCurDef->ampeg_attackcc.add( CC(num_cc, check(key, -100.0f, 100.0f, ToFloat(value))) );
1473                else if ("ampeg_hold"    == key_cc) pCurDef->ampeg_holdcc.add( CC(num_cc, check(key, -100.0f, 100.0f, ToFloat(value))) );
1474                else if ("ampeg_decay"   == key_cc) pCurDef->ampeg_decaycc.add( CC(num_cc, check(key, -100.0f, 100.0f, ToFloat(value))) );
1475                else if ("ampeg_sustain" == key_cc) pCurDef->ampeg_sustaincc.add( CC(num_cc, check(key, -100.0f, 100.0f, ToFloat(value))) );
1476                else if ("ampeg_release" == key_cc) pCurDef->ampeg_releasecc.add( CC(num_cc, check(key, -100.0f, 100.0f, ToFloat(value))) );
1477                
1478                else if ("pitchlfo_depth" == key_cc) pCurDef->pitchlfo_depthcc.set(num_cc, ToInt(value));
1479                else if ("pitchlfo_freq" == key_cc) pCurDef->pitchlfo_freqcc.add( CC(num_cc, check(key, -200.0f, 200.0f, ToFloat(value))) );
1480                else if ("fillfo_freq" == key_cc) pCurDef->fillfo_freqcc.add( CC(num_cc, check(key, -200.0f, 200.0f, ToFloat(value))) );
1481                else if ("amplfo_freq" == key_cc) pCurDef->amplfo_freqcc.add( CC(num_cc, check(key, -200.0f, 200.0f, ToFloat(value))) );
1482                else if ("volume_on" == key_cc) pCurDef->volume_oncc.add( CC(num_cc, check(key, -100.0f, 100.0f, ToFloat(value))) );
1483                else if ("volume_curve" == key_cc) pCurDef->volume_curvecc.add( CC(num_cc, 0, check(key, 0, 30000, ToInt(value))) );
1484                else if ("volume_smooth" == key_cc) pCurDef->volume_smoothcc.add( CC(num_cc, 0, -1, check(key, 0.0f, 100000.0f /* max? */, ToFloat(value))) );
1485                else std::cerr << "The opcode '" << key << "' is unsupported by libsfz!" << std::endl;
1486            }
1487    
1488          else {          else {
1489              std::cerr << "The opcode '" << key << "' is unsupported by libsfz!" << std::endl;              std::cerr << "The opcode '" << key << "' is unsupported by libsfz!" << std::endl;
# Line 1404  namespace sfz Line 1528  namespace sfz
1528    
1529      EGNode::EGNode() : time(0), level(0), shape(0), curve(0) {      EGNode::EGNode() : time(0), level(0), shape(0), curve(0) {
1530      }      }
1531        
1532        void EGNode::Copy(const EGNode& egNode) {
1533            time  = egNode.time;
1534            level = egNode.level;
1535            shape = egNode.shape;
1536            curve = egNode.curve;
1537            
1538            time_oncc = egNode.time_oncc;
1539            level_oncc = egNode.level_oncc;
1540        }
1541    
1542      EG::EG() :      EG::EG() :
1543          sustain(0), loop(0), loop_count(0),          sustain(0), loop(0), loop_count(0),
1544          amplitude(0), cutoff(0) {          amplitude(0), cutoff(0) {
1545      }      }
1546        
1547        void EG::Copy(const EG& eg) {
1548            sustain    = eg.sustain;
1549            loop       = eg.loop;
1550            loop_count = eg.loop_count;
1551            amplitude  = eg.amplitude;
1552            cutoff     = eg.cutoff;
1553            node       = eg.node;
1554        }
1555        
1556        LFO::LFO(): freq (-1),/* -1 is used to determine whether the LFO was initialized */
1557                    fade(0), phase(0), wave(0), delay(0), pitch(0), cutoff(0), resonance(0), pan(0) {
1558            
1559        }
1560        
1561        void LFO::Copy(const LFO& lfo) {
1562            delay      = lfo.delay;
1563            freq       = lfo.freq;
1564            fade       = lfo.fade;
1565            phase      = lfo.phase;
1566            wave       = lfo.wave;
1567            volume     = lfo.volume;
1568            pitch      = lfo.pitch;
1569            cutoff     = lfo.cutoff;
1570            resonance  = lfo.resonance;
1571            pan        = lfo.pan;
1572            freq_oncc  = lfo.freq_oncc;
1573            fade_oncc  = lfo.fade_oncc;
1574            phase_oncc = lfo.phase_oncc;
1575            pitch_oncc = lfo.pitch_oncc;
1576        }
1577    
1578      EG& File::eg(int x) {      EG& File::eg(int x) {
1579          while (pCurDef->eg.size() <= x) {          while (pCurDef->eg.size() <= x) {
# Line 1424  namespace sfz Line 1589  namespace sfz
1589          }          }
1590          return e.node[y];          return e.node[y];
1591      }      }
       
     LFO::LFO(): freq (-1),/* -1 is used to determine whether the LFO was initialized */  
                 wave(0), delay(0), pitch(0), cutoff(0), resonance(0), pan(0) {  
           
     }  
1592    
1593      LFO& File::lfo(int x) {      LFO& File::lfo(int x) {
1594          while (pCurDef->lfos.size() <= x) {          while (pCurDef->lfos.size() <= x) {

Legend:
Removed from v.2222  
changed lines
  Added in v.2232

  ViewVC Help
Powered by ViewVC