--- linuxsampler/trunk/src/engines/sfz/sfz.cpp 2011/07/28 17:17:42 2221 +++ linuxsampler/trunk/src/engines/sfz/sfz.cpp 2012/12/02 16:30:42 2382 @@ -3,7 +3,7 @@ * LinuxSampler - modular, streaming capable sampler * * * * Copyright (C) 2008 Anders Dahnielson * - * Copyright (C) 2009 - 2011 Anders Dahnielson and Grigor Iliev * + * Copyright (C) 2009 - 2012 Anders Dahnielson and Grigor Iliev * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -31,7 +31,6 @@ #include "../../common/File.h" #include "../../common/Path.h" -#include "../../common/global_private.h" #include "LookupTable.h" namespace sfz @@ -51,7 +50,7 @@ return val; } - Sample* SampleManager::FindSample(std::string samplePath, int offset) { + Sample* SampleManager::FindSample(std::string samplePath, uint offset, int end) { std::map >::iterator it = sampleMap.begin(); for (; it != sampleMap.end(); it++) { if (it->first->GetFile() == samplePath) { @@ -59,10 +58,7 @@ * same sample with different offset as different samples * // TODO: Ignore offset when the whole sample is cached in RAM? */ - int maxOffset = it->first->MaxOffset; - if(it->first->Offset == offset || (it->first->Offset < maxOffset && offset < maxOffset)) { - return it->first; - } + if (it->first->Offset == offset && it->first->End == end) return it->first; } } @@ -112,11 +108,11 @@ Sample* Region::GetSample(bool create) { - if(pSample == NULL && create) { - int i = offset ? *offset : 0; - Sample* sf = GetInstrument()->GetSampleManager()->FindSample(sample, i); + if (pSample == NULL && create) { + uint i = offset ? *offset : 0; + Sample* sf = GetInstrument()->GetSampleManager()->FindSample(sample, i, end); if (sf != NULL) pSample = sf; // Reuse already created sample - else pSample = new Sample(sample, false, i); + else pSample = new Sample(sample, false, i, end); GetInstrument()->GetSampleManager()->AddSampleConsumer(pSample, this); } return pSample; @@ -173,9 +169,9 @@ } bool Region::HasLoop() { - bool b = loop_mode == ::sfz::LOOP_UNSET ? pSample->GetLoops() : - (loop_mode == ::sfz::LOOP_CONTINUOUS || loop_mode == ::sfz::LOOP_SUSTAIN); - return b && GetLoopStart() && GetLoopEnd() && GetLoopEnd() > GetLoopStart(); + bool b = loop_mode == LOOP_UNSET ? pSample->GetLoops() : + (loop_mode == LOOP_CONTINUOUS || loop_mode == LOOP_SUSTAIN); + return b && GetLoopEnd() > GetLoopStart(); } uint Region::GetLoopStart() { @@ -198,6 +194,13 @@ this->name = name; this->pSampleManager = pSampleManager ? pSampleManager : this; pLookupTable = 0; + + // The first 6 curves are defined internally (actually 7 with the one at index 0) + Curve c; + for (int i = 0; i < 128; i++) c.v[i] = i / 127.0f; + curves.add(c); curves.add(c); curves.add(c); curves.add(c); + curves.add(c); curves.add(c); curves.add(c); + /////// } Instrument::~Instrument() @@ -306,7 +309,7 @@ delay.unset(); delay_random.unset(); delay_beats.unset(); stop_beats.unset(); delay_samples.unset(); - end.unset(); + end = 0; loop_crossfade.unset(); offset.unset(); offset_random.unset(); loop_mode = LOOP_UNSET; @@ -315,7 +318,15 @@ // amplifier volume = 0; + volume_oncc.clear(); + volume_curvecc.clear(); + volume_smoothcc.clear(); + volume_stepcc.clear(); pan = 0; + pan_oncc.clear(); + pan_curvecc.clear(); + pan_smoothcc.clear(); + pan_stepcc.clear(); width = 100; position = 0; amp_keytrack = 0; @@ -341,6 +352,11 @@ bend_up = 200; bend_down = -200; bend_step = 1; + + pitch_oncc.clear(); + pitch_smoothcc.clear(); + pitch_curvecc.clear(); + pitch_stepcc.clear(); // filter fil_type = LPF_2P; @@ -362,6 +378,24 @@ fil2_keycenter = 60; fil2_veltrack = 0; fil2_random = 0; + + cutoff_oncc.clear(); + cutoff_smoothcc.clear(); + cutoff_curvecc.clear(); + cutoff_stepcc.clear(); + cutoff2_oncc.clear(); + cutoff2_smoothcc.clear(); + cutoff2_curvecc.clear(); + cutoff2_stepcc.clear(); + + resonance_oncc.clear(); + resonance_smoothcc.clear(); + resonance_curvecc.clear(); + resonance_stepcc.clear(); + resonance2_oncc.clear(); + resonance2_smoothcc.clear(); + resonance2_curvecc.clear(); + resonance2_stepcc.clear(); // per voice equalizer eq1_freq = 50; @@ -403,27 +437,8 @@ gain_oncc.set(i, 0); xfin_locc.set(i, 0); xfin_hicc.set(i, 0); - xfout_locc.set(i, 127); - xfout_hicc.set(i, 127); - - // filter - cutoff_oncc.set(i, 0); - cutoff_smoothcc.set(i, 0); - cutoff_stepcc.set(i, 0); - cutoff_curvecc.set(i, 0); - resonance_oncc.set(i, 0); - resonance_smoothcc.set(i, 0); - resonance_stepcc.set(i, 0); - resonance_curvecc.set(i, 0); - - cutoff2_oncc.set(i, 0); - cutoff2_smoothcc.set(i, 0); - cutoff2_stepcc.set(i, 0); - cutoff2_curvecc.set(i, 0); - resonance2_oncc.set(i, 0); - resonance2_smoothcc.set(i, 0); - resonance2_stepcc.set(i, 0); - resonance2_curvecc.set(i, 0); + xfout_locc.set(i, 0); + xfout_hicc.set(i, 0); // per voice equalizer eq1_freq_oncc.set(i, 0); @@ -436,9 +451,9 @@ eq2_gain_oncc.set(i, 0); eq3_gain_oncc.set(i, 0); } - cutoff_cc = 0; eg.clear(); + lfos.clear(); // deprecated ampeg_delay = 0; @@ -455,6 +470,14 @@ ampeg_vel2decay = 0; ampeg_vel2sustain = 0; ampeg_vel2release = 0; + + ampeg_delaycc.clear(); + ampeg_startcc.clear(); + ampeg_attackcc.clear(); + ampeg_holdcc.clear(); + ampeg_decaycc.clear(); + ampeg_sustaincc.clear(); + ampeg_releasecc.clear(); fileg_delay = 0; fileg_start = 0; //in percentage @@ -464,6 +487,23 @@ fileg_sustain = 100; // in percentage fileg_release = 0; + fileg_vel2delay = 0; + fileg_vel2attack = 0; + fileg_vel2hold = 0; + fileg_vel2decay = 0; + fileg_vel2sustain = 0; + fileg_vel2release = 0; + fileg_depth = 0; + + fileg_delay_oncc.clear(); + fileg_start_oncc.clear(); + fileg_attack_oncc.clear(); + fileg_hold_oncc.clear(); + fileg_decay_oncc.clear(); + fileg_sustain_oncc.clear(); + fileg_release_oncc.clear(); + fileg_depth_oncc.clear(); + pitcheg_delay = 0; pitcheg_start = 0; //in percentage pitcheg_attack = 0; @@ -479,21 +519,42 @@ pitcheg_vel2decay = 0; pitcheg_vel2sustain = 0; pitcheg_vel2release = 0; + + pitcheg_delay_oncc.clear(); + pitcheg_start_oncc.clear(); + pitcheg_attack_oncc.clear(); + pitcheg_hold_oncc.clear(); + pitcheg_decay_oncc.clear(); + pitcheg_sustain_oncc.clear(); + pitcheg_release_oncc.clear(); + pitcheg_depth_oncc.clear(); amplfo_delay = 0; amplfo_fade = 0; - amplfo_freq = 0; + amplfo_freq = -1; /* -1 is used to determine whether the LFO was initialized */ amplfo_depth = 0; + amplfo_delay_oncc.clear(); + amplfo_fade_oncc.clear(); + amplfo_depthcc.clear(); + amplfo_freqcc.clear(); fillfo_delay = 0; fillfo_fade = 0; - fillfo_freq = 0; + fillfo_freq = -1; /* -1 is used to determine whether the LFO was initialized */ fillfo_depth = 0; + fillfo_delay_oncc.clear(); + fillfo_fade_oncc.clear(); + fillfo_depthcc.clear(); + fillfo_freqcc.clear(); pitchlfo_delay = 0; pitchlfo_fade = 0; - pitchlfo_freq = 0; + pitchlfo_freq = -1; /* -1 is used to determine whether the LFO was initialized */ pitchlfo_depth = 0; + pitchlfo_delay_oncc.clear(); + pitchlfo_fade_oncc.clear(); + pitchlfo_depthcc.clear(); + pitchlfo_freqcc.clear(); } Region* @@ -573,7 +634,15 @@ // amplifier region->volume = volume; + region->volume_oncc = volume_oncc; + region->volume_curvecc = volume_curvecc; + region->volume_smoothcc = volume_smoothcc; + region->volume_stepcc = volume_stepcc; region->pan = pan; + region->pan_oncc = pan_oncc; + region->pan_curvecc = pan_curvecc; + region->pan_smoothcc = pan_smoothcc; + region->pan_stepcc = pan_stepcc; region->width = width; region->position = position; region->amp_keytrack = amp_keytrack; @@ -609,12 +678,16 @@ region->bend_up = bend_up; region->bend_down = bend_down; region->bend_step = bend_step; + + region->pitch_oncc = pitch_oncc; + region->pitch_smoothcc = pitch_smoothcc; + region->pitch_curvecc = pitch_curvecc; + region->pitch_stepcc = pitch_stepcc; // filter region->fil_type = fil_type; region->cutoff = cutoff; region->cutoff_oncc = cutoff_oncc; - region->cutoff_cc = cutoff_cc; region->cutoff_smoothcc = cutoff_smoothcc; region->cutoff_stepcc = cutoff_stepcc; region->cutoff_curvecc = cutoff_curvecc; @@ -692,6 +765,14 @@ region->ampeg_vel2decay = ampeg_vel2decay; region->ampeg_vel2sustain = ampeg_vel2sustain; region->ampeg_vel2release = ampeg_vel2release; + + region->ampeg_delaycc = ampeg_delaycc; + region->ampeg_startcc = ampeg_startcc; + region->ampeg_attackcc = ampeg_attackcc; + region->ampeg_holdcc = ampeg_holdcc; + region->ampeg_decaycc = ampeg_decaycc; + region->ampeg_sustaincc = ampeg_sustaincc; + region->ampeg_releasecc = ampeg_releasecc; region->fileg_delay = fileg_delay; region->fileg_start = fileg_start; @@ -700,6 +781,23 @@ region->fileg_decay = fileg_decay; region->fileg_sustain = fileg_sustain; region->fileg_release = fileg_release; + region->fileg_depth = fileg_depth; + + region->fileg_vel2delay = fileg_vel2delay; + region->fileg_vel2attack = fileg_vel2attack; + region->fileg_vel2hold = fileg_vel2hold; + region->fileg_vel2decay = fileg_vel2decay; + region->fileg_vel2sustain = fileg_vel2sustain; + region->fileg_vel2release = fileg_vel2release; + + region->fileg_delay_oncc = fileg_delay_oncc; + region->fileg_start_oncc = fileg_start_oncc; + region->fileg_attack_oncc = fileg_attack_oncc; + region->fileg_hold_oncc = fileg_hold_oncc; + region->fileg_decay_oncc = fileg_decay_oncc; + region->fileg_sustain_oncc = fileg_sustain_oncc; + region->fileg_release_oncc = fileg_release_oncc; + region->fileg_depth_oncc = fileg_depth_oncc; region->pitcheg_delay = pitcheg_delay; region->pitcheg_start = pitcheg_start; @@ -716,21 +814,48 @@ region->pitcheg_vel2decay = pitcheg_vel2decay; region->pitcheg_vel2sustain = pitcheg_vel2sustain; region->pitcheg_vel2release = pitcheg_vel2release; + + region->pitcheg_delay_oncc = pitcheg_delay_oncc; + region->pitcheg_start_oncc = pitcheg_start_oncc; + region->pitcheg_attack_oncc = pitcheg_attack_oncc; + region->pitcheg_hold_oncc = pitcheg_hold_oncc; + region->pitcheg_decay_oncc = pitcheg_decay_oncc; + region->pitcheg_sustain_oncc = pitcheg_sustain_oncc; + region->pitcheg_release_oncc = pitcheg_release_oncc; + region->pitcheg_depth_oncc = pitcheg_depth_oncc; region->amplfo_delay = amplfo_delay; region->amplfo_fade = amplfo_fade; region->amplfo_freq = amplfo_freq; region->amplfo_depth = amplfo_depth; + + region->amplfo_delay_oncc = amplfo_delay_oncc; + region->amplfo_fade_oncc = amplfo_fade_oncc; + region->amplfo_depthcc = amplfo_depthcc; + region->amplfo_freqcc = amplfo_freqcc; region->fillfo_delay = fillfo_delay; region->fillfo_fade = fillfo_fade; region->fillfo_freq = fillfo_freq; region->fillfo_depth = fillfo_depth; + + region->fillfo_delay_oncc = fillfo_delay_oncc; + region->fillfo_fade_oncc = fillfo_fade_oncc; + region->fillfo_depthcc = fillfo_depthcc; + region->fillfo_freqcc = fillfo_freqcc; region->pitchlfo_delay = pitchlfo_delay; region->pitchlfo_fade = pitchlfo_fade; region->pitchlfo_freq = pitchlfo_freq; region->pitchlfo_depth = pitchlfo_depth; + + region->pitchlfo_delay_oncc = pitchlfo_delay_oncc; + region->pitchlfo_fade_oncc = pitchlfo_fade_oncc; + region->pitchlfo_depthcc = pitchlfo_depthcc; + region->pitchlfo_freqcc = pitchlfo_freqcc; + + region->eg = eg; + region->lfos = lfos; return region; } @@ -755,9 +880,11 @@ currentDir = LinuxSampler::Path::stripLastName(file); std::string token; std::string line; + currentLine = 0; while (std::getline(fs, line)) { + currentLine++; // COMMENT std::string::size_type slash_index = line.find("//"); if (slash_index != std::string::npos) @@ -765,9 +892,11 @@ // DEFINITION std::stringstream linestream(line); + linestream >> std::noskipws; + int spaces = 0; while (linestream >> token) { - if (token[0] == '<' and token[token.size()-1] == '>') + if (token[0] == '<' && token[token.size()-1] == '>') { // HEAD if (!token_string.empty()) @@ -808,9 +937,14 @@ else { // TAIL - token_string.append(" "); + token_string.append(spaces, ' '); token_string.append(token); } + spaces = 0; + while (isspace(linestream.peek())) { + linestream.ignore(); + spaces++; + } } // EOL @@ -886,13 +1020,6 @@ velcurve[v] = v * v / (127.0 * 127.0); } } - - // apply amp_veltrack - float offset = -pRegion->amp_veltrack; - if (offset <= 0) offset += 100; - for (int v = 0 ; v < 128 ; v++) { - velcurve[v] = (offset + pRegion->amp_veltrack * velcurve[v]) / 100; - } } } @@ -903,6 +1030,119 @@ for (int i = 0 ; i < 128 ; i++) { _instrument->pLookupTableCC[i] = new LookupTable(_instrument, i); } + + for (int i = 0; i < _instrument->regions.size(); i++) { + Region* r = _instrument->regions[i]; + + copyCurves(r->volume_curvecc, r->volume_oncc); + r->volume_curvecc.clear(); + + copySmoothValues(r->volume_smoothcc, r->volume_oncc); + r->volume_smoothcc.clear(); + + copyStepValues(r->volume_stepcc, r->volume_oncc); + r->volume_stepcc.clear(); + + copyCurves(r->pitch_curvecc, r->pitch_oncc); + r->pitch_curvecc.clear(); + + copySmoothValues(r->pitch_smoothcc, r->pitch_oncc); + r->pitch_smoothcc.clear(); + + copyStepValues(r->pitch_stepcc, r->pitch_oncc); + r->pitch_stepcc.clear(); + + copyCurves(r->pan_curvecc, r->pan_oncc); + r->pan_curvecc.clear(); + + copySmoothValues(r->pan_smoothcc, r->pan_oncc); + r->pan_smoothcc.clear(); + + copyStepValues(r->pan_stepcc, r->pan_oncc); + r->pan_stepcc.clear(); + + copyCurves(r->cutoff_curvecc, r->cutoff_oncc); + r->cutoff_curvecc.clear(); + + copySmoothValues(r->cutoff_smoothcc, r->cutoff_oncc); + r->cutoff_smoothcc.clear(); + + copyStepValues(r->cutoff_stepcc, r->cutoff_oncc); + r->cutoff_stepcc.clear(); + + copyCurves(r->cutoff2_curvecc, r->cutoff2_oncc); + r->cutoff2_curvecc.clear(); + + copySmoothValues(r->cutoff2_smoothcc, r->cutoff2_oncc); + r->cutoff2_smoothcc.clear(); + + copyStepValues(r->cutoff2_stepcc, r->cutoff2_oncc); + r->cutoff2_stepcc.clear(); + + copyCurves(r->resonance_curvecc, r->resonance_oncc); + r->resonance_curvecc.clear(); + + copySmoothValues(r->resonance_smoothcc, r->resonance_oncc); + r->resonance_smoothcc.clear(); + + copyStepValues(r->resonance_stepcc, r->resonance_oncc); + r->resonance_stepcc.clear(); + + copyCurves(r->resonance2_curvecc, r->resonance2_oncc); + r->resonance2_curvecc.clear(); + + copySmoothValues(r->resonance2_smoothcc, r->resonance2_oncc); + r->resonance2_smoothcc.clear(); + + copyStepValues(r->resonance2_stepcc, r->resonance2_oncc); + r->resonance2_stepcc.clear(); + + for (int j = 0; j < r->eg.size(); j++) { + copyCurves(r->eg[j].pan_curvecc, r->eg[j].pan_oncc); + r->eg[j].pan_curvecc.clear(); + } + + for (int j = 0; j < r->lfos.size(); j++) { + r->lfos[j].copySmoothValues(); + r->lfos[j].copyStepValues(); + + copySmoothValues(r->lfos[j].volume_smoothcc, r->lfos[j].volume_oncc); + r->lfos[j].volume_smoothcc.clear(); + + copyStepValues(r->lfos[j].volume_stepcc, r->lfos[j].volume_oncc); + r->lfos[j].volume_stepcc.clear(); + + copySmoothValues(r->lfos[j].freq_smoothcc, r->lfos[j].freq_oncc); + r->lfos[j].freq_smoothcc.clear(); + + copyStepValues(r->lfos[j].freq_stepcc, r->lfos[j].freq_oncc); + r->lfos[j].freq_stepcc.clear(); + + copySmoothValues(r->lfos[j].pitch_smoothcc, r->lfos[j].pitch_oncc); + r->lfos[j].pitch_smoothcc.clear(); + + copyStepValues(r->lfos[j].pitch_stepcc, r->lfos[j].pitch_oncc); + r->lfos[j].pitch_stepcc.clear(); + + copySmoothValues(r->lfos[j].pan_smoothcc, r->lfos[j].pan_oncc); + r->lfos[j].pan_smoothcc.clear(); + + copyStepValues(r->lfos[j].pan_stepcc, r->lfos[j].pan_oncc); + r->lfos[j].pan_stepcc.clear(); + + copySmoothValues(r->lfos[j].cutoff_smoothcc, r->lfos[j].cutoff_oncc); + r->lfos[j].cutoff_smoothcc.clear(); + + copyStepValues(r->lfos[j].cutoff_stepcc, r->lfos[j].cutoff_oncc); + r->lfos[j].cutoff_stepcc.clear(); + + copySmoothValues(r->lfos[j].resonance_smoothcc, r->lfos[j].resonance_oncc); + r->lfos[j].resonance_smoothcc.clear(); + + copyStepValues(r->lfos[j].resonance_stepcc, r->lfos[j].resonance_oncc); + r->lfos[j].resonance_stepcc.clear(); + } + } } File::~File() @@ -916,6 +1156,58 @@ { return _instrument; } + + void File::copyCurves(LinuxSampler::ArrayList& curves, LinuxSampler::ArrayList& dest) { + for (int i = 0; i < curves.size(); i++) { + for (int j = 0; j < dest.size(); j++) { + if (curves[i].Controller == dest[j].Controller) { + dest[j].Curve = curves[i].Curve; + } + } + } + } + + void File::copySmoothValues(LinuxSampler::ArrayList& smooths, LinuxSampler::ArrayList& dest) { + for (int i = 0; i < smooths.size(); i++) { + for (int j = 0; j < dest.size(); j++) { + if (smooths[i].Controller == dest[j].Controller) { + dest[j].Smooth = smooths[i].Smooth; + } + } + } + } + + void File::copyStepValues(LinuxSampler::ArrayList& steps, LinuxSampler::ArrayList& dest) { + for (int i = 0; i < steps.size(); i++) { + for (int j = 0; j < dest.size(); j++) { + if (steps[i].Controller == dest[j].Controller) { + dest[j].Step = steps[i].Step; + } + } + } + } + + int File::ToInt(const std::string& s) throw(LinuxSampler::Exception) { + int i; + std::istringstream iss(s); + if(!(iss >> i)) { + std::ostringstream oss; + oss << "Line " << currentLine << ": Expected an integer"; + throw LinuxSampler::Exception(oss.str()); + } + return i; + } + + float File::ToFloat(const std::string& s) throw(LinuxSampler::Exception) { + float i; + std::istringstream iss(s); + if(!(iss >> i)) { + std::ostringstream oss; + oss << "Line " << currentLine << ": Expected a floating-point number"; + throw LinuxSampler::Exception(oss.str()); + } + return i; + } void File::push_header(std::string token) @@ -941,6 +1233,12 @@ octave_offset = 0; note_offset = 0; } + else if (token == "") + { + _current_section = CURVE; + _instrument->curves.add(Curve()); + _current_curve = &_instrument->curves[_instrument->curves.size() - 1]; + } else { _current_section = UNKNOWN; @@ -957,17 +1255,33 @@ std::string::size_type delimiter_index = token.find('='); std::string key = token.substr(0, delimiter_index); std::string value = token.substr(delimiter_index + 1); - int x, y; + int x, y, z; + + if (_current_section == CURVE) { + if (sscanf(key.c_str(), "v%d", &x)) { + if (x < 0 || x > 127) { + std::cerr << "Invalid curve index: " << x << std::endl; + } + _current_curve->v[x] = check(key, 0.0f, 1.0f, ToFloat(value)); + } else { + std::cerr << "The opcode '" << key << "' in section is unsupported by libsfz!" << std::endl; + } + + return; + } // sample definition if ("sample" == key) { std::string path = default_path + value; #ifndef WIN32 - for (int i = 0; i < path.length(); i++) if( path[i] == '\\') path[i] = '/'; + for (int i = 0; i < path.length(); i++) if (path[i] == '\\') path[i] = '/'; + bool absolute = path[0] == '/'; + #else + bool absolute = path[0] == '/' || path[0] == '\\' || + (path.length() >= 2 && isalpha(path[0]) && path[1] == ':'); #endif - path = currentDir + LinuxSampler::File::DirSeparator + path; // TODO: check for absolute path - + if (!absolute) path = currentDir + LinuxSampler::File::DirSeparator + path; if(pCurDef) pCurDef->sample = path; return; } @@ -1088,7 +1402,7 @@ else if ("amp_keycenter" == key) pCurDef->amp_keycenter = parseKey(value); else if ("amp_veltrack" == key) pCurDef->amp_veltrack = ToFloat(value); else if ("amp_random" == key) pCurDef->amp_random = ToFloat(value); - else if ("rt_decay" == key) pCurDef->rt_decay = ToFloat(value); + else if ("rt_decay" == key || "rtdecay" == key) pCurDef->rt_decay = ToFloat(value); else if ("xfin_lokey" == key) pCurDef->xfin_lokey = parseKey(value); else if ("xfin_hikey" == key) pCurDef->xfin_hikey = parseKey(value); else if ("xfout_lokey" == key) pCurDef->xfout_lokey = parseKey(value); @@ -1122,7 +1436,7 @@ else if ("pitch_random" == key) pCurDef->pitch_random = ToInt(value); else if ("bend_up" == key || "bendup" == key) pCurDef->bend_up = ToInt(value); else if ("bend_down" == key || "benddown" == key) pCurDef->bend_down = ToInt(value); - else if ("bend_step" == key) pCurDef->bend_step = ToInt(value); + else if ("bend_step" == key || "bendstep" == key) pCurDef->bend_step = ToInt(value); // filter else if ("fil_type" == key || "filtype" == key) @@ -1161,8 +1475,10 @@ } else if ("cutoff" == key) pCurDef->cutoff = ToFloat(value); else if ("cutoff2" == key) pCurDef->cutoff2 = ToFloat(value); - else if ("cutoff_chanaft" == key) pCurDef->cutoff_chanaft = ToInt(value); - else if ("cutoff2_chanaft" == key) pCurDef->cutoff2_chanaft = ToInt(value); + else if ("cutoff_chanaft" == key) { + pCurDef->cutoff_chanaft = check(key, -9600, 9600, ToInt(value)); + pCurDef->cutoff_oncc.add( CC(128, check(key, -9600, 9600, ToInt(value))) ); + } else if ("cutoff2_chanaft" == key) pCurDef->cutoff2_chanaft = ToInt(value); else if ("cutoff_polyaft" == key) pCurDef->cutoff_polyaft = ToInt(value); else if ("cutoff2_polyaft" == key) pCurDef->cutoff2_polyaft = ToInt(value); else if ("resonance" == key) pCurDef->resonance = ToFloat(value); @@ -1196,80 +1512,56 @@ else if (sscanf(key.c_str(), "amp_velcurve_%d", &x)) { pCurDef->amp_velcurve.set(x, ToFloat(value)); } - - // 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; - } + // v2 envelope generators else if (sscanf(key.c_str(), "eg%d%n", &x, &y)) { const char* s = key.c_str() + y; - if (sscanf(s, "_time%d", &y)) egnode(x, y).time = ToFloat(value); - else if (sscanf(s, "_level%d", &y)) egnode(x, y).level = ToFloat(value); + if (sscanf(s, "_time%d%n", &y, &z)) { + const char* s2 = s + z; + if (strcmp(s2, "") == 0) egnode(x, y).time = check(key, 0.0f, 100.0f, ToFloat(value)); + else if (sscanf(s2, "_oncc%d", &z)) egnode(x, y).time_oncc.add( CC(z, check(key, 0.0f, 100.0f, ToFloat(value))) ); + } else if (sscanf(s, "_level%d%n", &y, &z)) { + const char* s2 = s + z; + if (strcmp(s2, "") == 0) egnode(x, y).level = check(key, 0.0f, 1.0f, ToFloat(value)); + else if (sscanf(s2, "_oncc%d", &z)) egnode(x, y).level_oncc.add( CC(z, check(key, 0.0f, 1.0f, ToFloat(value))) ); + } else if (sscanf(s, "_shape%d", &y)) egnode(x, y).shape = ToFloat(value); else if (sscanf(s, "_curve%d", &y)) egnode(x, y).curve = ToFloat(value); else if (strcmp(s, "_sustain") == 0) eg(x).sustain = ToInt(value); else if (strcmp(s, "_loop") == 0) eg(x).loop = ToInt(value); else if (strcmp(s, "_loop_count") == 0) eg(x).loop_count = ToInt(value); else if (strcmp(s, "_amplitude") == 0) eg(x).amplitude = ToFloat(value); + else if (sscanf(s, "_amplitude_oncc%d", &y)) eg(x).amplitude_oncc.add( CC(y, check(key, 0.0f, 100.0f, ToFloat(value))) ); + else if (strcmp(s, "_volume") == 0) eg(x).volume = check(key, -144.0f, 6.0f, ToFloat(value)); + else if (sscanf(s, "_volume_oncc%d", &y)) eg(x).volume_oncc.add( CC(y, check(key, -144.0f, 6.0f, ToFloat(value))) ); else if (strcmp(s, "_cutoff") == 0) eg(x).cutoff = ToFloat(value); + else if (sscanf(s, "_cutoff_oncc%d", &y)) eg(x).cutoff_oncc.add( CC(y, check(key, -9600, 9600, ToInt(value))) ); + else if (strcmp(s, "_pitch") == 0) eg(x).pitch = check(key, -9600, 9600, ToInt(value)); + else if (sscanf(s, "_pitch_oncc%d", &y)) eg(x).pitch_oncc.add( CC(y, check(key, -9600, 9600, ToInt(value))) ); + else if (strcmp(s, "_resonance") == 0) eg(x).resonance = check(key, 0.0f, 40.0f, ToFloat(value)); + else if (sscanf(s, "_resonance_oncc%d", &y)) eg(x).resonance_oncc.add( CC(y, check(key, 0.0f, 40.0f, ToFloat(value))) ); + else if (strcmp(s, "_pan") == 0) eg(x).pan = check(key, -100.0f, 100.0f, ToFloat(value)); + else if (strcmp(s, "_pan_curve") == 0) eg(x).pan_curve = check(key, 0, 30000, ToInt(value)); + else if (sscanf(s, "_pan_oncc%d", &y)) eg(x).pan_oncc.add( CC(y, check(key, -100.0f, 100.0f, ToFloat(value))) ); + else if (sscanf(s, "_pan_curvecc%d", &y)) eg(x).pan_curvecc.add( CC(y, 0.0f, check(key, 0, 30000, ToInt(value))) ); + else if (strcmp(s, "_eq1freq") == 0) eg(x).eq1freq = check(key, 0.0f, 30000.0f, ToFloat(value)); + else if (strcmp(s, "_eq2freq") == 0) eg(x).eq2freq = check(key, 0.0f, 30000.0f, ToFloat(value)); + else if (strcmp(s, "_eq3freq") == 0) eg(x).eq3freq = check(key, 0.0f, 30000.0f, ToFloat(value)); + else if (strcmp(s, "_eq1bw") == 0) eg(x).eq1bw = check(key, 0.001f, 4.0f, ToFloat(value)); + else if (strcmp(s, "_eq2bw") == 0) eg(x).eq2bw = check(key, 0.001f, 4.0f, ToFloat(value)); + else if (strcmp(s, "_eq3bw") == 0) eg(x).eq3bw = check(key, 0.001f, 4.0f, ToFloat(value)); + else if (strcmp(s, "_eq1gain") == 0) eg(x).eq1gain = check(key, -96.0f, 24.0f, ToFloat(value)); + else if (strcmp(s, "_eq2gain") == 0) eg(x).eq2gain = check(key, -96.0f, 24.0f, ToFloat(value)); + else if (strcmp(s, "_eq3gain") == 0) eg(x).eq3gain = check(key, -96.0f, 24.0f, ToFloat(value)); + else if (sscanf(s, "_eq1freq_oncc%d", &y)) eg(x).eq1freq_oncc.add( CC(y, check(key, 0.0f, 30000.0f, ToFloat(value))) ); + else if (sscanf(s, "_eq2freq_oncc%d", &y)) eg(x).eq2freq_oncc.add( CC(y, check(key, 0.0f, 30000.0f, ToFloat(value))) ); + else if (sscanf(s, "_eq3freq_oncc%d", &y)) eg(x).eq3freq_oncc.add( CC(y, check(key, 0.0f, 30000.0f, ToFloat(value))) ); + else if (sscanf(s, "_eq1bw_oncc%d", &y)) eg(x).eq1bw_oncc.add( CC(y, check(key, 0.001f, 4.0f, ToFloat(value))) ); + else if (sscanf(s, "_eq2bw_oncc%d", &y)) eg(x).eq2bw_oncc.add( CC(y, check(key, 0.001f, 4.0f, ToFloat(value))) ); + else if (sscanf(s, "_eq3bw_oncc%d", &y)) eg(x).eq3bw_oncc.add( CC(y, check(key, 0.001f, 4.0f, ToFloat(value))) ); + else if (sscanf(s, "_eq1gain_oncc%d", &y)) eg(x).eq1gain_oncc.add( CC(y, check(key, -96.0f, 24.0f, ToFloat(value))) ); + else if (sscanf(s, "_eq2gain_oncc%d", &y)) eg(x).eq2gain_oncc.add( CC(y, check(key, -96.0f, 24.0f, ToFloat(value))) ); + else if (sscanf(s, "_eq3gain_oncc%d", &y)) eg(x).eq3gain_oncc.add( CC(y, check(key, -96.0f, 24.0f, ToFloat(value))) ); else std::cerr << "The opcode '" << key << "' is unsupported by libsfz!" << std::endl; } @@ -1294,6 +1586,13 @@ else if ("fileg_decay" == key) pCurDef->fileg_decay = ToFloat(value); else if ("fileg_sustain" == key) pCurDef->fileg_sustain = ToFloat(value); else if ("fileg_release" == key) pCurDef->fileg_release = ToFloat(value); + else if ("fileg_depth" == key) pCurDef->fileg_depth = check(key, -12000, 12000, ToInt(value)); + else if ("fileg_vel2delay" == key) pCurDef->fileg_vel2delay = check(key, -100.0f, 100.0f, ToFloat(value)); + else if ("fileg_vel2attack" == key) pCurDef->fileg_vel2attack = ToFloat(value); + else if ("fileg_vel2hold" == key) pCurDef->fileg_vel2hold = ToFloat(value); + else if ("fileg_vel2decay" == key) pCurDef->fileg_vel2decay = ToFloat(value); + else if ("fileg_vel2sustain" == key) pCurDef->fileg_vel2sustain = ToFloat(value); + else if ("fileg_vel2release" == key) pCurDef->fileg_vel2release = ToFloat(value); else if ("pitcheg_delay" == key) pCurDef->pitcheg_delay = ToFloat(value); else if ("pitcheg_start" == key) pCurDef->pitcheg_start = ToFloat(value); else if ("pitcheg_attack" == key) pCurDef->pitcheg_attack = ToFloat(value); @@ -1314,27 +1613,210 @@ else if ("amplfo_delay" == key) pCurDef->amplfo_delay = ToFloat(value); else if ("amplfo_fade" == key) pCurDef->amplfo_fade = ToFloat(value); else if ("amplfo_freq" == key) pCurDef->amplfo_freq = ToFloat(value); + else if ("amplfo_freqchanaft" == key) pCurDef->amplfo_freqcc.add( CC(128, check(key, -200.0f, 200.0f, ToFloat(value))) ); else if ("amplfo_depth" == key) pCurDef->amplfo_depth = ToFloat(value); + else if ("amplfo_depthchanaft" == key) pCurDef->amplfo_depthcc.add( CC(128, check(key, -10.0f, 10.0f, ToFloat(value))) ); else if ("fillfo_delay" == key) pCurDef->fillfo_delay = ToFloat(value); else if ("fillfo_fade" == key) pCurDef->fillfo_fade = ToFloat(value); else if ("fillfo_freq" == key) pCurDef->fillfo_freq = ToFloat(value); + else if ("fillfo_freqchanaft" == key) pCurDef->fillfo_freqcc.add( CC(128, check(key, -200.0f, 200.0f, ToFloat(value))) ); else if ("fillfo_depth" == key) pCurDef->fillfo_depth = ToFloat(value); + else if ("fillfo_depthchanaft" == key) pCurDef->fillfo_depthcc.add( CC(128, check(key, -1200, 1200, ToInt(value))) ); else if ("pitchlfo_delay" == key) pCurDef->pitchlfo_delay = ToFloat(value); else if ("pitchlfo_fade" == key) pCurDef->pitchlfo_fade = ToFloat(value); else if ("pitchlfo_freq" == key) pCurDef->pitchlfo_freq = ToFloat(value); + else if ("pitchlfo_freqchanaft" == key) pCurDef->pitchlfo_freqcc.add( CC(128, check(key, -200.0f, 200.0f, ToFloat(value))) ); else if ("pitchlfo_depth" == key) pCurDef->pitchlfo_depth = ToInt(value); + else if ("pitchlfo_depthchanaft" == key) pCurDef->pitchlfo_depthcc.add( CC(128, check(key, -1200, 1200, ToInt(value))) ); + // v2 LFO else if (sscanf(key.c_str(), "lfo%d%n", &x, &y)) { const char* s = key.c_str() + y; if (strcmp(s, "_freq") == 0) lfo(x).freq = check(key, 0.0f, 20.0f, ToFloat(value)); + else if (sscanf(s, "_freq_oncc%d", &y)) lfo(x).freq_oncc.add( CC(y, check(key, 0.0f, 20.0f, ToFloat(value))) ); + else if (sscanf(s, "_freq_smoothcc%d", &y)) lfo(x).freq_smoothcc.add( CC(y, 0, -1, check(key, 0, 100000 /* max? */, ToInt(value))) ); + else if (sscanf(s, "_freq_stepcc%d", &y)) lfo(x).freq_stepcc.add( CC(y, 0, -1, 0, check(key, 0.0f, 20.0f, ToFloat(value))) ); else if (strcmp(s, "_wave") == 0) lfo(x).wave = ToInt(value); else if (strcmp(s, "_delay") == 0) lfo(x).delay = check(key, 0.0f, 100.0f, ToFloat(value)); + else if (sscanf(s, "_delay_oncc%d", &y)) lfo(x).delay_oncc.add( CC(y, check(key, 0.0f, 100.0f, ToFloat(value))) ); + else if (strcmp(s, "_fade") == 0) lfo(x).fade = check(key, 0.0f, 100.0f, ToFloat(value)); + else if (sscanf(s, "_fade_oncc%d", &y)) lfo(x).fade_oncc.add( CC(y, check(key, 0.0f, 100.0f, ToFloat(value))) ); + else if (strcmp(s, "_phase") == 0) lfo(x).phase = check(key, 0.0f, 360.0f, ToFloat(value)); + else if (sscanf(s, "_phase_oncc%d", &y)) lfo(x).phase_oncc.add( CC(y, check(key, 0.0f, 360.0f, ToFloat(value))) ); else if (strcmp(s, "_volume") == 0) lfo(x).volume = check(key, -144.0f, 6.0f, ToFloat(value)); + else if (sscanf(s, "_volume_oncc%d", &y)) lfo(x).volume_oncc.add( CC(y, check(key, -144.0f, 6.0f, ToFloat(value))) ); + else if (sscanf(s, "_volume_smoothcc%d", &y)) lfo(x).volume_smoothcc.add( CC(y, 0, -1, check(key, 0, 100000 /* max? */, ToInt(value))) ); + else if (sscanf(s, "_volume_stepcc%d", &y)) lfo(x).volume_stepcc.add( CC(y, 0, -1, 0, check(key, -20.0f, 20.0f, ToFloat(value))) ); else if (strcmp(s, "_pitch") == 0) lfo(x).pitch = check(key, -9600, 9600, ToInt(value)); + else if (sscanf(s, "_pitch_oncc%d", &y)) lfo(x).pitch_oncc.add( CC(y, check(key, -9600, 9600, ToInt(value))) ); + else if (sscanf(s, "_pitch_smoothcc%d", &y)) lfo(x).pitch_smoothcc.add( CC(y, 0, -1, check(key, 0, 100000 /* max? */, ToInt(value))) ); + else if (sscanf(s, "_pitch_stepcc%d", &y)) lfo(x).pitch_stepcc.add( CC(y, 0, -1, 0, check(key, -9600, 9600, ToInt(value))) ); else if (strcmp(s, "_cutoff") == 0) lfo(x).cutoff = check(key, -9600, 9600, ToInt(value)); + else if (sscanf(s, "_cutoff_oncc%d", &y)) lfo(x).cutoff_oncc.add( CC(y, check(key, -9600, 9600, ToInt(value))) ); + else if (sscanf(s, "_cutoff_smoothcc%d", &y)) lfo(x).cutoff_smoothcc.add( CC(y, 0, -1, check(key, 0, 100000 /* max? */, ToInt(value))) ); + else if (sscanf(s, "_cutoff_stepcc%d", &y)) lfo(x).cutoff_stepcc.add( CC(y, 0, -1, 0, check(key, -9600, 9600, ToInt(value))) ); else if (strcmp(s, "_resonance") == 0) lfo(x).resonance = check(key, 0.0f, 40.0f, ToFloat(value)); + else if (sscanf(s, "_resonance_oncc%d", &y)) lfo(x).resonance_oncc.add( CC(y, check(key, 0.0f, 40.0f, ToFloat(value))) ); + else if (sscanf(s, "_resonance_smoothcc%d", &y)) lfo(x).resonance_smoothcc.add( CC(y, 0, -1, check(key, 0, 100000 /* max? */, ToInt(value))) ); + else if (sscanf(s, "_resonance_stepcc%d", &y)) lfo(x).resonance_stepcc.add( CC(y, 0, -1, 0, check(key, 0.0f, 40.0f, ToFloat(value))) ); else if (strcmp(s, "_pan") == 0) lfo(x).pan = check(key, -100.0f, 100.0f, ToFloat(value)); + else if (sscanf(s, "_pan_oncc%d", &y)) lfo(x).pan_oncc.add( CC(y, check(key, -100.0f, 100.0f, ToFloat(value))) ); + else if (sscanf(s, "_pan_smoothcc%d", &y)) lfo(x).pan_smoothcc.add( CC(y, 0, -1, check(key, 0, 100000 /* max? */, ToInt(value))) ); + else if (sscanf(s, "_pan_stepcc%d", &y)) lfo(x).pan_stepcc.add( CC(y, 0, -1, 0, check(key, -100.0f, 100.0f, ToFloat(value))) ); + else if (strcmp(s, "_eq1freq") == 0) lfo(x).eq1freq = check(key, 0.0f, 30000.0f, ToFloat(value)); + else if (strcmp(s, "_eq2freq") == 0) lfo(x).eq2freq = check(key, 0.0f, 30000.0f, ToFloat(value)); + else if (strcmp(s, "_eq3freq") == 0) lfo(x).eq3freq = check(key, 0.0f, 30000.0f, ToFloat(value)); + else if (strcmp(s, "_eq1bw") == 0) lfo(x).eq1bw = check(key, 0.001f, 4.0f, ToFloat(value)); + else if (strcmp(s, "_eq2bw") == 0) lfo(x).eq2bw = check(key, 0.001f, 4.0f, ToFloat(value)); + else if (strcmp(s, "_eq3bw") == 0) lfo(x).eq3bw = check(key, 0.001f, 4.0f, ToFloat(value)); + else if (strcmp(s, "_eq1gain") == 0) lfo(x).eq1gain = check(key, -96.0f, 24.0f, ToFloat(value)); + else if (strcmp(s, "_eq2gain") == 0) lfo(x).eq2gain = check(key, -96.0f, 24.0f, ToFloat(value)); + else if (strcmp(s, "_eq3gain") == 0) lfo(x).eq3gain = check(key, -96.0f, 24.0f, ToFloat(value)); + else if (sscanf(s, "_eq1freq_oncc%d", &y)) lfo(x).eq1freq_oncc.add( CC(y, check(key, 0.0f, 30000.0f, ToFloat(value))) ); + else if (sscanf(s, "_eq1freq_smoothcc%d", &y)) lfo(x).eq1freq_smoothcc.add( CC(y, 0, -1, check(key, 0, 100000 /* max? */, ToInt(value))) ); + else if (sscanf(s, "_eq1freq_stepcc%d", &y)) lfo(x).eq1freq_stepcc.add( CC(y, 0, -1, 0, check(key, 0.0f, 4294967296.0f, ToFloat(value))) ); + else if (sscanf(s, "_eq2freq_oncc%d", &y)) lfo(x).eq2freq_oncc.add( CC(y, check(key, 0.0f, 30000.0f, ToFloat(value))) ); + else if (sscanf(s, "_eq2freq_smoothcc%d", &y)) lfo(x).eq2freq_smoothcc.add( CC(y, 0, -1, check(key, 0, 100000 /* max? */, ToInt(value))) ); + else if (sscanf(s, "_eq2freq_stepcc%d", &y)) lfo(x).eq2freq_stepcc.add( CC(y, 0, -1, 0, check(key, 0.0f, 4294967296.0f, ToFloat(value))) ); + else if (sscanf(s, "_eq3freq_oncc%d", &y)) lfo(x).eq3freq_oncc.add( CC(y, check(key, 0.0f, 30000.0f, ToFloat(value))) ); + else if (sscanf(s, "_eq3freq_smoothcc%d", &y)) lfo(x).eq3freq_smoothcc.add( CC(y, 0, -1, check(key, 0, 100000 /* max? */, ToInt(value))) ); + else if (sscanf(s, "_eq3freq_stepcc%d", &y)) lfo(x).eq3freq_stepcc.add( CC(y, 0, -1, 0, check(key, 0.0f, 4294967296.0f, ToFloat(value))) ); + else if (sscanf(s, "_eq1bw_oncc%d", &y)) lfo(x).eq1bw_oncc.add( CC(y, check(key, 0.001f, 4.0f, ToFloat(value))) ); + else if (sscanf(s, "_eq1bw_smoothcc%d", &y)) lfo(x).eq1bw_smoothcc.add( CC(y, 0, -1, check(key, 0, 100000 /* max? */, ToInt(value))) ); + else if (sscanf(s, "_eq1bw_stepcc%d", &y)) lfo(x).eq1bw_stepcc.add( CC(y, 0, -1, 0, check(key, 0.0f, 4294967296.0f, ToFloat(value))) ); + else if (sscanf(s, "_eq2bw_oncc%d", &y)) lfo(x).eq2bw_oncc.add( CC(y, check(key, 0.001f, 4.0f, ToFloat(value))) ); + else if (sscanf(s, "_eq2bw_smoothcc%d", &y)) lfo(x).eq2bw_smoothcc.add( CC(y, 0, -1, check(key, 0, 100000 /* max? */, ToInt(value))) ); + else if (sscanf(s, "_eq2bw_stepcc%d", &y)) lfo(x).eq2bw_stepcc.add( CC(y, 0, -1, 0, check(key, 0.0f, 4294967296.0f, ToFloat(value))) ); + else if (sscanf(s, "_eq3bw_oncc%d", &y)) lfo(x).eq3bw_oncc.add( CC(y, check(key, 0.001f, 4.0f, ToFloat(value))) ); + else if (sscanf(s, "_eq3bw_smoothcc%d", &y)) lfo(x).eq3bw_smoothcc.add( CC(y, 0, -1, check(key, 0, 100000 /* max? */, ToInt(value))) ); + else if (sscanf(s, "_eq3bw_stepcc%d", &y)) lfo(x).eq3bw_stepcc.add( CC(y, 0, -1, 0, check(key, 0.0f, 4294967296.0f, ToFloat(value))) ); + else if (sscanf(s, "_eq1gain_oncc%d", &y)) lfo(x).eq1gain_oncc.add( CC(y, check(key, -96.0f, 24.0f, ToFloat(value))) ); + else if (sscanf(s, "_eq1gain_smoothcc%d", &y)) lfo(x).eq1gain_smoothcc.add( CC(y, 0, -1, check(key, 0, 100000 /* max? */, ToInt(value))) ); + else if (sscanf(s, "_eq1gain_stepcc%d", &y)) lfo(x).eq1gain_stepcc.add( CC(y, 0, -1, 0, check(key, 0.0f, 4294967296.0f, ToFloat(value))) ); + else if (sscanf(s, "_eq2gain_oncc%d", &y)) lfo(x).eq2gain_oncc.add( CC(y, check(key, -96.0f, 24.0f, ToFloat(value))) ); + else if (sscanf(s, "_eq2gain_smoothcc%d", &y)) lfo(x).eq2gain_smoothcc.add( CC(y, 0, -1, check(key, 0, 100000 /* max? */, ToInt(value))) ); + else if (sscanf(s, "_eq2gain_stepcc%d", &y)) lfo(x).eq2gain_stepcc.add( CC(y, 0, -1, 0, check(key, 0.0f, 4294967296.0f, ToFloat(value))) ); + else if (sscanf(s, "_eq3gain_oncc%d", &y)) lfo(x).eq3gain_oncc.add( CC(y, check(key, -96.0f, 24.0f, ToFloat(value))) ); + else if (sscanf(s, "_eq3gain_smoothcc%d", &y)) lfo(x).eq3gain_smoothcc.add( CC(y, 0, -1, check(key, 0, 100000 /* max? */, ToInt(value))) ); + else if (sscanf(s, "_eq3gain_stepcc%d", &y)) lfo(x).eq3gain_stepcc.add( CC(y, 0, -1, 0, check(key, 0.0f, 4294967296.0f, ToFloat(value))) ); + else std::cerr << "The opcode '" << key << "' is unsupported by libsfz!" << std::endl; + } + + // 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); + if (key_cc.size() > 3 && !strcmp(key_cc.c_str() + (key_cc.size() - 3), "_on")) { + key_cc = key_cc.substr(0, key_cc.size() - 3); + } + 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" == key_cc) pCurDef->delay_oncc.set(num_cc, ToFloat(value)); + else if ("delay_samples" == key_cc) pCurDef->delay_samples_oncc.set(num_cc, ToInt(value)); + else if ("offset" == key_cc) pCurDef->offset_oncc.set(num_cc, ToInt(value)); + + // amplifier + else if ("gain" == 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)); + + // pitch + else if ("pitch" == key_cc) pCurDef->pitch_oncc.add( CC(num_cc, check(key, -9600, 9600, ToInt(value))) ); + else if ("pitch_smooth" == key_cc) pCurDef->pitch_smoothcc.add( CC(num_cc, 0, -1, check(key, 0.0f, 100000.0f /* max? */, ToFloat(value))) ); + else if ("pitch_curve" == key_cc) pCurDef->pitch_curvecc.add( CC(num_cc, 0, check(key, 0, 30000, ToInt(value))) ); + else if ("pitch_step" == key_cc) pCurDef->pitch_stepcc.add( CC(num_cc, 0, -1, 0, check(key, 0, 1200, ToInt(value))) ); + + // filter + else if ("cutoff" == key_cc || "cutoff_" == key_cc) { + pCurDef->cutoff_oncc.add( CC(num_cc, check(key, -9600, 9600, ToInt(value))) ); + } else if ("cutoff2" == key_cc) pCurDef->cutoff2_oncc.add( CC(num_cc, check(key, -9600, 9600, ToInt(value))) ); + else if ("cutoff_smooth" == key_cc) pCurDef->cutoff_smoothcc.add( CC(num_cc, 0, -1, check(key, 0.0f, 100000.0f /* max? */, ToFloat(value))) ); + else if ("cutoff2_smooth" == key_cc) pCurDef->cutoff2_smoothcc.add( CC(num_cc, 0, -1, check(key, 0.0f, 100000.0f /* max? */, ToFloat(value))) ); + else if ("cutoff_step" == key_cc) pCurDef->cutoff_stepcc.add( CC(num_cc, 0, -1, 0, check(key, -1200, 1200, ToInt(value))) ); + else if ("cutoff2_step" == key_cc) pCurDef->cutoff2_stepcc.add( CC(num_cc, 0, -1, 0, check(key, -1200, 1200, ToInt(value))) ); + else if ("cutoff_curve" == key_cc) pCurDef->cutoff_curvecc.add( CC(num_cc, 0, check(key, 0, 30000, ToInt(value))) ); + else if ("cutoff2_curve" == key_cc) pCurDef->cutoff2_curvecc.add( CC(num_cc, 0, check(key, 0, 30000, ToInt(value))) ); + else if ("resonance" == key_cc) pCurDef->resonance_oncc.add( CC(num_cc, check(key, 0.0f, 40.0f, ToFloat(value))) ); + else if ("resonance2" == key_cc) pCurDef->resonance2_oncc.add( CC(num_cc, check(key, 0.0f, 40.0f, ToFloat(value))) ); + else if ("resonance_smooth" == key_cc) pCurDef->resonance_smoothcc.add( CC(num_cc, 0, -1, check(key, 0, 100000 /* max? */, ToInt(value))) ); + else if ("resonance2_smooth" == key_cc) pCurDef->resonance2_smoothcc.add( CC(num_cc, 0, -1, check(key, 0, 100000 /* max? */, ToInt(value))) ); + else if ("resonance_step" == key_cc) pCurDef->resonance_stepcc.add( CC(num_cc, 0, -1, 0, check(key, 0.0f, 40.0f, ToFloat(value))) ); + else if ("resonance2_step" == key_cc) pCurDef->resonance2_stepcc.add( CC(num_cc, 0, -1, 0, check(key, 0.0f, 40.0f, ToFloat(value))) ); + else if ("resonance_curve" == key_cc) pCurDef->resonance_curvecc.add( CC(num_cc, 0.0f, check(key, 0, 30000, ToInt(value))) ); + else if ("resonance2_curve" == key_cc) pCurDef->resonance2_curvecc.add( CC(num_cc, 0.0f, check(key, 0, 30000, ToInt(value))) ); + + // per voice equalizer + else if ("eq1_freq" == key_cc) pCurDef->eq1_freq_oncc.set(num_cc, ToInt(value)); + else if ("eq2_freq" == key_cc) pCurDef->eq2_freq_oncc.set(num_cc, ToInt(value)); + else if ("eq3_freq" == key_cc) pCurDef->eq3_freq_oncc.set(num_cc, ToInt(value)); + else if ("eq1_bw" == key_cc) pCurDef->eq1_bw_oncc.set(num_cc, ToInt(value)); + else if ("eq2_bw" == key_cc) pCurDef->eq2_bw_oncc.set(num_cc, ToInt(value)); + else if ("eq3_bw" == key_cc) pCurDef->eq3_bw_oncc.set(num_cc, ToInt(value)); + else if ("eq1_gain" == key_cc) pCurDef->eq1_gain_oncc.set(num_cc, ToInt(value)); + else if ("eq2_gain" == key_cc) pCurDef->eq2_gain_oncc.set(num_cc, ToInt(value)); + else if ("eq3_gain" == key_cc) pCurDef->eq3_gain_oncc.set(num_cc, ToInt(value)); + + else if ("ampeg_delay" == key_cc) pCurDef->ampeg_delaycc.add( CC(num_cc, check(key, -100.0f, 100.0f, ToFloat(value))) ); + else if ("ampeg_start" == key_cc) pCurDef->ampeg_startcc.add( CC(num_cc, check(key, -100.0f, 100.0f, ToFloat(value))) ); + else if ("ampeg_attack" == key_cc) pCurDef->ampeg_attackcc.add( CC(num_cc, check(key, -100.0f, 100.0f, ToFloat(value))) ); + else if ("ampeg_hold" == key_cc) pCurDef->ampeg_holdcc.add( CC(num_cc, check(key, -100.0f, 100.0f, ToFloat(value))) ); + else if ("ampeg_decay" == key_cc) pCurDef->ampeg_decaycc.add( CC(num_cc, check(key, -100.0f, 100.0f, ToFloat(value))) ); + else if ("ampeg_sustain" == key_cc) pCurDef->ampeg_sustaincc.add( CC(num_cc, check(key, -100.0f, 100.0f, ToFloat(value))) ); + else if ("ampeg_release" == key_cc) pCurDef->ampeg_releasecc.add( CC(num_cc, check(key, -100.0f, 100.0f, ToFloat(value))) ); + + else if ("fileg_delay" == key_cc) pCurDef->fileg_delay_oncc.add( CC(num_cc, check(key, -100.0f, 100.0f, ToFloat(value))) ); + else if ("fileg_start" == key_cc) pCurDef->fileg_start_oncc.add( CC(num_cc, check(key, -100.0f, 100.0f, ToFloat(value))) ); + else if ("fileg_attack" == key_cc) pCurDef->fileg_attack_oncc.add( CC(num_cc, check(key, -100.0f, 100.0f, ToFloat(value))) ); + else if ("fileg_hold" == key_cc) pCurDef->fileg_hold_oncc.add( CC(num_cc, check(key, -100.0f, 100.0f, ToFloat(value))) ); + else if ("fileg_decay" == key_cc) pCurDef->fileg_decay_oncc.add( CC(num_cc, check(key, -100.0f, 100.0f, ToFloat(value))) ); + else if ("fileg_sustain" == key_cc) pCurDef->fileg_sustain_oncc.add( CC(num_cc, check(key, -100.0f, 100.0f, ToFloat(value))) ); + else if ("fileg_release" == key_cc) pCurDef->fileg_release_oncc.add( CC(num_cc, check(key, -100.0f, 100.0f, ToFloat(value))) ); + else if ("fileg_depth" == key_cc) pCurDef->fileg_depth_oncc.add( CC(num_cc, check(key, -12000, 12000, ToInt(value))) ); + + else if ("pitcheg_delay" == key_cc) pCurDef->pitcheg_delay_oncc.add( CC(num_cc, check(key, -100.0f, 100.0f, ToFloat(value))) ); + else if ("pitcheg_start" == key_cc) pCurDef->pitcheg_start_oncc.add( CC(num_cc, check(key, -100.0f, 100.0f, ToFloat(value))) ); + else if ("pitcheg_attack" == key_cc) pCurDef->pitcheg_attack_oncc.add( CC(num_cc, check(key, -100.0f, 100.0f, ToFloat(value))) ); + else if ("pitcheg_hold" == key_cc) pCurDef->pitcheg_hold_oncc.add( CC(num_cc, check(key, -100.0f, 100.0f, ToFloat(value))) ); + else if ("pitcheg_decay" == key_cc) pCurDef->pitcheg_decay_oncc.add( CC(num_cc, check(key, -100.0f, 100.0f, ToFloat(value))) ); + else if ("pitcheg_sustain" == key_cc) pCurDef->pitcheg_sustain_oncc.add( CC(num_cc, check(key, -100.0f, 100.0f, ToFloat(value))) ); + else if ("pitcheg_release" == key_cc) pCurDef->pitcheg_release_oncc.add( CC(num_cc, check(key, -100.0f, 100.0f, ToFloat(value))) ); + else if ("pitcheg_depth" == key_cc) pCurDef->pitcheg_depth_oncc.add( CC(num_cc, check(key, -12000, 12000, ToInt(value))) ); + + else if ("pitchlfo_delay" == key_cc) pCurDef->pitchlfo_delay_oncc.add( CC(num_cc, check(key, 0.0f, 100.0f, ToFloat(value))) ); + else if ("pitchlfo_fade" == key_cc) pCurDef->pitchlfo_fade_oncc.add( CC(num_cc, check(key, 0.0f, 100.0f, ToFloat(value))) ); + else if ("pitchlfo_depth" == key_cc) pCurDef->pitchlfo_depthcc.add( CC(num_cc, check(key, -1200, 1200, ToInt(value))) ); + else if ("pitchlfo_freq" == key_cc) pCurDef->pitchlfo_freqcc.add( CC(num_cc, check(key, -200.0f, 200.0f, ToFloat(value))) ); + else if ("fillfo_delay" == key_cc) pCurDef->fillfo_delay_oncc.add( CC(num_cc, check(key, 0.0f, 100.0f, ToFloat(value))) ); + else if ("fillfo_fade" == key_cc) pCurDef->fillfo_fade_oncc.add( CC(num_cc, check(key, 0.0f, 100.0f, ToFloat(value))) ); + else if ("fillfo_depth" == key_cc) pCurDef->fillfo_depthcc.add( CC(num_cc, check(key, -1200, 1200, ToInt(value))) ); + else if ("fillfo_freq" == key_cc) pCurDef->fillfo_freqcc.add( CC(num_cc, check(key, -200.0f, 200.0f, ToFloat(value))) ); + else if ("amplfo_delay" == key_cc) pCurDef->amplfo_delay_oncc.add( CC(num_cc, check(key, 0.0f, 100.0f, ToFloat(value))) ); + else if ("amplfo_fade" == key_cc) pCurDef->amplfo_fade_oncc.add( CC(num_cc, check(key, 0.0f, 100.0f, ToFloat(value))) ); + else if ("amplfo_depth" == key_cc) pCurDef->amplfo_depthcc.add( CC(num_cc, check(key, -10.0f, 10.0f, ToFloat(value))) ); + else if ("amplfo_freq" == key_cc) pCurDef->amplfo_freqcc.add( CC(num_cc, check(key, -200.0f, 200.0f, ToFloat(value))) ); + else if ("volume" == key_cc) pCurDef->volume_oncc.add( CC(num_cc, check(key, -144.0f, 100.0f, ToFloat(value))) ); + else if ("volume_curve" == key_cc) pCurDef->volume_curvecc.add( CC(num_cc, 0, check(key, 0, 30000, ToInt(value))) ); + else if ("volume_smooth" == key_cc) pCurDef->volume_smoothcc.add( CC(num_cc, 0, -1, check(key, 0.0f, 100000.0f /* max? */, ToFloat(value))) ); + else if ("volume_step" == key_cc) pCurDef->volume_stepcc.add( CC(num_cc, 0, -1, 0, check(key, -20.0f, 20.0f, ToFloat(value))) ); + else if ("pan" == key_cc) pCurDef->pan_oncc.add( CC(num_cc, check(key, -200.0f, 200.0f, ToFloat(value))) ); + else if ("pan_curve" == key_cc) pCurDef->pan_curvecc.add( CC(num_cc, 0, check(key, 0, 30000, ToInt(value))) ); + else if ("pan_smooth" == key_cc) pCurDef->pan_smoothcc.add( CC(num_cc, 0, -1, check(key, 0.0f, 100000.0f /* max? */, ToFloat(value))) ); + else if ("pan_step" == key_cc) pCurDef->pan_stepcc.add( CC(num_cc, 0, -1, 0, check(key, -100.0f, 100.0f, ToFloat(value))) ); else std::cerr << "The opcode '" << key << "' is unsupported by libsfz!" << std::endl; } @@ -1381,10 +1863,204 @@ EGNode::EGNode() : time(0), level(0), shape(0), curve(0) { } + + void EGNode::Copy(const EGNode& egNode) { + time = egNode.time; + level = egNode.level; + shape = egNode.shape; + curve = egNode.curve; + + time_oncc = egNode.time_oncc; + level_oncc = egNode.level_oncc; + } EG::EG() : - sustain(0), loop(0), loop_count(0), - amplitude(0), cutoff(0) { + sustain(0), loop(0), loop_count(0), amplitude(0), pan(0), pan_curve(-1), + cutoff(0), pitch(0), resonance(0), volume(-200) /* less than -144 dB is considered unset */ + { } + + void EG::Copy(const EG& eg) { + EqImpl::Copy(static_cast(eg)); + + sustain = eg.sustain; + loop = eg.loop; + loop_count = eg.loop_count; + amplitude = eg.amplitude; + volume = eg.volume; + cutoff = eg.cutoff; + pitch = eg.pitch; + resonance = eg.resonance; + pan = eg.pan; + pan_curve = eg.pan_curve; + node = eg.node; + + amplitude_oncc = eg.amplitude_oncc; + volume_oncc = eg.volume_oncc; + cutoff_oncc = eg.cutoff_oncc; + pitch_oncc = eg.pitch_oncc; + resonance_oncc = eg.resonance_oncc; + pan_oncc = eg.pan_oncc; + pan_curvecc = eg.pan_curvecc; + } + + LFO::LFO(): freq (-1),/* -1 is used to determine whether the LFO was initialized */ + fade(0), phase(0), wave(0), delay(0), pitch(0), cutoff(0), resonance(0), pan(0), volume(0) { + + } + + void LFO::Copy(const LFO& lfo) { + EqSmoothStepImpl::Copy(static_cast(lfo)); + + delay = lfo.delay; + freq = lfo.freq; + fade = lfo.fade; + phase = lfo.phase; + wave = lfo.wave; + volume = lfo.volume; + pitch = lfo.pitch; + cutoff = lfo.cutoff; + resonance = lfo.resonance; + pan = lfo.pan; + + delay_oncc = lfo.delay_oncc; + freq_oncc = lfo.freq_oncc; + freq_smoothcc = lfo.freq_smoothcc; + freq_stepcc = lfo.freq_stepcc; + fade_oncc = lfo.fade_oncc; + phase_oncc = lfo.phase_oncc; + pitch_oncc = lfo.pitch_oncc; + pitch_smoothcc = lfo.pitch_smoothcc; + pitch_stepcc = lfo.pitch_stepcc; + volume_oncc = lfo.volume_oncc; + volume_smoothcc = lfo.volume_smoothcc; + volume_stepcc = lfo.volume_stepcc; + pan_oncc = lfo.pan_oncc; + pan_smoothcc = lfo.pan_smoothcc; + pan_stepcc = lfo.pan_stepcc; + cutoff_oncc = lfo.cutoff_oncc; + cutoff_smoothcc = lfo.cutoff_smoothcc; + cutoff_stepcc = lfo.cutoff_stepcc; + resonance_oncc = lfo.resonance_oncc; + resonance_smoothcc = lfo.resonance_smoothcc; + resonance_stepcc = lfo.resonance_stepcc; + } + + EqImpl::EqImpl() { + eq1freq = eq2freq = eq3freq = 0; + eq1bw = eq2bw = eq3bw = 0; + eq1gain = eq2gain = eq3gain = 0; + } + + void EqImpl::Copy(const EqImpl& eq) { + eq1freq = eq.eq1freq; + eq2freq = eq.eq2freq; + eq3freq = eq.eq3freq; + eq1bw = eq.eq1bw; + eq2bw = eq.eq2bw; + eq3bw = eq.eq3bw; + eq1gain = eq.eq1gain; + eq2gain = eq.eq2gain; + eq3gain = eq.eq3gain; + + eq1freq_oncc = eq.eq1freq_oncc; + eq2freq_oncc = eq.eq2freq_oncc; + eq3freq_oncc = eq.eq3freq_oncc; + eq1bw_oncc = eq.eq1bw_oncc; + eq2bw_oncc = eq.eq2bw_oncc; + eq3bw_oncc = eq.eq3bw_oncc; + eq1gain_oncc = eq.eq1gain_oncc; + eq2gain_oncc = eq.eq2gain_oncc; + eq3gain_oncc = eq.eq3gain_oncc; + } + + bool EqImpl::HasEq() { + return eq1freq || eq2freq || eq3freq || eq1bw || eq2bw || eq3bw || + eq1gain || eq2gain || eq3gain || !eq1gain_oncc.empty() || + !eq2gain_oncc.empty() || !eq3gain_oncc.empty() || + !eq1freq_oncc.empty() || !eq2freq_oncc.empty() || !eq3freq_oncc.empty() || + !eq1bw_oncc.empty() || !eq2bw_oncc.empty() || !eq3bw_oncc.empty(); + } + + void EqSmoothStepImpl::Copy(const EqSmoothStepImpl& eq) { + EqImpl::Copy(eq); + + eq1freq_smoothcc = eq.eq1freq_smoothcc; + eq2freq_smoothcc = eq.eq2freq_smoothcc; + eq3freq_smoothcc = eq.eq3freq_smoothcc; + eq1bw_smoothcc = eq.eq1bw_smoothcc; + eq2bw_smoothcc = eq.eq2bw_smoothcc; + eq3bw_smoothcc = eq.eq3bw_smoothcc; + eq1gain_smoothcc = eq.eq1gain_smoothcc; + eq2gain_smoothcc = eq.eq2gain_smoothcc; + eq3gain_smoothcc = eq.eq3gain_smoothcc; + + eq1freq_stepcc = eq.eq1freq_stepcc; + eq2freq_stepcc = eq.eq2freq_stepcc; + eq3freq_stepcc = eq.eq3freq_stepcc; + eq1bw_stepcc = eq.eq1bw_stepcc; + eq2bw_stepcc = eq.eq2bw_stepcc; + eq3bw_stepcc = eq.eq3bw_stepcc; + eq1gain_stepcc = eq.eq1gain_stepcc; + eq2gain_stepcc = eq.eq2gain_stepcc; + eq3gain_stepcc = eq.eq3gain_stepcc; + } + + void EqSmoothStepImpl::copySmoothValues() { + File::copySmoothValues(eq1freq_smoothcc, eq1freq_oncc); + eq1freq_smoothcc.clear(); + + File::copySmoothValues(eq2freq_smoothcc, eq2freq_oncc); + eq2freq_smoothcc.clear(); + + File::copySmoothValues(eq3freq_smoothcc, eq3freq_oncc); + eq3freq_smoothcc.clear(); + + File::copySmoothValues(eq1bw_smoothcc, eq1bw_oncc); + eq1bw_smoothcc.clear(); + + File::copySmoothValues(eq2bw_smoothcc, eq2bw_oncc); + eq2bw_smoothcc.clear(); + + File::copySmoothValues(eq3bw_smoothcc, eq3bw_oncc); + eq3bw_smoothcc.clear(); + + File::copySmoothValues(eq1gain_smoothcc, eq1gain_oncc); + eq1gain_smoothcc.clear(); + + File::copySmoothValues(eq2gain_smoothcc, eq2gain_oncc); + eq2gain_smoothcc.clear(); + + File::copySmoothValues(eq3gain_smoothcc, eq3gain_oncc); + eq3gain_smoothcc.clear(); + } + + void EqSmoothStepImpl::copyStepValues() { + File::copyStepValues(eq1freq_stepcc, eq1freq_oncc); + eq1freq_stepcc.clear(); + + File::copyStepValues(eq2freq_stepcc, eq2freq_oncc); + eq2freq_stepcc.clear(); + + File::copyStepValues(eq3freq_stepcc, eq3freq_oncc); + eq3freq_stepcc.clear(); + + File::copyStepValues(eq1bw_stepcc, eq1bw_oncc); + eq1bw_stepcc.clear(); + + File::copyStepValues(eq2bw_stepcc, eq2bw_oncc); + eq2bw_stepcc.clear(); + + File::copyStepValues(eq3bw_stepcc, eq3bw_oncc); + eq3bw_stepcc.clear(); + + File::copyStepValues(eq1gain_stepcc, eq1gain_oncc); + eq1gain_stepcc.clear(); + + File::copyStepValues(eq2gain_stepcc, eq2gain_oncc); + eq2gain_stepcc.clear(); + + File::copyStepValues(eq3gain_stepcc, eq3gain_oncc); + eq3gain_stepcc.clear(); } EG& File::eg(int x) { @@ -1401,11 +2077,6 @@ } return e.node[y]; } - - 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) { - - } LFO& File::lfo(int x) { while (pCurDef->lfos.size() <= x) {