bool readNextBlock() { jassert (reader != nullptr); if (! isFullyLoaded()) { const int numToDo = (int) jmin (256 * (int64) owner.samplesPerThumbSample, lengthInSamples - numSamplesFinished); if (numToDo > 0) { int64 startSample = numSamplesFinished; const int firstThumbIndex = sampleToThumbSample (startSample); const int lastThumbIndex = sampleToThumbSample (startSample + numToDo); const int numThumbSamps = lastThumbIndex - firstThumbIndex; HeapBlock<MinMaxValue> levelData ((size_t) numThumbSamps * numChannels); HeapBlock<MinMaxValue*> levels (numChannels); for (int i = 0; i < (int) numChannels; ++i) levels[i] = levelData + i * numThumbSamps; HeapBlock<Range<float> > levelsRead (numChannels); for (int i = 0; i < numThumbSamps; ++i) { reader->readMaxLevels ((firstThumbIndex + i) * owner.samplesPerThumbSample, owner.samplesPerThumbSample, levelsRead, (int) numChannels); for (int j = 0; j < (int) numChannels; ++j) levels[j][i].setFloat (levelsRead[j]); } { const ScopedUnlock su (readerLock); owner.setLevels (levels, firstThumbIndex, (int) numChannels, numThumbSamps); } numSamplesFinished += numToDo; lastReaderUseTime = Time::getMillisecondCounter(); } } return isFullyLoaded(); }
bool readNextBlock() { jassert (reader != nullptr); if (! isFullyLoaded()) { const int numToDo = (int) jmin (256 * (int64) owner.samplesPerThumbSample, lengthInSamples - numSamplesFinished); if (numToDo > 0) { int64 startSample = numSamplesFinished; const int firstThumbIndex = sampleToThumbSample (startSample); const int lastThumbIndex = sampleToThumbSample (startSample + numToDo); const int numThumbSamps = lastThumbIndex - firstThumbIndex; HeapBlock<MinMaxValue> levelData ((size_t) numThumbSamps * 2); MinMaxValue* levels[2] = { levelData, levelData + numThumbSamps }; for (int i = 0; i < numThumbSamps; ++i) { float lowestLeft, highestLeft, lowestRight, highestRight; reader->readMaxLevels ((firstThumbIndex + i) * owner.samplesPerThumbSample, owner.samplesPerThumbSample, lowestLeft, highestLeft, lowestRight, highestRight); levels[0][i].setFloat (lowestLeft, highestLeft); levels[1][i].setFloat (lowestRight, highestRight); } { const ScopedUnlock su (readerLock); owner.setLevels (levels, firstThumbIndex, 2, numThumbSamps); } numSamplesFinished += numToDo; lastReaderUseTime = Time::getMillisecondCounter(); } } return isFullyLoaded(); }