/[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 2012 by iliev, Fri Oct 23 17:53:17 2009 UTC revision 2021 by iliev, Fri Oct 30 16:36:20 2009 UTC
# Line 33  Line 33 
33  namespace sfz  namespace sfz
34  {  {
35    
36      LinuxSampler::SampleFile* SampleManager::FindSample(std::string samplePath) {      Sample* SampleManager::FindSample(std::string samplePath) {
37          std::map<LinuxSampler::SampleFile*, std::set<Region*> >::iterator it = sampleMap.begin();          std::map<Sample*, std::set<Region*> >::iterator it = sampleMap.begin();
38          for (; it != sampleMap.end(); it++) {          for (; it != sampleMap.end(); it++) {
39              if (it->first->GetFile() == samplePath) return it->first;              if (it->first->GetFile() == samplePath) return it->first;
40          }          }
# Line 93  namespace sfz Line 93  namespace sfz
93          DestroySampleIfNotUsed();          DestroySampleIfNotUsed();
94      }      }
95    
96      LinuxSampler::SampleFile* Region::GetSample(bool create)      Sample* Region::GetSample(bool create)
97      {      {
98          if(pSample == NULL && create) {          if(pSample == NULL && create) {
99              LinuxSampler::SampleFile* sf = GetInstrument()->GetSampleManager()->FindSample(sample);              Sample* sf = GetInstrument()->GetSampleManager()->FindSample(sample);
100              if (sf != NULL) pSample = sf; // Reuse already created sample              if (sf != NULL) pSample = sf; // Reuse already created sample
101              else pSample = new LinuxSampler::SampleFile(sample);              else pSample = new Sample(sample);
102              GetInstrument()->GetSampleManager()->AddSampleConsumer(pSample, this);              GetInstrument()->GetSampleManager()->AddSampleConsumer(pSample, this);
103          }          }
104          return pSample;          return pSample;
# Line 246  namespace sfz Line 246  namespace sfz
246          return new Articulation(); //todo: implement GetArticulation()          return new Articulation(); //todo: implement GetArticulation()
247      }      }
248    
249        bool Region::HasLoop() {
250            bool b = loop_mode == ::sfz::LOOP_CONTINUOUS || loop_mode == ::sfz::LOOP_SUSTAIN; // TODO: ONE_SHOT mode
251            return b && GetLoopStart() && GetLoopEnd() && GetLoopEnd() > GetLoopStart();
252        }
253    
254        uint Region::GetLoopStart() {
255            return (!loop_start) ? 0 : *loop_start; // TODO: use sample loop when loop_start not defined
256        }
257    
258        uint Region::GetLoopEnd() {
259            return (!loop_end) ? 0 : *loop_end; // TODO: use sample loop when loop_end not defined
260        }
261    
262        uint Region::GetLoopCount() {
263            return (!count) ? 0 : *count;
264        }
265    
266      /////////////////////////////////////////////////////////////      /////////////////////////////////////////////////////////////
267      // class Instrument      // class Instrument
268    
# Line 486  namespace sfz Line 503  namespace sfz
503              eq2_gain_oncc[i] = 0;              eq2_gain_oncc[i] = 0;
504              eq3_gain_oncc[i] = 0;              eq3_gain_oncc[i] = 0;
505          }          }
506    
507            // deprecated
508            ampeg_delay    = 0;
509            ampeg_start    = 0; //in percentage
510            ampeg_attack   = 0;
511            ampeg_hold     = 0;
512            ampeg_decay    = 0;
513            ampeg_sustain  = 100; // in percentage
514            ampeg_release  = 0;
515    
516            fileg_delay    = 0;
517            fileg_start    = 0; //in percentage
518            fileg_attack   = 0;
519            fileg_hold     = 0;
520            fileg_decay    = 0;
521            fileg_sustain  = 100; // in percentage
522            fileg_release  = 0;
523    
524            pitcheg_delay    = 0;
525            pitcheg_start    = 0; //in percentage
526            pitcheg_attack   = 0;
527            pitcheg_hold     = 0;
528            pitcheg_decay    = 0;
529            pitcheg_sustain  = 100; // in percentage
530            pitcheg_release  = 0;
531      }      }
532    
533      Region*      Region*
# Line 665  namespace sfz Line 707  namespace sfz
707          region->eq2_vel2gain = eq2_vel2gain;          region->eq2_vel2gain = eq2_vel2gain;
708          region->eq3_vel2gain = eq3_vel2gain;          region->eq3_vel2gain = eq3_vel2gain;
709    
710            // deprecated
711            region->ampeg_delay    = ampeg_delay;
712            region->ampeg_start    = ampeg_start;
713            region->ampeg_attack   = ampeg_attack;
714            region->ampeg_hold     = ampeg_hold;
715            region->ampeg_decay    = ampeg_decay;
716            region->ampeg_sustain  = ampeg_sustain;
717            region->ampeg_release  = ampeg_release;
718    
719            region->fileg_delay    = fileg_delay;
720            region->fileg_start    = fileg_start;
721            region->fileg_attack   = fileg_attack;
722            region->fileg_hold     = fileg_hold;
723            region->fileg_decay    = fileg_decay;
724            region->fileg_sustain  = fileg_sustain;
725            region->fileg_release  = fileg_release;
726    
727            region->pitcheg_delay    = pitcheg_delay;
728            region->pitcheg_start    = pitcheg_start;
729            region->pitcheg_attack   = pitcheg_attack;
730            region->pitcheg_hold     = pitcheg_hold;
731            region->pitcheg_decay    = pitcheg_decay;
732            region->pitcheg_sustain  = pitcheg_sustain;
733            region->pitcheg_release  = pitcheg_release;
734    
735          return region;          return region;
736      }      }
737    
# Line 935  namespace sfz Line 1002  namespace sfz
1002          }          }
1003    
1004          // sample player          // sample player
1005          else if ("count" == key) pCurDef->count = ToInt(value);          else if ("count" == key) { pCurDef->count = ToInt(value); pCurDef->loop_mode = ONE_SHOT; }
1006          else if ("delay" == key) pCurDef->delay = ToFloat(value);          else if ("delay" == key) pCurDef->delay = ToFloat(value);
1007          else if ("delay_random"   == key) pCurDef->delay_random = ToFloat(value);          else if ("delay_random"   == key) pCurDef->delay_random = ToFloat(value);
1008          else if ("delay_beats"    == key) pCurDef->delay_beats = ToInt(value);          else if ("delay_beats"    == key) pCurDef->delay_beats = ToInt(value);
# Line 948  namespace sfz Line 1015  namespace sfz
1015          {          {
1016              if (value == "no_loop") pCurDef->loop_mode = NO_LOOP;              if (value == "no_loop") pCurDef->loop_mode = NO_LOOP;
1017              else if (value == "one_shot") pCurDef->loop_mode = ONE_SHOT;              else if (value == "one_shot") pCurDef->loop_mode = ONE_SHOT;
1018              else if (value == "loop_continous") pCurDef->loop_mode = LOOP_CONTINOUS;              else if (value == "loop_continuous") pCurDef->loop_mode = LOOP_CONTINUOUS;
1019              else if (value == "loop_sustain") pCurDef->loop_mode = LOOP_SUSTAIN;              else if (value == "loop_sustain") pCurDef->loop_mode = LOOP_SUSTAIN;
1020          }          }
1021          else if ("loop_start" == key) pCurDef->loop_start = ToInt(value);          else if ("loop_start" == key) pCurDef->loop_start = ToInt(value);
1022            else if ("loopstart" == key) pCurDef->loop_start = ToInt(value); // nonstandard
1023          else if ("loop_end" == key) pCurDef->loop_end = ToInt(value);          else if ("loop_end" == key) pCurDef->loop_end = ToInt(value);
1024            else if ("loopend" == key) pCurDef->loop_end = ToInt(value); // nonstandard
1025          else if ("sync_beats" == key) pCurDef->sync_beats = ToInt(value);          else if ("sync_beats" == key) pCurDef->sync_beats = ToInt(value);
1026          else if ("sync_offset" == key) pCurDef->sync_offset = ToInt(value);          else if ("sync_offset" == key) pCurDef->sync_offset = ToInt(value);
1027    
# Line 1130  namespace sfz Line 1199  namespace sfz
1199              else if ("eq2_gain_on" == key_cc) pCurDef->eq2_gain_oncc[num_cc] = ToInt(value);              else if ("eq2_gain_on" == key_cc) pCurDef->eq2_gain_oncc[num_cc] = ToInt(value);
1200              else if ("eq3_gain_on" == key_cc) pCurDef->eq3_gain_oncc[num_cc] = ToInt(value);              else if ("eq3_gain_on" == key_cc) pCurDef->eq3_gain_oncc[num_cc] = ToInt(value);
1201              else std::cerr << "The opcode '" << key << "' is unsupported by libsfz!" << std::endl;              else std::cerr << "The opcode '" << key << "' is unsupported by libsfz!" << std::endl;
1202          } else {          }
1203            // Deprecated opcodes
1204            else if ("ampeg_delay"   == key) pCurDef->ampeg_delay = ToFloat(value);
1205            else if ("ampeg_start"   == key) pCurDef->ampeg_start = ToFloat(value);
1206            else if ("ampeg_attack"   == key) pCurDef->ampeg_attack = ToFloat(value);
1207            else if ("ampeg_hold"   == key) pCurDef->ampeg_hold = ToFloat(value);
1208            else if ("ampeg_decay"   == key) pCurDef->ampeg_decay = ToFloat(value);
1209            else if ("ampeg_sustain"   == key) pCurDef->ampeg_sustain = ToFloat(value);
1210            else if ("ampeg_release"   == key) pCurDef->ampeg_release = ToFloat(value);
1211            else if ("fileg_delay"   == key) pCurDef->fileg_delay = ToFloat(value);
1212            else if ("fileg_start"   == key) pCurDef->fileg_start = ToFloat(value);
1213            else if ("fileg_attack"   == key) pCurDef->fileg_attack = ToFloat(value);
1214            else if ("fileg_hold"   == key) pCurDef->fileg_hold = ToFloat(value);
1215            else if ("fileg_decay"   == key) pCurDef->fileg_decay = ToFloat(value);
1216            else if ("fileg_sustain"   == key) pCurDef->fileg_sustain = ToFloat(value);
1217            else if ("fileg_release"   == key) pCurDef->fileg_release = ToFloat(value);
1218            else if ("pitcheg_delay"   == key) pCurDef->pitcheg_delay = ToFloat(value);
1219            else if ("pitcheg_start"   == key) pCurDef->pitcheg_start = ToFloat(value);
1220            else if ("pitcheg_attack"   == key) pCurDef->pitcheg_attack = ToFloat(value);
1221            else if ("pitcheg_hold"   == key) pCurDef->pitcheg_hold = ToFloat(value);
1222            else if ("pitcheg_decay"   == key) pCurDef->pitcheg_decay = ToFloat(value);
1223            else if ("pitcheg_sustain"   == key) pCurDef->pitcheg_sustain = ToFloat(value);
1224            else if ("pitcheg_release"   == key) pCurDef->pitcheg_release = ToFloat(value);
1225            else {
1226              std::cerr << "The opcode '" << key << "' is unsupported by libsfz!" << std::endl;              std::cerr << "The opcode '" << key << "' is unsupported by libsfz!" << std::endl;
1227          }          }
1228      }      }

Legend:
Removed from v.2012  
changed lines
  Added in v.2021

  ViewVC Help
Powered by ViewVC