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 |
} |
} |
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; |
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 |
|
|
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); |
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 |
|
|