This commit is contained in:
paulfd 2019-09-21 13:01:50 +02:00
parent 41010019e3
commit 105c459a4a
16 changed files with 156 additions and 147 deletions

View file

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

View file

@ -41,13 +41,14 @@ void lowpass(absl::Span<const float> input, absl::Span<float> 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<const float> input, absl::Span<float> 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<const float> input, absl::Span<float> 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<const float> input, absl::Span<float> 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<float> input(state.range(0));
std::vector<float> output(state.range(0));
std::random_device rd { };
std::mt19937 gen { rd() };
std::normal_distribution<float> 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<float> input(state.range(0));
std::vector<float> 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();

View file

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

View file

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

2
external/abseil-cpp vendored

@ -1 +1 @@
Subproject commit aa844899c937bde5d2b24f276b59997e5b668bde
Subproject commit ac78ffc3bc0a8b295cab9a03817760fd460df2a1

2
external/benchmark vendored

@ -1 +1 @@
Subproject commit 090faecb454fbd6e6e17a75ef8146acb037118d4
Subproject commit bf4f2ea0bd1180b34718ac26eb79b170a4f6290e

View file

@ -36,24 +36,59 @@ endif()
set(SFIZZ_SOURCES ${SFIZZ_SOURCES} ${SFIZZ_SIMD_SOURCES})
# include(CheckCXXSourceCompiles)
# check_cxx_source_compiles("
# #include <filesystem>
# 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)

View file

@ -50,8 +50,8 @@ std::unique_ptr<AudioBuffer<T>> readFromFile(SndfileHandle& sndFile, int numFram
absl::optional<sfz::FilePool::FileInformation> 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<const char*>(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;
}

View file

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

View file

@ -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<std::string>& lines) noexcept
void sfz::Parser::readSfzFile(const fs::path& fileName, std::vector<std::string>& 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);

View file

@ -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<std::string, std::string>& getDefines() const noexcept { return defines; }
const std::vector<std::filesystem::path>& getIncludedFiles() const noexcept { return includedFiles; }
const std::vector<fs::path>& getIncludedFiles() const noexcept { return includedFiles; }
void disableRecursiveIncludeGuard() { recursiveIncludeGuard = false; }
void enableRecursiveIncludeGuard() { recursiveIncludeGuard = true; }
protected:
virtual void callback(absl::string_view header, const std::vector<Opcode>& members) = 0;
std::filesystem::path rootDirectory { std::filesystem::current_path() };
fs::path rootDirectory { fs::current_path() };
private:
bool recursiveIncludeGuard { false };
std::map<std::string, std::string> defines;
std::vector<std::filesystem::path> includedFiles;
std::vector<fs::path> includedFiles;
std::string aggregatedContent {};
void readSfzFile(const std::filesystem::path& fileName, std::vector<std::string>& lines) noexcept;
void readSfzFile(const fs::path& fileName, std::vector<std::string>& lines) noexcept;
};
} // namespace sfz

View file

@ -152,8 +152,8 @@ void sfz::Synth::handleControlOpcodes(const std::vector<Opcode>& 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) {

View file

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

View file

@ -1,15 +1,16 @@
#pragma once
#ifdef __cplusplus
#if (__cplusplus >= 201703L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)
#include <filesystem>
#elif (__cplusplus >= 201402L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201402L)
#warning std::experimental::filesystem in use
#include <experimental/filesystem>
namespace std {
namespace filesystem = std::experimental::filesystem;
}
#endif
#ifdef USE_STD_FILESYSTEM
#warning FS
#include <filesystem>
namespace fs = std::filesystem;
#else
#error no filesystem support
#warning EXPFS
#include <experimental/filesystem>
namespace fs = std::experimental::filesystem;
#endif
// #if __cplusplus < 201703L
// #warning EXPFSNS
// #else
// #warning FSNS
// #endif

View file

@ -23,13 +23,13 @@
#include "Synth.h"
#include "catch2/catch.hpp"
#include <filesystem>
#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<uint8_t>(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<uint8_t>(36, 36));
REQUIRE(synth.getRegionView(1)->keyRange == Range<uint8_t>(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<uint8_t>(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 );

View file

@ -46,7 +46,7 @@ inline bool approxEqual(const std::vector<Type>& lhs, const std::vector<Type>& r
}
template <class Type>
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 <class Type>
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<float>(
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<float>(
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<float>(
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<float>(
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<float>(
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<double>(
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<double>(
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<double>(
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<double>(
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<double>(
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<float>(
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<float>(
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<float>(
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<float>(
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<float>(
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<double>(
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<double>(
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<double>(
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<double>(
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<double>(
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);
}