From 68fb7fe0d9cb2d5ba28b50919b04d43d802f40b4 Mon Sep 17 00:00:00 2001 From: Paul Ferrand Date: Sun, 22 Dec 2019 23:37:22 +0100 Subject: [PATCH] Change the oversampling enum to enum class --- src/sfizz/Config.h | 2 +- src/sfizz/Region.cpp | 8 ++++---- src/sfizz/Region.h | 8 ++++---- tests/SynthT.cpp | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/sfizz/Config.h b/src/sfizz/Config.h index e741b6d3..14cf3373 100644 --- a/src/sfizz/Config.h +++ b/src/sfizz/Config.h @@ -24,7 +24,7 @@ #pragma once namespace sfz { -enum Oversampling { +enum class Oversampling: int { x1 = 1, x2 = 2, x4 = 4, diff --git a/src/sfizz/Region.cpp b/src/sfizz/Region.cpp index e7bc0663..1893d67a 100644 --- a/src/sfizz/Region.cpp +++ b/src/sfizz/Region.cpp @@ -684,7 +684,7 @@ float sfz::Region::getBaseGain() noexcept uint32_t sfz::Region::getOffset(Oversampling factor) noexcept { - return (offset + offsetDistribution(Random::randomGenerator)) * factor; + return (offset + offsetDistribution(Random::randomGenerator)) * static_cast(factor); } float sfz::Region::getDelay() noexcept @@ -694,17 +694,17 @@ float sfz::Region::getDelay() noexcept uint32_t sfz::Region::trueSampleEnd(Oversampling factor) const noexcept { - return min(sampleEnd, loopRange.getEnd()) * factor; + return min(sampleEnd, loopRange.getEnd()) * static_cast(factor); } uint32_t sfz::Region::loopStart(Oversampling factor) const noexcept { - return loopRange.getStart() * factor; + return loopRange.getStart() * static_cast(factor); } uint32_t sfz::Region::loopEnd(Oversampling factor) const noexcept { - return loopRange.getEnd() * factor; + return loopRange.getEnd() * static_cast(factor); } template diff --git a/src/sfizz/Region.h b/src/sfizz/Region.h index 6621b3af..c2b0c6cc 100644 --- a/src/sfizz/Region.h +++ b/src/sfizz/Region.h @@ -196,7 +196,7 @@ struct Region { * * @return uint32_t */ - uint32_t getOffset(Oversampling factor = x1) noexcept; + uint32_t getOffset(Oversampling factor = Oversampling::x1) noexcept; /** * @brief Get the region delay in seconds * @@ -209,7 +209,7 @@ struct Region { * * @return uint32_t */ - uint32_t trueSampleEnd(Oversampling factor = x1) const noexcept; + uint32_t trueSampleEnd(Oversampling factor = Oversampling::x1) const noexcept; /** * @brief Parse a new opcode into the region to fill in the proper parameters. * This must be called multiple times for each opcode applying to this region. @@ -222,8 +222,8 @@ struct Region { void offsetAllKeys(int offset) noexcept; - uint32_t loopStart(Oversampling factor = x1) const noexcept; - uint32_t loopEnd(Oversampling factor = x1) const noexcept; + uint32_t loopStart(Oversampling factor = Oversampling::x1) const noexcept; + uint32_t loopEnd(Oversampling factor = Oversampling::x1) const noexcept; // Sound source: sample playback std::string sample {}; // Sample diff --git a/tests/SynthT.cpp b/tests/SynthT.cpp index ecba9e80..4ccb27c6 100644 --- a/tests/SynthT.cpp +++ b/tests/SynthT.cpp @@ -109,15 +109,15 @@ TEST_CASE("[Synth] Check that we can change the size of the preload before and a TEST_CASE("[Synth] Check that we can change the oversampling factor before and after loading") { sfz::Synth synth; - synth.setOversamplingFactor(sfz::x2); + synth.setOversamplingFactor(sfz::Oversampling::x2); sfz::AudioBuffer buffer { 2, blockSize }; synth.loadSfzFile(fs::current_path() / "tests/TestFiles/groups_avl.sfz"); - synth.setOversamplingFactor(sfz::x4); + synth.setOversamplingFactor(sfz::Oversampling::x4); synth.noteOn(0, 1, 36, 24); synth.noteOn(0, 1, 36, 89); synth.renderBlock(buffer); - synth.setOversamplingFactor(sfz::x2); + synth.setOversamplingFactor(sfz::Oversampling::x2); synth.renderBlock(buffer); }