Added a method to FilePromise to get a data source
This commit is contained in:
parent
c0f1350cc4
commit
d1e031e8e2
2 changed files with 16 additions and 9 deletions
|
|
@ -47,10 +47,21 @@ struct PreloadedFileHandle
|
|||
|
||||
struct FilePromise
|
||||
{
|
||||
auto getData()
|
||||
{
|
||||
if (dataReady)
|
||||
return AudioSpan<const float>(*fileData);
|
||||
else if (availableFrames > preloadedData->getNumFrames())
|
||||
return AudioSpan<const float>(*fileData).first(availableFrames);
|
||||
else
|
||||
return AudioSpan<const float>(*preloadedData);
|
||||
}
|
||||
|
||||
absl::string_view filename {};
|
||||
AudioBufferPtr preloadedData {};
|
||||
std::unique_ptr<AudioBuffer<float>> fileData {};
|
||||
float sampleRate { config::defaultSampleRate };
|
||||
std::atomic<int> availableFrames { 0 };
|
||||
std::atomic<bool> dataReady { false };
|
||||
Oversampling oversamplingFactor { config::defaultOversamplingFactor };
|
||||
};
|
||||
|
|
|
|||
|
|
@ -374,16 +374,12 @@ void sfz::Voice::fillWithData(AudioSpan<float> buffer) noexcept
|
|||
if (buffer.getNumFrames() == 0)
|
||||
return;
|
||||
|
||||
auto source { [&]() {
|
||||
// if (region->trueSampleEnd() < currentPromise->preloadedData->getNumFrames())
|
||||
// return AudioSpan<const float>(*currentPromise->preloadedData);
|
||||
// else
|
||||
if (!currentPromise->dataReady)
|
||||
return AudioSpan<const float>(*currentPromise->preloadedData);
|
||||
else
|
||||
return AudioSpan<const float>(*currentPromise->fileData);
|
||||
}() };
|
||||
if (currentPromise == nullptr) {
|
||||
DBG("[Voice] Missing promise during fillWithData");
|
||||
return;
|
||||
}
|
||||
|
||||
auto source = currentPromise->getData();
|
||||
auto indices = indexSpan.first(buffer.getNumFrames());
|
||||
auto jumps = tempSpan1.first(buffer.getNumFrames());
|
||||
auto bends = tempSpan2.first(buffer.getNumFrames());
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue