From 105c459a4abbc4f491c2e2905c99d3b7a7f51b69 Mon Sep 17 00:00:00 2001 From: paulfd Date: Sat, 21 Sep 2019 13:01:50 +0200 Subject: [PATCH] cleanups --- CMakeLists.txt | 5 +- benchmarks/BM_OPF_high_vs_low.cpp | 46 +++-------- benchmarks/BM_pointerIterationOrOffsets.cpp | 2 +- clients/sfzprint.cpp | 3 +- external/abseil-cpp | 2 +- external/benchmark | 2 +- sfizz/CMakeLists.txt | 47 ++++++++++-- sfizz/FilePool.cpp | 8 +- sfizz/FilePool.h | 4 +- sfizz/Parser.cpp | 8 +- sfizz/Parser.h | 10 +-- sfizz/Synth.cpp | 6 +- sfizz/Synth.h | 3 +- sfizz/compat/filesystem.h | 25 +++--- tests/FilesT.cpp | 48 ++++++------ tests/OnePoleFilterT.cpp | 84 ++++++++++----------- 16 files changed, 156 insertions(+), 147 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 94a039d5..434bb819 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,11 +9,10 @@ set(CMAKE_POLICY_DEFAULT_CMP0069 NEW) # To override the policy in abseil and ben set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT ANDROID) + set(USE_LIBCPP ON CACHE BOOL "Use libc++ with clang") add_compile_options(-stdlib=libc++) # Presumably need the above for linking too, maybe other options missing as well - add_link_options(-stdlib=libc++) # New command on CMake master, not in 3.12 release -else() - add_link_options(-lstdc++fs) + add_link_options(-lc++abi) # New command on CMake master, not in 3.12 release endif() if (UNIX) diff --git a/benchmarks/BM_OPF_high_vs_low.cpp b/benchmarks/BM_OPF_high_vs_low.cpp index db23bd92..5a67d73f 100644 --- a/benchmarks/BM_OPF_high_vs_low.cpp +++ b/benchmarks/BM_OPF_high_vs_low.cpp @@ -41,13 +41,14 @@ void lowpass(absl::Span input, absl::Span lowpass, float gai float state = 0.0f; float intermediate; const auto G = gain / (1 - gain); - for (auto [in, out] = std::make_pair(input.begin(), lowpass.begin()); - in < input.end() && out < lowpass.end(); - in++, out++) - { + auto in = input.begin(); + auto out = lowpass.begin(); + while (in < input.end()) { intermediate = G * (*in - state); *out = intermediate + state; state = *out + intermediate; + in++; + out++; } } @@ -56,32 +57,23 @@ void highpass(absl::Span input, absl::Span highpass, float g float state = 0.0f; float intermediate; const auto G = gain / (1 - gain); - for (auto [in, out] = std::make_pair(input.begin(), highpass.begin()); - in < input.end() && out < highpass.end(); - in++, out++) - { + auto in = input.begin(); + auto out = highpass.begin(); + while (in < input.end()) { intermediate = G * (*in - state); *out = *in - intermediate - state; state += 2*intermediate; + in++; + out++; } } -void highpass_foreach(absl::Span input, absl::Span highpass, float gain) -{ - lowpass(input, highpass, gain); - for (auto [in, out] = std::make_pair(input.begin(), highpass.begin()); - in < input.end() && out < highpass.end(); - in++, out++) - *out = *in - *out; -} - void highpass_raw(absl::Span input, absl::Span highpass, float gain) { lowpass(input, highpass, gain); auto in = input.data(); auto out = highpass.data(); - while (in < input.end() && out < highpass.end()) - { + while (in < input.end()) { *out = *in - *out; out++; in++; @@ -144,21 +136,6 @@ static void High(benchmark::State& state) { highpass(input, absl::MakeSpan(output), filterGain); } -static void High_ForEach(benchmark::State& state) { - std::vector input(state.range(0)); - 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); - }); - - for (auto _ : state) - highpass_foreach(input, absl::MakeSpan(output), filterGain); -} - static void High_Raw(benchmark::State& state) { std::vector input(state.range(0)); std::vector output(state.range(0)); @@ -192,7 +169,6 @@ static void High_SSE(benchmark::State& state) { BENCHMARK(Low)->RangeMultiplier(2)->Range((2<<5), (2<<10)); BENCHMARK(High)->RangeMultiplier(2)->Range((2<<5), (2<<10)); -BENCHMARK(High_ForEach)->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 diff --git a/benchmarks/BM_pointerIterationOrOffsets.cpp b/benchmarks/BM_pointerIterationOrOffsets.cpp index be2ce371..23b10fc0 100644 --- a/benchmarks/BM_pointerIterationOrOffsets.cpp +++ b/benchmarks/BM_pointerIterationOrOffsets.cpp @@ -27,7 +27,7 @@ #include "../sfizz/SIMDHelpers.h" #include "absl/types/span.h" -inline constexpr int bigNumber { 2399132 }; +constexpr int bigNumber { 2399132 }; class IterOffset : public benchmark::Fixture { public: diff --git a/clients/sfzprint.cpp b/clients/sfzprint.cpp index 91ab76ff..caae4036 100644 --- a/clients/sfzprint.cpp +++ b/clients/sfzprint.cpp @@ -74,8 +74,7 @@ int main(int argc, char** argv) std::cout << '\n'; PrintingParser parser; - std::filesystem::path filename { filesToParse[0] }; - parser.loadSfzFile(filename); + parser.loadSfzFile(filesToParse[0]); std::cout << "==========" << '\n'; std::cout << "Total:" << '\n'; std::cout << "\tMasters: " << parser.getNumMasters() << '\n'; diff --git a/external/abseil-cpp b/external/abseil-cpp index aa844899..ac78ffc3 160000 --- a/external/abseil-cpp +++ b/external/abseil-cpp @@ -1 +1 @@ -Subproject commit aa844899c937bde5d2b24f276b59997e5b668bde +Subproject commit ac78ffc3bc0a8b295cab9a03817760fd460df2a1 diff --git a/external/benchmark b/external/benchmark index 090faecb..bf4f2ea0 160000 --- a/external/benchmark +++ b/external/benchmark @@ -1 +1 @@ -Subproject commit 090faecb454fbd6e6e17a75ef8146acb037118d4 +Subproject commit bf4f2ea0bd1180b34718ac26eb79b170a4f6290e diff --git a/sfizz/CMakeLists.txt b/sfizz/CMakeLists.txt index aa12a72f..58d4e0c5 100644 --- a/sfizz/CMakeLists.txt +++ b/sfizz/CMakeLists.txt @@ -36,24 +36,59 @@ endif() set(SFIZZ_SOURCES ${SFIZZ_SOURCES} ${SFIZZ_SIMD_SOURCES}) +# include(CheckCXXSourceCompiles) +# check_cxx_source_compiles(" +# #include + +# int main(int argc, char** argv) +# { +# std::filesystem::path p; +# return 0; +# } +# " HAVE_STD_FILESYSTEM) + +check_include_file_cxx("filesystem" HAVE_STD_FILESYSTEM) +if (HAVE_STD_FILESYSTEM) + # if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 8.0) + # add_compile_options(-DUSE_STD_FILESYSTEM) + # endif() + if (WIN32) + add_compile_options(/DUSE_STD_FILESYSTEM) + endif() +endif() + + add_library(sfizz_parser STATIC) target_sources(sfizz_parser PRIVATE Parser.cpp Opcode.cpp) target_include_directories(sfizz_parser PUBLIC .) -if(UNIX) - target_link_libraries(sfizz_parser PUBLIC stdc++fs) - # target_compile_options(sfizz_parser PUBLIC -fno-rtti -fno-exceptions) -endif(UNIX) target_link_libraries(sfizz_parser PRIVATE absl::strings) +if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT ANDROID) + target_link_libraries(sfizz_parser PUBLIC c++fs) +endif() + +if (CMAKE_CXX_COMPILER_ID MATCHES "GNU") + target_link_libraries(sfizz_parser PUBLIC stdc++fs) +endif() + + add_library(sfizz STATIC ${SFIZZ_SOURCES}) target_link_libraries(sfizz PRIVATE sfizz_parser) target_include_directories(sfizz PUBLIC .) find_package(Threads REQUIRED) target_link_libraries(sfizz PRIVATE Threads::Threads) if(UNIX) - target_link_libraries(sfizz PUBLIC stdc++fs atomic) - # target_compile_options(sfizz PUBLIC -fno-rtti -fno-exceptions) + target_link_libraries(sfizz PUBLIC atomic) endif(UNIX) + +if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT ANDROID) + target_link_libraries(sfizz PUBLIC c++fs) +endif() + +if (CMAKE_CXX_COMPILER_ID MATCHES "GNU") + target_link_libraries(sfizz PUBLIC stdc++fs) +endif() + target_link_libraries(sfizz PUBLIC absl::strings) target_link_libraries(sfizz PRIVATE sndfile absl::flat_hash_map) diff --git a/sfizz/FilePool.cpp b/sfizz/FilePool.cpp index 0e1c31a2..dacf704b 100644 --- a/sfizz/FilePool.cpp +++ b/sfizz/FilePool.cpp @@ -50,8 +50,8 @@ std::unique_ptr> readFromFile(SndfileHandle& sndFile, int numFram absl::optional sfz::FilePool::getFileInformation(const std::string& filename, uint32_t offset) noexcept { - std::filesystem::path file { rootDirectory / filename }; - if (!std::filesystem::exists(file)) + fs::path file { rootDirectory / filename }; + if (!fs::exists(file)) return {}; SndfileHandle sndFile(reinterpret_cast(file.c_str())); @@ -128,8 +128,8 @@ void sfz::FilePool::loadingThread() noexcept } DBG("Background loading of: " << *fileToLoad.sample); - std::filesystem::path file { rootDirectory / *fileToLoad.sample }; - if (!std::filesystem::exists(file)) { + fs::path file { rootDirectory / *fileToLoad.sample }; + if (!fs::exists(file)) { DBG("Background thread: no file " << *fileToLoad.sample << " exists."); continue; } diff --git a/sfizz/FilePool.h b/sfizz/FilePool.h index fb30c353..4c25250b 100644 --- a/sfizz/FilePool.h +++ b/sfizz/FilePool.h @@ -46,7 +46,7 @@ public: fileLoadingThread.join(); garbageCollectionThread.join(); } - void setRootDirectory(const std::filesystem::path& directory) noexcept { rootDirectory = directory; } + void setRootDirectory(const fs::path& directory) noexcept { rootDirectory = directory; } size_t getNumPreloadedSamples() const noexcept { return preloadedData.size(); } struct FileInformation { @@ -60,7 +60,7 @@ public: void enqueueLoading(Voice* voice, const std::string* sample, int numFrames, unsigned ticket) noexcept; void clear(); private: - std::filesystem::path rootDirectory; + fs::path rootDirectory; struct FileLoadingInformation { Voice* voice; const std::string* sample; diff --git a/sfizz/Parser.cpp b/sfizz/Parser.cpp index 307c0664..d007a205 100644 --- a/sfizz/Parser.cpp +++ b/sfizz/Parser.cpp @@ -41,10 +41,10 @@ void removeCommentOnLine(absl::string_view& line) line.remove_suffix(line.size() - position); } -bool sfz::Parser::loadSfzFile(const std::filesystem::path& file) +bool sfz::Parser::loadSfzFile(const fs::path& file) { const auto sfzFile = file.is_absolute() ? file : rootDirectory / file; - if (!std::filesystem::exists(sfzFile)) + if (!fs::exists(sfzFile)) return false; rootDirectory = file.parent_path(); @@ -81,7 +81,7 @@ bool sfz::Parser::loadSfzFile(const std::filesystem::path& file) return true; } -void sfz::Parser::readSfzFile(const std::filesystem::path& fileName, std::vector& lines) noexcept +void sfz::Parser::readSfzFile(const fs::path& fileName, std::vector& lines) noexcept { std::ifstream fileStream(fileName.c_str()); if (!fileStream) @@ -107,7 +107,7 @@ void sfz::Parser::readSfzFile(const std::filesystem::path& fileName, std::vector std::replace(includePath.begin(), includePath.end(), '\\', '/'); const auto newFile = rootDirectory / includePath; auto alreadyIncluded = std::find(includedFiles.begin(), includedFiles.end(), newFile); - if (std::filesystem::exists(newFile)) { + if (fs::exists(newFile)) { if (alreadyIncluded == includedFiles.end()) { includedFiles.push_back(newFile); readSfzFile(newFile, lines); diff --git a/sfizz/Parser.h b/sfizz/Parser.h index 481b6eb0..25d2307a 100644 --- a/sfizz/Parser.h +++ b/sfizz/Parser.h @@ -32,20 +32,20 @@ namespace sfz { class Parser { public: - virtual bool loadSfzFile(const std::filesystem::path& file); + virtual bool loadSfzFile(const fs::path& file); const std::map& getDefines() const noexcept { return defines; } - const std::vector& getIncludedFiles() const noexcept { return includedFiles; } + const std::vector& getIncludedFiles() const noexcept { return includedFiles; } void disableRecursiveIncludeGuard() { recursiveIncludeGuard = false; } void enableRecursiveIncludeGuard() { recursiveIncludeGuard = true; } protected: virtual void callback(absl::string_view header, const std::vector& members) = 0; - std::filesystem::path rootDirectory { std::filesystem::current_path() }; + fs::path rootDirectory { fs::current_path() }; private: bool recursiveIncludeGuard { false }; std::map defines; - std::vector includedFiles; + std::vector includedFiles; std::string aggregatedContent {}; - void readSfzFile(const std::filesystem::path& fileName, std::vector& lines) noexcept; + void readSfzFile(const fs::path& fileName, std::vector& lines) noexcept; }; } // namespace sfz diff --git a/sfizz/Synth.cpp b/sfizz/Synth.cpp index 81453549..3cc03336 100644 --- a/sfizz/Synth.cpp +++ b/sfizz/Synth.cpp @@ -152,8 +152,8 @@ void sfz::Synth::handleControlOpcodes(const std::vector& members) case hash("Default_path"): [[fallthrough]]; case hash("default_path"): { auto stringPath = std::string(member.value.begin(), member.value.end()); - auto newPath = std::filesystem::path(stringPath); - if (std::filesystem::exists(newPath)) + auto newPath = fs::path(stringPath); + if (fs::exists(newPath)) rootDirectory = newPath; break; } @@ -182,7 +182,7 @@ void addEndpointsToVelocityCurve(sfz::Region& region) } } -bool sfz::Synth::loadSfzFile(const std::filesystem::path& filename) +bool sfz::Synth::loadSfzFile(const fs::path& filename) { canEnterCallback = false; while (inCallback) { diff --git a/sfizz/Synth.h b/sfizz/Synth.h index 763415e4..24fd9604 100644 --- a/sfizz/Synth.h +++ b/sfizz/Synth.h @@ -40,8 +40,7 @@ namespace sfz { class Synth : public Parser { public: Synth(); - - bool loadSfzFile(const std::filesystem::path& file) final; + bool loadSfzFile(const fs::path& file) final; int getNumRegions() const noexcept; int getNumGroups() const noexcept; int getNumMasters() const noexcept; diff --git a/sfizz/compat/filesystem.h b/sfizz/compat/filesystem.h index 6b040bf7..38f13894 100644 --- a/sfizz/compat/filesystem.h +++ b/sfizz/compat/filesystem.h @@ -1,15 +1,16 @@ #pragma once - -#ifdef __cplusplus - #if (__cplusplus >= 201703L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) - #include - #elif (__cplusplus >= 201402L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201402L) - #warning std::experimental::filesystem in use - #include - namespace std { - namespace filesystem = std::experimental::filesystem; - } - #endif +#ifdef USE_STD_FILESYSTEM + #warning FS + #include + namespace fs = std::filesystem; #else - #error no filesystem support + #warning EXPFS + #include + namespace fs = std::experimental::filesystem; #endif + +// #if __cplusplus < 201703L +// #warning EXPFSNS +// #else +// #warning FSNS +// #endif \ No newline at end of file diff --git a/tests/FilesT.cpp b/tests/FilesT.cpp index 7462a3f6..d8c9177d 100644 --- a/tests/FilesT.cpp +++ b/tests/FilesT.cpp @@ -23,13 +23,13 @@ #include "Synth.h" #include "catch2/catch.hpp" -#include +#include "../sfizz/compat/filesystem.h" using namespace Catch::literals; TEST_CASE("[Files] Single region (regions_one.sfz)") { sfz::Synth synth; - synth.loadSfzFile(std::filesystem::current_path() / "tests/TestFiles/Regions/regions_one.sfz"); + synth.loadSfzFile(fs::current_path() / "tests/TestFiles/Regions/regions_one.sfz"); REQUIRE(synth.getNumRegions() == 1); REQUIRE(synth.getRegionView(0)->sample == "dummy.wav"); } @@ -38,7 +38,7 @@ TEST_CASE("[Files] Single region (regions_one.sfz)") TEST_CASE("[Files] Multiple regions (regions_many.sfz)") { sfz::Synth synth; - synth.loadSfzFile(std::filesystem::current_path() / "tests/TestFiles/Regions/regions_many.sfz"); + synth.loadSfzFile(fs::current_path() / "tests/TestFiles/Regions/regions_many.sfz"); REQUIRE(synth.getNumRegions() == 3); REQUIRE(synth.getRegionView(0)->sample == "dummy.wav"); REQUIRE(synth.getRegionView(1)->sample == "dummy.1.wav"); @@ -48,7 +48,7 @@ TEST_CASE("[Files] Multiple regions (regions_many.sfz)") TEST_CASE("[Files] Basic opcodes (regions_opcodes.sfz)") { sfz::Synth synth; - synth.loadSfzFile(std::filesystem::current_path() / "tests/TestFiles/Regions/regions_opcodes.sfz"); + synth.loadSfzFile(fs::current_path() / "tests/TestFiles/Regions/regions_opcodes.sfz"); REQUIRE(synth.getNumRegions() == 1); REQUIRE(synth.getRegionView(0)->channelRange == Range(2, 14)); } @@ -56,7 +56,7 @@ TEST_CASE("[Files] Basic opcodes (regions_opcodes.sfz)") TEST_CASE("[Files] Underscore opcodes (underscore_opcodes.sfz)") { sfz::Synth synth; - synth.loadSfzFile(std::filesystem::current_path() / "tests/TestFiles/Regions/underscore_opcodes.sfz"); + synth.loadSfzFile(fs::current_path() / "tests/TestFiles/Regions/underscore_opcodes.sfz"); REQUIRE(synth.getNumRegions() == 1); REQUIRE(synth.getRegionView(0)->loopMode == SfzLoopMode::loop_sustain); } @@ -64,7 +64,7 @@ TEST_CASE("[Files] Underscore opcodes (underscore_opcodes.sfz)") TEST_CASE("[Files] Local include") { sfz::Synth synth; - synth.loadSfzFile(std::filesystem::current_path() / "tests/TestFiles/Includes/root_local.sfz"); + synth.loadSfzFile(fs::current_path() / "tests/TestFiles/Includes/root_local.sfz"); REQUIRE(synth.getNumRegions() == 1); REQUIRE(synth.getRegionView(0)->sample == "dummy.wav"); } @@ -72,7 +72,7 @@ TEST_CASE("[Files] Local include") TEST_CASE("[Files] Multiple includes") { sfz::Synth synth; - synth.loadSfzFile(std::filesystem::current_path() / "tests/TestFiles/Includes/multiple_includes.sfz"); + synth.loadSfzFile(fs::current_path() / "tests/TestFiles/Includes/multiple_includes.sfz"); REQUIRE(synth.getNumRegions() == 2); REQUIRE(synth.getRegionView(0)->sample == "dummy.wav"); REQUIRE(synth.getRegionView(1)->sample == "dummy2.wav"); @@ -81,7 +81,7 @@ TEST_CASE("[Files] Multiple includes") TEST_CASE("[Files] Multiple includes with comments") { sfz::Synth synth; - synth.loadSfzFile(std::filesystem::current_path() / "tests/TestFiles/Includes/multiple_includes_with_comments.sfz"); + synth.loadSfzFile(fs::current_path() / "tests/TestFiles/Includes/multiple_includes_with_comments.sfz"); REQUIRE(synth.getNumRegions() == 2); REQUIRE(synth.getRegionView(0)->sample == "dummy.wav"); REQUIRE(synth.getRegionView(1)->sample == "dummy2.wav"); @@ -90,7 +90,7 @@ TEST_CASE("[Files] Multiple includes with comments") TEST_CASE("[Files] Subdir include") { sfz::Synth synth; - synth.loadSfzFile(std::filesystem::current_path() / "tests/TestFiles/Includes/root_subdir.sfz"); + synth.loadSfzFile(fs::current_path() / "tests/TestFiles/Includes/root_subdir.sfz"); REQUIRE(synth.getNumRegions() == 1); REQUIRE(synth.getRegionView(0)->sample == "dummy_subdir.wav"); } @@ -98,7 +98,7 @@ TEST_CASE("[Files] Subdir include") TEST_CASE("[Files] Subdir include Win") { sfz::Synth synth; - synth.loadSfzFile(std::filesystem::current_path() / "tests/TestFiles/Includes/root_subdir_win.sfz"); + synth.loadSfzFile(fs::current_path() / "tests/TestFiles/Includes/root_subdir_win.sfz"); REQUIRE(synth.getNumRegions() == 1); REQUIRE(synth.getRegionView(0)->sample == "dummy_subdir.wav"); } @@ -107,7 +107,7 @@ TEST_CASE("[Files] Recursive include (with include guard)") { sfz::Synth synth; synth.enableRecursiveIncludeGuard(); - synth.loadSfzFile(std::filesystem::current_path() / "tests/TestFiles/Includes/root_recursive.sfz"); + synth.loadSfzFile(fs::current_path() / "tests/TestFiles/Includes/root_recursive.sfz"); REQUIRE(synth.getNumRegions() == 2); REQUIRE(synth.getRegionView(0)->sample == "dummy_recursive2.wav"); REQUIRE(synth.getRegionView(1)->sample == "dummy_recursive1.wav"); @@ -117,7 +117,7 @@ TEST_CASE("[Files] Include loops (with include guard)") { sfz::Synth synth; synth.enableRecursiveIncludeGuard(); - synth.loadSfzFile(std::filesystem::current_path() / "tests/TestFiles/Includes/root_loop.sfz"); + synth.loadSfzFile(fs::current_path() / "tests/TestFiles/Includes/root_loop.sfz"); REQUIRE(synth.getNumRegions() == 2); REQUIRE(synth.getRegionView(0)->sample == "dummy_loop2.wav"); REQUIRE(synth.getRegionView(1)->sample == "dummy_loop1.wav"); @@ -126,7 +126,7 @@ TEST_CASE("[Files] Include loops (with include guard)") TEST_CASE("[Files] Define test") { sfz::Synth synth; - synth.loadSfzFile(std::filesystem::current_path() / "tests/TestFiles/defines.sfz"); + synth.loadSfzFile(fs::current_path() / "tests/TestFiles/defines.sfz"); REQUIRE(synth.getNumRegions() == 3); REQUIRE(synth.getRegionView(0)->keyRange == Range(36, 36)); REQUIRE(synth.getRegionView(1)->keyRange == Range(38, 38)); @@ -136,7 +136,7 @@ TEST_CASE("[Files] Define test") TEST_CASE("[Files] Group from AVL") { sfz::Synth synth; - synth.loadSfzFile(std::filesystem::current_path() / "tests/TestFiles/groups_avl.sfz"); + synth.loadSfzFile(fs::current_path() / "tests/TestFiles/groups_avl.sfz"); REQUIRE(synth.getNumRegions() == 5); for (int i = 0; i < synth.getNumRegions(); ++i) { REQUIRE(synth.getRegionView(i)->volume == 6.0f); @@ -152,7 +152,7 @@ TEST_CASE("[Files] Group from AVL") TEST_CASE("[Files] Full hierarchy") { sfz::Synth synth; - synth.loadSfzFile(std::filesystem::current_path() / "tests/TestFiles/basic_hierarchy.sfz"); + synth.loadSfzFile(fs::current_path() / "tests/TestFiles/basic_hierarchy.sfz"); REQUIRE(synth.getNumRegions() == 8); for (int i = 0; i < synth.getNumRegions(); ++i) { REQUIRE(synth.getRegionView(i)->width == 40.0f); @@ -193,9 +193,9 @@ TEST_CASE("[Files] Full hierarchy") TEST_CASE("[Files] Reloading files") { sfz::Synth synth; - synth.loadSfzFile(std::filesystem::current_path() / "tests/TestFiles/basic_hierarchy.sfz"); + synth.loadSfzFile(fs::current_path() / "tests/TestFiles/basic_hierarchy.sfz"); REQUIRE(synth.getNumRegions() == 8); - synth.loadSfzFile(std::filesystem::current_path() / "tests/TestFiles/basic_hierarchy.sfz"); + synth.loadSfzFile(fs::current_path() / "tests/TestFiles/basic_hierarchy.sfz"); REQUIRE(synth.getNumRegions() == 8); } @@ -203,7 +203,7 @@ TEST_CASE("[Files] Full hierarchy with antislashes") { { sfz::Synth synth; - synth.loadSfzFile(std::filesystem::current_path() / "tests/TestFiles/basic_hierarchy.sfz"); + synth.loadSfzFile(fs::current_path() / "tests/TestFiles/basic_hierarchy.sfz"); REQUIRE(synth.getNumRegions() == 8); REQUIRE(synth.getRegionView(0)->sample == "Regions/dummy.wav"); REQUIRE(synth.getRegionView(1)->sample == "Regions/dummy.1.wav"); @@ -217,7 +217,7 @@ TEST_CASE("[Files] Full hierarchy with antislashes") { sfz::Synth synth; - synth.loadSfzFile(std::filesystem::current_path() / "tests/TestFiles/basic_hierarchy_antislash.sfz"); + synth.loadSfzFile(fs::current_path() / "tests/TestFiles/basic_hierarchy_antislash.sfz"); REQUIRE(synth.getNumRegions() == 8); REQUIRE(synth.getRegionView(0)->sample == "Regions/dummy.wav"); REQUIRE(synth.getRegionView(1)->sample == "Regions/dummy.1.wav"); @@ -233,7 +233,7 @@ TEST_CASE("[Files] Full hierarchy with antislashes") TEST_CASE("[Files] Pizz basic") { sfz::Synth synth; - synth.loadSfzFile(std::filesystem::current_path() / "tests/TestFiles/SpecificBugs/MeatBassPizz/Programs/pizz.sfz"); + synth.loadSfzFile(fs::current_path() / "tests/TestFiles/SpecificBugs/MeatBassPizz/Programs/pizz.sfz"); REQUIRE(synth.getNumRegions() == 4); for (int i = 0; i < synth.getNumRegions(); ++i) { REQUIRE(synth.getRegionView(i)->keyRange == Range(12, 22)); @@ -254,7 +254,7 @@ TEST_CASE("[Files] Pizz basic") TEST_CASE("[Files] Channels (channels.sfz)") { sfz::Synth synth; - synth.loadSfzFile(std::filesystem::current_path() / "tests/TestFiles/channels.sfz"); + synth.loadSfzFile(fs::current_path() / "tests/TestFiles/channels.sfz"); REQUIRE(synth.getNumRegions() == 2); REQUIRE(synth.getRegionView(0)->sample == "mono_sample.wav"); REQUIRE(!synth.getRegionView(0)->isStereo()); @@ -265,7 +265,7 @@ TEST_CASE("[Files] Channels (channels.sfz)") TEST_CASE("[Files] sw_default") { sfz::Synth synth; - synth.loadSfzFile(std::filesystem::current_path() / "tests/TestFiles/sw_default.sfz"); + synth.loadSfzFile(fs::current_path() / "tests/TestFiles/sw_default.sfz"); REQUIRE( synth.getNumRegions() == 4 ); REQUIRE( !synth.getRegionView(0)->isSwitchedOn() ); REQUIRE( synth.getRegionView(1)->isSwitchedOn() ); @@ -276,7 +276,7 @@ TEST_CASE("[Files] sw_default") TEST_CASE("[Files] sw_default and playing with switches") { sfz::Synth synth; - synth.loadSfzFile(std::filesystem::current_path() / "tests/TestFiles/sw_default.sfz"); + synth.loadSfzFile(fs::current_path() / "tests/TestFiles/sw_default.sfz"); REQUIRE( synth.getNumRegions() == 4 ); REQUIRE( !synth.getRegionView(0)->isSwitchedOn() ); REQUIRE( synth.getRegionView(1)->isSwitchedOn() ); @@ -306,7 +306,7 @@ TEST_CASE("[Files] sw_default and playing with switches") TEST_CASE("[Files] wrong (overlapping) replacement for defines") { sfz::Synth synth; - synth.loadSfzFile(std::filesystem::current_path() / "tests/TestFiles/SpecificBugs/wrong-replacements.sfz"); + synth.loadSfzFile(fs::current_path() / "tests/TestFiles/SpecificBugs/wrong-replacements.sfz"); REQUIRE( synth.getNumRegions() == 3 ); REQUIRE( synth.getRegionView(0)->keyRange.getStart() == 52 ); REQUIRE( synth.getRegionView(0)->keyRange.getEnd() == 52 ); diff --git a/tests/OnePoleFilterT.cpp b/tests/OnePoleFilterT.cpp index 14cadcaf..c33000e5 100644 --- a/tests/OnePoleFilterT.cpp +++ b/tests/OnePoleFilterT.cpp @@ -46,7 +46,7 @@ inline bool approxEqual(const std::vector& lhs, const std::vector& r } template -void testLowpass(const std::filesystem::path& inputNumpyFile, const std::filesystem::path& outputNumpyFile, Type gain) +void testLowpass(const fs::path& inputNumpyFile, const fs::path& outputNumpyFile, Type gain) { const auto input = cnpy::npy_load(inputNumpyFile.string()); REQUIRE(input.word_size == 8); @@ -81,7 +81,7 @@ void testLowpass(const std::filesystem::path& inputNumpyFile, const std::filesys } template -void testHighpass(const std::filesystem::path& inputNumpyFile, const std::filesystem::path& outputNumpyFile, Type gain) +void testHighpass(const fs::path& inputNumpyFile, const fs::path& outputNumpyFile, Type gain) { const auto input = cnpy::npy_load(inputNumpyFile.string()); REQUIRE(input.word_size == 8); @@ -118,95 +118,95 @@ void testHighpass(const std::filesystem::path& inputNumpyFile, const std::filesy TEST_CASE("[OnePoleFilter] Lowpass Float") { testLowpass( - std::filesystem::current_path() / "tests/TestFiles/OnePoleFilter/OPF_input_gain_0.1.npy", - std::filesystem::current_path() / "tests/TestFiles/OnePoleFilter/OPF_low_gain_0.1.npy", + fs::current_path() / "tests/TestFiles/OnePoleFilter/OPF_input_gain_0.1.npy", + fs::current_path() / "tests/TestFiles/OnePoleFilter/OPF_low_gain_0.1.npy", 0.1f); testLowpass( - std::filesystem::current_path() / "tests/TestFiles/OnePoleFilter/OPF_input_gain_0.3.npy", - std::filesystem::current_path() / "tests/TestFiles/OnePoleFilter/OPF_low_gain_0.3.npy", + fs::current_path() / "tests/TestFiles/OnePoleFilter/OPF_input_gain_0.3.npy", + fs::current_path() / "tests/TestFiles/OnePoleFilter/OPF_low_gain_0.3.npy", 0.3f); testLowpass( - std::filesystem::current_path() / "tests/TestFiles/OnePoleFilter/OPF_input_gain_0.5.npy", - std::filesystem::current_path() / "tests/TestFiles/OnePoleFilter/OPF_low_gain_0.5.npy", + fs::current_path() / "tests/TestFiles/OnePoleFilter/OPF_input_gain_0.5.npy", + fs::current_path() / "tests/TestFiles/OnePoleFilter/OPF_low_gain_0.5.npy", 0.5f); testLowpass( - std::filesystem::current_path() / "tests/TestFiles/OnePoleFilter/OPF_input_gain_0.7.npy", - std::filesystem::current_path() / "tests/TestFiles/OnePoleFilter/OPF_low_gain_0.7.npy", + fs::current_path() / "tests/TestFiles/OnePoleFilter/OPF_input_gain_0.7.npy", + fs::current_path() / "tests/TestFiles/OnePoleFilter/OPF_low_gain_0.7.npy", 0.7f); testLowpass( - std::filesystem::current_path() / "tests/TestFiles/OnePoleFilter/OPF_input_gain_0.9.npy", - std::filesystem::current_path() / "tests/TestFiles/OnePoleFilter/OPF_low_gain_0.9.npy", + fs::current_path() / "tests/TestFiles/OnePoleFilter/OPF_input_gain_0.9.npy", + fs::current_path() / "tests/TestFiles/OnePoleFilter/OPF_low_gain_0.9.npy", 0.9f); } TEST_CASE("[OnePoleFilter] Lowpass Double") { testLowpass( - std::filesystem::current_path() / "tests/TestFiles/OnePoleFilter/OPF_input_gain_0.1.npy", - std::filesystem::current_path() / "tests/TestFiles/OnePoleFilter/OPF_low_gain_0.1.npy", + fs::current_path() / "tests/TestFiles/OnePoleFilter/OPF_input_gain_0.1.npy", + fs::current_path() / "tests/TestFiles/OnePoleFilter/OPF_low_gain_0.1.npy", 0.1f); testLowpass( - std::filesystem::current_path() / "tests/TestFiles/OnePoleFilter/OPF_input_gain_0.3.npy", - std::filesystem::current_path() / "tests/TestFiles/OnePoleFilter/OPF_low_gain_0.3.npy", + fs::current_path() / "tests/TestFiles/OnePoleFilter/OPF_input_gain_0.3.npy", + fs::current_path() / "tests/TestFiles/OnePoleFilter/OPF_low_gain_0.3.npy", 0.3f); testLowpass( - std::filesystem::current_path() / "tests/TestFiles/OnePoleFilter/OPF_input_gain_0.5.npy", - std::filesystem::current_path() / "tests/TestFiles/OnePoleFilter/OPF_low_gain_0.5.npy", + fs::current_path() / "tests/TestFiles/OnePoleFilter/OPF_input_gain_0.5.npy", + fs::current_path() / "tests/TestFiles/OnePoleFilter/OPF_low_gain_0.5.npy", 0.5f); testLowpass( - std::filesystem::current_path() / "tests/TestFiles/OnePoleFilter/OPF_input_gain_0.7.npy", - std::filesystem::current_path() / "tests/TestFiles/OnePoleFilter/OPF_low_gain_0.7.npy", + fs::current_path() / "tests/TestFiles/OnePoleFilter/OPF_input_gain_0.7.npy", + fs::current_path() / "tests/TestFiles/OnePoleFilter/OPF_low_gain_0.7.npy", 0.7f); testLowpass( - std::filesystem::current_path() / "tests/TestFiles/OnePoleFilter/OPF_input_gain_0.9.npy", - std::filesystem::current_path() / "tests/TestFiles/OnePoleFilter/OPF_low_gain_0.9.npy", + fs::current_path() / "tests/TestFiles/OnePoleFilter/OPF_input_gain_0.9.npy", + fs::current_path() / "tests/TestFiles/OnePoleFilter/OPF_low_gain_0.9.npy", 0.9f); } TEST_CASE("[OnePoleFilter] Highpass Float") { testHighpass( - std::filesystem::current_path() / "tests/TestFiles/OnePoleFilter/OPF_input_gain_0.1.npy", - std::filesystem::current_path() / "tests/TestFiles/OnePoleFilter/OPF_high_gain_0.1.npy", + fs::current_path() / "tests/TestFiles/OnePoleFilter/OPF_input_gain_0.1.npy", + fs::current_path() / "tests/TestFiles/OnePoleFilter/OPF_high_gain_0.1.npy", 0.1f); testHighpass( - std::filesystem::current_path() / "tests/TestFiles/OnePoleFilter/OPF_input_gain_0.3.npy", - std::filesystem::current_path() / "tests/TestFiles/OnePoleFilter/OPF_high_gain_0.3.npy", + fs::current_path() / "tests/TestFiles/OnePoleFilter/OPF_input_gain_0.3.npy", + fs::current_path() / "tests/TestFiles/OnePoleFilter/OPF_high_gain_0.3.npy", 0.3f); testHighpass( - std::filesystem::current_path() / "tests/TestFiles/OnePoleFilter/OPF_input_gain_0.5.npy", - std::filesystem::current_path() / "tests/TestFiles/OnePoleFilter/OPF_high_gain_0.5.npy", + fs::current_path() / "tests/TestFiles/OnePoleFilter/OPF_input_gain_0.5.npy", + fs::current_path() / "tests/TestFiles/OnePoleFilter/OPF_high_gain_0.5.npy", 0.5f); testHighpass( - std::filesystem::current_path() / "tests/TestFiles/OnePoleFilter/OPF_input_gain_0.7.npy", - std::filesystem::current_path() / "tests/TestFiles/OnePoleFilter/OPF_high_gain_0.7.npy", + fs::current_path() / "tests/TestFiles/OnePoleFilter/OPF_input_gain_0.7.npy", + fs::current_path() / "tests/TestFiles/OnePoleFilter/OPF_high_gain_0.7.npy", 0.7f); testHighpass( - std::filesystem::current_path() / "tests/TestFiles/OnePoleFilter/OPF_input_gain_0.9.npy", - std::filesystem::current_path() / "tests/TestFiles/OnePoleFilter/OPF_high_gain_0.9.npy", + fs::current_path() / "tests/TestFiles/OnePoleFilter/OPF_input_gain_0.9.npy", + fs::current_path() / "tests/TestFiles/OnePoleFilter/OPF_high_gain_0.9.npy", 0.9f); } TEST_CASE("[OnePoleFilter] Highpass Double") { testHighpass( - std::filesystem::current_path() / "tests/TestFiles/OnePoleFilter/OPF_input_gain_0.1.npy", - std::filesystem::current_path() / "tests/TestFiles/OnePoleFilter/OPF_high_gain_0.1.npy", + fs::current_path() / "tests/TestFiles/OnePoleFilter/OPF_input_gain_0.1.npy", + fs::current_path() / "tests/TestFiles/OnePoleFilter/OPF_high_gain_0.1.npy", 0.1f); testHighpass( - std::filesystem::current_path() / "tests/TestFiles/OnePoleFilter/OPF_input_gain_0.3.npy", - std::filesystem::current_path() / "tests/TestFiles/OnePoleFilter/OPF_high_gain_0.3.npy", + fs::current_path() / "tests/TestFiles/OnePoleFilter/OPF_input_gain_0.3.npy", + fs::current_path() / "tests/TestFiles/OnePoleFilter/OPF_high_gain_0.3.npy", 0.3f); testHighpass( - std::filesystem::current_path() / "tests/TestFiles/OnePoleFilter/OPF_input_gain_0.5.npy", - std::filesystem::current_path() / "tests/TestFiles/OnePoleFilter/OPF_high_gain_0.5.npy", + fs::current_path() / "tests/TestFiles/OnePoleFilter/OPF_input_gain_0.5.npy", + fs::current_path() / "tests/TestFiles/OnePoleFilter/OPF_high_gain_0.5.npy", 0.5f); testHighpass( - std::filesystem::current_path() / "tests/TestFiles/OnePoleFilter/OPF_input_gain_0.7.npy", - std::filesystem::current_path() / "tests/TestFiles/OnePoleFilter/OPF_high_gain_0.7.npy", + fs::current_path() / "tests/TestFiles/OnePoleFilter/OPF_input_gain_0.7.npy", + fs::current_path() / "tests/TestFiles/OnePoleFilter/OPF_high_gain_0.7.npy", 0.7f); testHighpass( - std::filesystem::current_path() / "tests/TestFiles/OnePoleFilter/OPF_input_gain_0.9.npy", - std::filesystem::current_path() / "tests/TestFiles/OnePoleFilter/OPF_high_gain_0.9.npy", + fs::current_path() / "tests/TestFiles/OnePoleFilter/OPF_input_gain_0.9.npy", + fs::current_path() / "tests/TestFiles/OnePoleFilter/OPF_high_gain_0.9.npy", 0.9f); }