From ab6d1c5d02ae803afcaaa5938a9a9676e6bbf802 Mon Sep 17 00:00:00 2001 From: Paul Ferrand Date: Sat, 4 Jan 2020 17:38:51 +0100 Subject: [PATCH] Explicit casting --- benchmarks/BM_ADSR.cpp | 13 +- benchmarks/BM_OPF_high_vs_low.cpp | 11 +- benchmarks/BM_add.cpp | 4 +- benchmarks/BM_copy.cpp | 4 +- benchmarks/BM_cumsum.cpp | 6 +- benchmarks/BM_diff.cpp | 6 +- benchmarks/BM_divide.cpp | 2 +- benchmarks/BM_envelopes.cpp | 12 +- benchmarks/BM_fill.cpp | 4 +- benchmarks/BM_flacfile.cpp | 2 +- benchmarks/BM_gain.cpp | 4 +- benchmarks/BM_interpolationCast.cpp | 4 +- benchmarks/BM_looping.cpp | 4 +- benchmarks/BM_multiplyAdd.cpp | 4 +- benchmarks/BM_pan.cpp | 6 +- benchmarks/BM_pointerIterationOrOffsets.cpp | 12 +- benchmarks/BM_ramp.cpp | 4 +- benchmarks/BM_readChunk.cpp | 4 +- benchmarks/BM_readInterleaved.cpp | 4 +- benchmarks/BM_resampleChunk.cpp | 20 +-- benchmarks/BM_saturating.cpp | 4 +- benchmarks/BM_subtract.cpp | 4 +- benchmarks/BM_wavfile.cpp | 2 +- benchmarks/BM_writeInterleaved.cpp | 4 +- src/external/mathfuns/sse_mathfun.h | 128 ++++++++++---------- src/sfizz/ADSREnvelope.cpp | 2 +- src/sfizz/Buffer.h | 17 ++- src/sfizz/EventEnvelopes.cpp | 18 +-- src/sfizz/MathHelpers.h | 13 +- src/sfizz/Parser.cpp | 1 - src/sfizz/Parser.h | 1 + 31 files changed, 171 insertions(+), 153 deletions(-) diff --git a/benchmarks/BM_ADSR.cpp b/benchmarks/BM_ADSR.cpp index 850c4e7c..bb61f1af 100644 --- a/benchmarks/BM_ADSR.cpp +++ b/benchmarks/BM_ADSR.cpp @@ -21,8 +21,9 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#include +#include "Config.h" #include "ADSREnvelope.h" +#include #include #include #include @@ -44,12 +45,12 @@ static void Point(benchmark::State& state) { for (auto _ : state) { envelope.reset(attack, release, 1.0, fixedAmount, decay, fixedAmount); envelope.startRelease(releaseTime); - for(int offset = 0; offset < envelopeSize; offset += state.range(0)) + for(int offset = 0; offset < envelopeSize; offset += static_cast(state.range(0))) for (auto& out: output) out = envelope.getNextValue(); benchmark::DoNotOptimize(output); } - state.counters["Per block"] = benchmark::Counter(envelopeSize / state.range(0), benchmark::Counter::kIsRate); + state.counters["Per block"] = benchmark::Counter(envelopeSize / static_cast(state.range(0)), benchmark::Counter::kIsRate); } static void Block(benchmark::State& state) { @@ -58,14 +59,14 @@ static void Block(benchmark::State& state) { for (auto _ : state) { envelope.reset(attack, release, 1.0, fixedAmount, decay, fixedAmount); envelope.startRelease(releaseTime); - for(int offset = 0; offset < envelopeSize; offset += state.range(0)) + for(int offset = 0; offset < envelopeSize; offset += static_cast(state.range(0))) envelope.getBlock(absl::MakeSpan(output)); benchmark::DoNotOptimize(output); } - state.counters["Per block"] = benchmark::Counter(envelopeSize / state.range(0), benchmark::Counter::kIsRate); + state.counters["Per block"] = benchmark::Counter(envelopeSize / static_cast(state.range(0)), benchmark::Counter::kIsRate); } BENCHMARK(Point)->RangeMultiplier(2)->Range((2<<6), (2<<11)); BENCHMARK(Block)->RangeMultiplier(2)->Range((2<<6), (2<<11)); -BENCHMARK_MAIN(); \ No newline at end of file +BENCHMARK_MAIN(); diff --git a/benchmarks/BM_OPF_high_vs_low.cpp b/benchmarks/BM_OPF_high_vs_low.cpp index 5a67d73f..b9bba592 100644 --- a/benchmarks/BM_OPF_high_vs_low.cpp +++ b/benchmarks/BM_OPF_high_vs_low.cpp @@ -21,6 +21,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include "Config.h" #include #include #include @@ -111,7 +112,7 @@ static void Low(benchmark::State& state) { std::vector output(state.range(0)); std::random_device rd { }; std::mt19937 gen { rd() }; - + std::normal_distribution dist { }; std::generate(input.begin(), input.end(), [&]() { return dist(gen); @@ -126,7 +127,7 @@ static void High(benchmark::State& state) { std::vector output(state.range(0)); std::random_device rd { }; std::mt19937 gen { rd() }; - + std::normal_distribution dist { }; std::generate(input.begin(), input.end(), [&]() { return dist(gen); @@ -141,7 +142,7 @@ static void High_Raw(benchmark::State& state) { std::vector output(state.range(0)); std::random_device rd { }; std::mt19937 gen { rd() }; - + std::normal_distribution dist { }; std::generate(input.begin(), input.end(), [&]() { return dist(gen); @@ -156,7 +157,7 @@ static void High_SSE(benchmark::State& state) { std::vector output(state.range(0)); std::random_device rd { }; std::mt19937 gen { rd() }; - + std::normal_distribution dist { }; std::generate(input.begin(), input.end(), [&]() { return dist(gen); @@ -171,4 +172,4 @@ BENCHMARK(Low)->RangeMultiplier(2)->Range((2<<5), (2<<10)); BENCHMARK(High)->RangeMultiplier(2)->Range((2<<5), (2<<10)); BENCHMARK(High_Raw)->RangeMultiplier(2)->Range((2<<5), (2<<10)); BENCHMARK(High_SSE)->RangeMultiplier(2)->Range((2<<5), (2<<10)); -BENCHMARK_MAIN(); \ No newline at end of file +BENCHMARK_MAIN(); diff --git a/benchmarks/BM_add.cpp b/benchmarks/BM_add.cpp index 26b3c62f..b15f38c2 100644 --- a/benchmarks/BM_add.cpp +++ b/benchmarks/BM_add.cpp @@ -21,13 +21,13 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include "SIMDHelpers.h" #include #include #include #include #include #include -#include "SIMDHelpers.h" class AddArray : public benchmark::Fixture { public: @@ -113,4 +113,4 @@ BENCHMARK_REGISTER_F(AddArray, Scalar)->RangeMultiplier(4)->Range(1 << 2, 1 << 1 BENCHMARK_REGISTER_F(AddArray, SIMD)->RangeMultiplier(4)->Range(1 << 2, 1 << 12); BENCHMARK_REGISTER_F(AddArray, Scalar_Unaligned)->RangeMultiplier(4)->Range(1 << 2, 1 << 12); BENCHMARK_REGISTER_F(AddArray, SIMD_Unaligned)->RangeMultiplier(4)->Range(1 << 2, 1 << 12); -BENCHMARK_MAIN(); \ No newline at end of file +BENCHMARK_MAIN(); diff --git a/benchmarks/BM_copy.cpp b/benchmarks/BM_copy.cpp index 9a9298d3..a256a252 100644 --- a/benchmarks/BM_copy.cpp +++ b/benchmarks/BM_copy.cpp @@ -21,13 +21,13 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include "SIMDHelpers.h" #include #include #include #include #include #include -#include "SIMDHelpers.h" class CopyArray : public benchmark::Fixture { public: @@ -98,4 +98,4 @@ BENCHMARK_REGISTER_F(CopyArray, SIMD)->RangeMultiplier(4)->Range(1 << 4, 1 << 16 BENCHMARK_REGISTER_F(CopyArray, StdCopy_Unaligned)->RangeMultiplier(4)->Range(1 << 4, 1 << 16); BENCHMARK_REGISTER_F(CopyArray, Scalar_Unaligned)->RangeMultiplier(4)->Range(1 << 4, 1 << 16); BENCHMARK_REGISTER_F(CopyArray, SIMD_Unaligned)->RangeMultiplier(4)->Range(1 << 4, 1 << 16); -BENCHMARK_MAIN(); \ No newline at end of file +BENCHMARK_MAIN(); diff --git a/benchmarks/BM_cumsum.cpp b/benchmarks/BM_cumsum.cpp index fb2cb28c..b4d89fa3 100644 --- a/benchmarks/BM_cumsum.cpp +++ b/benchmarks/BM_cumsum.cpp @@ -21,20 +21,20 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include "SIMDHelpers.h" #include #include #include #include #include #include -#include "SIMDHelpers.h" class CumArray : public benchmark::Fixture { public: void SetUp(const ::benchmark::State& state) { std::random_device rd { }; std::mt19937 gen { rd() }; - std::uniform_real_distribution dist { 0.1, 1 }; + std::uniform_real_distribution dist { 0.1f, 1.0f }; input = std::vector(state.range(0)); output = std::vector(state.range(0)); std::generate(input.begin(), input.end(), [&]() { return dist(gen); }); @@ -82,4 +82,4 @@ BENCHMARK_REGISTER_F(CumArray, Sum_Scalar)->RangeMultiplier(4)->Range(1 << 2, 1 BENCHMARK_REGISTER_F(CumArray, Sum_SIMD)->RangeMultiplier(4)->Range(1 << 2, 1 << 12); BENCHMARK_REGISTER_F(CumArray, Sum_Scalar_Unaligned)->RangeMultiplier(4)->Range(1 << 2, 1 << 12); BENCHMARK_REGISTER_F(CumArray, Sum_SIMD_Unaligned)->RangeMultiplier(4)->Range(1 << 2, 1 << 12); -BENCHMARK_MAIN(); \ No newline at end of file +BENCHMARK_MAIN(); diff --git a/benchmarks/BM_diff.cpp b/benchmarks/BM_diff.cpp index bdc3b4b5..d72c1cee 100644 --- a/benchmarks/BM_diff.cpp +++ b/benchmarks/BM_diff.cpp @@ -21,13 +21,13 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include "SIMDHelpers.h" #include #include #include #include #include #include -#include "SIMDHelpers.h" #include "absl/types/span.h" class DiffArray : public benchmark::Fixture { @@ -35,7 +35,7 @@ public: void SetUp(const ::benchmark::State& state) { std::random_device rd { }; std::mt19937 gen { rd() }; - std::uniform_real_distribution dist { 0.1, 1 }; + std::uniform_real_distribution dist { 0.1f, 1.0f }; input = std::vector(state.range(0)); output = std::vector(state.range(0)); std::generate(input.begin(), input.end(), [&]() { return dist(gen); }); @@ -84,4 +84,4 @@ BENCHMARK_REGISTER_F(DiffArray, Diff_Scalar)->RangeMultiplier(4)->Range(1 << 2, BENCHMARK_REGISTER_F(DiffArray, Diff_SIMD)->RangeMultiplier(4)->Range(1 << 2, 1 << 12); BENCHMARK_REGISTER_F(DiffArray, Diff_Scalar_Unaligned)->RangeMultiplier(4)->Range(1 << 2, 1 << 12); BENCHMARK_REGISTER_F(DiffArray, Diff_SIMD_Unaligned)->RangeMultiplier(4)->Range(1 << 2, 1 << 12); -BENCHMARK_MAIN(); \ No newline at end of file +BENCHMARK_MAIN(); diff --git a/benchmarks/BM_divide.cpp b/benchmarks/BM_divide.cpp index 824fa120..b5bb8696 100644 --- a/benchmarks/BM_divide.cpp +++ b/benchmarks/BM_divide.cpp @@ -21,13 +21,13 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include "SIMDHelpers.h" #include #include #include #include #include #include -#include "SIMDHelpers.h" class Divide : public benchmark::Fixture { diff --git a/benchmarks/BM_envelopes.cpp b/benchmarks/BM_envelopes.cpp index 70eb3fdd..d313499b 100644 --- a/benchmarks/BM_envelopes.cpp +++ b/benchmarks/BM_envelopes.cpp @@ -21,6 +21,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include "SIMDHelpers.h" #include #include #include @@ -28,7 +29,6 @@ #include #include #include "EventEnvelopes.h" -#include "SIMDHelpers.h" #include "absl/types/span.h" #include "FloatEnvelopes.cpp" @@ -59,7 +59,7 @@ BENCHMARK_DEFINE_F(EnvelopeFixture, Linear)(benchmark::State& state) { sfz::LinearEnvelope envelope; for (auto _ : state) { - envelope.registerEvent(state.range(0) - 1, dist(gen)); + envelope.registerEvent(static_cast(state.range(0) - 1), dist(gen)); envelope.getBlock(absl::MakeSpan(output)); } } @@ -68,7 +68,7 @@ BENCHMARK_DEFINE_F(EnvelopeFixture, LinearQuantized)(benchmark::State& state) { sfz::LinearEnvelope envelope; for (auto _ : state) { - envelope.registerEvent(state.range(0) - 1, dist(gen)); + envelope.registerEvent(static_cast(state.range(0) - 1), dist(gen)); envelope.getQuantizedBlock(absl::MakeSpan(output), 0.5); } } @@ -77,7 +77,7 @@ BENCHMARK_DEFINE_F(EnvelopeFixture, Multiplicative)(benchmark::State& state) { sfz::MultiplicativeEnvelope envelope; for (auto _ : state) { - envelope.registerEvent(state.range(0) - 1, dist(gen)); + envelope.registerEvent(static_cast(state.range(0) - 1), dist(gen)); envelope.getBlock(absl::MakeSpan(output)); } } @@ -86,7 +86,7 @@ BENCHMARK_DEFINE_F(EnvelopeFixture, MultiplicativeQuantized)(benchmark::State& s sfz::MultiplicativeEnvelope envelope; for (auto _ : state) { - envelope.registerEvent(state.range(0) - 1, dist(gen)); + envelope.registerEvent(static_cast(state.range(0) - 1), dist(gen)); envelope.getQuantizedBlock(absl::MakeSpan(output), 1.5); } } @@ -96,4 +96,4 @@ BENCHMARK_REGISTER_F(EnvelopeFixture, Linear)->RangeMultiplier(4)->Range(1 << 2, BENCHMARK_REGISTER_F(EnvelopeFixture, LinearQuantized)->RangeMultiplier(4)->Range(1 << 2, 1 << 12); BENCHMARK_REGISTER_F(EnvelopeFixture, Multiplicative)->RangeMultiplier(4)->Range(1 << 2, 1 << 12); BENCHMARK_REGISTER_F(EnvelopeFixture, MultiplicativeQuantized)->RangeMultiplier(4)->Range(1 << 2, 1 << 12); -BENCHMARK_MAIN(); \ No newline at end of file +BENCHMARK_MAIN(); diff --git a/benchmarks/BM_fill.cpp b/benchmarks/BM_fill.cpp index 2bb5ef0e..a7173c1f 100644 --- a/benchmarks/BM_fill.cpp +++ b/benchmarks/BM_fill.cpp @@ -21,8 +21,8 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#include #include "SIMDHelpers.h" +#include #include "Buffer.h" #include #include @@ -84,4 +84,4 @@ BENCHMARK(FillScalar)->RangeMultiplier(4)->Range((1<<2), (1<<12)); BENCHMARK(FillSIMD)->RangeMultiplier(4)->Range((1<<2), (1<<12)); BENCHMARK(FillScalar_unaligned)->RangeMultiplier(4)->Range((1<<2), (1<<12)); BENCHMARK(FillSIMD_unaligned)->RangeMultiplier(4)->Range((1<<2), (1<<12)); -BENCHMARK_MAIN(); \ No newline at end of file +BENCHMARK_MAIN(); diff --git a/benchmarks/BM_flacfile.cpp b/benchmarks/BM_flacfile.cpp index 5daff23c..6f5ec187 100644 --- a/benchmarks/BM_flacfile.cpp +++ b/benchmarks/BM_flacfile.cpp @@ -20,12 +20,12 @@ // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include "Buffer.h" #include #include #define DR_FLAC_IMPLEMENTATION #include "dr_flac.h" #include "ghc/filesystem.hpp" -#include "Buffer.h" #include #ifndef NDEBUG #include diff --git a/benchmarks/BM_gain.cpp b/benchmarks/BM_gain.cpp index a8855760..20407d0b 100644 --- a/benchmarks/BM_gain.cpp +++ b/benchmarks/BM_gain.cpp @@ -21,13 +21,13 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include "SIMDHelpers.h" #include #include #include #include #include #include -#include "SIMDHelpers.h" class GainSingle : public benchmark::Fixture { public: @@ -140,4 +140,4 @@ BENCHMARK_REGISTER_F(GainArray, Scalar)->RangeMultiplier(4)->Range(1 << 2, 1 << BENCHMARK_REGISTER_F(GainArray, SIMD)->RangeMultiplier(4)->Range(1 << 2, 1 << 12); BENCHMARK_REGISTER_F(GainArray, Scalar_Unaligned)->RangeMultiplier(4)->Range(1 << 2, 1 << 12); BENCHMARK_REGISTER_F(GainArray, SIMD_Unaligned)->RangeMultiplier(4)->Range(1 << 2, 1 << 12); -BENCHMARK_MAIN(); \ No newline at end of file +BENCHMARK_MAIN(); diff --git a/benchmarks/BM_interpolationCast.cpp b/benchmarks/BM_interpolationCast.cpp index f7c2b8a7..c710a976 100644 --- a/benchmarks/BM_interpolationCast.cpp +++ b/benchmarks/BM_interpolationCast.cpp @@ -21,12 +21,12 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include "SIMDHelpers.h" #include #include #include #include #include -#include "SIMDHelpers.h" // In this one we have an array of jumps @@ -90,4 +90,4 @@ BENCHMARK_REGISTER_F(InterpolationCast, Scalar)->RangeMultiplier(2)->Range((2<<6 BENCHMARK_REGISTER_F(InterpolationCast, SIMD)->RangeMultiplier(2)->Range((2<<6), (2<<12)); BENCHMARK_REGISTER_F(InterpolationCast, Scalar_Unaligned)->RangeMultiplier(2)->Range((2<<6), (2<<12)); BENCHMARK_REGISTER_F(InterpolationCast, SIMD_Unaligned)->RangeMultiplier(2)->Range((2<<6), (2<<12)); -BENCHMARK_MAIN(); \ No newline at end of file +BENCHMARK_MAIN(); diff --git a/benchmarks/BM_looping.cpp b/benchmarks/BM_looping.cpp index b036da82..4458e918 100644 --- a/benchmarks/BM_looping.cpp +++ b/benchmarks/BM_looping.cpp @@ -22,11 +22,11 @@ // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include +#include "SIMDHelpers.h" #include #include #include #include -#include "SIMDHelpers.h" // In this one we have an array of indices @@ -92,4 +92,4 @@ BENCHMARK_REGISTER_F(LoopingFixture, Scalar)->RangeMultiplier(2)->Range((2<<6), BENCHMARK_REGISTER_F(LoopingFixture, SIMD)->RangeMultiplier(2)->Range((2<<6), (2<<12)); BENCHMARK_REGISTER_F(LoopingFixture, Scalar_Unaligned)->RangeMultiplier(2)->Range((2<<6), (2<<12)); BENCHMARK_REGISTER_F(LoopingFixture, SIMD_Unaligned)->RangeMultiplier(2)->Range((2<<6), (2<<12)); -BENCHMARK_MAIN(); \ No newline at end of file +BENCHMARK_MAIN(); diff --git a/benchmarks/BM_multiplyAdd.cpp b/benchmarks/BM_multiplyAdd.cpp index 25218ea4..a6111fdc 100644 --- a/benchmarks/BM_multiplyAdd.cpp +++ b/benchmarks/BM_multiplyAdd.cpp @@ -21,13 +21,13 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include "SIMDHelpers.h" #include #include #include #include #include #include -#include "SIMDHelpers.h" class MultiplyAdd : public benchmark::Fixture { public: @@ -93,4 +93,4 @@ BENCHMARK_REGISTER_F(MultiplyAdd, Scalar)->RangeMultiplier(4)->Range(1 << 2, 1 < BENCHMARK_REGISTER_F(MultiplyAdd, SIMD)->RangeMultiplier(4)->Range(1 << 2, 1 << 12); BENCHMARK_REGISTER_F(MultiplyAdd, Scalar_Unaligned)->RangeMultiplier(4)->Range(1 << 2, 1 << 12); BENCHMARK_REGISTER_F(MultiplyAdd, SIMD_Unaligned)->RangeMultiplier(4)->Range(1 << 2, 1 << 12); -BENCHMARK_MAIN(); \ No newline at end of file +BENCHMARK_MAIN(); diff --git a/benchmarks/BM_pan.cpp b/benchmarks/BM_pan.cpp index 20d6b539..441a170b 100644 --- a/benchmarks/BM_pan.cpp +++ b/benchmarks/BM_pan.cpp @@ -21,13 +21,13 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include "SIMDHelpers.h" #include #include #include #include #include #include -#include "SIMDHelpers.h" #include "Config.h" #include "absl/types/span.h" @@ -36,7 +36,7 @@ public: void SetUp(const ::benchmark::State& state) { std::random_device rd { }; std::mt19937 gen { rd() }; - std::uniform_real_distribution dist { 0.001, 1 }; + std::uniform_real_distribution dist { 0.001f, 1.0f }; pan = std::vector(state.range(0)); left = std::vector(state.range(0)); right = std::vector(state.range(0)); @@ -93,4 +93,4 @@ BENCHMARK_DEFINE_F(PanArray, BlockOps)(benchmark::State& state) { BENCHMARK_REGISTER_F(PanArray, Scalar)->RangeMultiplier(4)->Range(1 << 2, 1 << 12); BENCHMARK_REGISTER_F(PanArray, SIMD)->RangeMultiplier(4)->Range(1 << 2, 1 << 12); BENCHMARK_REGISTER_F(PanArray, BlockOps)->RangeMultiplier(4)->Range(1 << 2, 1 << 12); -BENCHMARK_MAIN(); \ No newline at end of file +BENCHMARK_MAIN(); diff --git a/benchmarks/BM_pointerIterationOrOffsets.cpp b/benchmarks/BM_pointerIterationOrOffsets.cpp index 57a891ea..04d2812c 100644 --- a/benchmarks/BM_pointerIterationOrOffsets.cpp +++ b/benchmarks/BM_pointerIterationOrOffsets.cpp @@ -21,10 +21,10 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include "SIMDHelpers.h" #include #include #include -#include "SIMDHelpers.h" #include "absl/types/span.h" constexpr int bigNumber { 2399132 }; @@ -33,8 +33,8 @@ class IterOffset : public benchmark::Fixture { public: void SetUp(const ::benchmark::State& state [[maybe_unused]]) { std::random_device rd { }; - std::mt19937 gen { rd() }; - std::uniform_real_distribution dist { 0.001, 1 }; + std::mt19937 gen { rd() }; + std::uniform_real_distribution dist { 0.001f, 1.0f }; std::uniform_int_distribution jumpDist { 0, 3 }; source = std::vector(bigNumber); result.resize(state.range(0)); @@ -57,7 +57,7 @@ public: BENCHMARK_DEFINE_F(IterOffset, Pointers)(benchmark::State& state) { for (auto _ : state) - { + { sfz::diff(offsets, absl::MakeSpan(jumps)); auto jump = jumps.begin(); auto in = source.begin(); @@ -71,7 +71,7 @@ BENCHMARK_DEFINE_F(IterOffset, Pointers)(benchmark::State& state) { BENCHMARK_DEFINE_F(IterOffset, Offsets)(benchmark::State& state) { for (auto _ : state) - { + { auto offset = offsets.begin(); auto out = result.begin(); while (offset < offsets.end()) @@ -83,4 +83,4 @@ BENCHMARK_DEFINE_F(IterOffset, Offsets)(benchmark::State& state) { // Register the function as a benchmark BENCHMARK_REGISTER_F(IterOffset, Pointers)->RangeMultiplier(4)->Range((1 << 2), (1 << 12)); BENCHMARK_REGISTER_F(IterOffset, Offsets)->RangeMultiplier(4)->Range((1 << 2), (1 << 12)); -BENCHMARK_MAIN(); \ No newline at end of file +BENCHMARK_MAIN(); diff --git a/benchmarks/BM_ramp.cpp b/benchmarks/BM_ramp.cpp index e59615b1..919e83e0 100644 --- a/benchmarks/BM_ramp.cpp +++ b/benchmarks/BM_ramp.cpp @@ -21,9 +21,9 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include "SIMDHelpers.h" #include #include -#include "SIMDHelpers.h" #include "Buffer.h" @@ -204,4 +204,4 @@ BENCHMARK(LogDomainScalar)->RangeMultiplier(4)->Range((1 << 2), (1 << 12)); BENCHMARK(LogDomainSIMD)->RangeMultiplier(4)->Range((1 << 2), (1 << 12)); BENCHMARK(LogDomainScalarUnaligned)->RangeMultiplier(4)->Range((1 << 2), (1 << 12)); BENCHMARK(LogDomainSIMDUnaligned)->RangeMultiplier(4)->Range((1 << 2), (1 << 12)); -BENCHMARK_MAIN(); \ No newline at end of file +BENCHMARK_MAIN(); diff --git a/benchmarks/BM_readChunk.cpp b/benchmarks/BM_readChunk.cpp index a1759a0a..6b233603 100644 --- a/benchmarks/BM_readChunk.cpp +++ b/benchmarks/BM_readChunk.cpp @@ -20,11 +20,11 @@ // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include "SIMDHelpers.h" +#include "Buffer.h" #include #include #include "ghc/filesystem.hpp" -#include "Buffer.h" -#include "SIMDHelpers.h" #define DR_WAV_IMPLEMENTATION #include "dr_wav.h" #include "AudioBuffer.h" diff --git a/benchmarks/BM_readInterleaved.cpp b/benchmarks/BM_readInterleaved.cpp index 48692243..6435c047 100644 --- a/benchmarks/BM_readInterleaved.cpp +++ b/benchmarks/BM_readInterleaved.cpp @@ -21,9 +21,9 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#include #include "SIMDHelpers.h" #include "Buffer.h" +#include #include #include #include @@ -96,4 +96,4 @@ BENCHMARK(Scalar_Unaligned)->Range((8<<10), (8<<20)); BENCHMARK(SSE_Unaligned)->Range((8<<10), (8<<20)); BENCHMARK(Scalar_Unaligned_2)->Range((8<<10), (8<<20)); BENCHMARK(SSE_Unaligned_2)->Range((8<<10), (8<<20)); -BENCHMARK_MAIN(); \ No newline at end of file +BENCHMARK_MAIN(); diff --git a/benchmarks/BM_resampleChunk.cpp b/benchmarks/BM_resampleChunk.cpp index 9e4358b6..bb866bb0 100644 --- a/benchmarks/BM_resampleChunk.cpp +++ b/benchmarks/BM_resampleChunk.cpp @@ -20,11 +20,11 @@ // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include "Buffer.h" +#include "SIMDHelpers.h" #include #include #include "ghc/filesystem.hpp" -#include "Buffer.h" -#include "SIMDHelpers.h" #include "Oversampler.h" #include "AudioBuffer.h" #include @@ -139,14 +139,14 @@ BENCHMARK_DEFINE_F(FileFixture, ResampleAtOnce)(benchmark::State& state) { sndfile.readf(buffer.data(), numFrames); sfz::readInterleaved(buffer, output->getSpan(0), output->getSpan(1)); - upsampler2x.process_block(temp.data(), output->channelReader(0), numFrames); - upsampler4x.process_block(output->channelWriter(0), temp.data(), numFrames * 2); + upsampler2x.process_block(temp.data(), output->channelReader(0), static_cast(numFrames)); + upsampler4x.process_block(output->channelWriter(0), temp.data(), static_cast(numFrames * 2)); upsampler2x.clear_buffers(); upsampler4x.clear_buffers(); - upsampler2x.process_block(temp.data(), output->channelReader(1), numFrames); - upsampler4x.process_block(output->channelWriter(1), temp.data(), numFrames * 2); + upsampler2x.process_block(temp.data(), output->channelReader(1), static_cast(numFrames)); + upsampler4x.process_block(output->channelWriter(1), temp.data(), static_cast(numFrames * 2)); } } @@ -189,11 +189,11 @@ BENCHMARK_DEFINE_F(FileFixture, ResampleInChunks)(benchmark::State& state) { sfz::readInterleaved(bufferChunk, leftSpan, rightSpan); - upsampler2xLeft.process_block(chunkSpan.data(), leftSpan.data(), thisChunkSize); - upsampler4xLeft.process_block(output->channelWriter(0) + outputFrameCounter, chunkSpan.data(), thisChunkSize * 2); + upsampler2xLeft.process_block(chunkSpan.data(), leftSpan.data(), static_cast(thisChunkSize)); + upsampler4xLeft.process_block(output->channelWriter(0) + outputFrameCounter, chunkSpan.data(), static_cast(thisChunkSize * 2)); - upsampler2xRight.process_block(chunkSpan.data(), rightSpan.data(), thisChunkSize); - upsampler4xRight.process_block(output->channelWriter(1) + outputFrameCounter, chunkSpan.data(), thisChunkSize * 2); + upsampler2xRight.process_block(chunkSpan.data(), rightSpan.data(), static_cast(thisChunkSize)); + upsampler4xRight.process_block(output->channelWriter(1) + outputFrameCounter, chunkSpan.data(), static_cast(thisChunkSize * 2)); inputFrameCounter += chunkSize; outputFrameCounter += chunkSize * 4; diff --git a/benchmarks/BM_saturating.cpp b/benchmarks/BM_saturating.cpp index e41c420f..a4927bf8 100644 --- a/benchmarks/BM_saturating.cpp +++ b/benchmarks/BM_saturating.cpp @@ -21,12 +21,12 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include "SIMDHelpers.h" #include #include #include #include #include -#include "SIMDHelpers.h" // In this one we have an array of indices @@ -91,4 +91,4 @@ BENCHMARK_REGISTER_F(SaturatingFixture, Scalar)->RangeMultiplier(2)->Range((2<<6 BENCHMARK_REGISTER_F(SaturatingFixture, SIMD)->RangeMultiplier(2)->Range((2<<6), (2<<12)); BENCHMARK_REGISTER_F(SaturatingFixture, Scalar_Unaligned)->RangeMultiplier(2)->Range((2<<6), (2<<12)); BENCHMARK_REGISTER_F(SaturatingFixture, SIMD_Unaligned)->RangeMultiplier(2)->Range((2<<6), (2<<12)); -BENCHMARK_MAIN(); \ No newline at end of file +BENCHMARK_MAIN(); diff --git a/benchmarks/BM_subtract.cpp b/benchmarks/BM_subtract.cpp index 7eb8cf18..ce4507de 100644 --- a/benchmarks/BM_subtract.cpp +++ b/benchmarks/BM_subtract.cpp @@ -21,13 +21,13 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include "SIMDHelpers.h" #include #include #include #include #include #include -#include "SIMDHelpers.h" class SubArray : public benchmark::Fixture { public: @@ -82,4 +82,4 @@ BENCHMARK_REGISTER_F(SubArray, Scalar)->RangeMultiplier(4)->Range(1 << 2, 1 << 1 BENCHMARK_REGISTER_F(SubArray, SIMD)->RangeMultiplier(4)->Range(1 << 2, 1 << 12); BENCHMARK_REGISTER_F(SubArray, Scalar_Unaligned)->RangeMultiplier(4)->Range(1 << 2, 1 << 12); BENCHMARK_REGISTER_F(SubArray, SIMD_Unaligned)->RangeMultiplier(4)->Range(1 << 2, 1 << 12); -BENCHMARK_MAIN(); \ No newline at end of file +BENCHMARK_MAIN(); diff --git a/benchmarks/BM_wavfile.cpp b/benchmarks/BM_wavfile.cpp index c2d2338b..0bf503bf 100644 --- a/benchmarks/BM_wavfile.cpp +++ b/benchmarks/BM_wavfile.cpp @@ -20,12 +20,12 @@ // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include "Buffer.h" #include #include #define DR_WAV_IMPLEMENTATION #include "dr_wav.h" #include "ghc/filesystem.hpp" -#include "Buffer.h" #include #ifndef NDEBUG #include diff --git a/benchmarks/BM_writeInterleaved.cpp b/benchmarks/BM_writeInterleaved.cpp index dd6c2884..30389ead 100644 --- a/benchmarks/BM_writeInterleaved.cpp +++ b/benchmarks/BM_writeInterleaved.cpp @@ -21,9 +21,9 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#include #include "SIMDHelpers.h" #include "Buffer.h" +#include #include #include #include @@ -106,4 +106,4 @@ BENCHMARK(Unaligned_Interleaved_Write)->Range((8<<10), (8<<20)); BENCHMARK(Unaligned_Interleaved_Write_SSE)->Range((8<<10), (8<<20)); BENCHMARK(Unaligned_Interleaved_Write_2)->Range((8<<10), (8<<20)); BENCHMARK(Unaligned_Interleaved_Write_SSE_2)->Range((8<<10), (8<<20)); -BENCHMARK_MAIN(); \ No newline at end of file +BENCHMARK_MAIN(); diff --git a/src/external/mathfuns/sse_mathfun.h b/src/external/mathfuns/sse_mathfun.h index bcc0f218..bf062a40 100644 --- a/src/external/mathfuns/sse_mathfun.h +++ b/src/external/mathfuns/sse_mathfun.h @@ -35,7 +35,7 @@ #ifdef _MSC_VER /* visual c++ */ # define ALIGN16_BEG __declspec(align(16)) -# define ALIGN16_END +# define ALIGN16_END #else /* gcc or icc */ # define ALIGN16_BEG # define ALIGN16_END __attribute__((aligned(16))) @@ -77,18 +77,18 @@ _PI32_CONST(2, 2); _PI32_CONST(4, 4); _PI32_CONST(0x7f, 0x7f); -_PS_CONST(cephes_SQRTHF, 0.707106781186547524); -_PS_CONST(cephes_log_p0, 7.0376836292E-2); -_PS_CONST(cephes_log_p1, - 1.1514610310E-1); -_PS_CONST(cephes_log_p2, 1.1676998740E-1); -_PS_CONST(cephes_log_p3, - 1.2420140846E-1); -_PS_CONST(cephes_log_p4, + 1.4249322787E-1); -_PS_CONST(cephes_log_p5, - 1.6668057665E-1); -_PS_CONST(cephes_log_p6, + 2.0000714765E-1); -_PS_CONST(cephes_log_p7, - 2.4999993993E-1); -_PS_CONST(cephes_log_p8, + 3.3333331174E-1); -_PS_CONST(cephes_log_q1, -2.12194440e-4); -_PS_CONST(cephes_log_q2, 0.693359375); +_PS_CONST(cephes_SQRTHF, 0.707106781186547524f); +_PS_CONST(cephes_log_p0, 7.0376836292E-2f); +_PS_CONST(cephes_log_p1, - 1.1514610310E-1f); +_PS_CONST(cephes_log_p2, 1.1676998740E-1f); +_PS_CONST(cephes_log_p3, - 1.2420140846E-1f); +_PS_CONST(cephes_log_p4, + 1.4249322787E-1f); +_PS_CONST(cephes_log_p5, - 1.6668057665E-1f); +_PS_CONST(cephes_log_p6, + 2.0000714765E-1f); +_PS_CONST(cephes_log_p7, - 2.4999993993E-1f); +_PS_CONST(cephes_log_p8, + 3.3333331174E-1f); +_PS_CONST(cephes_log_q1, -2.12194440e-4f); +_PS_CONST(cephes_log_q2, 0.693359375f); #ifndef USE_SSE2 typedef union xmm_mm_union { @@ -108,7 +108,7 @@ typedef union xmm_mm_union { #endif // USE_SSE2 -/* natural logarithm computed for 4 simultaneous float +/* natural logarithm computed for 4 simultaneous float return NaN for x <= 0 */ v4sf log_ps(v4sf x) { @@ -148,7 +148,7 @@ v4sf log_ps(v4sf x) { e = _mm_add_ps(e, one); - /* part2: + /* part2: if( x < SQRTHF ) { e -= 1; x = x + x - 1.0; @@ -183,7 +183,7 @@ v4sf log_ps(v4sf x) { y = _mm_mul_ps(y, x); y = _mm_mul_ps(y, z); - + tmp = _mm_mul_ps(e, *(v4sf*)_ps_cephes_log_q1); y = _mm_add_ps(y, tmp); @@ -202,16 +202,16 @@ v4sf log_ps(v4sf x) { _PS_CONST(exp_hi, 88.3762626647949f); _PS_CONST(exp_lo, -88.3762626647949f); -_PS_CONST(cephes_LOG2EF, 1.44269504088896341); -_PS_CONST(cephes_exp_C1, 0.693359375); -_PS_CONST(cephes_exp_C2, -2.12194440e-4); +_PS_CONST(cephes_LOG2EF, 1.44269504088896341f); +_PS_CONST(cephes_exp_C1, 0.693359375f); +_PS_CONST(cephes_exp_C2, -2.12194440e-4f); -_PS_CONST(cephes_exp_p0, 1.9875691500E-4); -_PS_CONST(cephes_exp_p1, 1.3981999507E-3); -_PS_CONST(cephes_exp_p2, 8.3334519073E-3); -_PS_CONST(cephes_exp_p3, 4.1665795894E-2); -_PS_CONST(cephes_exp_p4, 1.6666665459E-1); -_PS_CONST(cephes_exp_p5, 5.0000001201E-1); +_PS_CONST(cephes_exp_p0, 1.9875691500E-4f); +_PS_CONST(cephes_exp_p1, 1.3981999507E-3f); +_PS_CONST(cephes_exp_p2, 8.3334519073E-3f); +_PS_CONST(cephes_exp_p3, 4.1665795894E-2f); +_PS_CONST(cephes_exp_p4, 1.6666665459E-1f); +_PS_CONST(cephes_exp_p5, 5.0000001201E-1f); v4sf exp_ps(v4sf x) { v4sf tmp = _mm_setzero_ps(), fx; @@ -242,7 +242,7 @@ v4sf exp_ps(v4sf x) { tmp = _mm_cvtepi32_ps(emm0); #endif /* if greater, substract 1 */ - v4sf mask = _mm_cmpgt_ps(tmp, fx); + v4sf mask = _mm_cmpgt_ps(tmp, fx); mask = _mm_and_ps(mask, one); fx = _mm_sub_ps(tmp, mask); @@ -252,7 +252,7 @@ v4sf exp_ps(v4sf x) { x = _mm_sub_ps(x, z); z = _mm_mul_ps(x,x); - + v4sf y = *(v4sf*)_ps_cephes_exp_p0; y = _mm_mul_ps(y, x); y = _mm_add_ps(y, *(v4sf*)_ps_cephes_exp_p1); @@ -275,10 +275,10 @@ v4sf exp_ps(v4sf x) { mm1 = _mm_cvttps_pi32(z); mm0 = _mm_add_pi32(mm0, *(v2si*)_pi32_0x7f); mm1 = _mm_add_pi32(mm1, *(v2si*)_pi32_0x7f); - mm0 = _mm_slli_pi32(mm0, 23); + mm0 = _mm_slli_pi32(mm0, 23); mm1 = _mm_slli_pi32(mm1, 23); - - v4sf pow2n; + + v4sf pow2n; COPY_MM_TO_XMM(mm0, mm1, pow2n); _mm_empty(); #else @@ -291,16 +291,16 @@ v4sf exp_ps(v4sf x) { return y; } -_PS_CONST(minus_cephes_DP1, -0.78515625); -_PS_CONST(minus_cephes_DP2, -2.4187564849853515625e-4); -_PS_CONST(minus_cephes_DP3, -3.77489497744594108e-8); -_PS_CONST(sincof_p0, -1.9515295891E-4); -_PS_CONST(sincof_p1, 8.3321608736E-3); -_PS_CONST(sincof_p2, -1.6666654611E-1); -_PS_CONST(coscof_p0, 2.443315711809948E-005); -_PS_CONST(coscof_p1, -1.388731625493765E-003); -_PS_CONST(coscof_p2, 4.166664568298827E-002); -_PS_CONST(cephes_FOPI, 1.27323954473516); // 4 / M_PI +_PS_CONST(minus_cephes_DP1, -0.78515625f); +_PS_CONST(minus_cephes_DP2, -2.4187564849853515625e-4f); +_PS_CONST(minus_cephes_DP3, -3.77489497744594108e-8f); +_PS_CONST(sincof_p0, -1.9515295891E-4f); +_PS_CONST(sincof_p1, 8.3321608736E-3f); +_PS_CONST(sincof_p2, -1.6666654611E-1f); +_PS_CONST(coscof_p0, 2.443315711809948E-005f); +_PS_CONST(coscof_p1, -1.388731625493765E-003f); +_PS_CONST(coscof_p2, 4.166664568298827E-002f); +_PS_CONST(cephes_FOPI, 1.27323954473516f); // 4 / M_PI /* evaluation of 4 sines at onces, using only SSE1+MMX intrinsics so @@ -344,7 +344,7 @@ v4sf sin_ps(v4sf x) { // any x x = _mm_and_ps(x, *(v4sf*)_ps_inv_sign_mask); /* extract the sign bit (upper one) */ sign_bit = _mm_and_ps(sign_bit, *(v4sf*)_ps_sign_mask); - + /* scale by 4/Pi */ y = _mm_mul_ps(x, *(v4sf*)_ps_cephes_FOPI); @@ -359,7 +359,7 @@ v4sf sin_ps(v4sf x) { // any x /* get the swap sign flag */ emm0 = _mm_and_si128(emm2, *(v4si*)_pi32_4); emm0 = _mm_slli_epi32(emm0, 29); - /* get the polynom selection mask + /* get the polynom selection mask there is one polynom for 0 <= x <= Pi/4 and another one for Pi/4::getNextValue() noexcept return start; currentState = State::Attack; - step = (1.0 - currentValue) / (attack > 0 ? attack : 1); + step = (static_cast(1.0) - currentValue) / (attack > 0 ? attack : 1); [[fallthrough]]; case State::Attack: if (attack-- > 0) { diff --git a/src/sfizz/Buffer.h b/src/sfizz/Buffer.h index 6a899da2..e97843ed 100644 --- a/src/sfizz/Buffer.h +++ b/src/sfizz/Buffer.h @@ -68,6 +68,21 @@ public: bytes.fetch_sub(size); } + void bufferDeleted(size_t size) + { + bufferDeleted(static_cast(size)); + } + + void bufferResized(size_t oldSize, size_t newSize) + { + bufferResized(static_cast(oldSize), static_cast(newSize)); + } + + void newBuffer(size_t size) + { + newBuffer(static_cast(size)); + } + int getNumBuffers() { return numBuffers; } int getTotalBytes() { return bytes; } private: @@ -165,7 +180,7 @@ public: */ void clear() { - counter().bufferResized(largerSize * sizeof(value_type), 0); + counter().bufferResized(largerSize * sizeof(value_type), static_cast(0)); largerSize = 0; alignedSize = 0; std::free(paddedData); diff --git a/src/sfizz/EventEnvelopes.cpp b/src/sfizz/EventEnvelopes.cpp index 1128eba6..f31d9978 100644 --- a/src/sfizz/EventEnvelopes.cpp +++ b/src/sfizz/EventEnvelopes.cpp @@ -73,7 +73,7 @@ void EventEnvelope::prepareEvents() absl::c_sort(events, [](const auto& lhs, const auto& rhs) { return lhs.first < rhs.first; }); - + resetEvents = true; } @@ -134,7 +134,7 @@ void LinearEnvelope::getQuantizedBlock(absl::Span output, Type quant EventEnvelope::getQuantizedBlock(output, quantizationStep); auto& events = EventEnvelope::events; auto& currentValue = EventEnvelope::currentValue; - + ASSERT(quantizationStep != 0.0); int index { 0 }; @@ -167,7 +167,7 @@ void LinearEnvelope::getQuantizedBlock(absl::Span output, Type quant continue; } - const int numSteps = difference / quantizationStep; + const auto numSteps = static_cast(difference / quantizationStep); const auto stepLength = static_cast(length / numSteps); for (int i = 0; i < numSteps; ++i) { fill(output.subspan(index, stepLength), currentValue); @@ -218,15 +218,15 @@ void MultiplicativeEnvelope::getQuantizedBlock(absl::Span output, Ty EventEnvelope::getQuantizedBlock(output, quantizationStep); auto& events = EventEnvelope::events; auto& currentValue = EventEnvelope::currentValue; - + ASSERT(quantizationStep != 0.0); int index { 0 }; const auto logStep = std::log(quantizationStep); // If we assume that a = b.q^r for b in (1, q) then - // log a log b - // ----- = ----- + r - // log q log q + // log a log b + // ----- = ----- + r + // log q log q // and log(b)\log(q) is between 0 and 1. auto quantize = [logStep](Type value) -> Type { return std::exp(logStep * std::round(std::log(value)/logStep)); @@ -257,11 +257,11 @@ void MultiplicativeEnvelope::getQuantizedBlock(absl::Span output, Ty continue; } - const int numSteps = std::log(difference) / logStep; + const auto numSteps = static_cast(std::log(difference) / logStep); const auto stepLength = static_cast(length / numSteps); for (int i = 0; i < numSteps; ++i) { fill(output.subspan(index, stepLength), currentValue); - const auto delta = newValue > currentValue ? + const auto delta = newValue > currentValue ? quantize(currentValue) / currentValue * quantizationStep : quantize(currentValue) / currentValue / quantizationStep ; currentValue *= delta; diff --git a/src/sfizz/MathHelpers.h b/src/sfizz/MathHelpers.h index 4d708a0a..059dcaef 100644 --- a/src/sfizz/MathHelpers.h +++ b/src/sfizz/MathHelpers.h @@ -29,6 +29,7 @@ * @date 2019-11-23 */ #pragma once +#include "Config.h" #include #include #include @@ -156,14 +157,14 @@ constexpr ValueType linearInterpolation(ValueType left, ValueType right, ValueTy } template -constexpr Type pi { 3.141592653589793238462643383279502884 }; +constexpr Type pi { static_cast(3.141592653589793238462643383279502884) }; template -constexpr Type twoPi { 2 * pi }; +constexpr Type twoPi { static_cast(2) * pi }; template -constexpr Type piTwo { pi / 2 }; +constexpr Type piTwo { pi / static_cast(2) }; template -constexpr Type piFour { pi / 4 }; +constexpr Type piFour { pi / static_cast(4) }; template -constexpr Type sqrtTwo { 1.414213562373095048801688724209698078569671875376948073176 }; +constexpr Type sqrtTwo { static_cast(1.414213562373095048801688724209698078569671875376948073176) }; template -constexpr Type sqrtTwoInv { 0.707106781186547524400844362104849039284835937688474036588 }; +constexpr Type sqrtTwoInv { static_cast(0.707106781186547524400844362104849039284835937688474036588) }; diff --git a/src/sfizz/Parser.cpp b/src/sfizz/Parser.cpp index f0286db6..73444d0b 100644 --- a/src/sfizz/Parser.cpp +++ b/src/sfizz/Parser.cpp @@ -22,7 +22,6 @@ // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "Parser.h" -#include "Config.h" #include "StringViewHelpers.h" #include "SfzHelpers.h" #include "absl/strings/str_join.h" diff --git a/src/sfizz/Parser.h b/src/sfizz/Parser.h index 222fd153..1edf8a61 100644 --- a/src/sfizz/Parser.h +++ b/src/sfizz/Parser.h @@ -22,6 +22,7 @@ // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #pragma once +#include "Config.h" #include "Opcode.h" #include "ghc/fs_std.hpp" #include