/[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 2233 by iliev, Mon Aug 8 18:46:19 2011 UTC revision 2235 by iliev, Wed Aug 10 19:40:39 2011 UTC
# Line 51  namespace sfz Line 51  namespace sfz
51          return val;          return val;
52      }      }
53    
54      Sample* SampleManager::FindSample(std::string samplePath, int offset) {      Sample* SampleManager::FindSample(std::string samplePath, uint offset, int end) {
55          std::map<Sample*, std::set<Region*> >::iterator it = sampleMap.begin();          std::map<Sample*, std::set<Region*> >::iterator it = sampleMap.begin();
56          for (; it != sampleMap.end(); it++) {          for (; it != sampleMap.end(); it++) {
57              if (it->first->GetFile() == samplePath) {              if (it->first->GetFile() == samplePath) {
# Line 59  namespace sfz Line 59  namespace sfz
59                   * same sample with different offset as different samples                   * same sample with different offset as different samples
60                   * // TODO: Ignore offset when the whole sample is cached in RAM?                   * // TODO: Ignore offset when the whole sample is cached in RAM?
61                   */                   */
62                  int maxOffset = it->first->MaxOffset;                  if (it->first->Offset == offset && it->first->End == end) return it->first;
                 if(it->first->Offset == offset || (it->first->Offset < maxOffset && offset < maxOffset)) {  
                     return it->first;  
                 }  
63              }              }
64          }          }
65    
# Line 113  namespace sfz Line 110  namespace sfz
110      Sample* Region::GetSample(bool create)      Sample* Region::GetSample(bool create)
111      {      {
112          if(pSample == NULL && create) {          if(pSample == NULL && create) {
113              int i = offset ? *offset : 0;              uint i = offset ? *offset : 0;
114              Sample* sf = GetInstrument()->GetSampleManager()->FindSample(sample, i);              int e = end ? *end : -2;
115                Sample* sf = GetInstrument()->GetSampleManager()->FindSample(sample, i, e);
116              if (sf != NULL) pSample = sf; // Reuse already created sample              if (sf != NULL) pSample = sf; // Reuse already created sample
117              else pSample = new Sample(sample, false, i);              else pSample = new Sample(sample, false, i, e);
118              GetInstrument()->GetSampleManager()->AddSampleConsumer(pSample, this);              GetInstrument()->GetSampleManager()->AddSampleConsumer(pSample, this);
119          }          }
120          return pSample;          return pSample;
# Line 1349  namespace sfz Line 1347  namespace sfz
1347              else if (strcmp(s, "_loop") == 0) eg(x).loop = ToInt(value);              else if (strcmp(s, "_loop") == 0) eg(x).loop = ToInt(value);
1348              else if (strcmp(s, "_loop_count") == 0) eg(x).loop_count = ToInt(value);              else if (strcmp(s, "_loop_count") == 0) eg(x).loop_count = ToInt(value);
1349              else if (strcmp(s, "_amplitude") == 0) eg(x).amplitude = ToFloat(value);              else if (strcmp(s, "_amplitude") == 0) eg(x).amplitude = ToFloat(value);
1350                else if (sscanf(s, "_amplitude_oncc%d", &y)) eg(x).amplitude_oncc.add( CC(y, check(key, 0.0f, 100.0f, ToFloat(value))) );
1351                else if (strcmp(s, "_volume") == 0) eg(x).volume = check(key, -144.0f, 6.0f, ToFloat(value));
1352                else if (sscanf(s, "_volume_oncc%d", &y)) eg(x).volume_oncc.add( CC(y, check(key, -144.0f, 6.0f, ToFloat(value))) );
1353              else if (strcmp(s, "_cutoff") == 0) eg(x).cutoff = ToFloat(value);              else if (strcmp(s, "_cutoff") == 0) eg(x).cutoff = ToFloat(value);
1354                else if (sscanf(s, "_cutoff_oncc%d", &y)) eg(x).cutoff_oncc.add( CC(y, check(key, -9600, 9600, ToInt(value))) );
1355                else if (strcmp(s, "_pitch") == 0) eg(x).pitch = check(key, -9600, 9600, ToInt(value));
1356                else if (sscanf(s, "_pitch_oncc%d", &y)) eg(x).pitch_oncc.add( CC(y, check(key, -9600, 9600, ToInt(value))) );
1357                else if (strcmp(s, "_resonance") == 0) eg(x).resonance = check(key, 0.0f, 40.0f, ToFloat(value));
1358                else if (sscanf(s, "_resonance_oncc%d", &y)) eg(x).resonance_oncc.add( CC(y, check(key, 0.0f, 40.0f, ToFloat(value))) );
1359              else std::cerr << "The opcode '" << key << "' is unsupported by libsfz!" << std::endl;              else std::cerr << "The opcode '" << key << "' is unsupported by libsfz!" << std::endl;
1360          }          }
1361    
# Line 1577  namespace sfz Line 1583  namespace sfz
1583      }      }
1584    
1585      EG::EG() :      EG::EG() :
1586          sustain(0), loop(0), loop_count(0),          sustain(0), loop(0), loop_count(0), amplitude(0),
1587          amplitude(0), cutoff(0) {          cutoff(0), pitch(0), resonance(0), volume(-200) /* less than -144 dB is considered unset */
1588      }      { }
1589            
1590      void EG::Copy(const EG& eg) {      void EG::Copy(const EG& eg) {
1591          sustain    = eg.sustain;          sustain    = eg.sustain;
1592          loop       = eg.loop;          loop       = eg.loop;
1593          loop_count = eg.loop_count;          loop_count = eg.loop_count;
1594          amplitude  = eg.amplitude;          amplitude  = eg.amplitude;
1595            volume     = eg.volume;
1596          cutoff     = eg.cutoff;          cutoff     = eg.cutoff;
1597            pitch      = eg.pitch;
1598            resonance  = eg.resonance;
1599          node       = eg.node;          node       = eg.node;
1600            
1601            amplitude_oncc = eg.amplitude_oncc;
1602            volume_oncc    = eg.volume_oncc;
1603            cutoff_oncc    = eg.cutoff_oncc;
1604            pitch_oncc     = eg.pitch_oncc;
1605            resonance_oncc = eg.resonance_oncc;
1606      }      }
1607            
1608      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 */

Legend:
Removed from v.2233  
changed lines
  Added in v.2235

  ViewVC Help
Powered by ViewVC