3 |
* LinuxSampler - modular, streaming capable sampler * |
* LinuxSampler - modular, streaming capable sampler * |
4 |
* * |
* * |
5 |
* Copyright (C) 2008 Anders Dahnielson <anders@dahnielson.com> * |
* Copyright (C) 2008 Anders Dahnielson <anders@dahnielson.com> * |
6 |
* Copyright (C) 2009 - 2012 Anders Dahnielson and Grigor Iliev * |
* Copyright (C) 2009 - 2013 Anders Dahnielson and Grigor Iliev * |
7 |
* * |
* * |
8 |
* This program is free software; you can redistribute it and/or modify * |
* This program is free software; you can redistribute it and/or modify * |
9 |
* it under the terms of the GNU General Public License as published by * |
* it under the terms of the GNU General Public License as published by * |
322 |
volume_curvecc.clear(); |
volume_curvecc.clear(); |
323 |
volume_smoothcc.clear(); |
volume_smoothcc.clear(); |
324 |
volume_stepcc.clear(); |
volume_stepcc.clear(); |
325 |
|
amplitude = 100; |
326 |
pan = 0; |
pan = 0; |
327 |
pan_oncc.clear(); |
pan_oncc.clear(); |
328 |
pan_curvecc.clear(); |
pan_curvecc.clear(); |
639 |
region->volume_curvecc = volume_curvecc; |
region->volume_curvecc = volume_curvecc; |
640 |
region->volume_smoothcc = volume_smoothcc; |
region->volume_smoothcc = volume_smoothcc; |
641 |
region->volume_stepcc = volume_stepcc; |
region->volume_stepcc = volume_stepcc; |
642 |
|
region->amplitude = amplitude; |
643 |
region->pan = pan; |
region->pan = pan; |
644 |
region->pan_oncc = pan_oncc; |
region->pan_oncc = pan_oncc; |
645 |
region->pan_curvecc = pan_curvecc; |
region->pan_curvecc = pan_curvecc; |
874 |
_instrument = new Instrument(LinuxSampler::Path::getBaseName(file), pSampleManager); |
_instrument = new Instrument(LinuxSampler::Path::getBaseName(file), pSampleManager); |
875 |
_current_group = new Group(); |
_current_group = new Group(); |
876 |
pCurDef = _current_group; |
pCurDef = _current_group; |
877 |
|
|
878 |
|
parseFile(file,pSampleManager); |
879 |
|
} |
880 |
|
|
881 |
|
void File::parseFile(std::string file, SampleManager* pSampleManager){ |
882 |
enum token_type_t { HEADER, OPCODE }; |
enum token_type_t { HEADER, OPCODE }; |
883 |
token_type_t token_type; |
token_type_t token_type; |
884 |
std::string token_string; |
std::string token_string; |
897 |
if (slash_index != std::string::npos) |
if (slash_index != std::string::npos) |
898 |
line.resize(slash_index); |
line.resize(slash_index); |
899 |
|
|
900 |
|
// #include |
901 |
|
if (line.find("#include ") == 0) { |
902 |
|
size_t fname_start = line.find("\""); |
903 |
|
if (fname_start == std::string::npos) continue; |
904 |
|
|
905 |
|
size_t fname_end = line.find("\"", fname_start + 1); |
906 |
|
if (fname_end == std::string::npos || fname_start == fname_end) |
907 |
|
continue; |
908 |
|
std::string fname = line.substr(fname_start + 1, fname_end - fname_start - 1); |
909 |
|
|
910 |
|
if (!currentDir.empty() && !LinuxSampler::Path(fname).isAbsolute()) |
911 |
|
fname = currentDir + LinuxSampler::File::DirSeparator + fname; |
912 |
|
|
913 |
|
std::string cd = currentDir; // backup current dir |
914 |
|
parseFile(fname, pSampleManager); |
915 |
|
currentDir = cd; // restore currentDir (since altered by parsefile()) |
916 |
|
continue; |
917 |
|
} |
918 |
|
|
919 |
// DEFINITION |
// DEFINITION |
920 |
std::stringstream linestream(line); |
std::stringstream linestream(line); |
|
linestream >> std::noskipws; |
|
921 |
int spaces = 0; |
int spaces = 0; |
922 |
while (linestream >> token) |
while (linestream >> token) |
923 |
{ |
{ |
924 |
|
linestream >> std::noskipws; |
925 |
if (token[0] == '<' && token[token.size()-1] == '>') |
if (token[0] == '<' && token[token.size()-1] == '>') |
926 |
{ |
{ |
927 |
// HEAD |
// HEAD |
1421 |
|
|
1422 |
// amplifier |
// amplifier |
1423 |
else if ("volume" == key) pCurDef->volume = ToFloat(value); |
else if ("volume" == key) pCurDef->volume = ToFloat(value); |
1424 |
|
else if ("amplitude" == key) pCurDef->amplitude = ToFloat(value); |
1425 |
else if ("pan" == key) pCurDef->pan = ToFloat(value); |
else if ("pan" == key) pCurDef->pan = ToFloat(value); |
1426 |
else if ("width" == key) pCurDef->width = ToFloat(value); |
else if ("width" == key) pCurDef->width = ToFloat(value); |
1427 |
else if ("position" == key) pCurDef->position = ToFloat(value); |
else if ("position" == key) pCurDef->position = ToFloat(value); |