2 |
* * |
* * |
3 |
* libsf2 - C++ cross-platform SF2 format file access library * |
* libsf2 - C++ cross-platform SF2 format file access library * |
4 |
* * |
* * |
5 |
* Copyright (C) 2009 Grigor Iliev <grigor@grigoriliev.com> * |
* Copyright (C) 2009-2010 Grigor Iliev <grigor@grigoriliev.com>, * |
6 |
* Copyright (C) 2009 Christian Schoenebeck * |
* Christian Schoenebeck and Andreas Persson * |
|
* Copyright (C) 2009 Andreas Persson * |
|
7 |
* * |
* * |
8 |
* This library is free software; you can redistribute it and/or modify * |
* This library 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 * |
615 |
if (pPresetRegion == NULL || pPresetRegion->freqModLfo == NONE) return ToHz(freqModLfo); |
if (pPresetRegion == NULL || pPresetRegion->freqModLfo == NONE) return ToHz(freqModLfo); |
616 |
return ToHz(pPresetRegion->freqModLfo + freqModLfo); |
return ToHz(pPresetRegion->freqModLfo + freqModLfo); |
617 |
} |
} |
618 |
|
|
619 |
double Region::GetDelayModLfo(Region* pPresetRegion) { |
double Region::GetDelayModLfo(Region* pPresetRegion) { |
620 |
if (pPresetRegion == NULL || pPresetRegion->delayModLfo == NONE) return ToSeconds(delayModLfo); |
if (pPresetRegion == NULL || pPresetRegion->delayModLfo == NONE) return ToSeconds(delayModLfo); |
621 |
return ToSeconds(pPresetRegion->delayModLfo + delayModLfo); |
return ToSeconds(pPresetRegion->delayModLfo + delayModLfo); |
681 |
} |
} |
682 |
|
|
683 |
Instrument::~Instrument() { |
Instrument::~Instrument() { |
|
|
|
684 |
} |
} |
685 |
|
|
686 |
Region* Instrument::CreateRegion() { |
Region* Instrument::CreateRegion() { |
769 |
} |
} |
770 |
|
|
771 |
Region* reg = CreateRegion(); |
Region* reg = CreateRegion(); |
772 |
|
|
773 |
for (int j = gIdx1; j < gIdx2; j++) { |
for (int j = gIdx1; j < gIdx2; j++) { |
774 |
reg->SetGenerator(pFile, pFile->InstGenLists[j]); |
reg->SetGenerator(pFile, pFile->InstGenLists[j]); |
775 |
// TODO: ignore generators following a sampleID generator |
// TODO: ignore generators following a sampleID generator |
804 |
} |
} |
805 |
|
|
806 |
Preset::~Preset() { |
Preset::~Preset() { |
|
|
|
807 |
} |
} |
808 |
|
|
809 |
Region* Preset::CreateRegion() { |
Region* Preset::CreateRegion() { |
1071 |
if (Samples[i]) delete (Samples[i]); |
if (Samples[i]) delete (Samples[i]); |
1072 |
} |
} |
1073 |
} |
} |
1074 |
|
|
1075 |
int File::GetPresetCount() { |
int File::GetPresetCount() { |
1076 |
return Presets.size() - 1; // exclude terminal preset (EOP) |
return Presets.size() - 1; // exclude terminal preset (EOP) |
1077 |
} |
} |
1182 |
* that the size is given in bytes! You get the number of actually cached |
* that the size is given in bytes! You get the number of actually cached |
1183 |
* samples by dividing it by the frame size of the sample: |
* samples by dividing it by the frame size of the sample: |
1184 |
* @code |
* @code |
1185 |
* buffer_t buf = pSample->LoadSampleData(acquired_samples); |
* buffer_t buf = pSample->LoadSampleData(acquired_samples); |
1186 |
* long cachedsamples = buf.Size / pSample->FrameSize; |
* long cachedsamples = buf.Size / pSample->FrameSize; |
1187 |
* @endcode |
* @endcode |
1188 |
* |
* |
1189 |
* @param SampleCount - number of sample points to load into RAM |
* @param SampleCount - number of sample points to load into RAM |
1227 |
* that the size is given in bytes! You get the number of actually cached |
* that the size is given in bytes! You get the number of actually cached |
1228 |
* samples by dividing it by the frame size of the sample: |
* samples by dividing it by the frame size of the sample: |
1229 |
* @code |
* @code |
1230 |
* buffer_t buf = pSample->LoadSampleDataWithNullSamplesExtension(acquired_samples, null_samples); |
* buffer_t buf = pSample->LoadSampleDataWithNullSamplesExtension(acquired_samples, null_samples); |
1231 |
* long cachedsamples = buf.Size / pSample->FrameSize; |
* long cachedsamples = buf.Size / pSample->FrameSize; |
1232 |
* @endcode |
* @endcode |
1233 |
* The method will add \a NullSamplesCount silence samples past the |
* The method will add \a NullSamplesCount silence samples past the |
1234 |
* official buffer end (this won't affect the 'Size' member of the |
* official buffer end (this won't affect the 'Size' member of the |
1334 |
if (SampleCount == 0) return 0; |
if (SampleCount == 0) return 0; |
1335 |
long pos = GetPos(); |
long pos = GetPos(); |
1336 |
if (pos + SampleCount > GetTotalFrameCount()) SampleCount = GetTotalFrameCount() - pos; |
if (pos + SampleCount > GetTotalFrameCount()) SampleCount = GetTotalFrameCount() - pos; |
1337 |
|
|
1338 |
if (GetFrameSize() / GetChannelCount() == 3 /* 24 bit */) { |
if (GetFrameSize() / GetChannelCount() == 3 /* 24 bit */) { |
1339 |
uint8_t* pBuf = (uint8_t*)pBuffer; |
uint8_t* pBuf = (uint8_t*)pBuffer; |
1340 |
if (SampleType == MONO_SAMPLE || SampleType == ROM_MONO_SAMPLE) { |
if (SampleType == MONO_SAMPLE || SampleType == ROM_MONO_SAMPLE) { |