diff --git a/README.md b/README.md index 7e69b2b4..73a76b73 100644 --- a/README.md +++ b/README.md @@ -39,3 +39,35 @@ git submodule update --init --recursive ``` You can build with `clang`, although in that case the CMakeFile defaults to using `libc++` instead of `libstdc++`. + +### Building with MSVC on windows + +The simplest is to use `vcpkg` as a package manager, which will give you access to `libsndfile`. +```powershell +git clone https://github.com/Microsoft/vcpkg.git +cd vcpkg +.\bootstrap-vcpkg.bat +.\vcpkg integrate install +.\vcpkg integrate powershell +``` + +Assuming you want to build for x64, install the relevant packages as follows +```powershell +.\vcpkg.exe install libsndfile:x64-windows zlib:x64-windows libsamplerate:x64-windows +``` + +In the sfizz source directory, you can then build with CMake as usual, although you should clone the windows branch: +```powershell +git clone --branch windows --recursive https://github.com/sfztools/sfizz.git +cd sfizz +mkdir build +cd build +cmake .. -DSFIZZ_JACK=OFF "-DCMAKE_TOOLCHAIN_FILE=C:\Users\Paul\source\vcpkg\scripts\buildsystems\vcpkg.cmake" -DVCPKG_TARGET_TRIPLET=x64-windows +cmake --build . -j 16 --config Release +``` + +This builds the lv2 plugin in `build\lv2\Release` and the Turtle files in `build\sfizz.lv2`, but the installation procedure is not entirely automatic yet. +In particular, having the required DLLs along with `sfizz.dll` is actually not helpful because the system cannot find dlls from another dll's root directory. +You thus need to add all of `FLAC.dll`, `libsndfile-1.dll`, `vorbis.dll`, `ogg.dll`, `vorbisenc.dll` in some directory in your `PATH` variable, and manually add `sfizz.dll` to the `sfizz.lv2` directory, and the the `sfizz.lv2` directory to `%APPDATA%\Roaming\LV2`. +Ardour should then find the plugin correctly and load it without issues. + 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..0352fced 100644 --- a/benchmarks/BM_flacfile.cpp +++ b/benchmarks/BM_flacfile.cpp @@ -20,23 +20,27 @@ // 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 #endif +#include "libnyquist/Decoders.h" class FileFixture : public benchmark::Fixture { public: void SetUp(const ::benchmark::State& state) { - rootPath1 = getPath() / "sample1.flac"; - rootPath2 = getPath() / "sample2.flac"; - if (!ghc::filesystem::exists(rootPath1) || !ghc::filesystem::exists(rootPath2)) { + filePath1 = getPath() / "sample1.flac"; + filePath2 = getPath() / "sample2.flac"; + filePath3 = getPath() / "sample3.flac"; + if ( !ghc::filesystem::exists(filePath1) + || !ghc::filesystem::exists(filePath2) + || !ghc::filesystem::exists(filePath3) ) { #ifndef NDEBUG std::cerr << "Can't find path" << '\n'; #endif @@ -62,15 +66,16 @@ public: std::unique_ptr> buffer; - ghc::filesystem::path rootPath1; - ghc::filesystem::path rootPath2; + ghc::filesystem::path filePath1; + ghc::filesystem::path filePath2; + ghc::filesystem::path filePath3; }; BENCHMARK_DEFINE_F(FileFixture, SndFile)(benchmark::State& state) { for (auto _ : state) { - SndfileHandle sndfile(rootPath1.c_str()); + SndfileHandle sndfile(filePath1.c_str()); buffer = std::make_unique>(sndfile.channels() * sndfile.frames()); sndfile.readf(buffer->data(), sndfile.frames()); } @@ -79,12 +84,23 @@ BENCHMARK_DEFINE_F(FileFixture, SndFile)(benchmark::State& state) { BENCHMARK_DEFINE_F(FileFixture, DrFlac)(benchmark::State& state) { for (auto _ : state) { - auto* flac = drflac_open_file(rootPath2.c_str(), nullptr); + auto* flac = drflac_open_file(filePath2.c_str(), nullptr); buffer = std::make_unique>(flac->channels * flac->totalPCMFrameCount); drflac_read_pcm_frames_f32(flac, flac->totalPCMFrameCount, buffer->data()); } } +BENCHMARK_DEFINE_F(FileFixture, LibNyquist)(benchmark::State& state) { + for (auto _ : state) + { + nqr::AudioData data; + nqr::NyquistIO loader; + loader.Load(&data, filePath3.string()); + benchmark::DoNotOptimize(data); + } +} + BENCHMARK_REGISTER_F(FileFixture, SndFile); BENCHMARK_REGISTER_F(FileFixture, DrFlac); +BENCHMARK_REGISTER_F(FileFixture, LibNyquist); BENCHMARK_MAIN(); 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_mathfuns.cpp b/benchmarks/BM_mathfuns.cpp index 1b4339b4..c8844743 100644 --- a/benchmarks/BM_mathfuns.cpp +++ b/benchmarks/BM_mathfuns.cpp @@ -36,7 +36,7 @@ public: { 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 }; source = std::vector(state.range(0)); result = std::vector(state.range(0)); std::generate(source.begin(), source.end(), [&]() { return dist(gen); }); @@ -162,4 +162,4 @@ BENCHMARK_REGISTER_F(MyFixture, SIMDSin)->RangeMultiplier(4)->Range(1 << 6, 1 << BENCHMARK_REGISTER_F(MyFixture, ScalarCos)->RangeMultiplier(4)->Range(1 << 6, 1 << 10); BENCHMARK_REGISTER_F(MyFixture, SIMDCos)->RangeMultiplier(4)->Range(1 << 6, 1 << 10); -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_resample.cpp b/benchmarks/BM_resample.cpp index 27110ef7..86499690 100644 --- a/benchmarks/BM_resample.cpp +++ b/benchmarks/BM_resample.cpp @@ -64,7 +64,7 @@ void upsample2xStage(absl::Span input, absl::Span output) ASSERT(output.size() >= 2 * input.size()); hiir::Upsampler2xFpu upsampler; upsampler.set_coefs(coeffsStage2x.data()); - upsampler.process_block(output.data(), input.data(), input.size()); + upsampler.process_block(output.data(), input.data(), static_cast(input.size())); } @@ -74,7 +74,7 @@ void upsample4xStage(absl::Span input, absl::Span output) ASSERT(output.size() >= 2 * input.size()); hiir::Upsampler2xFpu upsampler; upsampler.set_coefs(coeffsStage4x.data()); - upsampler.process_block(output.data(), input.data(), input.size()); + upsampler.process_block(output.data(), input.data(), static_cast(input.size())); } template @@ -83,7 +83,7 @@ void upsample8xStage(absl::Span input, absl::Span output) ASSERT(output.size() >= 2 * input.size()); hiir::Upsampler2xFpu upsampler; upsampler.set_coefs(coeffsStage8x.data()); - upsampler.process_block(output.data(), input.data(), input.size()); + upsampler.process_block(output.data(), input.data(), static_cast(input.size())); } #if defined(__x86_64__) || defined(__i386__) @@ -94,7 +94,7 @@ void upsample2xStage(absl::Span input, absl::Span outp ASSERT(output.size() >= 2 * input.size()); hiir::Upsampler2xSse upsampler; upsampler.set_coefs(coeffsStage2x.data()); - upsampler.process_block(output.data(), input.data(), input.size()); + upsampler.process_block(output.data(), input.data(), static_cast(input.size())); } template<> @@ -103,7 +103,7 @@ void upsample4xStage(absl::Span input, absl::Span outp ASSERT(output.size() >= 2 * input.size()); hiir::Upsampler2xSse upsampler; upsampler.set_coefs(coeffsStage4x.data()); - upsampler.process_block(output.data(), input.data(), input.size()); + upsampler.process_block(output.data(), input.data(), static_cast(input.size())); } template<> @@ -112,7 +112,7 @@ void upsample8xStage(absl::Span input, absl::Span outp ASSERT(output.size() >= 2 * input.size()); hiir::Upsampler2xSse upsampler; upsampler.set_coefs(coeffsStage8x.data()); - upsampler.process_block(output.data(), input.data(), input.size()); + upsampler.process_block(output.data(), input.data(), static_cast(input.size())); } #elif defined(__arm__) || defined (__aarch64__) @@ -125,7 +125,7 @@ void upsample2xStage(absl::Span input, absl::Span outp ASSERT(output.size() >= 2 * input.size()); hiir::Upsampler2xNeon upsampler; upsampler.set_coefs(coeffsStage2x.data()); - upsampler.process_block(output.data(), input.data(), input.size()); + upsampler.process_block(output.data(), input.data(), static_cast(input.size())); } template<> @@ -134,7 +134,7 @@ void upsample4xStage(absl::Span input, absl::Span outp ASSERT(output.size() >= 2 * input.size()); hiir::Upsampler2xNeon upsampler; upsampler.set_coefs(coeffsStage4x.data()); - upsampler.process_block(output.data(), input.data(), input.size()); + upsampler.process_block(output.data(), input.data(), static_cast(input.size())); } template<> @@ -143,7 +143,7 @@ void upsample8xStage(absl::Span input, absl::Span outp ASSERT(output.size() >= 2 * input.size()); hiir::Upsampler2xNeon upsampler; upsampler.set_coefs(coeffsStage8x.data()); - upsampler.process_block(output.data(), input.data(), input.size()); + upsampler.process_block(output.data(), input.data(), static_cast(input.size())); } #else @@ -170,7 +170,7 @@ std::unique_ptr> upsample2x(const sfz::AudioBuffer& buffe { // auto tempBuffer = std::make_unique>(buffer.getNumFrames() * 2); auto outputBuffer = std::make_unique>(buffer.getNumChannels(), buffer.getNumFrames() * 2); - for (int channelIdx = 0; channelIdx < buffer.getNumChannels(); channelIdx++) { + for (size_t channelIdx = 0; channelIdx < buffer.getNumChannels(); channelIdx++) { upsample2xStage(buffer.getConstSpan(channelIdx), outputBuffer->getSpan(channelIdx)); } return outputBuffer; @@ -181,7 +181,7 @@ std::unique_ptr> upsample4x(const sfz::AudioBuffer& buffe { auto tempBuffer = std::make_unique>(buffer.getNumFrames() * 2); auto outputBuffer = std::make_unique>(buffer.getNumChannels(), buffer.getNumFrames() * 4); - for (int channelIdx = 0; channelIdx < buffer.getNumChannels(); channelIdx++) { + for (size_t channelIdx = 0; channelIdx < buffer.getNumChannels(); channelIdx++) { upsample2xStage(buffer.getConstSpan(channelIdx), absl::MakeSpan(*tempBuffer)); upsample4xStage(absl::MakeConstSpan(*tempBuffer), outputBuffer->getSpan(channelIdx)); } @@ -194,7 +194,7 @@ std::unique_ptr> upsample8x(const sfz::AudioBuffer& buffe auto tempBuffer2x = std::make_unique>(buffer.getNumFrames() * 2); auto tempBuffer4x = std::make_unique>(buffer.getNumFrames() * 4); auto outputBuffer = std::make_unique>(buffer.getNumChannels(), buffer.getNumFrames() * 8); - for (int channelIdx = 0; channelIdx < buffer.getNumChannels(); channelIdx++) { + for (size_t channelIdx = 0; channelIdx < buffer.getNumChannels(); channelIdx++) { upsample2xStage(buffer.getConstSpan(channelIdx), absl::MakeSpan(*tempBuffer2x)); upsample4xStage(absl::MakeConstSpan(*tempBuffer2x), absl::MakeSpan(*tempBuffer4x)); upsample8xStage(absl::MakeConstSpan(*tempBuffer4x), outputBuffer->getSpan(channelIdx)); @@ -240,8 +240,8 @@ public: #endif } - int numChannels; - int numFrames; + size_t numChannels; + size_t numFrames; std::unique_ptr> interleavedBuffer; }; @@ -313,9 +313,9 @@ BENCHMARK_DEFINE_F(SndFile, SRC2x_BEST)(benchmark::State& state) srcData.data_in = interleavedBuffer->data(); srcData.data_out = intermediateBuffer->data(); srcData.src_ratio = 2.0; - srcData.input_frames = numFrames; - srcData.output_frames = 2 * numFrames; - src_simple(&srcData, SRC_SINC_BEST_QUALITY, numChannels); + srcData.input_frames = static_cast(numFrames); + srcData.output_frames = static_cast(2 * numFrames); + src_simple(&srcData, SRC_SINC_BEST_QUALITY, static_cast(numChannels)); auto outBuffer = std::make_unique>(numChannels, 2 * numFrames); sfz::readInterleaved(*intermediateBuffer, outBuffer->getSpan(0), outBuffer->getSpan(1)); benchmark::DoNotOptimize(outBuffer); @@ -330,9 +330,9 @@ BENCHMARK_DEFINE_F(SndFile, SRC2x_MEDIUM)(benchmark::State& state) srcData.data_in = interleavedBuffer->data(); srcData.data_out = intermediateBuffer->data(); srcData.src_ratio = 2.0; - srcData.input_frames = numFrames; - srcData.output_frames = 2 * numFrames; - src_simple(&srcData, SRC_SINC_MEDIUM_QUALITY, numChannels); + srcData.input_frames = static_cast(numFrames); + srcData.output_frames = static_cast(2 * numFrames); + src_simple(&srcData, SRC_SINC_MEDIUM_QUALITY, static_cast(numChannels)); auto outBuffer = std::make_unique>(numChannels, 2 * numFrames); sfz::readInterleaved(*intermediateBuffer, outBuffer->getSpan(0), outBuffer->getSpan(1)); benchmark::DoNotOptimize(outBuffer); @@ -347,9 +347,9 @@ BENCHMARK_DEFINE_F(SndFile, SRC2x_FASTEST)(benchmark::State& state) srcData.data_in = interleavedBuffer->data(); srcData.data_out = intermediateBuffer->data(); srcData.src_ratio = 2.0; - srcData.input_frames = numFrames; - srcData.output_frames = 2 * numFrames; - src_simple(&srcData, SRC_SINC_FASTEST, numChannels); + srcData.input_frames = static_cast(numFrames); + srcData.output_frames = static_cast(2 * numFrames); + src_simple(&srcData, SRC_SINC_FASTEST, static_cast(numChannels)); auto outBuffer = std::make_unique>(numChannels, 2 * numFrames); sfz::readInterleaved(*intermediateBuffer, outBuffer->getSpan(0), outBuffer->getSpan(1)); benchmark::DoNotOptimize(outBuffer); @@ -365,9 +365,9 @@ BENCHMARK_DEFINE_F(SndFile, SRC4x_BEST)(benchmark::State& state) srcData.data_in = interleavedBuffer->data(); srcData.data_out = intermediateBuffer->data(); srcData.src_ratio = 4.0; - srcData.input_frames = numFrames; - srcData.output_frames = 2 * numFrames; - src_simple(&srcData, SRC_SINC_BEST_QUALITY, numChannels); + srcData.input_frames = static_cast(numFrames); + srcData.output_frames = static_cast(2 * numFrames); + src_simple(&srcData, SRC_SINC_BEST_QUALITY, static_cast(numChannels)); auto outBuffer = std::make_unique>(numChannels, 2 * numFrames); sfz::readInterleaved(*intermediateBuffer, outBuffer->getSpan(0), outBuffer->getSpan(1)); benchmark::DoNotOptimize(outBuffer); @@ -382,9 +382,9 @@ BENCHMARK_DEFINE_F(SndFile, SRC4x_MEDIUM)(benchmark::State& state) srcData.data_in = interleavedBuffer->data(); srcData.data_out = intermediateBuffer->data(); srcData.src_ratio = 4.0; - srcData.input_frames = numFrames; - srcData.output_frames = 2 * numFrames; - src_simple(&srcData, SRC_SINC_MEDIUM_QUALITY, numChannels); + srcData.input_frames = static_cast(numFrames); + srcData.output_frames = static_cast(2 * numFrames); + src_simple(&srcData, SRC_SINC_MEDIUM_QUALITY, static_cast(numChannels)); auto outBuffer = std::make_unique>(numChannels, 2 * numFrames); sfz::readInterleaved(*intermediateBuffer, outBuffer->getSpan(0), outBuffer->getSpan(1)); benchmark::DoNotOptimize(outBuffer); @@ -399,9 +399,9 @@ BENCHMARK_DEFINE_F(SndFile, SRC4x_FASTEST)(benchmark::State& state) srcData.data_in = interleavedBuffer->data(); srcData.data_out = intermediateBuffer->data(); srcData.src_ratio = 4.0; - srcData.input_frames = numFrames; - srcData.output_frames = 2 * numFrames; - src_simple(&srcData, SRC_SINC_FASTEST, numChannels); + srcData.input_frames = static_cast(numFrames); + srcData.output_frames = static_cast(2 * numFrames); + src_simple(&srcData, SRC_SINC_FASTEST, static_cast(numChannels)); auto outBuffer = std::make_unique>(numChannels, 2 * numFrames); sfz::readInterleaved(*intermediateBuffer, outBuffer->getSpan(0), outBuffer->getSpan(1)); benchmark::DoNotOptimize(outBuffer); @@ -416,9 +416,9 @@ BENCHMARK_DEFINE_F(SndFile, SRC8x_BEST)(benchmark::State& state) srcData.data_in = interleavedBuffer->data(); srcData.data_out = intermediateBuffer->data(); srcData.src_ratio = 8.0; - srcData.input_frames = numFrames; - srcData.output_frames = 2 * numFrames; - src_simple(&srcData, SRC_SINC_BEST_QUALITY, numChannels); + srcData.input_frames = static_cast(numFrames); + srcData.output_frames = static_cast(2 * numFrames); + src_simple(&srcData, SRC_SINC_BEST_QUALITY, static_cast(numChannels)); auto outBuffer = std::make_unique>(numChannels, 2 * numFrames); sfz::readInterleaved(*intermediateBuffer, outBuffer->getSpan(0), outBuffer->getSpan(1)); benchmark::DoNotOptimize(outBuffer); @@ -433,9 +433,9 @@ BENCHMARK_DEFINE_F(SndFile, SRC8x_MEDIUM)(benchmark::State& state) srcData.data_in = interleavedBuffer->data(); srcData.data_out = intermediateBuffer->data(); srcData.src_ratio = 8.0; - srcData.input_frames = numFrames; - srcData.output_frames = 2 * numFrames; - src_simple(&srcData, SRC_SINC_MEDIUM_QUALITY, numChannels); + srcData.input_frames = static_cast(numFrames); + srcData.output_frames = static_cast(2 * numFrames); + src_simple(&srcData, SRC_SINC_MEDIUM_QUALITY, static_cast(numChannels)); auto outBuffer = std::make_unique>(numChannels, 2 * numFrames); sfz::readInterleaved(*intermediateBuffer, outBuffer->getSpan(0), outBuffer->getSpan(1)); benchmark::DoNotOptimize(outBuffer); @@ -450,9 +450,9 @@ BENCHMARK_DEFINE_F(SndFile, SRC8x_FASTEST)(benchmark::State& state) srcData.data_in = interleavedBuffer->data(); srcData.data_out = intermediateBuffer->data(); srcData.src_ratio = 8.0; - srcData.input_frames = numFrames; - srcData.output_frames = 2 * numFrames; - src_simple(&srcData, SRC_SINC_FASTEST, numChannels); + srcData.input_frames = static_cast(numFrames); + srcData.output_frames = static_cast(2 * numFrames); + src_simple(&srcData, SRC_SINC_FASTEST, static_cast(numChannels)); auto outBuffer = std::make_unique>(numChannels, 2 * numFrames); sfz::readInterleaved(*intermediateBuffer, outBuffer->getSpan(0), outBuffer->getSpan(1)); benchmark::DoNotOptimize(outBuffer); 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..75d6d576 100644 --- a/benchmarks/BM_wavfile.cpp +++ b/benchmarks/BM_wavfile.cpp @@ -20,23 +20,27 @@ // 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 #endif +#include "libnyquist/Decoders.h" class FileFixture : public benchmark::Fixture { public: void SetUp(const ::benchmark::State& state) { - rootPath1 = getPath() / "sample1.wav"; - rootPath2 = getPath() / "sample2.wav"; - if (!ghc::filesystem::exists(rootPath1) || !ghc::filesystem::exists(rootPath2)) { + filePath1 = getPath() / "sample1.wav"; + filePath2 = getPath() / "sample2.wav"; + filePath3 = getPath() / "sample3.wav"; + if ( !ghc::filesystem::exists(filePath1) + || !ghc::filesystem::exists(filePath2) + || !ghc::filesystem::exists(filePath3)) { #ifndef NDEBUG std::cerr << "Can't find path" << '\n'; #endif @@ -62,15 +66,16 @@ public: std::unique_ptr> buffer; - ghc::filesystem::path rootPath1; - ghc::filesystem::path rootPath2; + ghc::filesystem::path filePath1; + ghc::filesystem::path filePath2; + ghc::filesystem::path filePath3; }; BENCHMARK_DEFINE_F(FileFixture, SndFile)(benchmark::State& state) { for (auto _ : state) { - SndfileHandle sndfile(rootPath1.c_str()); + SndfileHandle sndfile(filePath1.c_str()); buffer = std::make_unique>(sndfile.channels() * sndfile.frames()); sndfile.readf(buffer->data(), sndfile.frames()); } @@ -80,7 +85,7 @@ BENCHMARK_DEFINE_F(FileFixture, DrWav)(benchmark::State& state) { for (auto _ : state) { drwav wav; - if (!drwav_init_file(&wav, rootPath2.c_str(), nullptr)) { + if (!drwav_init_file(&wav, filePath2.c_str(), nullptr)) { #ifndef NDEBUG std::cerr << "Can't find path" << '\n'; #endif @@ -91,6 +96,17 @@ BENCHMARK_DEFINE_F(FileFixture, DrWav)(benchmark::State& state) { } } +BENCHMARK_DEFINE_F(FileFixture, LibNyquist)(benchmark::State& state) { + for (auto _ : state) + { + nqr::AudioData data; + nqr::NyquistIO loader; + loader.Load(&data, filePath3.string()); + benchmark::DoNotOptimize(data); + } +} + BENCHMARK_REGISTER_F(FileFixture, SndFile); BENCHMARK_REGISTER_F(FileFixture, DrWav); +BENCHMARK_REGISTER_F(FileFixture, LibNyquist); BENCHMARK_MAIN(); 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/benchmarks/CMakeLists.txt b/benchmarks/CMakeLists.txt index cfadf051..038069a2 100644 --- a/benchmarks/CMakeLists.txt +++ b/benchmarks/CMakeLists.txt @@ -22,115 +22,133 @@ set(BENCHMARK_SIMD_SOURCES ${SFIZZ_SIMD_SOURCES}) list(TRANSFORM BENCHMARK_SIMD_SOURCES PREPEND "../src/") add_executable(bm_opf_high_vs_low BM_OPF_high_vs_low.cpp) -target_link_libraries(bm_opf_high_vs_low benchmark absl::span) +target_link_libraries(bm_opf_high_vs_low PRIVATE benchmark absl::span) target_include_directories(bm_opf_high_vs_low PRIVATE ../src/sfizz ../src/external) add_executable(bm_write BM_writeInterleaved.cpp ${BENCHMARK_SIMD_SOURCES}) -target_link_libraries(bm_write benchmark absl::span) +target_link_libraries(bm_write PRIVATE benchmark absl::span) target_include_directories(bm_write PRIVATE ../src/sfizz ../src/external) add_executable(bm_read BM_readInterleaved.cpp ${BENCHMARK_SIMD_SOURCES}) -target_link_libraries(bm_read benchmark absl::span) +target_link_libraries(bm_read PRIVATE benchmark absl::span) target_include_directories(bm_read PRIVATE ../src/sfizz ../src/external) add_executable(bm_fill BM_fill.cpp ${BENCHMARK_SIMD_SOURCES}) -target_link_libraries(bm_fill benchmark absl::span) +target_link_libraries(bm_fill PRIVATE benchmark absl::span) target_include_directories(bm_fill PRIVATE ../src/sfizz ../src/external) add_executable(bm_mathfuns BM_mathfuns.cpp ${BENCHMARK_SIMD_SOURCES}) -target_link_libraries(bm_mathfuns benchmark absl::span) +target_link_libraries(bm_mathfuns PRIVATE benchmark absl::span) target_include_directories(bm_mathfuns PRIVATE ../src/sfizz ../src/external) add_executable(bm_gain BM_gain.cpp ${BENCHMARK_SIMD_SOURCES}) -target_link_libraries(bm_gain benchmark absl::span) +target_link_libraries(bm_gain PRIVATE benchmark absl::span) target_include_directories(bm_gain PRIVATE ../src/sfizz ../src/external) add_executable(bm_divide BM_divide.cpp ${BENCHMARK_SIMD_SOURCES}) -target_link_libraries(bm_divide benchmark absl::span) +target_link_libraries(bm_divide PRIVATE benchmark absl::span) target_include_directories(bm_divide PRIVATE ../src/sfizz ../src/external) add_executable(bm_looping BM_looping.cpp ${BENCHMARK_SIMD_SOURCES}) -target_link_libraries(bm_looping benchmark absl::span absl::algorithm) +target_link_libraries(bm_looping PRIVATE benchmark absl::span absl::algorithm) target_include_directories(bm_looping PRIVATE ../src/sfizz ../src/external) add_executable(bm_saturating BM_saturating.cpp ${BENCHMARK_SIMD_SOURCES}) -target_link_libraries(bm_saturating benchmark absl::span absl::algorithm) +target_link_libraries(bm_saturating PRIVATE benchmark absl::span absl::algorithm) target_include_directories(bm_saturating PRIVATE ../src/sfizz ../src/external) add_executable(bm_ramp BM_ramp.cpp ${BENCHMARK_SIMD_SOURCES}) -target_link_libraries(bm_ramp benchmark absl::span absl::algorithm) +target_link_libraries(bm_ramp PRIVATE benchmark absl::span absl::algorithm) target_include_directories(bm_ramp PRIVATE ../src/sfizz ../src/external) add_executable(bm_ADSR BM_ADSR.cpp ${BENCHMARK_SIMD_SOURCES}) -target_link_libraries(bm_ADSR benchmark absl::span absl::algorithm) +target_link_libraries(bm_ADSR PRIVATE benchmark absl::span absl::algorithm) target_include_directories(bm_ADSR PRIVATE ../src/sfizz ../src/external) add_executable(bm_add BM_add.cpp ${BENCHMARK_SIMD_SOURCES}) -target_link_libraries(bm_add benchmark absl::span absl::algorithm) +target_link_libraries(bm_add PRIVATE benchmark absl::span absl::algorithm) target_include_directories(bm_add PRIVATE ../src/sfizz ../src/external) add_executable(bm_multiplyAdd BM_multiplyAdd.cpp ${BENCHMARK_SIMD_SOURCES}) -target_link_libraries(bm_multiplyAdd benchmark absl::span absl::algorithm) +target_link_libraries(bm_multiplyAdd PRIVATE benchmark absl::span absl::algorithm) target_include_directories(bm_multiplyAdd PRIVATE ../src/sfizz ../src/external) add_executable(bm_subtract BM_subtract.cpp ${BENCHMARK_SIMD_SOURCES}) -target_link_libraries(bm_subtract benchmark absl::span absl::algorithm) +target_link_libraries(bm_subtract PRIVATE benchmark absl::span absl::algorithm) target_include_directories(bm_subtract PRIVATE ../src/sfizz ../src/external) add_executable(bm_copy BM_copy.cpp ${BENCHMARK_SIMD_SOURCES}) -target_link_libraries(bm_copy benchmark absl::span absl::algorithm) +target_link_libraries(bm_copy PRIVATE benchmark absl::span absl::algorithm) target_include_directories(bm_copy PRIVATE ../src/sfizz ../src/external) add_executable(bm_pan BM_pan.cpp ${BENCHMARK_SIMD_SOURCES}) -target_link_libraries(bm_pan benchmark absl::span absl::algorithm) +target_link_libraries(bm_pan PRIVATE benchmark absl::span absl::algorithm) target_include_directories(bm_pan PRIVATE ../src/sfizz ../src/external) add_executable(bm_mean BM_mean.cpp ${BENCHMARK_SIMD_SOURCES}) -target_link_libraries(bm_mean benchmark absl::span absl::algorithm) +target_link_libraries(bm_mean PRIVATE benchmark absl::span absl::algorithm) target_include_directories(bm_mean PRIVATE ../src/sfizz ../src/external) add_executable(bm_meanSquared BM_meanSquared.cpp ${BENCHMARK_SIMD_SOURCES}) -target_link_libraries(bm_meanSquared benchmark absl::span absl::algorithm) +target_link_libraries(bm_meanSquared PRIVATE benchmark absl::span absl::algorithm) target_include_directories(bm_meanSquared PRIVATE ../src/sfizz ../src/external) add_executable(bm_cumsum BM_cumsum.cpp ${BENCHMARK_SIMD_SOURCES}) -target_link_libraries(bm_cumsum benchmark absl::span absl::algorithm) +target_link_libraries(bm_cumsum PRIVATE benchmark absl::span absl::algorithm) target_include_directories(bm_cumsum PRIVATE ../src/sfizz ../src/external) add_executable(bm_diff BM_diff.cpp ${BENCHMARK_SIMD_SOURCES}) -target_link_libraries(bm_diff benchmark absl::span absl::algorithm) +target_link_libraries(bm_diff PRIVATE benchmark absl::span absl::algorithm) target_include_directories(bm_diff PRIVATE ../src/sfizz ../src/external) add_executable(bm_interpolationCast BM_interpolationCast.cpp ${BENCHMARK_SIMD_SOURCES}) -target_link_libraries(bm_interpolationCast benchmark absl::span absl::algorithm) +target_link_libraries(bm_interpolationCast PRIVATE benchmark absl::span absl::algorithm) target_include_directories(bm_interpolationCast PRIVATE ../src/sfizz ../src/external) add_executable(bm_pointerIterationOrOffsets BM_pointerIterationOrOffsets.cpp ${BENCHMARK_SIMD_SOURCES}) -target_link_libraries(bm_pointerIterationOrOffsets benchmark absl::span absl::algorithm) +target_link_libraries(bm_pointerIterationOrOffsets PRIVATE benchmark absl::span absl::algorithm) target_include_directories(bm_pointerIterationOrOffsets PRIVATE ../src/sfizz ../src/external) add_executable(bm_resample BM_resample.cpp ${BENCHMARK_SIMD_SOURCES}) -target_link_libraries(bm_resample benchmark absl::span absl::algorithm sndfile samplerate) +target_link_libraries(bm_resample PRIVATE benchmark absl::span absl::algorithm) +sfizz_link_libsndfile(bm_resample) +sfizz_link_libsamplerate(bm_resample) target_include_directories(bm_resample PRIVATE ../src/sfizz ../src/external) add_executable(bm_envelopes BM_envelopes.cpp ${BENCHMARK_SIMD_SOURCES}) -target_link_libraries(bm_envelopes benchmark absl::span absl::algorithm sndfile samplerate) +target_link_libraries(bm_envelopes PRIVATE benchmark absl::span absl::algorithm) target_include_directories(bm_envelopes PRIVATE ../src/sfizz ../src/external) +include(FetchContent) +FetchContent_Declare( + libnyquist + GIT_REPOSITORY https://github.com/paulfd/libnyquist +) + +FetchContent_GetProperties(libnyquist) +if(NOT libnyquist_POPULATED) + FetchContent_Populate(libnyquist) + add_subdirectory(${libnyquist_SOURCE_DIR} ${libnyquist_BINARY_DIR} EXCLUDE_FROM_ALL) +endif() + add_executable(bm_wavfile BM_wavfile.cpp ${BENCHMARK_SIMD_SOURCES}) -target_link_libraries(bm_wavfile benchmark absl::span absl::algorithm sndfile) +target_link_libraries(bm_wavfile PRIVATE benchmark absl::span absl::algorithm libnyquist) +sfizz_link_libsndfile(bm_wavfile) target_include_directories(bm_wavfile PRIVATE ../src/sfizz ../src/external) add_executable(bm_flacfile BM_flacfile.cpp ${BENCHMARK_SIMD_SOURCES}) -target_link_libraries(bm_flacfile benchmark absl::span absl::algorithm sndfile) +target_link_libraries(bm_flacfile PRIVATE benchmark absl::span absl::algorithm libnyquist) +sfizz_link_libsndfile(bm_flacfile) target_include_directories(bm_flacfile PRIVATE ../src/sfizz ../src/external) add_executable(bm_readChunk BM_readChunk.cpp ${BENCHMARK_SIMD_SOURCES}) -target_link_libraries(bm_readChunk benchmark absl::span absl::algorithm sndfile) +target_link_libraries(bm_readChunk PRIVATE benchmark absl::span absl::algorithm) +sfizz_link_libsndfile(bm_readChunk) target_include_directories(bm_readChunk PRIVATE ../src/sfizz ../src/external) add_executable(bm_resampleChunk BM_resampleChunk.cpp ${BENCHMARK_SIMD_SOURCES}) -target_link_libraries(bm_resampleChunk benchmark absl::span absl::algorithm sndfile) +target_link_libraries(bm_resampleChunk PRIVATE benchmark absl::span absl::algorithm) +sfizz_link_libsndfile(bm_resampleChunk) target_include_directories(bm_resampleChunk PRIVATE ../src/sfizz ../src/external) add_custom_target(sfizz_benchmarks) @@ -166,5 +184,7 @@ add_dependencies(sfizz_benchmarks file(COPY "sample1.wav" DESTINATION ${CMAKE_BINARY_DIR}/benchmarks) file(COPY "sample2.wav" DESTINATION ${CMAKE_BINARY_DIR}/benchmarks) +file(COPY "sample3.wav" DESTINATION ${CMAKE_BINARY_DIR}/benchmarks) file(COPY "sample1.flac" DESTINATION ${CMAKE_BINARY_DIR}/benchmarks) file(COPY "sample2.flac" DESTINATION ${CMAKE_BINARY_DIR}/benchmarks) +file(COPY "sample3.flac" DESTINATION ${CMAKE_BINARY_DIR}/benchmarks) diff --git a/benchmarks/sample3.flac b/benchmarks/sample3.flac new file mode 100755 index 00000000..3b84350a Binary files /dev/null and b/benchmarks/sample3.flac differ diff --git a/benchmarks/sample3.wav b/benchmarks/sample3.wav new file mode 100755 index 00000000..2acb8351 Binary files /dev/null and b/benchmarks/sample3.wav differ diff --git a/cmake/SfizzConfig.cmake b/cmake/SfizzConfig.cmake index 90450eb1..8fa9a40c 100644 --- a/cmake/SfizzConfig.cmake +++ b/cmake/SfizzConfig.cmake @@ -16,8 +16,34 @@ if (UNIX) add_compile_options(-ffast-math) add_compile_options(-fno-omit-frame-pointer) # For debugging purposes add_compile_options(-fPIC) + endif() + +if (WIN32) + find_package(LibSndFile REQUIRED) + find_path(SNDFILE_INCLUDE_DIR sndfile.hh) + find_path(SAMPLERATE_INCLUDE_DIR samplerate.h) + set(CMAKE_CXX_STANDARD 17) + add_compile_options(/Zc:__cplusplus) endif() +function(SFIZZ_LINK_LIBSNDFILE TARGET) + if (WIN32) + target_link_libraries (${TARGET} PRIVATE sndfile-shared) + target_include_directories(${TARGET} PRIVATE ${SNDFILE_INCLUDE_DIR}) + else() + target_link_libraries(${TARGET} PRIVATE sndfile) + endif() +endfunction(SFIZZ_LINK_LIBSNDFILE) + +function(SFIZZ_LINK_LIBSAMPLERATE TARGET) + if (WIN32) + target_link_libraries (${TARGET} PRIVATE samplerate) + target_include_directories(${TARGET} PRIVATE ${SAMPLERATE_INCLUDE_DIR}) + else() + target_link_libraries(${TARGET} PRIVATE samplerate) + endif() +endfunction(SFIZZ_LINK_LIBSAMPLERATE) + # If we build with Clang use libc++ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT ANDROID) set(USE_LIBCPP ON CACHE BOOL "Use libc++ with clang") diff --git a/lv2/sfizz.c b/lv2/sfizz.c index 8d3b40d7..eb01217f 100644 --- a/lv2/sfizz.c +++ b/lv2/sfizz.c @@ -45,8 +45,6 @@ #include #include #include -#include -#include #define DEFAULT_SFZ_FILE "/home/paul/Documents/AVL_Percussions/AVL_Drumkits_Percussion-1.0-Alt.sfz" #define SFIZZ_URI "http://sfztools.github.io/sfizz" @@ -414,7 +412,7 @@ sfizz_lv2_send_file_path(sfizz_plugin_t *self) lv2_atom_forge_key(&self->forge, self->patch_property_uri); lv2_atom_forge_urid(&self->forge, self->sfizz_sfz_file_uri); lv2_atom_forge_key(&self->forge, self->patch_value_uri); - lv2_atom_forge_path(&self->forge, self->sfz_file_path, strlen(self->sfz_file_path)); + lv2_atom_forge_path(&self->forge, self->sfz_file_path, (uint32_t)strlen(self->sfz_file_path)); lv2_atom_forge_pop(&self->forge, &frame); } @@ -463,7 +461,7 @@ sfizz_lv2_handle_atom_object(sfizz_plugin_t *self, const LV2_Atom_Object *obj) const uint32_t original_atom_size = lv2_atom_total_size((const LV2_Atom *)atom); const uint32_t null_terminated_atom_size = original_atom_size + 1; - char atom_buffer[null_terminated_atom_size]; + char atom_buffer[MAX_PATH_SIZE]; memcpy(&atom_buffer, atom, original_atom_size); atom_buffer[original_atom_size] = 0; // Null terminate the string for safety LV2_Atom *sfz_file_path = (LV2_Atom *)&atom_buffer; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 34629d90..6fd32a59 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -26,7 +26,8 @@ target_include_directories (sfizz PUBLIC external) target_link_libraries (sfizz PRIVATE sfizz_parser) find_package (Threads REQUIRED) target_link_libraries (sfizz PUBLIC absl::strings) -target_link_libraries (sfizz PRIVATE sndfile absl::flat_hash_map Threads::Threads) +target_link_libraries (sfizz PRIVATE absl::flat_hash_map Threads::Threads) +sfizz_link_libsndfile(sfizz) if (UNIX AND NOT APPLE) target_link_libraries (sfizz PUBLIC atomic) diff --git a/src/external/atomic_queue/defs.h b/src/external/atomic_queue/defs.h index 7f7d3ada..0207032c 100644 --- a/src/external/atomic_queue/defs.h +++ b/src/external/atomic_queue/defs.h @@ -6,7 +6,7 @@ #include -#if defined(__x86_64__) +#if defined(__x86_64__) || defined(_M_X64) #include namespace atomic_queue { constexpr int CACHE_LINE_SIZE = 64; @@ -30,8 +30,13 @@ static inline void spin_loop_pause() noexcept { namespace atomic_queue { +#if defined(__GNUC__) #define ATOMIC_QUEUE_LIKELY(expr) __builtin_expect(static_cast(expr), 1) #define ATOMIC_QUEUE_UNLIKELY(expr) __builtin_expect(static_cast(expr), 0) +#else +#define ATOMIC_QUEUE_LIKELY(expr) expr +#define ATOMIC_QUEUE_UNLIKELY(expr) expr +#endif //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 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/AudioBuffer.h b/src/sfizz/AudioBuffer.h index d65e2a2d..729e4c70 100644 --- a/src/sfizz/AudioBuffer.h +++ b/src/sfizz/AudioBuffer.h @@ -42,7 +42,7 @@ namespace sfz * @tparam MaxChannels the maximum number of channels in the buffer * @tparam Alignment the alignment for the buffers */ -template +template class AudioBuffer { public: using value_type = std::remove_cv_t; @@ -50,7 +50,6 @@ public: using const_pointer = const value_type*; using iterator = pointer; using const_iterator = const_pointer; - using size_type = size_t; /** * @brief Construct a new Audio Buffer object @@ -67,11 +66,11 @@ public: * @param numChannels * @param numFrames */ - AudioBuffer(int numChannels, int numFrames) + AudioBuffer(size_t numChannels, size_t numFrames) : numChannels(numChannels) , numFrames(numFrames) { - for (auto i = 0; i < numChannels; ++i) + for (size_t i = 0; i < numChannels; ++i) buffers[i] = std::make_unique(numFrames); } @@ -82,11 +81,11 @@ public: * @return true if the resize worked * @return false otherwise */ - bool resize(size_type newSize) + bool resize(size_t newSize) { bool returnedOK = true; - for (auto i = 0; i < numChannels; ++i) + for (size_t i = 0; i < numChannels; ++i) returnedOK &= buffers[i]->resize(newSize); if (returnedOK) @@ -101,7 +100,7 @@ public: * @param channelIndex * @return iterator */ - iterator channelWriter(int channelIndex) + iterator channelWriter(size_t channelIndex) { ASSERT(channelIndex < numChannels) if (channelIndex < numChannels) @@ -116,7 +115,7 @@ public: * @param channelIndex * @return iterator */ - iterator channelWriterEnd(int channelIndex) + iterator channelWriterEnd(size_t channelIndex) { ASSERT(channelIndex < numChannels) if (channelIndex < numChannels) @@ -131,7 +130,7 @@ public: * @param channelIndex * @return const_iterator */ - const_iterator channelReader(int channelIndex) const + const_iterator channelReader(size_t channelIndex) const { ASSERT(channelIndex < numChannels) if (channelIndex < numChannels) @@ -146,7 +145,7 @@ public: * @param channelIndex * @return const_iterator */ - const_iterator channelReaderEnd(int channelIndex) const + const_iterator channelReaderEnd(size_t channelIndex) const { ASSERT(channelIndex < numChannels) if (channelIndex < numChannels) @@ -161,7 +160,7 @@ public: * @param channelIndex * @return absl::Span */ - absl::Span getSpan(int channelIndex) const + absl::Span getSpan(size_t channelIndex) const { ASSERT(channelIndex < numChannels) if (channelIndex < numChannels) @@ -176,7 +175,7 @@ public: * @param channelIndex * @return absl::Span */ - absl::Span getConstSpan(int channelIndex) const + absl::Span getConstSpan(size_t channelIndex) const { return getSpan(channelIndex); } @@ -194,9 +193,9 @@ public: /** * @brief Get the number of elements in each buffer * - * @return size_type + * @return size_t */ - size_type getNumFrames() const + size_t getNumFrames() const { return numFrames; } @@ -206,7 +205,7 @@ public: * * @return int */ - int getNumChannels() const + size_t getNumChannels() const { return numChannels; } @@ -231,7 +230,7 @@ public: * @param frameIndex * @return Type& */ - Type& getSample(int channelIndex, size_type frameIndex) + Type& getSample(size_t channelIndex, size_t frameIndex) { // Uhoh ASSERT(buffers[channelIndex] != nullptr); @@ -247,7 +246,7 @@ public: * @param frameIndex * @return Type& */ - Type& operator()(int channelIndex, size_type frameIndex) + Type& operator()(size_t channelIndex, size_t frameIndex) { return getSample(channelIndex, frameIndex); } @@ -258,7 +257,7 @@ public: */ void reset() { - for (int i = 0; i < numChannels; ++i) + for (size_t i = 0; i < numChannels; ++i) buffers[i].reset(); numFrames = 0; numChannels = 0; @@ -269,10 +268,10 @@ public: * * @param numChannels */ - void addChannels(int numChannels) + void addChannels(size_t numChannels) { ASSERT(this->numChannels + numChannels <= MaxChannels); - for (int i = 0; i < numChannels; ++i) + for (size_t i = 0; i < numChannels; ++i) addChannel(); } @@ -281,7 +280,7 @@ private: using buffer_ptr = std::unique_ptr; static_assert(MaxChannels > 0, "Need a positive number of channels"); std::array buffers; - int numChannels { 0 }; - size_type numFrames { 0 }; + size_t numChannels { 0 }; + size_t numFrames { 0 }; }; } diff --git a/src/sfizz/AudioSpan.h b/src/sfizz/AudioSpan.h index 0ccfd5e9..2e21e3f7 100644 --- a/src/sfizz/AudioSpan.h +++ b/src/sfizz/AudioSpan.h @@ -86,7 +86,7 @@ namespace sfz * @tparam Type the underlying buffer type * @tparam MaxChannels the maximum number of channels. Defaults to sfz::config::numChannels */ -template +template class AudioSpan { public: using size_type = size_t; @@ -102,12 +102,12 @@ public: * @param offset starting offset for the AudioSpan * @param numFrames size of the AudioSpan */ - AudioSpan(const std::array& spans, int numChannels, size_type offset, size_type numFrames) + AudioSpan(const std::array& spans, size_type numChannels, size_type offset, size_type numFrames) : numFrames(numFrames) , numChannels(numChannels) { ASSERT(numChannels <= MaxChannels); - for (auto i = 0; i < numChannels; ++i) + for (size_t i = 0; i < numChannels; ++i) this->spans[i] = spans[i] + offset; } @@ -164,12 +164,12 @@ public: * @tparam Alignment the alignment block size for the platform * @param audioBuffer the source AudioBuffer. */ - template , typename = std::enable_if_t::value, int>> + template , typename = std::enable_if_t::value, int>> AudioSpan(AudioBuffer& audioBuffer) : numFrames(audioBuffer.getNumFrames()) , numChannels(audioBuffer.getNumChannels()) { - for (int i = 0; i < numChannels; i++) { + for (size_t i = 0; i < numChannels; i++) { this->spans[i] = audioBuffer.channelReader(i); } } @@ -185,12 +185,12 @@ public: * @tparam Alignment the alignment block size for the platform * @param audioBuffer the source AudioBuffer. */ - template > + template > AudioSpan(AudioBuffer& audioBuffer) : numFrames(audioBuffer.getNumFrames()) , numChannels(audioBuffer.getNumChannels()) { - for (int i = 0; i < numChannels; i++) { + for (size_t i = 0; i < numChannels; i++) { this->spans[i] = audioBuffer.channelWriter(i); } } @@ -200,12 +200,12 @@ public: * * @param other the other AudioSpan */ - template > + template > AudioSpan(const AudioSpan& other) : numFrames(other.getNumFrames()) , numChannels(other.getNumChannels()) { - for (int i = 0; i < numChannels; i++) { + for (size_t i = 0; i < numChannels; i++) { this->spans[i] = other.getChannel(i); } } @@ -216,7 +216,7 @@ public: * @param channelIndex the channel * @return Type* the raw pointer to the channel */ - Type* getChannel(int channelIndex) + Type* getChannel(size_t channelIndex) { ASSERT(channelIndex < numChannels); if (channelIndex < numChannels) @@ -231,7 +231,7 @@ public: * @param channelIndex the channel * @return absl::Span */ - absl::Span getSpan(int channelIndex) + absl::Span getSpan(size_t channelIndex) { ASSERT(channelIndex < numChannels); if (channelIndex < numChannels) @@ -246,7 +246,7 @@ public: * @param channelIndex the channel * @return absl::Span */ - absl::Span getConstSpan(int channelIndex) + absl::Span getConstSpan(size_t channelIndex) { ASSERT(channelIndex < numChannels); if (channelIndex < numChannels) @@ -265,7 +265,7 @@ public: if (numChannels == 0) return 0.0; Type result = 0.0; - for (int i = 0; i < numChannels; ++i) + for (size_t i = 0; i < numChannels; ++i) result += sfz::meanSquared(getConstSpan(i)); return result / numChannels; } @@ -278,7 +278,7 @@ public: void fill(Type value) noexcept { static_assert(!std::is_const::value, "Can't allow mutating operations on const AudioSpans"); - for (int i = 0; i < numChannels; ++i) + for (size_t i = 0; i < numChannels; ++i) sfz::fill(getSpan(i), value); } @@ -290,7 +290,7 @@ public: void applyGain(absl::Span gain) noexcept { static_assert(!std::is_const::value, "Can't allow mutating operations on const AudioSpans"); - for (int i = 0; i < numChannels; ++i) + for (size_t i = 0; i < numChannels; ++i) sfz::applyGain(gain, getSpan(i)); } @@ -302,7 +302,7 @@ public: void applyGain(Type gain) noexcept { static_assert(!std::is_const::value, "Can't allow mutating operations on const AudioSpans"); - for (int i = 0; i < numChannels; ++i) + for (size_t i = 0; i < numChannels; ++i) sfz::applyGain(gain, getSpan(i)); } @@ -312,13 +312,13 @@ public: * * @param other the other AudioSpan */ - template > + template > void add(AudioSpan& other) { static_assert(!std::is_const::value, "Can't allow mutating operations on const AudioSpans"); ASSERT(other.getNumChannels() == numChannels); if (other.getNumChannels() == numChannels) { - for (int i = 0; i < numChannels; ++i) + for (size_t i = 0; i < numChannels; ++i) sfz::add(other.getConstSpan(i), getSpan(i)); } } @@ -329,13 +329,13 @@ public: * * @param other the other AudioSpan */ - template > + template > void copy(AudioSpan& other) { static_assert(!std::is_const::value, "Can't allow mutating operations on const AudioSpans"); ASSERT(other.getNumChannels() == numChannels); if (other.getNumChannels() == numChannels) { - for (int i = 0; i < numChannels; ++i) + for (size_t i = 0; i < numChannels; ++i) sfz::copy(other.getConstSpan(i), getSpan(i)); } } @@ -355,7 +355,7 @@ public: * * @returns size_type the number of channels in the AudioSpan */ - int getNumChannels() + size_t getNumChannels() { return numChannels; } @@ -413,6 +413,6 @@ private: static_assert(MaxChannels > 0, "Need a positive number of channels"); std::array spans; size_type numFrames { 0 }; - int numChannels { 0 }; + size_type numChannels { 0 }; }; } diff --git a/src/sfizz/Buffer.h b/src/sfizz/Buffer.h index 6a899da2..efad39c9 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); @@ -235,7 +250,7 @@ public: // return *this; // } - Type& operator[](int idx) { return *(normalData + idx); } + Type& operator[](size_t idx) { return *(normalData + idx); } constexpr pointer data() const noexcept { return normalData; } constexpr size_type size() const noexcept { return alignedSize; } constexpr bool empty() const noexcept { return alignedSize == 0; } diff --git a/src/sfizz/Config.h b/src/sfizz/Config.h index 5f949be8..8f69a244 100644 --- a/src/sfizz/Config.h +++ b/src/sfizz/Config.h @@ -22,6 +22,12 @@ // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #pragma once +#ifdef _WIN32 +// There's a spurious min/max function in MSVC that makes everything go badly... +#define NOMINMAX +#define _SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING +#endif +#include namespace sfz { enum class Oversampling: int { @@ -36,7 +42,7 @@ namespace config { constexpr int defaultSamplesPerBlock { 1024 }; constexpr int maxBlockSize { 8192 }; constexpr int preloadSize { 8192 }; - constexpr int numChannels { 2 }; + constexpr size_t numChannels { 2 }; constexpr int numBackgroundThreads { 4 }; constexpr int numVoices { 64 }; constexpr int maxVoices { 256 }; @@ -50,12 +56,12 @@ namespace config { constexpr int halfCCThreshold { 64 }; constexpr int centPerSemitone { 100 }; constexpr float virtuallyZero { 0.00005f }; - constexpr float fastReleaseDuration { 0.01 }; + constexpr float fastReleaseDuration { 0.01f }; constexpr char defineCharacter { '$' }; constexpr Oversampling defaultOversamplingFactor { Oversampling::x1 }; constexpr float A440 { 440.0 }; - constexpr unsigned powerHistoryLength { 16 }; - constexpr float voiceStealingThreshold { 0.00001 }; + constexpr size_t powerHistoryLength { 16 }; + constexpr float voiceStealingThreshold { 0.00001f }; constexpr int numCCs { 143 }; constexpr int chunkSize { 1024 }; } // namespace config 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/FilePool.cpp b/src/sfizz/FilePool.cpp index e0bd5a5a..d9a04abe 100644 --- a/src/sfizz/FilePool.cpp +++ b/src/sfizz/FilePool.cpp @@ -108,7 +108,7 @@ absl::optional sfz::FilePool::getFileInformation if (!fs::exists(file)) return {}; - SndfileHandle sndFile(file.c_str()); + SndfileHandle sndFile(file.string().c_str()); if (sndFile.channels() != 1 && sndFile.channels() != 2) { DBG("Missing logic for " << sndFile.channels() << " channels, discarding sample " << filename); return {}; @@ -135,12 +135,12 @@ bool sfz::FilePool::preloadFile(const std::string& filename, uint32_t maxOffset) if (!fs::exists(file)) return false; - SndfileHandle sndFile(file.c_str()); + SndfileHandle sndFile(file.string().c_str()); if (sndFile.channels() != 1 && sndFile.channels() != 2) return false; // FIXME: Large offsets will require large preloading; is this OK in practice? Apparently sforzando does the same - const uint32_t frames = sndFile.frames(); + const auto frames = static_cast(sndFile.frames()); const auto framesToLoad = [&]() { if (preloadSize == 0) return frames; @@ -196,9 +196,9 @@ void sfz::FilePool::setPreloadSize(uint32_t preloadSize) noexcept // Update all the preloaded sizes for (auto& preloadedFile : preloadedFiles) { const auto numFrames = preloadedFile.second.preloadedData->getNumFrames() / static_cast(oversamplingFactor); - const uint32_t maxOffset = numFrames > this->preloadSize ? numFrames - this->preloadSize : 0; + const auto maxOffset = numFrames > this->preloadSize ? static_cast(numFrames) - this->preloadSize : 0; fs::path file { rootDirectory / std::string(preloadedFile.first) }; - SndfileHandle sndFile(file.c_str()); + SndfileHandle sndFile(file.string().c_str()); preloadedFile.second.preloadedData = readFromFile(sndFile, preloadSize + maxOffset, oversamplingFactor); } this->preloadSize = preloadSize; @@ -248,12 +248,12 @@ void sfz::FilePool::loadingThread() noexcept [[maybe_unused]] const auto waitDurationMillis = std::chrono::duration(waitDuration).count(); fs::path file { rootDirectory / std::string(promise->filename) }; - SndfileHandle sndFile(file.c_str()); + SndfileHandle sndFile(file.string().c_str()); if (sndFile.error() != 0) { DBG("[sfizz] libsndfile errored for " << promise->filename << " with message " << sndFile.strError()); continue; } - const uint32_t frames = sndFile.frames(); + const auto frames = static_cast(sndFile.frames()); streamFromFile(sndFile, frames, oversamplingFactor, promise->fileData, &promise->availableFrames); promise->dataReady = true; threadsLoading--; @@ -289,17 +289,17 @@ void sfz::FilePool::cleanupPromises() noexcept // The garbage collection cleared the data from these so we can move them // back to the empty queue auto clearedIterator = promisesToClear.begin(); - auto clearedSentinel = promisesToClear.end() - 1; - while (clearedIterator != promisesToClear.end()) { + auto clearedSentinel = promisesToClear.rbegin(); + while (clearedIterator < clearedSentinel.base()) { if (clearedIterator->get()->dataReady == false) { emptyPromises.push_back(*clearedIterator); std::iter_swap(clearedIterator, clearedSentinel); - clearedSentinel--; - promisesToClear.pop_back(); + ++clearedSentinel; } else { - clearedIterator++; + ++clearedIterator; } } + promisesToClear.resize(std::distance(promisesToClear.begin(), clearedSentinel.base())); FilePromisePtr promise; // Remove the promises from the filled queue and put them in a linear @@ -308,17 +308,17 @@ void sfz::FilePool::cleanupPromises() noexcept temporaryFilePromises.push_back(promise); auto filledIterator = temporaryFilePromises.begin(); - auto filledSentinel = temporaryFilePromises.end() - 1; - while (filledIterator != temporaryFilePromises.end()) { + auto filledSentinel = temporaryFilePromises.rbegin(); + while (filledIterator < filledSentinel.base()) { if (filledIterator->use_count() == 1) { promisesToClear.push_back(*filledIterator); std::iter_swap(filledIterator, filledSentinel); - filledSentinel--; - temporaryFilePromises.pop_back(); + ++filledSentinel; } else { - filledIterator++; + ++filledIterator; } } + temporaryFilePromises.resize(std::distance(temporaryFilePromises.begin(), filledSentinel.base())); } void sfz::FilePool::setOversamplingFactor(sfz::Oversampling factor) noexcept @@ -326,9 +326,9 @@ void sfz::FilePool::setOversamplingFactor(sfz::Oversampling factor) noexcept float samplerateChange { static_cast(factor) / static_cast(this->oversamplingFactor) }; for (auto& preloadedFile : preloadedFiles) { const auto numFrames = preloadedFile.second.preloadedData->getNumFrames() / static_cast(this->oversamplingFactor); - const uint32_t maxOffset = numFrames > this->preloadSize ? numFrames - this->preloadSize : 0; + const uint32_t maxOffset = numFrames > this->preloadSize ? static_cast(numFrames) - this->preloadSize : 0; fs::path file { rootDirectory / std::string(preloadedFile.first) }; - SndfileHandle sndFile(file.c_str()); + SndfileHandle sndFile(file.string().c_str()); preloadedFile.second.preloadedData = readFromFile(sndFile, preloadSize + maxOffset, factor); preloadedFile.second.sampleRate *= samplerateChange; } diff --git a/src/sfizz/HistoricalBuffer.h b/src/sfizz/HistoricalBuffer.h index f717250d..09d68a1a 100644 --- a/src/sfizz/HistoricalBuffer.h +++ b/src/sfizz/HistoricalBuffer.h @@ -26,7 +26,7 @@ public: * * @param size */ - void resize(int size) + void resize(size_t size) { buffer.resize(size); fill(absl::MakeSpan(buffer), 0.0); 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/OnePoleFilter.h b/src/sfizz/OnePoleFilter.h index 9c3afd0f..6c1e3f0f 100644 --- a/src/sfizz/OnePoleFilter.h +++ b/src/sfizz/OnePoleFilter.h @@ -59,7 +59,7 @@ public: Type getGain() const { return gain; } - int processLowpass(absl::Span input, absl::Span lowpass) + size_t processLowpass(absl::Span input, absl::Span lowpass) { auto in = input.begin(); auto out = lowpass.begin(); @@ -73,7 +73,7 @@ public: return size; } - int processHighpass(absl::Span input, absl::Span highpass) + size_t processHighpass(absl::Span input, absl::Span highpass) { auto in = input.begin(); auto out = highpass.begin(); @@ -87,7 +87,7 @@ public: return size; } - int processLowpassVariableGain(absl::Span input, absl::Span lowpass, absl::Span gain) + size_t processLowpassVariableGain(absl::Span input, absl::Span lowpass, absl::Span gain) { auto in = input.begin(); auto out = lowpass.begin(); @@ -104,7 +104,7 @@ public: return size; } - int processHighpassVariableGain(absl::Span input, absl::Span highpass, absl::Span gain) + size_t processHighpassVariableGain(absl::Span input, absl::Span highpass, absl::Span gain) { auto in = input.begin(); auto out = highpass.begin(); diff --git a/src/sfizz/Oversampler.cpp b/src/sfizz/Oversampler.cpp index 4123e8fd..6cf1597c 100644 --- a/src/sfizz/Oversampler.cpp +++ b/src/sfizz/Oversampler.cpp @@ -104,7 +104,7 @@ void sfz::Oversampler::stream(const sfz::AudioBuffer& input, sfz::AudioBu upsampler.set_coefs(coeffsStage2x.data()); break; case Oversampling::x1: - for (int i = 0; i < numChannels; ++i) + for (size_t i = 0; i < numChannels; ++i) copy(input.getConstSpan(i), output.getSpan(i)); return; } @@ -122,22 +122,22 @@ void sfz::Oversampler::stream(const sfz::AudioBuffer& input, sfz::AudioBu // std::cout << "Input frames: " << inputFrameCounter << "/" << numFrames << '\n'; const auto thisChunkSize = std::min(chunkSize, numFrames - inputFrameCounter); const auto outputChunkSize { thisChunkSize * static_cast(factor) }; - for (int chanIdx = 0; chanIdx < numChannels; chanIdx++) { + for (size_t chanIdx = 0; chanIdx < numChannels; chanIdx++) { const auto inputChunk = input.getSpan(chanIdx).subspan(inputFrameCounter, thisChunkSize); const auto outputChunk = output.getSpan(chanIdx).subspan(outputFrameCounter, outputChunkSize); if (factor == Oversampling::x2) { - upsampler2x[chanIdx].process_block(outputChunk.data(), inputChunk.data(), thisChunkSize); + upsampler2x[chanIdx].process_block(outputChunk.data(), inputChunk.data(), static_cast(thisChunkSize)); continue; } if (factor == Oversampling::x4) { - upsampler2x[chanIdx].process_block(span1.data(), inputChunk.data(), thisChunkSize); - upsampler4x[chanIdx].process_block(outputChunk.data(), span1.data(), thisChunkSize * 2); + upsampler2x[chanIdx].process_block(span1.data(), inputChunk.data(), static_cast(thisChunkSize)); + upsampler4x[chanIdx].process_block(outputChunk.data(), span1.data(), static_cast(thisChunkSize * 2)); continue; } else if (factor == Oversampling::x8) { - upsampler2x[chanIdx].process_block(span1.data(), inputChunk.data(), thisChunkSize); - upsampler4x[chanIdx].process_block(span2.data(), span1.data(), thisChunkSize * 2); - upsampler8x[chanIdx].process_block(outputChunk.data(), span2.data(), thisChunkSize * 4); + upsampler2x[chanIdx].process_block(span1.data(), inputChunk.data(), static_cast(thisChunkSize)); + upsampler4x[chanIdx].process_block(span2.data(), span1.data(), static_cast(thisChunkSize * 2)); + upsampler8x[chanIdx].process_block(outputChunk.data(), span2.data(), static_cast(thisChunkSize * 4)); continue; } } 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 diff --git a/src/sfizz/SfzHelpers.h b/src/sfizz/SfzHelpers.h index 295f5279..fd323fb2 100644 --- a/src/sfizz/SfzHelpers.h +++ b/src/sfizz/SfzHelpers.h @@ -98,9 +98,9 @@ constexpr float normalizePercents(T percentValue) * @param bendValue * @return constexpr float */ -constexpr float normalizeBend(int bendValue) +constexpr float normalizeBend(float bendValue) { - return std::min(std::max(static_cast(bendValue), -8191.0f), 8191.0f) / 8191.0f; + return std::min(std::max(bendValue, -8191.0f), 8191.0f) / 8191.0f; } /** @@ -145,10 +145,10 @@ absl::optional readNoteValue(const absl::string_view& value); * return them, while updating the source by removing this header * and members from the beginning. The function "consumes" the * header and its members from the source if found. - * + * * No check is made to see if the header is "valid" in the sfz sense. * The output parameters are set only if the method returns true. - * + * * @param source A source view; can be updated and shortened * @param header An output view on the header, without the <> * @param members An output view on the members, untrimmed @@ -161,44 +161,44 @@ bool findHeader(absl::string_view& source, absl::string_view& header, absl::stri * Return them while updating the source by removing this opcode * and value from the beginning. The function "consumes" the * opcode from the source if one is found. - * + * * No check is made to see if the opcode is "valid" in the sfz sense. * The output parameters are set only if the method returns true. - * + * * @param source A source view; can be updated and shortened * @param opcode An output view on the opcode name * @param value An output view on the opcode value * @return true if an opcode was found - * @return false + * @return false */ bool findOpcode(absl::string_view& source, absl::string_view& opcode, absl::string_view& value); /** * @brief Find an SFZ #define statement on a line and return the variable and value as views. - * + * * This function assums that there is a single define per line and that the variable and value * are separated by whitespace. * The output parameters are set only if the method returns true. - * + * * @param line The source line * @param variable An output view on the define variable * @param value An output view on the define value * @return true If a define was found - * @return false + * @return false */ bool findDefine(absl::string_view line, absl::string_view& variable, absl::string_view& value); /** * @brief Find an SFZ #include statement on a line and return included path. - * + * * This function assums that there is a single include per line and that the * include path is within quotes. * The output parameter is set only if the method returns true. - * + * * @param line The source line * @param path The path, if found * @return true If an include was found - * @return false + * @return false */ bool findInclude(absl::string_view line, std::string& path); diff --git a/src/sfizz/Synth.cpp b/src/sfizz/Synth.cpp index 511e94c7..4d888366 100644 --- a/src/sfizz/Synth.cpp +++ b/src/sfizz/Synth.cpp @@ -237,9 +237,9 @@ bool sfz::Synth::loadSfzFile(const fs::path& filename) resources.filePool.setRootDirectory(this->originalDirectory); - auto lastRegion = regions.end() - 1; auto currentRegion = regions.begin(); - while (currentRegion <= lastRegion) { + auto lastRegion = regions.rbegin(); + while (currentRegion < lastRegion.base()) { auto region = currentRegion->get(); if (!region->isGenerator()) { @@ -247,7 +247,7 @@ bool sfz::Synth::loadSfzFile(const fs::path& filename) if (!fileInformation) { DBG("Removing the region with sample " << region->sample); std::iter_swap(currentRegion, lastRegion); - lastRegion--; + ++lastRegion; continue; } region->sampleEnd = std::min(region->sampleEnd, fileInformation->end); @@ -298,11 +298,11 @@ bool sfz::Synth::loadSfzFile(const fs::path& filename) region->registerAftertouch(0); region->registerTempo(2.0f); - currentRegion++; + ++currentRegion; } - - DBG("Removed " << regions.size() - std::distance(regions.begin(), lastRegion) - 1 << " out of " << regions.size() << " regions."); - regions.resize(std::distance(regions.begin(), lastRegion) + 1); + const auto remainingRegions = std::distance(regions.begin(), lastRegion.base()); + DBG("Removing " << (regions.size() - remainingRegions) << " out of " << regions.size() << " regions"); + regions.resize(remainingRegions); modificationTime = checkModificationTime(); return parserReturned; diff --git a/src/sfizz/Voice.cpp b/src/sfizz/Voice.cpp index 24af701f..c1aba0f6 100644 --- a/src/sfizz/Voice.cpp +++ b/src/sfizz/Voice.cpp @@ -95,10 +95,10 @@ void sfz::Voice::startVoice(Region* region, int delay, int number, uint8_t value pitchBendEnvelope.setFunction([region](float pitchValue){ const auto normalizedBend = normalizeBend(pitchValue); - const auto bendInCents = normalizedBend > 0 ? normalizedBend * region->bendUp : -normalizedBend * region->bendDown; + const auto bendInCents = normalizedBend > 0.0f ? normalizedBend * region->bendUp : -normalizedBend * region->bendDown; return centsFactor(bendInCents); }); - pitchBendEnvelope.reset(midiState.getPitchBend()); + pitchBendEnvelope.reset(static_cast(midiState.getPitchBend())); sourcePosition = region->getOffset(); triggerDelay = delay; @@ -209,7 +209,7 @@ void sfz::Voice::registerPitchWheel(int delay, int pitch) noexcept if (state == State::idle) return; - pitchBendEnvelope.registerEvent(delay, pitch); + pitchBendEnvelope.registerEvent(delay, static_cast(pitch)); } void sfz::Voice::registerAftertouch(int delay [[maybe_unused]], uint8_t aftertouch [[maybe_unused]]) noexcept @@ -246,13 +246,13 @@ void sfz::Voice::renderBlock(AudioSpan buffer) noexcept buffer.fill(0.0f); if (state == State::idle || region == nullptr) { - powerHistory.push(0.0); + powerHistory.push(0.0f); return; } - auto delay = min(static_cast(initialDelay), buffer.getNumFrames()); + const auto delay = min(static_cast(initialDelay), buffer.getNumFrames()); auto delayed_buffer = buffer.subspan(delay); - initialDelay -= delay; + initialDelay -= static_cast(delay); if (region->isGenerator()) fillWithGenerator(delayed_buffer); diff --git a/src/sfizz/Voice.h b/src/sfizz/Voice.h index 9cd5e1ed..42b0b8df 100644 --- a/src/sfizz/Voice.h +++ b/src/sfizz/Voice.h @@ -22,8 +22,8 @@ // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #pragma once -#include "ADSREnvelope.h" #include "Config.h" +#include "ADSREnvelope.h" #include "EventEnvelopes.h" #include "HistoricalBuffer.h" #include "Region.h" diff --git a/src/sfizz/sfizz_wrapper.cpp b/src/sfizz/sfizz_wrapper.cpp index 74e04fc4..fb8d54ed 100644 --- a/src/sfizz/sfizz_wrapper.cpp +++ b/src/sfizz/sfizz_wrapper.cpp @@ -66,7 +66,7 @@ int sfizz_get_num_curves(sfizz_synth_t* synth) auto self = reinterpret_cast(synth); return self->getNumCurves(); } -int sfizz_get_num_preloaded_samples(sfizz_synth_t* synth) +size_t sfizz_get_num_preloaded_samples(sfizz_synth_t* synth) { auto self = reinterpret_cast(synth); return self->getNumPreloadedSamples(); @@ -220,7 +220,7 @@ char* sfizz_get_unknown_opcodes(sfizz_synth_t* synth) { auto self = reinterpret_cast(synth); const auto unknownOpcodes = self->getUnknownOpcodes(); - int totalLength = 0; + size_t totalLength = 0; for (auto& opcode: unknownOpcodes) totalLength += opcode.length() + 1; diff --git a/tests/ADSREnvelopeT.cpp b/tests/ADSREnvelopeT.cpp index 9afc5407..7f2cea9d 100644 --- a/tests/ADSREnvelopeT.cpp +++ b/tests/ADSREnvelopeT.cpp @@ -54,7 +54,7 @@ TEST_CASE("[ADSREnvelope] Basic state") out = envelope.getNextValue(); REQUIRE(approxEqual(output, expected)); - absl::c_fill(output, -1.0); + absl::c_fill(output, -1.0f); envelope.getBlock(absl::MakeSpan(output)); REQUIRE(approxEqual(output, expected)); } @@ -64,13 +64,13 @@ TEST_CASE("[ADSREnvelope] Attack") sfz::ADSREnvelope envelope; envelope.reset(2, 0); std::array output; - std::array expected { 0.5, 1.0, 1.0, 1.0, 1.0 }; + std::array expected { 0.5f, 1.0f, 1.0f, 1.0f, 1.0f }; for (auto& out : output) out = envelope.getNextValue(); REQUIRE(approxEqual(output, expected)); envelope.reset(2, 0); - absl::c_fill(output, -1.0); + absl::c_fill(output, -1.0f); envelope.getBlock(absl::MakeSpan(output)); REQUIRE(approxEqual(output, expected)); } @@ -80,13 +80,13 @@ TEST_CASE("[ADSREnvelope] Attack again") sfz::ADSREnvelope envelope; envelope.reset(3, 0); std::array output; - std::array expected { 0.33333, 0.66667, 1.0, 1.0, 1.0 }; + std::array expected { 0.33333f, 0.66667f, 1.0f, 1.0f, 1.0f }; for (auto& out : output) out = envelope.getNextValue(); REQUIRE(approxEqual(output, expected)); envelope.reset(3, 0); - absl::c_fill(output, -1.0); + absl::c_fill(output, -1.0f); envelope.getBlock(absl::MakeSpan(output)); REQUIRE(approxEqual(output, expected)); } @@ -97,14 +97,14 @@ TEST_CASE("[ADSREnvelope] Release") envelope.reset(2, 4); envelope.startRelease(2); std::array output; - std::array expected { 0.5, 1.0, 0.08409f, 0.00707f, 0.000594604f, 0.00005f, 0.0f, 0.0f }; + std::array expected { 0.5f, 1.0f, 0.08409f, 0.00707f, 0.000594604f, 0.00005f, 0.0f, 0.0f }; for (auto& out : output) out = envelope.getNextValue(); REQUIRE(approxEqual(output, expected)); envelope.reset(2, 4); envelope.startRelease(2); - absl::c_fill(output, -1.0); + absl::c_fill(output, -1.0f); envelope.getBlock(absl::MakeSpan(output)); REQUIRE(approxEqual(output, expected)); } @@ -115,14 +115,14 @@ TEST_CASE("[ADSREnvelope] Delay") envelope.reset(2, 4, 1.0f, 2); std::array output; envelope.startRelease(4); - std::array expected { 0.0, 0.0, 0.5, 1.0, 0.08409f, 0.00707f, 0.000594604f, 0.00005f, 0.0f, 0.0f }; + std::array expected { 0.0f, 0.0f, 0.5f, 1.0f, 0.08409f, 0.00707f, 0.000594604f, 0.00005f, 0.0f, 0.0f }; for (auto& out : output) out = envelope.getNextValue(); REQUIRE(approxEqual(output, expected)); envelope.reset(2, 4, 1.0f, 2); envelope.startRelease(4); - absl::c_fill(output, -1.0); + absl::c_fill(output, -1.0f); envelope.getBlock(absl::MakeSpan(output)); REQUIRE(approxEqual(output, expected)); } @@ -130,15 +130,15 @@ TEST_CASE("[ADSREnvelope] Delay") TEST_CASE("[ADSREnvelope] Lower sustain") { sfz::ADSREnvelope envelope; - envelope.reset(2, 4, 0.5, 2); + envelope.reset(2, 4, 0.5f, 2); std::array output; - std::array expected { 0.0, 0.0, 0.5, 1.0, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5 }; + std::array expected { 0.0f, 0.0f, 0.5f, 1.0f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f }; for (auto& out : output) out = envelope.getNextValue(); REQUIRE(approxEqual(output, expected)); envelope.reset(2, 4, 0.5, 2); - absl::c_fill(output, -1.0); + absl::c_fill(output, -1.0f); envelope.getBlock(absl::MakeSpan(output)); REQUIRE(approxEqual(output, expected)); } @@ -146,15 +146,15 @@ TEST_CASE("[ADSREnvelope] Lower sustain") TEST_CASE("[ADSREnvelope] Decay") { sfz::ADSREnvelope envelope; - envelope.reset(2, 4, 0.5, 2, 2); + envelope.reset(2, 4, 0.5f, 2, 2); std::array output; - std::array expected { 0.0, 0.0, 0.5, 1.0, 0.707107, 0.5, 0.5, 0.5, 0.5, 0.5 }; + std::array expected { 0.0f, 0.0f, 0.5f, 1.0f, 0.707107f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5 }; for (auto& out : output) out = envelope.getNextValue(); REQUIRE(approxEqual(output, expected)); - envelope.reset(2, 4, 0.5, 2, 2); - absl::c_fill(output, -1.0); + envelope.reset(2, 4, 0.5f, 2, 2); + absl::c_fill(output, -1.0f); envelope.getBlock(absl::MakeSpan(output)); REQUIRE(approxEqual(output, expected)); } @@ -162,15 +162,15 @@ TEST_CASE("[ADSREnvelope] Decay") TEST_CASE("[ADSREnvelope] Hold") { sfz::ADSREnvelope envelope; - envelope.reset(2, 4, 0.5, 2, 2, 2); + envelope.reset(2, 4, 0.5f, 2, 2, 2); std::array output; - std::array expected { 0.0, 0.0, 0.5, 1.0, 1.0, 1.0, 0.707107, 0.5, 0.5, 0.5, 0.5, 0.5 }; + std::array expected { 0.0f, 0.0f, 0.5f, 1.0f, 1.0f, 1.0f, 0.707107f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f }; for (auto& out : output) out = envelope.getNextValue(); REQUIRE(approxEqual(output, expected)); - envelope.reset(2, 4, 0.5, 2, 2, 2); - absl::c_fill(output, -1.0); + envelope.reset(2, 4, 0.5f, 2, 2, 2); + absl::c_fill(output, -1.0f); envelope.getBlock(absl::MakeSpan(output)); REQUIRE(approxEqual(output, expected)); } @@ -178,17 +178,17 @@ TEST_CASE("[ADSREnvelope] Hold") TEST_CASE("[ADSREnvelope] Hold with release") { sfz::ADSREnvelope envelope; - envelope.reset(2, 4, 0.5, 2, 2, 2); + envelope.reset(2, 4, 0.5f, 2, 2, 2); envelope.startRelease(8); std::array output; - std::array expected { 0.0, 0.0, 0.5, 1.0, 1.0, 1.0, 0.707107, 0.5, 0.05, 0.005, 0.0005, 0.00005, 0.0, 0.0 }; + std::array expected { 0.0f, 0.0f, 0.5f, 1.0f, 1.0f, 1.0f, 0.707107f, 0.5f, 0.05f, 0.005f, 0.0005f, 0.00005f, 0.0f, 0.0f }; for (auto& out : output) out = envelope.getNextValue(); REQUIRE(approxEqual(output, expected)); - envelope.reset(2, 4, 0.5, 2, 2, 2); + envelope.reset(2, 4, 0.5f, 2, 2, 2); envelope.startRelease(8); - absl::c_fill(output, -1.0); + absl::c_fill(output, -1.0f); envelope.getBlock(absl::MakeSpan(output)); REQUIRE(approxEqual(output, expected)); } @@ -196,16 +196,16 @@ TEST_CASE("[ADSREnvelope] Hold with release") TEST_CASE("[ADSREnvelope] Hold with release 2") { sfz::ADSREnvelope envelope; - envelope.reset(2, 4, 0.5, 2, 2, 2); + envelope.reset(2, 4, 0.5f, 2, 2, 2); envelope.startRelease(4); std::array output; - std::array expected { 0.0, 0.0, 0.5, 1.0, 0.08409, 0.00707, 0.000594604, 0.00005, 0.0, 0.0, 0.0, 0.0 }; + std::array expected { 0.0f, 0.0f, 0.5f, 1.0f, 0.08409f, 0.00707f, 0.000594604f, 0.00005f, 0.0f, 0.0f, 0.0f, 0.0 }; for (auto& out : output) out = envelope.getNextValue(); REQUIRE(approxEqual(output, expected)); - envelope.reset(2, 4, 0.5, 2, 2, 2); + envelope.reset(2, 4, 0.5f, 2, 2, 2); envelope.startRelease(4); - absl::c_fill(output, -1.0); + absl::c_fill(output, -1.0f); envelope.getBlock(absl::MakeSpan(output)); REQUIRE(approxEqual(output, expected)); -} \ No newline at end of file +} diff --git a/tests/AudioBufferT.cpp b/tests/AudioBufferT.cpp index a2f8f55b..ebd0b61d 100644 --- a/tests/AudioBufferT.cpp +++ b/tests/AudioBufferT.cpp @@ -61,15 +61,15 @@ TEST_CASE("[AudioBuffer] Access") const int size { 5 }; sfz::AudioBuffer buffer(2, size); for (size_t frameIdx = 0; frameIdx < buffer.getNumFrames(); ++frameIdx) { - buffer.getSample(0, frameIdx) = static_cast(buffer.getNumFrames()) + frameIdx; - buffer.getSample(1, frameIdx) = static_cast(buffer.getNumFrames()) - frameIdx; + buffer.getSample(0, frameIdx) = static_cast(buffer.getNumFrames()) + frameIdx; + buffer.getSample(1, frameIdx) = static_cast(buffer.getNumFrames()) - frameIdx; } for (size_t frameIdx = 0; frameIdx < buffer.getNumFrames(); ++frameIdx) { - REQUIRE(buffer.getSample(0, frameIdx) == static_cast(buffer.getNumFrames()) + frameIdx); - REQUIRE(buffer(0, frameIdx) == static_cast(buffer.getNumFrames()) + frameIdx); - REQUIRE(buffer.getSample(1, frameIdx) == static_cast(buffer.getNumFrames()) - frameIdx); - REQUIRE(buffer(1, frameIdx) == static_cast(buffer.getNumFrames()) - frameIdx); + REQUIRE(buffer.getSample(0, frameIdx) == static_cast(buffer.getNumFrames()) + frameIdx); + REQUIRE(buffer(0, frameIdx) == static_cast(buffer.getNumFrames()) + frameIdx); + REQUIRE(buffer.getSample(1, frameIdx) == static_cast(buffer.getNumFrames()) - frameIdx); + REQUIRE(buffer(1, frameIdx) == static_cast(buffer.getNumFrames()) - frameIdx); } } @@ -98,5 +98,5 @@ TEST_CASE("[AudioSpan] Constructions") sfz::AudioSpan manualSpan { { buffer.channelWriter(0), buffer.channelWriter(1) }, buffer.getNumFrames() }; sfz::AudioSpan manualConstSpan { { buffer.channelReader(0), buffer.channelReader(1) }, buffer.getNumFrames() }; sfz::AudioSpan manualSpan2 { {buffer.getSpan(0), buffer.getSpan(1) } }; - sfz::AudioSpan manualConstSpan2 { {buffer.getConstSpan(0), buffer.getConstSpan(1) } }; -} \ No newline at end of file + sfz::AudioSpan manualConstSpan2 { { buffer.getConstSpan(0), buffer.getConstSpan(1) } }; +} diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 12c8b23d..d3e1511b 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -28,17 +28,14 @@ set(SFIZZ_TEST_SOURCES find_package(ZLIB REQUIRED) add_library(cnpy cnpy/cnpy.cpp) -target_link_libraries(cnpy PRIVATE ZLIB::ZLIB) +target_link_libraries(cnpy PUBLIC ZLIB::ZLIB) target_include_directories(cnpy PUBLIC cnpy) add_executable(sfizz_tests ${SFIZZ_TEST_SOURCES}) target_link_libraries(sfizz_tests PRIVATE sfizz::sfizz) +sfizz_link_libsndfile(sfizz_tests) -# Per OS properties -if(UNIX) - target_link_libraries(sfizz_tests PRIVATE atomic) -endif(UNIX) -target_link_libraries(sfizz_tests PRIVATE absl::strings absl::str_format absl::flat_hash_map sndfile cnpy absl::span absl::algorithm) +target_link_libraries(sfizz_tests PRIVATE absl::strings absl::str_format absl::flat_hash_map cnpy absl::span absl::algorithm) target_include_directories(sfizz_tests SYSTEM PRIVATE sources) sfizz_enable_lto_if_needed(sfizz_tests) diff --git a/tests/EGDescriptionT.cpp b/tests/EGDescriptionT.cpp index aaaf48b7..aaceb179 100644 --- a/tests/EGDescriptionT.cpp +++ b/tests/EGDescriptionT.cpp @@ -31,7 +31,7 @@ TEST_CASE("[EGDescription] Attack range") sfz::EGDescription eg; sfz::SfzCCArray ccArray { 0 }; eg.attack = 1; - eg.vel2attack = -1.27; + eg.vel2attack = -1.27f; eg.ccAttack = { 63, 1.27f }; REQUIRE( eg.getAttack(ccArray, 0) == 1.0f ); REQUIRE( eg.getAttack(ccArray, 127) == 0.0f ); @@ -47,7 +47,7 @@ TEST_CASE("[EGDescription] Delay range") sfz::EGDescription eg; sfz::SfzCCArray ccArray { 0 }; eg.delay = 1; - eg.vel2delay = -1.27; + eg.vel2delay = -1.27f; eg.ccDelay = { 63, 1.27f }; REQUIRE( eg.getDelay(ccArray, 0) == 1.0f ); REQUIRE( eg.getDelay(ccArray, 127) == 0.0f ); @@ -79,7 +79,7 @@ TEST_CASE("[EGDescription] Release range") sfz::EGDescription eg; sfz::SfzCCArray ccArray { 0 }; eg.release = 1; - eg.vel2release = -1.27; + eg.vel2release = -1.27f; eg.ccRelease = { 63, 1.27f }; REQUIRE( eg.getRelease(ccArray, 0) == 1.0f ); REQUIRE( eg.getRelease(ccArray, 127) == 0.0f ); @@ -95,7 +95,7 @@ TEST_CASE("[EGDescription] Hold range") sfz::EGDescription eg; sfz::SfzCCArray ccArray { 0 }; eg.hold = 1; - eg.vel2hold = -1.27; + eg.vel2hold = -1.27f; eg.ccHold = { 63, 1.27f }; REQUIRE( eg.getHold(ccArray, 0) == 1.0f ); REQUIRE( eg.getHold(ccArray, 127) == 0.0f ); diff --git a/tests/EventEnvelopesT.cpp b/tests/EventEnvelopesT.cpp index 10fc2c0d..6c968f5c 100644 --- a/tests/EventEnvelopesT.cpp +++ b/tests/EventEnvelopesT.cpp @@ -51,7 +51,7 @@ TEST_CASE("[LinearEnvelope] Basic state") { sfz::LinearEnvelope envelope; std::array output; - std::array expected { 0.0, 0.0, 0.0, 0.0, 0.0 }; + std::array expected { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }; envelope.getBlock(absl::MakeSpan(output)); REQUIRE(output == expected); } @@ -59,9 +59,9 @@ TEST_CASE("[LinearEnvelope] Basic state") TEST_CASE("[LinearEnvelope] Basic event") { sfz::LinearEnvelope envelope; - envelope.registerEvent(4, 1.0); + envelope.registerEvent(4, 1.0f); std::array output; - std::array expected { 0.25, 0.5, 0.75, 1.0, 1.0, 1.0, 1.0, 1.0 }; + std::array expected { 0.25f, 0.5f, 0.75f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f }; envelope.getBlock(absl::MakeSpan(output)); REQUIRE(output == expected); } @@ -69,10 +69,10 @@ TEST_CASE("[LinearEnvelope] Basic event") TEST_CASE("[LinearEnvelope] 2 events, close") { sfz::LinearEnvelope envelope; - envelope.registerEvent(4, 1.0); - envelope.registerEvent(5, 2.0); + envelope.registerEvent(4, 1.0f); + envelope.registerEvent(5, 2.0f); std::array output; - std::array expected { 0.25, 0.5, 0.75, 1.0, 2.0, 2.0, 2.0, 2.0 }; + std::array expected { 0.25f, 0.5f, 0.75f, 1.0f, 2.0f, 2.0f, 2.0f, 2.0f }; envelope.getBlock(absl::MakeSpan(output)); REQUIRE(output == expected); } @@ -80,10 +80,10 @@ TEST_CASE("[LinearEnvelope] 2 events, close") TEST_CASE("[LinearEnvelope] 2 events, far") { sfz::LinearEnvelope envelope; - envelope.registerEvent(2, 1.0); - envelope.registerEvent(6, 2.0); + envelope.registerEvent(2, 1.0f); + envelope.registerEvent(6, 2.0f); std::array output; - std::array expected { 0.5, 1, 1.25, 1.5, 1.75, 2.0, 2.0, 2.0 }; + std::array expected { 0.5f, 1.0f, 1.25f, 1.5f, 1.75f, 2.0f, 2.0f, 2.0f }; envelope.getBlock(absl::MakeSpan(output)); REQUIRE(output == expected); } @@ -91,10 +91,10 @@ TEST_CASE("[LinearEnvelope] 2 events, far") TEST_CASE("[LinearEnvelope] 2 events, reversed") { sfz::LinearEnvelope envelope; - envelope.registerEvent(6, 2.0); - envelope.registerEvent(2, 1.0); + envelope.registerEvent(6, 2.0f); + envelope.registerEvent(2, 1.0f); std::array output; - std::array expected { 0.5, 1, 1.25, 1.5, 1.75, 2.0, 2.0, 2.0 }; + std::array expected { 0.5f, 1.0f, 1.25f, 1.5f, 1.75f, 2.0f, 2.0f, 2.0f }; envelope.getBlock(absl::MakeSpan(output)); REQUIRE(output == expected); } @@ -102,11 +102,11 @@ TEST_CASE("[LinearEnvelope] 2 events, reversed") TEST_CASE("[LinearEnvelope] 3 events, overlapping") { sfz::LinearEnvelope envelope; - envelope.registerEvent(2, 1.0); - envelope.registerEvent(6, 2.0); - envelope.registerEvent(6, 3.0); + envelope.registerEvent(2, 1.0f); + envelope.registerEvent(6, 2.0f); + envelope.registerEvent(6, 3.0f); std::array output; - std::array expected { 0.5, 1, 1.25, 1.5, 1.75, 2.0, 3.0, 3.0 }; + std::array expected { 0.5f, 1.0f, 1.25f, 1.5f, 1.75f, 2.0f, 3.0f, 3.0f }; envelope.getBlock(absl::MakeSpan(output)); REQUIRE(output == expected); } @@ -114,11 +114,11 @@ TEST_CASE("[LinearEnvelope] 3 events, overlapping") TEST_CASE("[LinearEnvelope] 3 events, out of block") { sfz::LinearEnvelope envelope; - envelope.registerEvent(2, 1.0); - envelope.registerEvent(6, 2.0); - envelope.registerEvent(10, 3.0); + envelope.registerEvent(2, 1.0f); + envelope.registerEvent(6, 2.0f); + envelope.registerEvent(10, 3.0f); std::array output; - std::array expected { 0.5, 1, 1.25, 1.5, 1.75, 2.0, 2.5, 3.0 }; + std::array expected { 0.5f, 1.0f, 1.25f, 1.5f, 1.75f, 2.0f, 2.5f, 3.0f }; envelope.getBlock(absl::MakeSpan(output)); REQUIRE(output == expected); } @@ -126,11 +126,11 @@ TEST_CASE("[LinearEnvelope] 3 events, out of block") TEST_CASE("[LinearEnvelope] 3 events, out of block, with another block call") { sfz::LinearEnvelope envelope; - envelope.registerEvent(2, 1.0); - envelope.registerEvent(6, 2.0); - envelope.registerEvent(10, 3.0); + envelope.registerEvent(2, 1.0f); + envelope.registerEvent(6, 2.0f); + envelope.registerEvent(10, 3.0f); std::array output; - std::array expected { 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0 }; + std::array expected { 3.0f, 3.0f, 3.0f, 3.0f, 3.0f, 3.0f, 3.0f, 3.0f }; envelope.getBlock(absl::MakeSpan(output)); envelope.getBlock(absl::MakeSpan(output)); REQUIRE(output == expected); @@ -139,10 +139,10 @@ TEST_CASE("[LinearEnvelope] 3 events, out of block, with another block call") TEST_CASE("[LinearEnvelope] 2 events, with another block call") { sfz::LinearEnvelope envelope; - envelope.registerEvent(2, 1.0); - envelope.registerEvent(6, 2.0); + envelope.registerEvent(2, 1.0f); + envelope.registerEvent(6, 2.0f); std::array output; - std::array expected { 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0 }; + std::array expected { 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f }; envelope.getBlock(absl::MakeSpan(output)); envelope.getBlock(absl::MakeSpan(output)); REQUIRE(output == expected); @@ -152,10 +152,10 @@ TEST_CASE("[LinearEnvelope] 2 events, function") { sfz::LinearEnvelope envelope; envelope.setFunction([](auto x) { return 2 * x; }); - envelope.registerEvent(2, 1.0); - envelope.registerEvent(6, 2.0); + envelope.registerEvent(2, 1.0f); + envelope.registerEvent(6, 2.0f); std::array output; - std::array expected { 1, 2, 2.5, 3, 3.5, 4.0, 4.0, 4.0 }; + std::array expected { 1.0f, 2.0f, 2.5f, 3.0f, 3.5f, 4.0f, 4.0f, 4.0f }; envelope.getBlock(absl::MakeSpan(output)); REQUIRE(output == expected); } @@ -163,10 +163,10 @@ TEST_CASE("[LinearEnvelope] 2 events, function") TEST_CASE("[LinearEnvelope] Get quantized") { sfz::LinearEnvelope envelope; - envelope.registerEvent(2, 1.0); - envelope.registerEvent(6, 2.0); + envelope.registerEvent(2, 1.0f); + envelope.registerEvent(6, 2.0f); std::array output; - std::array expected { 0.0, 1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0 }; + std::array expected { 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 2.0f, 2.0f, 2.0f }; envelope.getQuantizedBlock(absl::MakeSpan(output), 1.0f); REQUIRE(output == expected); } @@ -174,10 +174,10 @@ TEST_CASE("[LinearEnvelope] Get quantized") TEST_CASE("[LinearEnvelope] Get quantized with unquantized targets") { sfz::LinearEnvelope envelope; - envelope.registerEvent(2, 1.1); - envelope.registerEvent(6, 1.9); + envelope.registerEvent(2, 1.1f); + envelope.registerEvent(6, 1.9f); std::array output; - std::array expected { 0.0, 1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0 }; + std::array expected { 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 2.0f, 2.0f, 2.0f }; envelope.getQuantizedBlock(absl::MakeSpan(output), 1.0f); REQUIRE(output == expected); } @@ -185,10 +185,10 @@ TEST_CASE("[LinearEnvelope] Get quantized with unquantized targets") TEST_CASE("[LinearEnvelope] Get quantized with 2 steps") { sfz::LinearEnvelope envelope; - envelope.registerEvent(2, 1.0); - envelope.registerEvent(6, 3.0); + envelope.registerEvent(2, 1.0f); + envelope.registerEvent(6, 3.0f); std::array output; - std::array expected { 0.0, 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 3.0 }; + std::array expected { 0.0f, 1.0f, 1.0f, 2.0f, 2.0f, 3.0f, 3.0f, 3.0f }; envelope.getQuantizedBlock(absl::MakeSpan(output), 1.0f); REQUIRE(output == expected); } @@ -196,12 +196,12 @@ TEST_CASE("[LinearEnvelope] Get quantized with 2 steps") TEST_CASE("[LinearEnvelope] Get quantized with 2 steps and an unquantized out of block step") { sfz::LinearEnvelope envelope; - envelope.registerEvent(2, 1.0); - envelope.registerEvent(6, 3.0); - envelope.registerEvent(10, 4.2); + envelope.registerEvent(2, 1.0f); + envelope.registerEvent(6, 3.0f); + envelope.registerEvent(10, 4.2f); std::array output; - std::array expected { 0.0, 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 3.0 }; - std::array expected2 { 4.0, 4.0, 4.0,4.0, 4.0, 4.0, 4.0, 4.0 }; + std::array expected { 0.0f, 1.0f, 1.0f, 2.0f, 2.0f, 3.0f, 3.0f, 3.0f }; + std::array expected2 { 4.0f, 4.0f, 4.0f,4.0f, 4.0f, 4.0f, 4.0f, 4.0f }; envelope.getQuantizedBlock(absl::MakeSpan(output), 1.0f); REQUIRE(output == expected); envelope.getQuantizedBlock(absl::MakeSpan(output), 1.0f); @@ -212,11 +212,11 @@ TEST_CASE("[LinearEnvelope] Get quantized with 2 steps and an unquantized out of TEST_CASE("[LinearEnvelope] Going down quantized with 2 steps") { sfz::LinearEnvelope envelope; - envelope.reset(3.0); - envelope.registerEvent(2, 2.0); - envelope.registerEvent(6, 0.0); + envelope.reset(3.0f); + envelope.registerEvent(2, 2.0f); + envelope.registerEvent(6, 0.0f); std::array output; - std::array expected { 3.0, 2.0, 2.0, 1.0, 1.0, 0.0, 0.0, 0.0 }; + std::array expected { 3.0f, 2.0f, 2.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f }; envelope.getQuantizedBlock(absl::MakeSpan(output), 1.0f); REQUIRE(output == expected); } @@ -224,11 +224,11 @@ TEST_CASE("[LinearEnvelope] Going down quantized with 2 steps") TEST_CASE("[LinearEnvelope] Get quantized with 2 steps and starting unquantized") { sfz::LinearEnvelope envelope; - envelope.reset(0.1); - envelope.registerEvent(3, 1.0); - envelope.registerEvent(7, 3.0); + envelope.reset(0.1f); + envelope.registerEvent(3, 1.0f); + envelope.registerEvent(7, 3.0f); std::array output; - std::array expected { 0.1, 0.1, 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 }; + std::array expected { 0.1f, 0.1f, 1.0f, 1.0f, 2.0f, 2.0f, 3.0f, 3.0f }; envelope.getQuantizedBlock(absl::MakeSpan(output), 1.0f); REQUIRE(output == expected); } @@ -237,11 +237,11 @@ TEST_CASE("[LinearEnvelope] Get quantized with 2 steps and starting unquantized" TEST_CASE("[LinearEnvelope] Going down quantized with 2 steps and starting unquantized") { sfz::LinearEnvelope envelope; - envelope.reset(3.6); - envelope.registerEvent(4, 1.0); + envelope.reset(3.6f); + envelope.registerEvent(4, 1.0f); envelope.registerEvent(7, 0.0); std::array output; - std::array expected { 3.6, 3.0, 2.0, 2.0, 1.0, 1.0, 0.0, 0.0 }; + std::array expected { 3.6f, 3.0f, 2.0f, 2.0f, 1.0f, 1.0f, 0.0f, 0.0f }; envelope.getQuantizedBlock(absl::MakeSpan(output), 1.0f); REQUIRE(output == expected); } @@ -249,10 +249,10 @@ TEST_CASE("[LinearEnvelope] Going down quantized with 2 steps and starting unqua TEST_CASE("[LinearEnvelope] Get quantized with unclean events") { sfz::LinearEnvelope envelope; - envelope.registerEvent(2, 1.2); - envelope.registerEvent(6, 2.5); + envelope.registerEvent(2, 1.2f); + envelope.registerEvent(6, 2.5f); std::array output; - std::array expected { 0.0, 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 3.0 }; + std::array expected { 0.0f, 1.0f, 1.0f, 2.0f, 2.0f, 3.0f, 3.0f, 3.0f }; envelope.getQuantizedBlock(absl::MakeSpan(output), 1.0f); REQUIRE(output == expected); } @@ -260,12 +260,12 @@ TEST_CASE("[LinearEnvelope] Get quantized with unclean events") TEST_CASE("[LinearEnvelope] Get quantized 3 events, one out of block") { sfz::LinearEnvelope envelope; - envelope.registerEvent(2, 1.0); - envelope.registerEvent(6, 2.0); - envelope.registerEvent(10, 3.0); + envelope.registerEvent(2, 1.0f); + envelope.registerEvent(6, 2.0f); + envelope.registerEvent(10, 3.0f); std::array output; - std::array expected { 0.0, 1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0 }; - std::array expected2 { 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0 }; + std::array expected { 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 2.0f, 2.0f, 2.0f }; + std::array expected2 { 3.0f, 3.0f, 3.0f, 3.0f, 3.0f, 3.0f, 3.0f, 3.0f }; envelope.getQuantizedBlock(absl::MakeSpan(output), 1.0f); REQUIRE(output == expected); envelope.getQuantizedBlock(absl::MakeSpan(output), 1.0f); @@ -277,7 +277,7 @@ TEST_CASE("[MultiplicativeEnvelope] Basic state") { sfz::MultiplicativeEnvelope envelope; std::array output; - std::array expected { 1.0, 1.0, 1.0, 1.0, 1.0 }; + std::array expected { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f }; envelope.getBlock(absl::MakeSpan(output)); REQUIRE(output == expected); } @@ -285,9 +285,9 @@ TEST_CASE("[MultiplicativeEnvelope] Basic state") TEST_CASE("[MultiplicativeEnvelope] Basic event") { sfz::MultiplicativeEnvelope envelope; - envelope.registerEvent(4, 2.0); + envelope.registerEvent(4, 2.0f); std::array output; - std::array expected { 1.1892, 1.4142, 1.68176, 2.0, 2.0, 2.0, 2.0, 2.0 }; + std::array expected { 1.1892f, 1.4142f, 1.68176f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f }; envelope.getBlock(absl::MakeSpan(output)); REQUIRE(approxEqual(output, expected)); } @@ -295,10 +295,10 @@ TEST_CASE("[MultiplicativeEnvelope] Basic event") TEST_CASE("[MultiplicativeEnvelope] 2 events") { sfz::MultiplicativeEnvelope envelope; - envelope.registerEvent(4, 2.0); - envelope.registerEvent(5, 4.0); + envelope.registerEvent(4, 2.0f); + envelope.registerEvent(5, 4.0f); std::array output; - std::array expected { 1.1892, 1.4142, 1.68176, 2.0, 4.0, 4.0, 4.0, 4.0 }; + std::array expected { 1.1892f, 1.4142f, 1.68176f, 2.0f, 4.0f, 4.0f, 4.0f, 4.0f }; envelope.getBlock(absl::MakeSpan(output)); REQUIRE(approxEqual(output, expected)); } @@ -306,10 +306,10 @@ TEST_CASE("[MultiplicativeEnvelope] 2 events") TEST_CASE("[MultiplicativeEnvelope] 2 events, far") { sfz::MultiplicativeEnvelope envelope; - envelope.registerEvent(2, 2.0); - envelope.registerEvent(6, 4.0); + envelope.registerEvent(2, 2.0f); + envelope.registerEvent(6, 4.0f); std::array output; - std::array expected { 1.4142, 2.0, 2.37841, 2.82843, 3.36358, 4.0, 4.0, 4.0 }; + std::array expected { 1.4142f, 2.0f, 2.37841f, 2.82843f, 3.36358f, 4.0f, 4.0f, 4.0f }; envelope.getBlock(absl::MakeSpan(output)); REQUIRE(approxEqual(output, expected)); } @@ -317,10 +317,10 @@ TEST_CASE("[MultiplicativeEnvelope] 2 events, far") TEST_CASE("[MultiplicativeEnvelope] Get quantized with 2 steps") { sfz::MultiplicativeEnvelope envelope; - envelope.registerEvent(2, 2.0); - envelope.registerEvent(6, 4.0); + envelope.registerEvent(2, 2.0f); + envelope.registerEvent(6, 4.0f); std::array output; - std::array expected { 1.0, 2.0, 2.0, 2.0, 2.0, 4.0, 4.0, 4.0 }; + std::array expected { 1.0f, 2.0f, 2.0f, 2.0f, 2.0f, 4.0f, 4.0f, 4.0f }; envelope.getQuantizedBlock(absl::MakeSpan(output), 2.0f); REQUIRE(output == expected); } @@ -328,12 +328,12 @@ TEST_CASE("[MultiplicativeEnvelope] Get quantized with 2 steps") TEST_CASE("[MultiplicativeEnvelope] Get quantized with an unquantized out of range step") { sfz::MultiplicativeEnvelope envelope; - envelope.registerEvent(2, 2.0); - envelope.registerEvent(6, 4.0); - envelope.registerEvent(10, 8.2); + envelope.registerEvent(2, 2.0f); + envelope.registerEvent(6, 4.0f); + envelope.registerEvent(10, 8.2f); std::array output; - std::array expected { 1.0, 2.0, 2.0, 2.0, 2.0, 4.0, 4.0, 4.0 }; - std::array expected2 { 8.0, 8.0, 8.0, 8.0, 8.0, 8.0, 8.0, 8.0 }; + std::array expected { 1.0f, 2.0f, 2.0f, 2.0f, 2.0f, 4.0f, 4.0f, 4.0f }; + std::array expected2 { 8.0f, 8.0f, 8.0f, 8.0f, 8.0f, 8.0f, 8.0f, 8.0f }; envelope.getQuantizedBlock(absl::MakeSpan(output), 2.0f); REQUIRE(output == expected); envelope.getQuantizedBlock(absl::MakeSpan(output), 2.0f); @@ -343,11 +343,11 @@ TEST_CASE("[MultiplicativeEnvelope] Get quantized with an unquantized out of ran TEST_CASE("[MultiplicativeEnvelope] Going down quantized with 2 steps") { sfz::MultiplicativeEnvelope envelope; - envelope.reset(4.0); - envelope.registerEvent(2, 2.0); - envelope.registerEvent(6, 0.5); + envelope.reset(4.0f); + envelope.registerEvent(2, 2.0f); + envelope.registerEvent(6, 0.5f); std::array output; - std::array expected { 4.0, 2.0, 2.0, 1.0, 1.0, 0.5, 0.5, 0.5 }; + std::array expected { 4.0f, 2.0f, 2.0f, 1.0f, 1.0f, 0.5f, 0.5f, 0.5f }; envelope.getQuantizedBlock(absl::MakeSpan(output), 2.0f); REQUIRE(output == expected); } @@ -355,10 +355,10 @@ TEST_CASE("[MultiplicativeEnvelope] Going down quantized with 2 steps") TEST_CASE("[MultiplicativeEnvelope] Get quantized with unclean events") { sfz::MultiplicativeEnvelope envelope; - envelope.registerEvent(2, 1.2); - envelope.registerEvent(6, 2.5); + envelope.registerEvent(2, 1.2f); + envelope.registerEvent(6, 2.5f); std::array output; - std::array expected { 1.0, 1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0 }; + std::array expected { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 2.0f, 2.0f, 2.0f }; envelope.getQuantizedBlock(absl::MakeSpan(output), 2.0f); REQUIRE(output == expected); } @@ -366,11 +366,11 @@ TEST_CASE("[MultiplicativeEnvelope] Get quantized with unclean events") TEST_CASE("[MultiplicativeEnvelope] Get quantized with 2 steps and starting unquantized") { sfz::MultiplicativeEnvelope envelope; - envelope.reset(0.9); - envelope.registerEvent(3, 1.0); - envelope.registerEvent(7, 4.0); + envelope.reset(0.9f); + envelope.registerEvent(3, 1.0f); + envelope.registerEvent(7, 4.0f); std::array output; - std::array expected { 0.9, 0.9, 1.0, 1.0, 2.0, 2.0, 4.0, 4.0 }; + std::array expected { 0.9f, 0.9f, 1.0f, 1.0f, 2.0f, 2.0f, 4.0f, 4.0f }; envelope.getQuantizedBlock(absl::MakeSpan(output), 2.0f); REQUIRE(output == expected); } @@ -379,11 +379,11 @@ TEST_CASE("[MultiplicativeEnvelope] Get quantized with 2 steps and starting unqu TEST_CASE("[MultiplicativeEnvelope] Going down quantized with 2 steps and starting unquantized") { sfz::MultiplicativeEnvelope envelope; - envelope.reset(4.6); - envelope.registerEvent(4, 1.0); - envelope.registerEvent(7, 0.25); + envelope.reset(4.6f); + envelope.registerEvent(4, 1.0f); + envelope.registerEvent(7, 0.25f); std::array output; - std::array expected { 4.6, 2.0, 1.0, 1.0, 0.5, 0.5, 0.25, 0.25 }; + std::array expected { 4.6f, 2.0f, 1.0f, 1.0f, 0.5f, 0.5f, 0.25f, 0.25f }; envelope.getQuantizedBlock(absl::MakeSpan(output), 2.0f); REQUIRE(output == expected); } @@ -394,13 +394,13 @@ TEST_CASE("[MultiplicativeEnvelope] Pitch envelope basic function") sfz::MultiplicativeEnvelope envelope; envelope.setFunction([](float pitchValue){ const auto normalizedBend = sfz::normalizeBend(pitchValue); - const auto bendInCents = normalizedBend * 200; + const auto bendInCents = normalizedBend * 200.0f; return sfz::centsFactor(bendInCents); }); - envelope.reset(0); + envelope.reset(0.0f); envelope.getBlock(absl::MakeSpan(output)); REQUIRE(output[255] == 1.0_a); - envelope.registerEvent(252, -6020); + envelope.registerEvent(252, -6020.0f); envelope.getBlock(absl::MakeSpan(output)); REQUIRE(output[255] == Approx(0.9168).epsilon(0.01)); } diff --git a/tests/FilesT.cpp b/tests/FilesT.cpp index 01a4ea2c..fb7db796 100644 --- a/tests/FilesT.cpp +++ b/tests/FilesT.cpp @@ -61,6 +61,15 @@ TEST_CASE("[Files] Underscore opcodes (underscore_opcodes.sfz)") REQUIRE(synth.getRegionView(0)->loopMode == SfzLoopMode::loop_sustain); } +TEST_CASE("[Files] (regions_bad.sfz)") +{ + sfz::Synth synth; + synth.loadSfzFile(fs::current_path() / "tests/TestFiles/Regions/regions_bad.sfz"); + REQUIRE(synth.getNumRegions() == 2); + REQUIRE(synth.getRegionView(0)->sample == "dummy.wav"); + REQUIRE(synth.getRegionView(1)->sample == "dummy.wav"); +} + TEST_CASE("[Files] Local include") { sfz::Synth synth; diff --git a/tests/OnePoleFilterT.cpp b/tests/OnePoleFilterT.cpp index 378271db..d4ffeaa1 100644 --- a/tests/OnePoleFilterT.cpp +++ b/tests/OnePoleFilterT.cpp @@ -73,7 +73,7 @@ void testLowpass(const fs::path& inputNumpyFile, const fs::path& outputNumpyFile REQUIRE(approxEqual(outputData, expectedData)); filter.reset(); - std::fill(outputData.begin(), outputData.end(), 0.0); + std::fill(outputData.begin(), outputData.end(), 0.0f); std::vector gains(size); std::fill(gains.begin(), gains.end(), gain); filter.processLowpassVariableGain(inputData, absl::MakeSpan(outputData), gains); @@ -108,7 +108,7 @@ void testHighpass(const fs::path& inputNumpyFile, const fs::path& outputNumpyFil REQUIRE(approxEqual(outputData, expectedData)); filter.reset(); - std::fill(outputData.begin(), outputData.end(), 0.0); + std::fill(outputData.begin(), outputData.end(), 0.0f); std::vector gains(size); std::fill(gains.begin(), gains.end(), gain); filter.processHighpassVariableGain(inputData, absl::MakeSpan(outputData), gains); diff --git a/tests/SIMDHelpersT.cpp b/tests/SIMDHelpersT.cpp index a0e798fc..8be6dec2 100644 --- a/tests/SIMDHelpersT.cpp +++ b/tests/SIMDHelpersT.cpp @@ -33,7 +33,7 @@ using namespace Catch::literals; constexpr int smallBufferSize { 3 }; constexpr int bigBufferSize { 4095 }; constexpr int medBufferSize { 127 }; -constexpr double fillValue { 1.3 }; +constexpr float fillValue { 1.3f }; template inline bool approxEqualMargin(absl::Span lhs, absl::Span rhs, Type eps = 1e-3) @@ -334,7 +334,7 @@ TEST_CASE("[Helpers] Interleaved write SIMD vs Scalar") std::array outputScalar; std::array outputSIMD; std::iota(leftInput.begin(), leftInput.end(), 0.0f); - std::iota(rightInput.begin(), rightInput.end(), medBufferSize); + std::iota(rightInput.begin(), rightInput.end(), static_cast(medBufferSize)); sfz::writeInterleaved(leftInput, rightInput, absl::MakeSpan(outputScalar)); sfz::writeInterleaved(leftInput, rightInput, absl::MakeSpan(outputSIMD)); REQUIRE(outputScalar == outputSIMD); @@ -414,7 +414,7 @@ TEST_CASE("[Helpers] Gain, spans and inplace (SIMD)") TEST_CASE("[Helpers] SFZ looping index") { - std::array jumps { 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f }; // 1.1 2.3 3.6 5.0 6.5 8.1 + std::array jumps { 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f }; // 1.1 2.3 3.6 5.0f 6.5 8.1 std::array indices; std::array leftCoeffs; std::array rightCoeffs; @@ -429,7 +429,7 @@ TEST_CASE("[Helpers] SFZ looping index") TEST_CASE("[Helpers] SFZ looping index (SIMD)") { - std::array jumps { 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f }; // 1.1 2.3 3.6 5.0 6.5 8.1 + std::array jumps { 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f }; // 1.1 2.3 3.6 5.0f 6.5 8.1 std::array indices; std::array leftCoeffs; std::array rightCoeffs; @@ -458,13 +458,13 @@ TEST_CASE("[Helpers] SFZ looping index (SIMD)") // sfz::loopingSFZIndex(jumps, absl::MakeSpan(leftCoeffs), absl::MakeSpan(rightCoeffs), absl::MakeSpan(indices), 1.0f, medBufferSize, 1); // sfz::loopingSFZIndex(jumps, absl::MakeSpan(leftCoeffsSIMD), absl::MakeSpan(rightCoeffsSIMD), absl::MakeSpan(indicesSIMD), 1.0f, medBufferSize, 1); // for (int i = 0; i < bigBufferSize; ++i) -// REQUIRE( ((static_cast(indices[i]) + rightCoeffs[i] == Approx(static_cast(indicesSIMD[i]) + rightCoeffsSIMD[i]).margin(1e-2)) +// REQUIRE( ((static_cast(indices[i]) + rightCoeffs[i] == Approx(static_cast(indicesSIMD[i]) + rightCoeffsSIMD[i]).margin(1e-2)) // || (static_cast(indices[i]) + rightCoeffs[i] == Approx(static_cast(indicesSIMD[i]) + rightCoeffsSIMD[i] - static_cast(medBufferSize)).margin(2e-2))) ); // } TEST_CASE("[Helpers] SFZ saturating index") { - std::array jumps { 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f }; // 1.1 2.3 3.6 5.0 6.5 8.1 + std::array jumps { 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f }; // 1.1 2.3 3.6 5.0f 6.5 8.1 std::array indices; std::array leftCoeffs; std::array rightCoeffs; @@ -479,7 +479,7 @@ TEST_CASE("[Helpers] SFZ saturating index") TEST_CASE("[Helpers] SFZ saturating index (SIMD)") { - std::array jumps { 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f }; // 1.1 2.3 3.6 5.0 6.5 8.1 + std::array jumps { 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f }; // 1.1 2.3 3.6 5.0f 6.5 8.1 std::array indices; std::array leftCoeffs; std::array rightCoeffs; @@ -558,7 +558,7 @@ TEST_CASE("[Helpers] Multiplicative Ramp") std::array output; std::array expected { v, v * v, v * v * v, v * v * v * v, v * v * v * v * v, v * v * v * v * v * v }; sfz::multiplicativeRamp(absl::MakeSpan(output), start, v); - REQUIRE(output == expected); + REQUIRE(approxEqual(output, expected)); } TEST_CASE("[Helpers] Multiplicative Ramp (SIMD)") @@ -568,7 +568,7 @@ TEST_CASE("[Helpers] Multiplicative Ramp (SIMD)") std::array output; std::array expected { v, v * v, v * v * v, v * v * v * v, v * v * v * v * v, v * v * v * v * v * v }; sfz::multiplicativeRamp(absl::MakeSpan(output), start, v); - REQUIRE(output == expected); + REQUIRE(approxEqual(output, expected)); } TEST_CASE("[Helpers] Multiplicative Ramp (SIMD vs scalar)") @@ -595,7 +595,7 @@ TEST_CASE("[Helpers] Add") { std::array input { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f }; std::array output { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f }; - std::array expected { 2.0, 3.0, 4.0, 5.0, 6.0 }; + std::array expected { 2.0f, 3.0f, 4.0f, 5.0f, 6.0f }; sfz::add(input, absl::MakeSpan(output)); REQUIRE(output == expected); } @@ -604,7 +604,7 @@ TEST_CASE("[Helpers] Add (SIMD)") { std::array input { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f }; std::array output { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f }; - std::array expected { 2.0, 3.0, 4.0, 5.0, 6.0 }; + std::array expected { 2.0f, 3.0f, 4.0f, 5.0f, 6.0f }; sfz::add(input, absl::MakeSpan(output)); REQUIRE(output == expected); } @@ -614,9 +614,9 @@ TEST_CASE("[Helpers] Add (SIMD vs scalar)") std::vector input(bigBufferSize); std::vector outputScalar(bigBufferSize); std::vector outputSIMD(bigBufferSize); - absl::c_iota(input, 0.0); - absl::c_fill(outputScalar, 0.0); - absl::c_fill(outputSIMD, 0.0); + absl::c_iota(input, 0.0f); + absl::c_fill(outputScalar, 0.0f); + absl::c_fill(outputSIMD, 0.0f); sfz::add(input, absl::MakeSpan(outputScalar)); sfz::add(input, absl::MakeSpan(outputSIMD)); @@ -627,7 +627,7 @@ TEST_CASE("[Helpers] Subtract") { std::array input { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f }; std::array output { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f }; - std::array expected { 0.0, -1.0, -2.0, -3.0, -4.0 }; + std::array expected { 0.0f, -1.0f, -2.0f, -3.0f, -4.0f }; sfz::subtract(input, absl::MakeSpan(output)); REQUIRE(output == expected); } @@ -635,7 +635,7 @@ TEST_CASE("[Helpers] Subtract") TEST_CASE("[Helpers] Subtract 2") { std::array output { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f }; - std::array expected { 0.0, 1.0, 2.0, 3.0, 4.0 }; + std::array expected { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f }; sfz::subtract(1.0f, absl::MakeSpan(output)); REQUIRE(output == expected); } @@ -645,7 +645,7 @@ TEST_CASE("[Helpers] Subtract (SIMD)") { std::array input { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f }; std::array output { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f }; - std::array expected { 0.0, -1.0, -2.0, -3.0, -4.0 }; + std::array expected { 0.0f, -1.0f, -2.0f, -3.0f, -4.0f }; sfz::subtract(input, absl::MakeSpan(output)); REQUIRE(output == expected); } @@ -655,9 +655,9 @@ TEST_CASE("[Helpers] Subtract (SIMD vs scalar)") std::vector input(bigBufferSize); std::vector outputScalar(bigBufferSize); std::vector outputSIMD(bigBufferSize); - absl::c_iota(input, 0.0); - absl::c_fill(outputScalar, 0.0); - absl::c_fill(outputSIMD, 0.0); + absl::c_iota(input, 0.0f); + absl::c_fill(outputScalar, 0.0f); + absl::c_fill(outputSIMD, 0.0f); sfz::subtract(input, absl::MakeSpan(outputScalar)); sfz::subtract(input, absl::MakeSpan(outputSIMD)); @@ -668,8 +668,8 @@ TEST_CASE("[Helpers] Subtract 2 (SIMD vs scalar)") { std::vector outputScalar(bigBufferSize); std::vector outputSIMD(bigBufferSize); - absl::c_iota(outputScalar, 0.0); - absl::c_iota(outputSIMD, 0.0); + absl::c_iota(outputScalar, 0.0f); + absl::c_iota(outputSIMD, 0.0f); sfz::subtract(1.2f, absl::MakeSpan(outputScalar)); sfz::subtract(1.2f, absl::MakeSpan(outputSIMD)); @@ -697,9 +697,9 @@ TEST_CASE("[Helpers] copy (SIMD vs scalar)") std::vector input(bigBufferSize); std::vector outputScalar(bigBufferSize); std::vector outputSIMD(bigBufferSize); - absl::c_iota(input, 0.0); - absl::c_fill(outputScalar, 0.0); - absl::c_fill(outputSIMD, 0.0); + absl::c_iota(input, 0.0f); + absl::c_fill(outputScalar, 0.0f); + absl::c_fill(outputSIMD, 0.0f); sfz::add(input, absl::MakeSpan(outputScalar)); sfz::add(input, absl::MakeSpan(outputSIMD)); @@ -716,7 +716,7 @@ TEST_CASE("[Helpers] Mean") TEST_CASE("[Helpers] Mean (SIMD vs scalar)") { std::vector input(bigBufferSize); - absl::c_iota(input, 0.0); + absl::c_iota(input, 0.0f); REQUIRE(sfz::mean(input) == Approx(sfz::mean(input)).margin(0.001)); } @@ -730,14 +730,14 @@ TEST_CASE("[Helpers] Mean Squared") TEST_CASE("[Helpers] Mean Squared (SIMD vs scalar)") { std::vector input(medBufferSize); - absl::c_iota(input, 0.0); + absl::c_iota(input, 0.0f); REQUIRE(sfz::meanSquared(input) == sfz::meanSquared(input)); } TEST_CASE("[Helpers] Cumulative sum ") { - std::array input { 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f }; // 1.1 2.3 3.6 5.0 6.5 8.1 - std::array output; + std::array input { 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f }; // 1.1 2.3 3.6 5.0f 6.5 8.1 + std::array output; std::array expected { 1.1f, 2.3f, 3.6f, 5.0f, 6.5f, 8.1f }; sfz::cumsum(input, absl::MakeSpan(output)); REQUIRE(approxEqual(output, expected)); @@ -748,7 +748,7 @@ TEST_CASE("[Helpers] Cumulative sum (SIMD vs Scalar)") std::vector input(bigBufferSize); std::vector outputScalar(bigBufferSize); std::vector outputSIMD(bigBufferSize); - sfz::linearRamp(absl::MakeSpan(input), 0.0, 0.1); + sfz::linearRamp(absl::MakeSpan(input), 0.0f, 0.1f); sfz::cumsum(input, absl::MakeSpan(outputScalar)); sfz::cumsum(input, absl::MakeSpan(outputSIMD)); REQUIRE(approxEqual(outputScalar, outputSIMD)); @@ -757,7 +757,7 @@ TEST_CASE("[Helpers] Cumulative sum (SIMD vs Scalar)") TEST_CASE("[Helpers] Diff ") { std::array input { 1.1f, 2.3f, 3.6f, 5.0f, 6.5f, 8.1f }; - std::array output; + std::array output; std::array expected { 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f }; sfz::diff(input, absl::MakeSpan(output)); REQUIRE(approxEqual(output, expected)); @@ -768,8 +768,8 @@ TEST_CASE("[Helpers] Diff (SIMD vs Scalar)") std::vector input(bigBufferSize); std::vector outputScalar(bigBufferSize); std::vector outputSIMD(bigBufferSize); - sfz::linearRamp(absl::MakeSpan(input), 0.0, 0.1); + sfz::linearRamp(absl::MakeSpan(input), 0.0f, 0.1f); sfz::diff(input, absl::MakeSpan(outputScalar)); sfz::diff(input, absl::MakeSpan(outputSIMD)); REQUIRE(approxEqual(outputScalar, outputSIMD)); -} \ No newline at end of file +} diff --git a/tests/TestFiles/Regions/regions_bad.sfz b/tests/TestFiles/Regions/regions_bad.sfz new file mode 100644 index 00000000..1084ddcc --- /dev/null +++ b/tests/TestFiles/Regions/regions_bad.sfz @@ -0,0 +1,4 @@ + sample=dummy.wav + sample=nonexistent.wav + sample=nonexistent.wav + sample=dummy.wav