Change the oversampling enum to enum class

This commit is contained in:
Paul Ferrand 2019-12-22 23:37:22 +01:00
parent 9187e0db41
commit 68fb7fe0d9
4 changed files with 12 additions and 12 deletions

View file

@ -24,7 +24,7 @@
#pragma once
namespace sfz {
enum Oversampling {
enum class Oversampling: int {
x1 = 1,
x2 = 2,
x4 = 4,

View file

@ -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<uint32_t>(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<uint32_t>(factor);
}
uint32_t sfz::Region::loopStart(Oversampling factor) const noexcept
{
return loopRange.getStart() * factor;
return loopRange.getStart() * static_cast<uint32_t>(factor);
}
uint32_t sfz::Region::loopEnd(Oversampling factor) const noexcept
{
return loopRange.getEnd() * factor;
return loopRange.getEnd() * static_cast<uint32_t>(factor);
}
template<class T, class U>

View file

@ -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

View file

@ -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<float> 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);
}