/[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 2299 by iliev, Sun Dec 11 20:50:31 2011 UTC revision 2382 by persson, Sun Dec 2 16:30:42 2012 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 - 2011 Anders Dahnielson and Grigor Iliev          *   *   Copyright (C) 2009 - 2012 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 108  namespace sfz Line 108  namespace sfz
108    
109      Sample* Region::GetSample(bool create)      Sample* Region::GetSample(bool create)
110      {      {
111          if(pSample == NULL && create) {          if (pSample == NULL && create) {
112              uint i = offset ? *offset : 0;              uint i = offset ? *offset : 0;
113              int e = end ? *end : -2;              Sample* sf = GetInstrument()->GetSampleManager()->FindSample(sample, i, end);
             Sample* sf = GetInstrument()->GetSampleManager()->FindSample(sample, i, e);  
114              if (sf != NULL) pSample = sf; // Reuse already created sample              if (sf != NULL) pSample = sf; // Reuse already created sample
115              else pSample = new Sample(sample, false, i, e);              else pSample = new Sample(sample, false, i, end);
116              GetInstrument()->GetSampleManager()->AddSampleConsumer(pSample, this);              GetInstrument()->GetSampleManager()->AddSampleConsumer(pSample, this);
117          }          }
118          return pSample;          return pSample;
# Line 170  namespace sfz Line 169  namespace sfz
169      }      }
170    
171      bool Region::HasLoop() {      bool Region::HasLoop() {
172          bool b = loop_mode == ::sfz::LOOP_UNSET ? pSample->GetLoops() :          bool b = loop_mode == LOOP_UNSET ? pSample->GetLoops() :
173              (loop_mode == ::sfz::LOOP_CONTINUOUS || loop_mode == ::sfz::LOOP_SUSTAIN);              (loop_mode == LOOP_CONTINUOUS || loop_mode == LOOP_SUSTAIN);
174          return b && GetLoopStart() && GetLoopEnd() && GetLoopEnd() > GetLoopStart();          return b && GetLoopEnd() > GetLoopStart();
175      }      }
176    
177      uint Region::GetLoopStart() {      uint Region::GetLoopStart() {
# Line 310  namespace sfz Line 309  namespace sfz
309          delay.unset(); delay_random.unset();          delay.unset(); delay_random.unset();
310          delay_beats.unset(); stop_beats.unset();          delay_beats.unset(); stop_beats.unset();
311          delay_samples.unset();          delay_samples.unset();
312          end.unset();          end = 0;
313          loop_crossfade.unset();          loop_crossfade.unset();
314          offset.unset(); offset_random.unset();          offset.unset(); offset_random.unset();
315          loop_mode = LOOP_UNSET;          loop_mode = LOOP_UNSET;
# Line 893  namespace sfz Line 892  namespace sfz
892    
893              // DEFINITION              // DEFINITION
894              std::stringstream linestream(line);              std::stringstream linestream(line);
895                linestream >> std::noskipws;
896                int spaces = 0;
897              while (linestream >> token)              while (linestream >> token)
898              {              {
899                  if (token[0] == '<' and token[token.size()-1] == '>')                  if (token[0] == '<' && token[token.size()-1] == '>')
900                  {                  {
901                      // HEAD                      // HEAD
902                      if (!token_string.empty())                      if (!token_string.empty())
# Line 936  namespace sfz Line 937  namespace sfz
937                  else                  else
938                  {                  {
939                      // TAIL                      // TAIL
940                      token_string.append(" ");                      token_string.append(spaces, ' ');
941                      token_string.append(token);                      token_string.append(token);
942                  }                  }
943                    spaces = 0;
944                    while (isspace(linestream.peek())) {
945                        linestream.ignore();
946                        spaces++;
947                    }
948              }              }
949    
950              // EOL              // EOL
# Line 1014  namespace sfz Line 1020  namespace sfz
1020                          velcurve[v] = v * v / (127.0 * 127.0);                          velcurve[v] = v * v / (127.0 * 127.0);
1021                      }                      }
1022                  }                  }
   
                 // 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;  
                 }  
1023              }              }
1024          }          }
1025    
# Line 1276  namespace sfz Line 1275  namespace sfz
1275          {          {
1276              std::string path = default_path + value;              std::string path = default_path + value;
1277              #ifndef WIN32              #ifndef WIN32
1278              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] = '/';
1279                bool absolute = path[0] == '/';
1280                #else
1281                bool absolute = path[0] == '/' || path[0] == '\\' ||
1282                    (path.length() >= 2 && isalpha(path[0]) && path[1] == ':');
1283              #endif              #endif
1284              path = currentDir + LinuxSampler::File::DirSeparator + path; // TODO: check for absolute path              if (!absolute) path = currentDir + LinuxSampler::File::DirSeparator + path;
   
1285              if(pCurDef) pCurDef->sample = path;              if(pCurDef) pCurDef->sample = path;
1286              return;              return;
1287          }          }
# Line 1811  namespace sfz Line 1813  namespace sfz
1813              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))) );
1814              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))) );
1815              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 ("volume_step" == key_cc) pCurDef->volume_stepcc.add( CC(num_cc, 0, -1, 0, check(key, -20.0f, 20.0f, ToFloat(value))) );
1816              else if ("pan" == key_cc) pCurDef->pan_oncc.add( CC(num_cc, check(key, -100.0f, 100.0f, ToFloat(value))) );              else if ("pan" == key_cc) pCurDef->pan_oncc.add( CC(num_cc, check(key, -200.0f, 200.0f, ToFloat(value))) );
1817              else if ("pan_curve" == key_cc) pCurDef->pan_curvecc.add( CC(num_cc, 0, check(key, 0, 30000, ToInt(value))) );              else if ("pan_curve" == key_cc) pCurDef->pan_curvecc.add( CC(num_cc, 0, check(key, 0, 30000, ToInt(value))) );
1818              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_smooth" == key_cc) pCurDef->pan_smoothcc.add( CC(num_cc, 0, -1, check(key, 0.0f, 100000.0f /* max? */, ToFloat(value))) );
1819              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 if ("pan_step" == key_cc) pCurDef->pan_stepcc.add( CC(num_cc, 0, -1, 0, check(key, -100.0f, 100.0f, ToFloat(value))) );

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

  ViewVC Help
Powered by ViewVC