Small, all zero files are replaced by *silence
This commit is contained in:
parent
69f7b54940
commit
16a790a33d
8 changed files with 35 additions and 3 deletions
|
|
@ -355,7 +355,6 @@ sfz::FileDataHolder sfz::FilePool::loadFile(const FileId& fileId) noexcept
|
|||
*fileInformation
|
||||
});
|
||||
insertedPair.first->second.status = FileData::Status::Preloaded;
|
||||
ASSERT(insertedPair.second);
|
||||
return { &insertedPair.first->second };
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -595,8 +595,24 @@ void Synth::Impl::finalizeSfzLoad()
|
|||
continue;
|
||||
}
|
||||
|
||||
region.hasWavetableSample = fileInformation->wavetable ||
|
||||
fileInformation->end < config::wavetableMaxFrames;
|
||||
region.hasWavetableSample = fileInformation->wavetable.has_value();
|
||||
|
||||
if (fileInformation->end < config::wavetableMaxFrames) {
|
||||
auto sample = resources_.filePool.loadFile(*region.sampleId);
|
||||
bool allZeros = true;
|
||||
int numChannels = sample->information.numChannels;
|
||||
for (int i = 0; i < numChannels; ++i) {
|
||||
allZeros &= allWithin(sample->preloadedData.getConstSpan(i),
|
||||
-config::virtuallyZero, config::virtuallyZero);
|
||||
}
|
||||
|
||||
if (allZeros) {
|
||||
region.sampleId.reset(new FileId("*silence"));
|
||||
region.hasWavetableSample = false;
|
||||
} else {
|
||||
region.hasWavetableSample |= true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!region.isOscillator()) {
|
||||
|
|
|
|||
|
|
@ -1811,3 +1811,20 @@ TEST_CASE("[Keyswitches] Trigger from aftertouch extended CC")
|
|||
synth.renderBlock(buffer);
|
||||
REQUIRE(synth.getNumActiveVoices() == 2);
|
||||
}
|
||||
|
||||
TEST_CASE("[Synth] Short empty files are turned into *silence")
|
||||
{
|
||||
sfz::Synth synth;
|
||||
std::vector<std::string> messageList;
|
||||
sfz::Client client(&messageList);
|
||||
client.setReceiveCallback(&simpleMessageReceiver);
|
||||
sfz::AudioBuffer<float> buffer { 2, static_cast<unsigned>(synth.getSamplesPerBlock()) };
|
||||
synth.loadSfzString(fs::current_path() / "tests/TestFiles/aftertouch_trigger.sfz", R"(
|
||||
<region> sample=silence.wav
|
||||
)");
|
||||
synth.dispatchMessage(client, 0, "/region0/sample", "", nullptr);
|
||||
std::vector<std::string> expected {
|
||||
"/region0/sample,s : { *silence }",
|
||||
};
|
||||
REQUIRE(messageList == expected);
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
tests/TestFiles/silence.wav
Normal file
BIN
tests/TestFiles/silence.wav
Normal file
Binary file not shown.
Loading…
Add table
Reference in a new issue