146 |
Sample::buffer_t SampleFile::LoadSampleDataWithNullSamplesExtension(unsigned long FrameCount, uint NullFramesCount) { |
Sample::buffer_t SampleFile::LoadSampleDataWithNullSamplesExtension(unsigned long FrameCount, uint NullFramesCount) { |
147 |
Open(); |
Open(); |
148 |
if (FrameCount > this->TotalFrameCount) FrameCount = this->TotalFrameCount; |
if (FrameCount > this->TotalFrameCount) FrameCount = this->TotalFrameCount; |
149 |
|
|
150 |
|
if (Offset > MaxOffset && FrameCount < TotalFrameCount) { |
151 |
|
FrameCount = FrameCount + Offset > TotalFrameCount ? TotalFrameCount - Offset : FrameCount; |
152 |
|
// Offset the RAM cache |
153 |
|
RAMCacheOffset = Offset; |
154 |
|
} |
155 |
if (RAMCache.pStart) delete[] (int8_t*) RAMCache.pStart; |
if (RAMCache.pStart) delete[] (int8_t*) RAMCache.pStart; |
156 |
unsigned long allocationsize = (FrameCount + NullFramesCount) * this->FrameSize; |
unsigned long allocationsize = (FrameCount + NullFramesCount) * this->FrameSize; |
157 |
SetPos(0, SEEK_SET); // reset read position to begin of sample |
SetPos(RAMCacheOffset, SEEK_SET); // reset read position to playback start point |
158 |
RAMCache.pStart = new int8_t[allocationsize]; |
RAMCache.pStart = new int8_t[allocationsize]; |
159 |
|
|
160 |
RAMCache.Size = Read(RAMCache.pStart, FrameCount) * this->FrameSize; |
RAMCache.Size = Read(RAMCache.pStart, FrameCount) * this->FrameSize; |