/[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 2382 by persson, Sun Dec 2 16:30:42 2012 UTC revision 2529 by schoenebeck, Tue Mar 4 20:41:47 2014 UTC
# Line 3  Line 3 
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  *
# Line 322  namespace sfz Line 322  namespace sfz
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();
# Line 638  namespace sfz Line 639  namespace sfz
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;
# Line 872  namespace sfz Line 874  namespace sfz
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;
# Line 890  namespace sfz Line 897  namespace sfz
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
# Line 1395  namespace sfz Line 1421  namespace sfz
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);

Legend:
Removed from v.2382  
changed lines
  Added in v.2529

  ViewVC Help
Powered by ViewVC