Merge pull request #954 from paulfd/short-audio-files

Parse oscillator=auto and only have implicit wavetables if the file is short AND wavetable tags are in
This commit is contained in:
JP Cimalando 2021-07-27 17:32:33 +02:00 committed by GitHub
commit 03472da8c8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 23 additions and 7 deletions

View file

@ -327,6 +327,9 @@ absl::optional<bool> readBoolean(absl::string_view value)
template <>
absl::optional<OscillatorEnabled> Opcode::readOptional(OpcodeSpec<OscillatorEnabled>, absl::string_view value)
{
if (value == "auto")
return OscillatorEnabled::Auto;
auto v = readBoolean(value);
if (!v)
return absl::nullopt;

View file

@ -637,8 +637,6 @@ void Synth::Impl::finalizeSfzLoad()
if (allZeros) {
region.sampleId.reset(new FileId("*silence"));
region.hasWavetableSample = false;
} else {
region.hasWavetableSample |= true;
}
}
}

View file

@ -274,7 +274,7 @@ TEST_CASE("[Files] Channels (channels_multi.sfz)")
{
Synth synth;
synth.loadSfzFile(fs::current_path() / "tests/TestFiles/channels_multi.sfz");
REQUIRE(synth.getNumRegions() == 10);
REQUIRE(synth.getNumRegions() == 12);
int regionNumber = 0;
const Region* region = nullptr;
@ -327,14 +327,27 @@ TEST_CASE("[Files] Channels (channels_multi.sfz)")
REQUIRE(!region->isOscillator());
REQUIRE(region->oscillatorEnabled == OscillatorEnabled::Off);
// implicit wavetable (sound file < 3000 frames)
// implicit wavetable (sound file < 3000 frames and wavetable tags)
region = synth.getRegionView(regionNumber++);
REQUIRE(region->sampleId->filename() == "ramp_wave.wav");
REQUIRE(!region->isStereo());
REQUIRE(region->sampleId->filename() == "wavetables/surge.wav");
REQUIRE(!region->isGenerator());
REQUIRE(region->isOscillator());
REQUIRE(region->oscillatorEnabled == OscillatorEnabled::Auto);
// Parse oscillator=auto and same as above
region = synth.getRegionView(regionNumber++);
REQUIRE(region->sampleId->filename() == "wavetables/surge.wav");
REQUIRE(!region->isGenerator());
REQUIRE(region->isOscillator());
REQUIRE(region->oscillatorEnabled == OscillatorEnabled::Auto);
// implicit non wavetable (sound file < 3000 frames but no wavetable tags)
region = synth.getRegionView(regionNumber++);
REQUIRE(region->sampleId->filename() == "short_non_wavetable.wav");
REQUIRE(!region->isGenerator());
REQUIRE(!region->isOscillator());
REQUIRE(region->oscillatorEnabled == OscillatorEnabled::Auto);
// implicit non-wavetable (sound file >= 3000 frames)
region = synth.getRegionView(regionNumber++);
REQUIRE(region->sampleId->filename() == "snare.wav");

View file

@ -4,7 +4,9 @@
<region> sample=ramp_wave.wav oscillator=on oscillator_multi=3
<region> sample=ramp_wave.wav oscillator=off
<region> sample=ramp_wave.wav oscillator=off oscillator_multi=3
<region> sample=ramp_wave.wav
<region> sample=wavetables/surge.wav
<region> oscillator=auto sample=wavetables/surge.wav
<region> sample=short_non_wavetable.wav
<region> sample=snare.wav
<region> sample=*sine oscillator_multi=1
<region> sample=*sine oscillator_multi=2

Binary file not shown.