Parse oscillator=auto and only have implicit wavetables if the file is short AND wavetable tags are in
This commit is contained in:
parent
53277dae3c
commit
aeb17c1fca
5 changed files with 24 additions and 6 deletions
|
|
@ -327,6 +327,9 @@ absl::optional<bool> readBoolean(absl::string_view value)
|
||||||
template <>
|
template <>
|
||||||
absl::optional<OscillatorEnabled> Opcode::readOptional(OpcodeSpec<OscillatorEnabled>, absl::string_view value)
|
absl::optional<OscillatorEnabled> Opcode::readOptional(OpcodeSpec<OscillatorEnabled>, absl::string_view value)
|
||||||
{
|
{
|
||||||
|
if (value == "auto")
|
||||||
|
return OscillatorEnabled::Auto;
|
||||||
|
|
||||||
auto v = readBoolean(value);
|
auto v = readBoolean(value);
|
||||||
if (!v)
|
if (!v)
|
||||||
return absl::nullopt;
|
return absl::nullopt;
|
||||||
|
|
|
||||||
|
|
@ -638,7 +638,7 @@ void Synth::Impl::finalizeSfzLoad()
|
||||||
region.sampleId.reset(new FileId("*silence"));
|
region.sampleId.reset(new FileId("*silence"));
|
||||||
region.hasWavetableSample = false;
|
region.hasWavetableSample = false;
|
||||||
} else {
|
} else {
|
||||||
region.hasWavetableSample |= true;
|
region.hasWavetableSample &= true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -274,7 +274,7 @@ TEST_CASE("[Files] Channels (channels_multi.sfz)")
|
||||||
{
|
{
|
||||||
Synth synth;
|
Synth synth;
|
||||||
synth.loadSfzFile(fs::current_path() / "tests/TestFiles/channels_multi.sfz");
|
synth.loadSfzFile(fs::current_path() / "tests/TestFiles/channels_multi.sfz");
|
||||||
REQUIRE(synth.getNumRegions() == 10);
|
REQUIRE(synth.getNumRegions() == 12);
|
||||||
|
|
||||||
int regionNumber = 0;
|
int regionNumber = 0;
|
||||||
const Region* region = nullptr;
|
const Region* region = nullptr;
|
||||||
|
|
@ -327,14 +327,27 @@ TEST_CASE("[Files] Channels (channels_multi.sfz)")
|
||||||
REQUIRE(!region->isOscillator());
|
REQUIRE(!region->isOscillator());
|
||||||
REQUIRE(region->oscillatorEnabled == OscillatorEnabled::Off);
|
REQUIRE(region->oscillatorEnabled == OscillatorEnabled::Off);
|
||||||
|
|
||||||
// implicit wavetable (sound file < 3000 frames)
|
// implicit wavetable (sound file < 3000 frames and wavetable tags)
|
||||||
region = synth.getRegionView(regionNumber++);
|
region = synth.getRegionView(regionNumber++);
|
||||||
REQUIRE(region->sampleId->filename() == "ramp_wave.wav");
|
REQUIRE(region->sampleId->filename() == "wavetables/surge.wav");
|
||||||
REQUIRE(!region->isStereo());
|
|
||||||
REQUIRE(!region->isGenerator());
|
REQUIRE(!region->isGenerator());
|
||||||
REQUIRE(region->isOscillator());
|
REQUIRE(region->isOscillator());
|
||||||
REQUIRE(region->oscillatorEnabled == OscillatorEnabled::Auto);
|
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)
|
// implicit non-wavetable (sound file >= 3000 frames)
|
||||||
region = synth.getRegionView(regionNumber++);
|
region = synth.getRegionView(regionNumber++);
|
||||||
REQUIRE(region->sampleId->filename() == "snare.wav");
|
REQUIRE(region->sampleId->filename() == "snare.wav");
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,9 @@
|
||||||
<region> sample=ramp_wave.wav oscillator=on oscillator_multi=3
|
<region> sample=ramp_wave.wav oscillator=on oscillator_multi=3
|
||||||
<region> sample=ramp_wave.wav oscillator=off
|
<region> sample=ramp_wave.wav oscillator=off
|
||||||
<region> sample=ramp_wave.wav oscillator=off oscillator_multi=3
|
<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=snare.wav
|
||||||
<region> sample=*sine oscillator_multi=1
|
<region> sample=*sine oscillator_multi=1
|
||||||
<region> sample=*sine oscillator_multi=2
|
<region> sample=*sine oscillator_multi=2
|
||||||
|
|
|
||||||
BIN
tests/TestFiles/short_non_wavetable.wav
Normal file
BIN
tests/TestFiles/short_non_wavetable.wav
Normal file
Binary file not shown.
Loading…
Add table
Reference in a new issue