Parse oscillator=auto and only have implicit wavetables if the file is short AND wavetable tags are in

This commit is contained in:
Paul Fd 2021-07-20 12:25:03 +02:00
parent 53277dae3c
commit aeb17c1fca
5 changed files with 24 additions and 6 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

@ -638,7 +638,7 @@ void Synth::Impl::finalizeSfzLoad()
region.sampleId.reset(new FileId("*silence"));
region.hasWavetableSample = false;
} else {
region.hasWavetableSample |= true;
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.