31 |
|
|
32 |
#include "../../common/File.h" |
#include "../../common/File.h" |
33 |
#include "../../common/Path.h" |
#include "../../common/Path.h" |
|
#include "../../common/global_private.h" |
|
34 |
#include "LookupTable.h" |
#include "LookupTable.h" |
35 |
|
|
36 |
namespace sfz |
namespace sfz |
323 |
volume_curvecc.clear(); |
volume_curvecc.clear(); |
324 |
volume_smoothcc.clear(); |
volume_smoothcc.clear(); |
325 |
pan = 0; |
pan = 0; |
326 |
|
pan_oncc.clear(); |
327 |
|
pan_curvecc.clear(); |
328 |
|
pan_smoothcc.clear(); |
329 |
width = 100; |
width = 100; |
330 |
position = 0; |
position = 0; |
331 |
amp_keytrack = 0; |
amp_keytrack = 0; |
611 |
region->volume_curvecc = volume_curvecc; |
region->volume_curvecc = volume_curvecc; |
612 |
region->volume_smoothcc = volume_smoothcc; |
region->volume_smoothcc = volume_smoothcc; |
613 |
region->pan = pan; |
region->pan = pan; |
614 |
|
region->pan_oncc = pan_oncc; |
615 |
|
region->pan_curvecc = pan_curvecc; |
616 |
|
region->pan_smoothcc = pan_smoothcc; |
617 |
region->width = width; |
region->width = width; |
618 |
region->position = position; |
region->position = position; |
619 |
region->amp_keytrack = amp_keytrack; |
region->amp_keytrack = amp_keytrack; |
823 |
currentDir = LinuxSampler::Path::stripLastName(file); |
currentDir = LinuxSampler::Path::stripLastName(file); |
824 |
std::string token; |
std::string token; |
825 |
std::string line; |
std::string line; |
826 |
|
currentLine = 0; |
827 |
|
|
828 |
while (std::getline(fs, line)) |
while (std::getline(fs, line)) |
829 |
{ |
{ |
830 |
|
currentLine++; |
831 |
// COMMENT |
// COMMENT |
832 |
std::string::size_type slash_index = line.find("//"); |
std::string::size_type slash_index = line.find("//"); |
833 |
if (slash_index != std::string::npos) |
if (slash_index != std::string::npos) |
983 |
copySmoothValues(r->volume_smoothcc, r->volume_oncc); |
copySmoothValues(r->volume_smoothcc, r->volume_oncc); |
984 |
r->volume_smoothcc.clear(); |
r->volume_smoothcc.clear(); |
985 |
|
|
986 |
|
copyCurves(r->pan_curvecc, r->pan_oncc); |
987 |
|
r->pan_curvecc.clear(); |
988 |
|
|
989 |
|
copySmoothValues(r->pan_smoothcc, r->pan_oncc); |
990 |
|
r->pan_smoothcc.clear(); |
991 |
|
|
992 |
|
for (int j = 0; j < r->eg.size(); j++) { |
993 |
|
copyCurves(r->eg[j].pan_curvecc, r->eg[j].pan_oncc); |
994 |
|
r->eg[j].pan_curvecc.clear(); |
995 |
|
} |
996 |
|
|
997 |
for (int j = 0; j < r->lfos.size(); j++) { |
for (int j = 0; j < r->lfos.size(); j++) { |
998 |
copySmoothValues(r->lfos[j].volume_smoothcc, r->lfos[j].volume_oncc); |
copySmoothValues(r->lfos[j].volume_smoothcc, r->lfos[j].volume_oncc); |
999 |
r->lfos[j].volume_smoothcc.clear(); |
r->lfos[j].volume_smoothcc.clear(); |
1047 |
} |
} |
1048 |
} |
} |
1049 |
} |
} |
1050 |
|
|
1051 |
|
int File::ToInt(const std::string& s) throw(LinuxSampler::Exception) { |
1052 |
|
int i; |
1053 |
|
std::istringstream iss(s); |
1054 |
|
if(!(iss >> i)) { |
1055 |
|
std::ostringstream oss; |
1056 |
|
oss << "Line " << currentLine << ": Expected an integer"; |
1057 |
|
throw LinuxSampler::Exception(oss.str()); |
1058 |
|
} |
1059 |
|
return i; |
1060 |
|
} |
1061 |
|
|
1062 |
|
float File::ToFloat(const std::string& s) throw(LinuxSampler::Exception) { |
1063 |
|
float i; |
1064 |
|
std::istringstream iss(s); |
1065 |
|
if(!(iss >> i)) { |
1066 |
|
std::ostringstream oss; |
1067 |
|
oss << "Line " << currentLine << ": Expected a floating-point number"; |
1068 |
|
throw LinuxSampler::Exception(oss.str()); |
1069 |
|
} |
1070 |
|
return i; |
1071 |
|
} |
1072 |
|
|
1073 |
void |
void |
1074 |
File::push_header(std::string token) |
File::push_header(std::string token) |
1396 |
else if (sscanf(s, "_pitch_oncc%d", &y)) eg(x).pitch_oncc.add( CC(y, 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))) ); |
1397 |
else if (strcmp(s, "_resonance") == 0) eg(x).resonance = check(key, 0.0f, 40.0f, ToFloat(value)); |
else if (strcmp(s, "_resonance") == 0) eg(x).resonance = check(key, 0.0f, 40.0f, ToFloat(value)); |
1398 |
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 (sscanf(s, "_resonance_oncc%d", &y)) eg(x).resonance_oncc.add( CC(y, check(key, 0.0f, 40.0f, ToFloat(value))) ); |
1399 |
|
else if (strcmp(s, "_pan") == 0) eg(x).pan = check(key, -100.0f, 100.0f, ToFloat(value)); |
1400 |
|
else if (strcmp(s, "_pan_curve") == 0) eg(x).pan_curve = check(key, 0, 30000, ToInt(value)); |
1401 |
|
else if (sscanf(s, "_pan_oncc%d", &y)) eg(x).pan_oncc.add( CC(y, check(key, -100.0f, 100.0f, ToFloat(value))) ); |
1402 |
|
else if (sscanf(s, "_pan_curvecc%d", &y)) eg(x).pan_curvecc.add( CC(y, 0.0f, check(key, 0, 30000, ToInt(value))) ); |
1403 |
else std::cerr << "The opcode '" << key << "' is unsupported by libsfz!" << std::endl; |
else std::cerr << "The opcode '" << key << "' is unsupported by libsfz!" << std::endl; |
1404 |
} |
} |
1405 |
|
|
1566 |
else if ("fillfo_freq" == key_cc) pCurDef->fillfo_freqcc.add( CC(num_cc, check(key, -200.0f, 200.0f, ToFloat(value))) ); |
else if ("fillfo_freq" == key_cc) pCurDef->fillfo_freqcc.add( CC(num_cc, check(key, -200.0f, 200.0f, ToFloat(value))) ); |
1567 |
else if ("amplfo_depth" == key_cc) pCurDef->amplfo_depthcc.add( CC(num_cc, check(key, -10.0f, 10.0f, ToFloat(value))) ); |
else if ("amplfo_depth" == key_cc) pCurDef->amplfo_depthcc.add( CC(num_cc, check(key, -10.0f, 10.0f, ToFloat(value))) ); |
1568 |
else if ("amplfo_freq" == key_cc) pCurDef->amplfo_freqcc.add( CC(num_cc, check(key, -200.0f, 200.0f, ToFloat(value))) ); |
else if ("amplfo_freq" == key_cc) pCurDef->amplfo_freqcc.add( CC(num_cc, check(key, -200.0f, 200.0f, ToFloat(value))) ); |
1569 |
else if ("volume_on" == key_cc) pCurDef->volume_oncc.add( CC(num_cc, check(key, -100.0f, 100.0f, ToFloat(value))) ); |
else if ("volume_on" == key_cc) pCurDef->volume_oncc.add( CC(num_cc, check(key, -144.0f, 100.0f, ToFloat(value))) ); |
1570 |
else if ("volume_curve" == key_cc) pCurDef->volume_curvecc.add( CC(num_cc, 0, check(key, 0, 30000, ToInt(value))) ); |
else if ("volume_curve" == key_cc) pCurDef->volume_curvecc.add( CC(num_cc, 0, check(key, 0, 30000, ToInt(value))) ); |
1571 |
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_smooth" == key_cc) pCurDef->volume_smoothcc.add( CC(num_cc, 0, -1, check(key, 0.0f, 100000.0f /* max? */, ToFloat(value))) ); |
1572 |
|
else if ("pan_on" == key_cc) pCurDef->pan_oncc.add( CC(num_cc, check(key, -100.0f, 100.0f, ToFloat(value))) ); |
1573 |
|
else if ("pan_curve" == key_cc) pCurDef->pan_curvecc.add( CC(num_cc, 0, check(key, 0, 30000, ToInt(value))) ); |
1574 |
|
else if ("pan_smooth" == key_cc) pCurDef->pan_smoothcc.add( CC(num_cc, 0, -1, check(key, 0.0f, 100000.0f /* max? */, ToFloat(value))) ); |
1575 |
else std::cerr << "The opcode '" << key << "' is unsupported by libsfz!" << std::endl; |
else std::cerr << "The opcode '" << key << "' is unsupported by libsfz!" << std::endl; |
1576 |
} |
} |
1577 |
|
|
1630 |
} |
} |
1631 |
|
|
1632 |
EG::EG() : |
EG::EG() : |
1633 |
sustain(0), loop(0), loop_count(0), amplitude(0), |
sustain(0), loop(0), loop_count(0), amplitude(0), pan(0), pan_curve(-1), |
1634 |
cutoff(0), pitch(0), resonance(0), volume(-200) /* less than -144 dB is considered unset */ |
cutoff(0), pitch(0), resonance(0), volume(-200) /* less than -144 dB is considered unset */ |
1635 |
{ } |
{ } |
1636 |
|
|
1643 |
cutoff = eg.cutoff; |
cutoff = eg.cutoff; |
1644 |
pitch = eg.pitch; |
pitch = eg.pitch; |
1645 |
resonance = eg.resonance; |
resonance = eg.resonance; |
1646 |
|
pan = eg.pan; |
1647 |
|
pan_curve = eg.pan_curve; |
1648 |
node = eg.node; |
node = eg.node; |
1649 |
|
|
1650 |
amplitude_oncc = eg.amplitude_oncc; |
amplitude_oncc = eg.amplitude_oncc; |
1652 |
cutoff_oncc = eg.cutoff_oncc; |
cutoff_oncc = eg.cutoff_oncc; |
1653 |
pitch_oncc = eg.pitch_oncc; |
pitch_oncc = eg.pitch_oncc; |
1654 |
resonance_oncc = eg.resonance_oncc; |
resonance_oncc = eg.resonance_oncc; |
1655 |
|
pan_oncc = eg.pan_oncc; |
1656 |
|
pan_curvecc = eg.pan_curvecc; |
1657 |
} |
} |
1658 |
|
|
1659 |
LFO::LFO(): freq (-1),/* -1 is used to determine whether the LFO was initialized */ |
LFO::LFO(): freq (-1),/* -1 is used to determine whether the LFO was initialized */ |