From ad65d8346c775ec68b0793bf21fd7ca3a33e43bb Mon Sep 17 00:00:00 2001 From: paulfd Date: Tue, 17 Sep 2019 14:53:09 +0200 Subject: [PATCH 01/26] added the cmake switch --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d42c1a5e..e76e3d67 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.13) project(sfizz VERSION 1.0.0 LANGUAGES CXX) # Set the highest possible standard -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 14) if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT ANDROID) add_compile_options(-stdlib=libc++) From a58ba1e7660410822c5aabeb7220d8f36153d436 Mon Sep 17 00:00:00 2001 From: paulfd Date: Tue, 17 Sep 2019 14:53:09 +0200 Subject: [PATCH 02/26] added the cmake switch --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d42c1a5e..e76e3d67 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.13) project(sfizz VERSION 1.0.0 LANGUAGES CXX) # Set the highest possible standard -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 14) if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT ANDROID) add_compile_options(-stdlib=libc++) From 257764ba354e0ab0545c1d448e13461ecfd67af6 Mon Sep 17 00:00:00 2001 From: paulfd Date: Tue, 17 Sep 2019 14:53:09 +0200 Subject: [PATCH 03/26] added the cmake switch --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b9b5c6f3..9dbcfaf0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.13) project(sfizz VERSION 1.0.0 LANGUAGES CXX) # Set the highest possible standard -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 14) if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT ANDROID) add_compile_options(-stdlib=libc++) From 2d1a4341d73f182f1b682702f342e5d94c6b295b Mon Sep 17 00:00:00 2001 From: redtide Date: Wed, 18 Sep 2019 09:13:36 +0200 Subject: [PATCH 04/26] Added Travis CI configuration. --- .travis.yml | 40 +++++++++++++++++++++++++++++++++++++++ .travis/after_success.sh | 19 +++++++++++++++++++ .travis/before_install.sh | 12 ++++++++++++ .travis/install.sh | 7 +++++++ .travis/script.sh | 16 ++++++++++++++++ README.md | 5 ++++- 6 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 .travis.yml create mode 100755 .travis/after_success.sh create mode 100755 .travis/before_install.sh create mode 100755 .travis/install.sh create mode 100755 .travis/script.sh diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..c039afda --- /dev/null +++ b/.travis.yml @@ -0,0 +1,40 @@ +language: cpp + +matrix: + include: + - os: linux + dist: xenial + addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - gcc-8 + - g++-8 + env: + - MATRIX_EVAL="CC=gcc-8 && CXX=g++-8" + + - os: osx + osx_image: xcode10.1 + +before_install: +- sh ${TRAVIS_BUILD_DIR}/.travis/before_install.sh + +install: +- sh ${TRAVIS_BUILD_DIR}/.travis/install.sh + +script: +- sh ${TRAVIS_BUILD_DIR}/.travis/script.sh + +after_success: +- sh ${TRAVIS_BUILD_DIR}/.travis/after_success.sh + +deploy: + provider: releases + skip_cleanup: true + api_key: + secure: cc6IkdalZRb+lOWzPkubCUvTcP9lBwiNBBPkXWVmeX7YXkdQlsoVQ11bZThd1Go+5Lt+jGFtEqEjJ0L7GxpdatEeBMEK5HXl0QtHAybl9J4Ax7hKba8FSX5RqPFOuKixCob6eCqJRchT26qRsQE/WYMY8DmproEFGMBHk0K4HXDWEq0HP8dbWVx3KudvellCYszUrVQYb2s49sDiF8OwSog5TiqdBqO5PRcqyt2ySmHgqwBYq7XV0pb+DxcKJcc7/gCBpBN7nyEhl8gmKELypLF81l8xUDBUjRy1jjf0r33ISHpX1MWeWIN9YzSNL0aLPQvwynAQ7OeckFAIMABah2UuYcxdd4ioXduPTbprVYpSwIyyxkeafK2jxgxwoKWi9GJZ3yAUHNS/V7Gh5DsFb7C6QDqr5gOxOMtjHwjmHnxmD44SsugjSosVzirvQR+JbrSsPsmZThQjCvwG+7hO3JatX4BXA7bp9WtgsoMrCH61gCp2GogQVLvYpgRpVErKK8PMTkt71OouewTDqD5iwc3N/2pNWP3cXxpPegerjl4R2sY0sZ57WRfW8ts7akPyqJZa2uKpzpM0eXy35fZl6WoJSlIv3akCnzdtLtaWAptzfXhgRSlF/33+gZ3jRcSP7ca2YpUviuZ+KYk+uGfMh092CMRMjPv1Et5h7zYGD+o= + file: "$DEPLOYFILE" + on: + repo: sfztools/sfizz + tags: true diff --git a/.travis/after_success.sh b/.travis/after_success.sh new file mode 100755 index 00000000..8acde8a9 --- /dev/null +++ b/.travis/after_success.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +set -e + +export VERSION=$(git describe --tags) +if [ "$TRAVIS_OS_NAME" = "linux" ]; then + export DEPLOYFILE=Sfizz-$VERSION-x86_64.AppImage + wget -c -nv "https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage" + chmod +x linuxdeploy-x86_64.AppImage + for size in 16 32 48 128 256; do dirname="sfizz/usr/share/icons/hicolor/${size}x${size}/apps"; mkdir -p $dirname; cp ./resources/icons/icon_${size}px.png ./${dirname}/sfizz.png; done + ./linuxdeploy-x86_64.AppImage --appdir=sfizz --desktop-file=./resources/linux/sfizz.desktop --executable=./build/clients/sfizz_jack --output=appimage +elif [ "$TRAVIS_OS_NAME" = "osx" ]; then + export DEPLOYFILE=sfizz-$VERSION.dmg + mkdir ./output + cp -r /build/* ./output/ + cp ./resources/icons/icon.icns ./output/sfizz.app/Contents/Resources/ + hdiutil create /tmp/tmp.dmg -ov -volname "sfizz-$VERSION" -fs HFS+ -srcfolder "./output/" + hdiutil convert /tmp/tmp.dmg -format UDZO -o ./$DEPLOYFILE; +fi diff --git a/.travis/before_install.sh b/.travis/before_install.sh new file mode 100755 index 00000000..d806bf92 --- /dev/null +++ b/.travis/before_install.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +set -e + +if [ "$TRAVIS_OS_NAME" = "linux" ]; then + wget https://cmake.org/files/v3.13/cmake-3.13.0-Linux-x86_64.sh + sudo sh cmake-3.13.0-Linux-x86_64.sh --skip-license --prefix=/usr/local + export PATH="/usr/local/bin:$PATH" # FIXME +elif [ "$TRAVIS_OS_NAME" = "osx" ]; then + brew update + brew upgrade cmake +fi diff --git a/.travis/install.sh b/.travis/install.sh new file mode 100755 index 00000000..fff4aa8a --- /dev/null +++ b/.travis/install.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +set -e + +if [ "$TRAVIS_OS_NAME" = "linux" ]; then + sudo apt-get install libasound2-dev libjack-jackd2-dev libsndfile1-dev +fi diff --git a/.travis/script.sh b/.travis/script.sh new file mode 100755 index 00000000..fa98dd09 --- /dev/null +++ b/.travis/script.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +set -e + +if [ "$TRAVIS_OS_NAME" = "linux" ]; then + sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-8 100 + gcc -v && g++ -v && cmake --version && /usr/local/bin/cmake --version && $SHELL --version + + mkdir build && cd build + /usr/local/bin/cmake -D CMAKE_BUILD_TYPE=Release -D SFIZZ_CLIENTS=ON .. + make -j$(nproc) +elif [ "$TRAVIS_OS_NAME" = "osx" ]; then + mkdir build && cd build + cmake -D CMAKE_BUILD_TYPE=Release -D SFIZZ_CLIENTS=ON -G Xcode .. + xcodebuild -project sfizz.xcodeproj -alltargets -configuration Release build +fi diff --git a/README.md b/README.md index 5db5060a..5c6fc71a 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ # sfizz +[![Travis](https://img.shields.io/travis/com/sfztools/sfizz.svg?label=Linux-macOS&style=popout&logo=travis)](https://travis-ci.com/sfztools/sfizz) +[![AppVeyor](https://img.shields.io/appveyor/ci/sfztools/sfizz.svg?label=Windows&style=popout&logo=appveyor)](https://ci.appveyor.com/project/sfztools/sfizz) + ## Building Sfizz depends on the `sndfile` library. @@ -37,4 +40,4 @@ If you already cloned the repository without the `--recursive` option, update th git submodule update --init --recursive ``` -You can build with `clang`, although in that case the CMakeFile defaults to using `libc++` instead of `libstdc++`. \ No newline at end of file +You can build with `clang`, although in that case the CMakeFile defaults to using `libc++` instead of `libstdc++`. From 72c34b657878f79d2a0e5a711b07af0582cd58e1 Mon Sep 17 00:00:00 2001 From: redtide Date: Wed, 18 Sep 2019 09:15:37 +0200 Subject: [PATCH 05/26] Added QtCreator CMake project files to .gitignore. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index e9bc5de1..7feb15e6 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ CMakeFiles/ cmake_install.cmake compile_commands.json *.a +*.txt.user clients/sfizz_jack clients/sfzprint From 080bdf45098b4218bf2d4fca59671472782f80ef Mon Sep 17 00:00:00 2001 From: redtide Date: Wed, 18 Sep 2019 09:23:29 +0200 Subject: [PATCH 06/26] Update README.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 5c6fc71a..b1cf4f58 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # sfizz [![Travis](https://img.shields.io/travis/com/sfztools/sfizz.svg?label=Linux-macOS&style=popout&logo=travis)](https://travis-ci.com/sfztools/sfizz) -[![AppVeyor](https://img.shields.io/appveyor/ci/sfztools/sfizz.svg?label=Windows&style=popout&logo=appveyor)](https://ci.appveyor.com/project/sfztools/sfizz) ## Building From 77e8694dd076e28be36b3af3b279c866eb9128c7 Mon Sep 17 00:00:00 2001 From: redtide Date: Wed, 18 Sep 2019 10:12:32 +0200 Subject: [PATCH 07/26] Trying Travis badge hack. --- .travis.yml | 12 ++++++++++++ README.md | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c039afda..5bf359a3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,9 @@ language: cpp +env: +- BADGE=linux +- BADGE=macos + matrix: include: - os: linux @@ -17,6 +21,14 @@ matrix: - os: osx osx_image: xcode10.1 + # Hack to get some OS-specific badges + exclude: + - os: osx + env: BADGE=linux + + - os: linux + env: BADGE=macos + before_install: - sh ${TRAVIS_BUILD_DIR}/.travis/before_install.sh diff --git a/README.md b/README.md index b1cf4f58..19d86b7a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # sfizz -[![Travis](https://img.shields.io/travis/com/sfztools/sfizz.svg?label=Linux-macOS&style=popout&logo=travis)](https://travis-ci.com/sfztools/sfizz) +[![Travis Linux Build Status](https://img.shields.io/travis/com/sfztools/sfizz.svg?env=BADGE=linux&label=Linux&style=popout&logo=travis)](https://travis-ci.com/sfztools/sfizz) +[![Travis macOS Build Status](https://img.shields.io/travis/com/sfztools/sfizz.svg?env=BADGE=macos&label=macOS&style=popout&logo=travis)](https://travis-ci.com/sfztools/sfizz) ## Building From b9980906e267e1ba3b63b78c171837d8070a89d6 Mon Sep 17 00:00:00 2001 From: redtide Date: Wed, 18 Sep 2019 10:18:24 +0200 Subject: [PATCH 08/26] Trying Travis badge hack. --- .travis.yml | 8 ++++---- README.md | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5bf359a3..1831a1f1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,7 @@ language: cpp env: - BADGE=linux -- BADGE=macos +- BADGE=osx matrix: include: @@ -23,12 +23,12 @@ matrix: # Hack to get some OS-specific badges exclude: + - os: linux + env: BADGE=osx + - os: osx env: BADGE=linux - - os: linux - env: BADGE=macos - before_install: - sh ${TRAVIS_BUILD_DIR}/.travis/before_install.sh diff --git a/README.md b/README.md index 19d86b7a..18004108 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # sfizz [![Travis Linux Build Status](https://img.shields.io/travis/com/sfztools/sfizz.svg?env=BADGE=linux&label=Linux&style=popout&logo=travis)](https://travis-ci.com/sfztools/sfizz) -[![Travis macOS Build Status](https://img.shields.io/travis/com/sfztools/sfizz.svg?env=BADGE=macos&label=macOS&style=popout&logo=travis)](https://travis-ci.com/sfztools/sfizz) +[![Travis macOS Build Status](https://img.shields.io/travis/com/sfztools/sfizz.svg?env=BADGE=osx&label=macOS&style=popout&logo=travis)](https://travis-ci.com/sfztools/sfizz) ## Building From c82fac078eb34ddb48c95e07a6c9e57456c2cde8 Mon Sep 17 00:00:00 2001 From: redtide Date: Wed, 18 Sep 2019 10:24:13 +0200 Subject: [PATCH 09/26] Trying Travis badge hack. --- .travis.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1831a1f1..26bb6309 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,5 @@ language: cpp -env: -- BADGE=linux -- BADGE=osx - matrix: include: - os: linux @@ -17,9 +13,12 @@ matrix: - g++-8 env: - MATRIX_EVAL="CC=gcc-8 && CXX=g++-8" + - BADGE=linux - os: osx osx_image: xcode10.1 + env: + - BADGE=osx # Hack to get some OS-specific badges exclude: From 1b674c7e6abeca96c4f204094613b6ece8bb1259 Mon Sep 17 00:00:00 2001 From: redtide Date: Wed, 18 Sep 2019 11:28:09 +0200 Subject: [PATCH 10/26] Revert Travis hack. --- .travis.yml | 11 ----------- README.md | 3 +-- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/.travis.yml b/.travis.yml index 26bb6309..c039afda 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,20 +13,9 @@ matrix: - g++-8 env: - MATRIX_EVAL="CC=gcc-8 && CXX=g++-8" - - BADGE=linux - os: osx osx_image: xcode10.1 - env: - - BADGE=osx - - # Hack to get some OS-specific badges - exclude: - - os: linux - env: BADGE=osx - - - os: osx - env: BADGE=linux before_install: - sh ${TRAVIS_BUILD_DIR}/.travis/before_install.sh diff --git a/README.md b/README.md index 18004108..fdbe3e29 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # sfizz -[![Travis Linux Build Status](https://img.shields.io/travis/com/sfztools/sfizz.svg?env=BADGE=linux&label=Linux&style=popout&logo=travis)](https://travis-ci.com/sfztools/sfizz) -[![Travis macOS Build Status](https://img.shields.io/travis/com/sfztools/sfizz.svg?env=BADGE=osx&label=macOS&style=popout&logo=travis)](https://travis-ci.com/sfztools/sfizz) +[![Travis Build Status](https://img.shields.io/travis/com/sfztools/sfizz.svg?label=Linux-macOS&style=popout&logo=travis)](https://travis-ci.com/sfztools/sfizz) ## Building From 2523ba3db09f5c2d71cb92268a957e1e6289bc6e Mon Sep 17 00:00:00 2001 From: redtide Date: Wed, 18 Sep 2019 11:35:51 +0200 Subject: [PATCH 11/26] Updated abseil submodule. --- external/abseil-cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/abseil-cpp b/external/abseil-cpp index ac78ffc3..6ec13628 160000 --- a/external/abseil-cpp +++ b/external/abseil-cpp @@ -1 +1 @@ -Subproject commit ac78ffc3bc0a8b295cab9a03817760fd460df2a1 +Subproject commit 6ec136281086b71da32b5fb068bd6e46b78a5c79 From 7b79a6dfc97450ea4a56480c332e4efa80eb9b2e Mon Sep 17 00:00:00 2001 From: redtide Date: Wed, 18 Sep 2019 15:08:16 +0200 Subject: [PATCH 12/26] Moved abseil-cpp submodule to tag-20190808 (local branch). --- external/abseil-cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/abseil-cpp b/external/abseil-cpp index 6ec13628..aa844899 160000 --- a/external/abseil-cpp +++ b/external/abseil-cpp @@ -1 +1 @@ -Subproject commit 6ec136281086b71da32b5fb068bd6e46b78a5c79 +Subproject commit aa844899c937bde5d2b24f276b59997e5b668bde From 6d1363a9cd88bb97c36e7d632ded7f1e02f4bb63 Mon Sep 17 00:00:00 2001 From: redtide Date: Wed, 18 Sep 2019 15:08:16 +0200 Subject: [PATCH 13/26] Moved benchmark submodule to tag-v1.5.0 (local branch). --- external/benchmark | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/benchmark b/external/benchmark index bf4f2ea0..090faecb 160000 --- a/external/benchmark +++ b/external/benchmark @@ -1 +1 @@ -Subproject commit bf4f2ea0bd1180b34718ac26eb79b170a4f6290e +Subproject commit 090faecb454fbd6e6e17a75ef8146acb037118d4 From 024ac4d832541ba09d57ad7d3bc89fc6b66212d1 Mon Sep 17 00:00:00 2001 From: redtide Date: Wed, 18 Sep 2019 20:33:08 +0200 Subject: [PATCH 14/26] WIP fixes: replace optional, string_view, nullopt with abseil versions, temporary clamp alternative. --- clients/sfzprint.cpp | 2 +- sfizz/ADSREnvelope.cpp | 2 +- sfizz/Buffer.h | 5 +- sfizz/Defaults.h | 184 +++++++++++++++++++------------------- sfizz/EGDescription.h | 18 ++-- sfizz/FilePool.cpp | 7 +- sfizz/FilePool.h | 10 +-- sfizz/LinearEnvelope.h | 3 +- sfizz/Opcode.cpp | 4 +- sfizz/Opcode.h | 20 ++--- sfizz/Parser.cpp | 23 ++--- sfizz/Parser.h | 2 +- sfizz/Range.h | 4 +- sfizz/Region.h | 24 ++--- sfizz/SfzHelpers.cpp | 2 +- sfizz/SfzHelpers.h | 9 +- sfizz/StringViewHelpers.h | 6 +- sfizz/Synth.cpp | 10 +-- sfizz/Synth.h | 10 +-- sfizz/compat/algorithm.h | 39 ++++++++ sfizz/filesystem.h | 14 +-- 21 files changed, 221 insertions(+), 177 deletions(-) create mode 100644 sfizz/compat/algorithm.h diff --git a/clients/sfzprint.cpp b/clients/sfzprint.cpp index 41e87b06..5a15f833 100644 --- a/clients/sfzprint.cpp +++ b/clients/sfzprint.cpp @@ -37,7 +37,7 @@ public: int getNumMasters() const noexcept { return numMasters; } int getNumCurves() const noexcept { return numCurves; } protected: - void callback(std::string_view header, const std::vector& members [[maybe_unused]]) final + void callback(absl::string_view header, const std::vector& members [[maybe_unused]]) final { switch (hash(header)) { diff --git a/sfizz/ADSREnvelope.cpp b/sfizz/ADSREnvelope.cpp index a5b12bc1..1a48030d 100644 --- a/sfizz/ADSREnvelope.cpp +++ b/sfizz/ADSREnvelope.cpp @@ -24,7 +24,7 @@ #include "ADSREnvelope.h" #include "Config.h" #include "SIMDHelpers.h" -#include +#include "compat/algorithm.h" namespace sfz { diff --git a/sfizz/Buffer.h b/sfizz/Buffer.h index c0f7f3bb..ca4e5c6f 100644 --- a/sfizz/Buffer.h +++ b/sfizz/Buffer.h @@ -72,7 +72,8 @@ public: paddedData = static_cast(newData); normalData = static_cast(std::align(Alignment, alignedSize, newData, tempSize)); normalEnd = normalData + alignedSize; - if (auto endMisalignment = (alignedSize & TypeAlignmentMask); endMisalignment != 0) + auto endMisalignment = (alignedSize & TypeAlignmentMask); + if (endMisalignment != 0) _alignedEnd = normalEnd + Alignment - endMisalignment; else _alignedEnd = normalEnd; @@ -156,4 +157,4 @@ private: pointer normalEnd { nullptr }; pointer _alignedEnd { nullptr }; LEAK_DETECTOR(Buffer); -}; \ No newline at end of file +}; diff --git a/sfizz/Defaults.h b/sfizz/Defaults.h index a4119be6..bbc0400a 100644 --- a/sfizz/Defaults.h +++ b/sfizz/Defaults.h @@ -39,114 +39,114 @@ namespace Default // The categories match http://sfzformat.com/ // ******* SFZ 1 ******* // Sound source: sample playback - inline constexpr float delay { 0.0 }; - inline constexpr float delayRandom { 0.0 }; - inline constexpr Range delayRange { 0.0, 100.0 }; - inline constexpr uint32_t offset { 0 }; - inline constexpr uint32_t offsetRandom { 0 }; - inline constexpr Range offsetRange { 0, std::numeric_limits::max() }; - inline constexpr Range sampleEndRange { 0, std::numeric_limits::max() }; - inline constexpr Range sampleCountRange { 0, std::numeric_limits::max() }; - inline constexpr SfzLoopMode loopMode { SfzLoopMode::no_loop }; - inline constexpr Range loopRange { 0, std::numeric_limits::max() }; + constexpr float delay { 0.0 }; + constexpr float delayRandom { 0.0 }; + constexpr Range delayRange { 0.0, 100.0 }; + constexpr uint32_t offset { 0 }; + constexpr uint32_t offsetRandom { 0 }; + constexpr Range offsetRange { 0, std::numeric_limits::max() }; + constexpr Range sampleEndRange { 0, std::numeric_limits::max() }; + constexpr Range sampleCountRange { 0, std::numeric_limits::max() }; + constexpr SfzLoopMode loopMode { SfzLoopMode::no_loop }; + constexpr Range loopRange { 0, std::numeric_limits::max() }; // Instrument setting: voice lifecycle - inline constexpr uint32_t group { 0 }; - inline constexpr Range groupRange { 0, std::numeric_limits::max() }; - inline constexpr SfzOffMode offMode { SfzOffMode::fast }; + constexpr uint32_t group { 0 }; + constexpr Range groupRange { 0, std::numeric_limits::max() }; + constexpr SfzOffMode offMode { SfzOffMode::fast }; // Region logic: key mapping - inline constexpr Range keyRange { 0, 127 }; - inline constexpr Range velocityRange { 0, 127 }; + constexpr Range keyRange { 0, 127 }; + constexpr Range velocityRange { 0, 127 }; // Region logic: MIDI conditions - inline constexpr Range channelRange { 1, 16 }; - inline constexpr Range ccRange { 0, 127 }; - inline constexpr uint8_t cc { 0 }; - inline constexpr Range bendRange { -8192, 8192 }; - inline constexpr int bend { 0 }; - inline constexpr SfzVelocityOverride velocityOverride { SfzVelocityOverride::current }; + constexpr Range channelRange { 1, 16 }; + constexpr Range ccRange { 0, 127 }; + constexpr uint8_t cc { 0 }; + constexpr Range bendRange { -8192, 8192 }; + constexpr int bend { 0 }; + constexpr SfzVelocityOverride velocityOverride { SfzVelocityOverride::current }; // Region logic: internal conditions - inline constexpr Range randRange { 0.0, 1.0 }; - inline constexpr Range aftertouchRange { 0, 127 }; - inline constexpr uint8_t aftertouch { 0 }; - inline constexpr Range bpmRange { 0.0, 500.0 }; - inline constexpr float bpm { 120.0 }; - inline constexpr uint8_t sequenceLength{ 1 }; - inline constexpr uint8_t sequencePosition{ 1 }; - inline constexpr Range sequenceRange { 1, 100 }; + constexpr Range randRange { 0.0, 1.0 }; + constexpr Range aftertouchRange { 0, 127 }; + constexpr uint8_t aftertouch { 0 }; + constexpr Range bpmRange { 0.0, 500.0 }; + constexpr float bpm { 120.0 }; + constexpr uint8_t sequenceLength{ 1 }; + constexpr uint8_t sequencePosition{ 1 }; + constexpr Range sequenceRange { 1, 100 }; // Region logic: Triggers - inline constexpr SfzTrigger trigger { SfzTrigger::attack }; - inline constexpr Range ccTriggerValueRange{ 0, 127 }; + constexpr SfzTrigger trigger { SfzTrigger::attack }; + constexpr Range ccTriggerValueRange{ 0, 127 }; // Performance parameters: amplifier - inline constexpr float volume { -3.0 }; - inline constexpr Range volumeRange { -144.0, 6.0 }; - inline constexpr Range volumeCCRange { -144.0, 6.0 }; - inline constexpr float amplitude { 100.0 }; - inline constexpr Range amplitudeRange { 0.0, 100.0 }; - inline constexpr float pan { 0.0 }; - inline constexpr Range panRange { -100.0, 100.0 }; - inline constexpr Range panCCRange { -200.0, 200.0 }; - inline constexpr float position { 0.0 }; - inline constexpr Range positionRange { -100.0, 100.0 }; - inline constexpr Range positionCCRange { -200.0, 200.0 }; - inline constexpr float width { 0.0 }; - inline constexpr Range widthRange { -100.0, 100.0 }; - inline constexpr Range widthCCRange { -200.0, 200.0 }; - inline constexpr uint8_t ampKeycenter { 60 }; - inline constexpr float ampKeytrack { 0.0 }; - inline constexpr Range ampKeytrackRange { -96, 12 }; - inline constexpr float ampVeltrack { 100.0 }; - inline constexpr Range ampVeltrackRange { -100.0, 100.0 }; - inline constexpr Range ampVelcurveRange { 0.0, 1.0 }; - inline constexpr float ampRandom { 0.0 }; - inline constexpr Range ampRandomRange { 0.0, 24.0 }; - inline constexpr Range crossfadeKeyInRange { 0, 0 }; - inline constexpr Range crossfadeKeyOutRange { 127, 127 }; - inline constexpr Range crossfadeVelInRange { 0, 0 }; - inline constexpr Range crossfadeVelOutRange { 127, 127 }; - inline constexpr Range crossfadeCCInRange { 0, 0 }; - inline constexpr Range crossfadeCCOutRange { 127, 127 }; - inline constexpr SfzCrossfadeCurve crossfadeKeyCurve { SfzCrossfadeCurve::power }; - inline constexpr SfzCrossfadeCurve crossfadeVelCurve { SfzCrossfadeCurve::power }; - inline constexpr SfzCrossfadeCurve crossfadeCCCurve { SfzCrossfadeCurve::power }; - inline constexpr float rtDecay { 0.0f }; - inline constexpr Range rtDecayRange { 0.0f, 200.0f }; + constexpr float volume { -3.0 }; + constexpr Range volumeRange { -144.0, 6.0 }; + constexpr Range volumeCCRange { -144.0, 6.0 }; + constexpr float amplitude { 100.0 }; + constexpr Range amplitudeRange { 0.0, 100.0 }; + constexpr float pan { 0.0 }; + constexpr Range panRange { -100.0, 100.0 }; + constexpr Range panCCRange { -200.0, 200.0 }; + constexpr float position { 0.0 }; + constexpr Range positionRange { -100.0, 100.0 }; + constexpr Range positionCCRange { -200.0, 200.0 }; + constexpr float width { 0.0 }; + constexpr Range widthRange { -100.0, 100.0 }; + constexpr Range widthCCRange { -200.0, 200.0 }; + constexpr uint8_t ampKeycenter { 60 }; + constexpr float ampKeytrack { 0.0 }; + constexpr Range ampKeytrackRange { -96, 12 }; + constexpr float ampVeltrack { 100.0 }; + constexpr Range ampVeltrackRange { -100.0, 100.0 }; + constexpr Range ampVelcurveRange { 0.0, 1.0 }; + constexpr float ampRandom { 0.0 }; + constexpr Range ampRandomRange { 0.0, 24.0 }; + constexpr Range crossfadeKeyInRange { 0, 0 }; + constexpr Range crossfadeKeyOutRange { 127, 127 }; + constexpr Range crossfadeVelInRange { 0, 0 }; + constexpr Range crossfadeVelOutRange { 127, 127 }; + constexpr Range crossfadeCCInRange { 0, 0 }; + constexpr Range crossfadeCCOutRange { 127, 127 }; + constexpr SfzCrossfadeCurve crossfadeKeyCurve { SfzCrossfadeCurve::power }; + constexpr SfzCrossfadeCurve crossfadeVelCurve { SfzCrossfadeCurve::power }; + constexpr SfzCrossfadeCurve crossfadeCCCurve { SfzCrossfadeCurve::power }; + constexpr float rtDecay { 0.0f }; + constexpr Range rtDecayRange { 0.0f, 200.0f }; // Performance parameters: pitch - inline constexpr uint8_t pitchKeycenter { 60 }; - inline constexpr int pitchKeytrack { 100 }; - inline constexpr Range pitchKeytrackRange { -1200, 1200 }; - inline constexpr int pitchRandom { 0 }; - inline constexpr Range pitchRandomRange { 0, 9600 }; - inline constexpr int pitchVeltrack { 0 }; - inline constexpr Range pitchVeltrackRange { -9600, 9600 }; - inline constexpr int transpose { 0 }; - inline constexpr Range transposeRange { -127, 127 }; - inline constexpr int tune { 0 }; - inline constexpr Range tuneRange { -100, 100 }; + constexpr uint8_t pitchKeycenter { 60 }; + constexpr int pitchKeytrack { 100 }; + constexpr Range pitchKeytrackRange { -1200, 1200 }; + constexpr int pitchRandom { 0 }; + constexpr Range pitchRandomRange { 0, 9600 }; + constexpr int pitchVeltrack { 0 }; + constexpr Range pitchVeltrackRange { -9600, 9600 }; + constexpr int transpose { 0 }; + constexpr Range transposeRange { -127, 127 }; + constexpr int tune { 0 }; + constexpr Range tuneRange { -100, 100 }; // Envelope generators - inline constexpr float attack { 0 }; - inline constexpr float decay { 0 }; - inline constexpr float delayEG { 0 }; - inline constexpr float hold { 0 }; - inline constexpr float release { 0 }; - inline constexpr float start { 0.0 }; - inline constexpr float sustain { 100.0 }; - inline constexpr float vel2sustain { 0.0 }; - inline constexpr int depth { 0 }; - inline constexpr Range egTimeRange { 0.0, 100.0 }; - inline constexpr Range egPercentRange { 0.0, 100.0 }; - inline constexpr Range egDepthRange { -12000, 12000 }; - inline constexpr Range egOnCCTimeRange { -100.0, 100.0 }; - inline constexpr Range egOnCCPercentRange { -100.0, 100.0 }; + constexpr float attack { 0 }; + constexpr float decay { 0 }; + constexpr float delayEG { 0 }; + constexpr float hold { 0 }; + constexpr float release { 0 }; + constexpr float start { 0.0 }; + constexpr float sustain { 100.0 }; + constexpr float vel2sustain { 0.0 }; + constexpr int depth { 0 }; + constexpr Range egTimeRange { 0.0, 100.0 }; + constexpr Range egPercentRange { 0.0, 100.0 }; + constexpr Range egDepthRange { -12000, 12000 }; + constexpr Range egOnCCTimeRange { -100.0, 100.0 }; + constexpr Range egOnCCPercentRange { -100.0, 100.0 }; // ***** SFZ v2 ******** - inline constexpr bool checkSustain { true }; // sustain_sw - inline constexpr bool checkSostenuto { true }; // sostenuto_sw + constexpr bool checkSustain { true }; // sustain_sw + constexpr bool checkSostenuto { true }; // sostenuto_sw +} } -} \ No newline at end of file diff --git a/sfizz/EGDescription.h b/sfizz/EGDescription.h index c5fc1e0e..ee40fba5 100644 --- a/sfizz/EGDescription.h +++ b/sfizz/EGDescription.h @@ -26,7 +26,7 @@ #include "Defaults.h" #include "LeakDetector.h" #include "SfzHelpers.h" -#include +#include namespace sfz @@ -55,13 +55,13 @@ struct EGDescription float vel2sustain { Default::vel2sustain }; int vel2depth { Default::depth }; - std::optional ccAttack; - std::optional ccDecay; - std::optional ccDelay; - std::optional ccHold; - std::optional ccRelease; - std::optional ccStart; - std::optional ccSustain; + absl::optional ccAttack; + absl::optional ccDecay; + absl::optional ccDelay; + absl::optional ccHold; + absl::optional ccRelease; + absl::optional ccStart; + absl::optional ccSustain; float getAttack(const CCValueArray &ccValues, uint8_t velocity) const noexcept { @@ -94,4 +94,4 @@ struct EGDescription LEAK_DETECTOR(EGDescription); }; -} //namespace sfz \ No newline at end of file +} //namespace sfz diff --git a/sfizz/FilePool.cpp b/sfizz/FilePool.cpp index 41f4e8f4..26662030 100644 --- a/sfizz/FilePool.cpp +++ b/sfizz/FilePool.cpp @@ -31,6 +31,7 @@ #include #include #include +#include using namespace std::chrono_literals; template @@ -47,7 +48,7 @@ std::unique_ptr> readFromFile(SndfileHandle& sndFile, int numFram return std::move(returnedBuffer); } -std::optional sfz::FilePool::getFileInformation(std::string_view filename, uint32_t offset) noexcept +absl::optional sfz::FilePool::getFileInformation(absl::string_view filename, uint32_t offset) noexcept { std::filesystem::path file { rootDirectory / filename }; if (!std::filesystem::exists(file)) @@ -101,7 +102,7 @@ std::optional sfz::FilePool::getFileInformation( return returnedValue; } -void sfz::FilePool::enqueueLoading(Voice* voice, std::string_view sample, int numFrames, unsigned ticket) noexcept +void sfz::FilePool::enqueueLoading(Voice* voice, absl::string_view sample, int numFrames, unsigned ticket) noexcept { if (!loadingQueue.try_enqueue({ voice, sample, numFrames, ticket })) { DBG("Problem enqueuing a file read for file " << sample); @@ -160,4 +161,4 @@ void sfz::FilePool::clear() while (loadingQueue.pop()) { // Pop the queue } -} \ No newline at end of file +} diff --git a/sfizz/FilePool.h b/sfizz/FilePool.h index c8041afa..69f5c7cf 100644 --- a/sfizz/FilePool.h +++ b/sfizz/FilePool.h @@ -31,7 +31,7 @@ #include "readerwriterqueue.h" #include #include -#include +#include #include #include @@ -60,14 +60,14 @@ public: double sampleRate { config::defaultSampleRate }; std::shared_ptr> preloadedData; }; - std::optional getFileInformation(std::string_view filename, uint32_t offset) noexcept; - void enqueueLoading(Voice* voice, std::string_view sample, int numFrames, unsigned ticket) noexcept; + absl::optional getFileInformation(absl::string_view filename, uint32_t offset) noexcept; + void enqueueLoading(Voice* voice, absl::string_view sample, int numFrames, unsigned ticket) noexcept; void clear(); private: std::filesystem::path rootDirectory; struct FileLoadingInformation { Voice* voice; - std::string_view sample; + absl::string_view sample; int numFrames; unsigned ticket; }; @@ -80,7 +80,7 @@ private: std::vector>> fileHandles; std::mutex fileHandleMutex; bool quitThread { false }; - absl::flat_hash_map>> preloadedData; + absl::flat_hash_map>> preloadedData; LEAK_DETECTOR(FilePool); }; } diff --git a/sfizz/LinearEnvelope.h b/sfizz/LinearEnvelope.h index 20a25b94..e246629f 100644 --- a/sfizz/LinearEnvelope.h +++ b/sfizz/LinearEnvelope.h @@ -27,6 +27,7 @@ #include #include #include +#include namespace sfz { @@ -50,4 +51,4 @@ private: LEAK_DETECTOR(LinearEnvelope); }; -} \ No newline at end of file +} diff --git a/sfizz/Opcode.cpp b/sfizz/Opcode.cpp index a52203fd..f75ce0e9 100644 --- a/sfizz/Opcode.cpp +++ b/sfizz/Opcode.cpp @@ -24,13 +24,13 @@ #include "Opcode.h" #include "StringViewHelpers.h" -sfz::Opcode::Opcode(std::string_view inputOpcode, std::string_view inputValue) +sfz::Opcode::Opcode(absl::string_view inputOpcode, absl::string_view inputValue) : opcode(inputOpcode) , value(inputValue) { if (const auto lastCharIndex = inputOpcode.find_last_not_of("1234567890"); lastCharIndex != inputOpcode.npos) { int returnedValue; - std::string_view parameterView = inputOpcode; + absl::string_view parameterView = inputOpcode; parameterView.remove_prefix(lastCharIndex + 1); if (absl::SimpleAtoi(parameterView, &returnedValue)) { parameter = returnedValue; diff --git a/sfizz/Opcode.h b/sfizz/Opcode.h index be818f86..f392e45d 100644 --- a/sfizz/Opcode.h +++ b/sfizz/Opcode.h @@ -27,7 +27,7 @@ #include "Range.h" #include "SfzHelpers.h" #include "StringViewHelpers.h" -#include +#include #include // charconv support is still sketchy with clang/gcc so we use abseil's numbers @@ -36,16 +36,16 @@ namespace sfz { struct Opcode { Opcode() = delete; - Opcode(std::string_view inputOpcode, std::string_view inputValue); - std::string_view opcode {}; - std::string_view value {}; + Opcode(absl::string_view inputOpcode, absl::string_view inputValue); + absl::string_view opcode {}; + absl::string_view value {}; // This is to handle the integer parameter of some opcodes - std::optional parameter; + absl::optional parameter; LEAK_DETECTOR(Opcode); }; template -inline std::optional readOpcode(std::string_view value, const Range& validRange) +inline absl::optional readOpcode(absl::string_view value, const Range& validRange) { if constexpr (std::is_integral::value) { int64_t returnedValue; @@ -65,13 +65,13 @@ inline std::optional readOpcode(std::string_view value, const Range readBooleanFromOpcode(const Opcode& opcode) +inline absl::optional readBooleanFromOpcode(const Opcode& opcode) { switch (hash(opcode.value)) { case hash("off"): @@ -94,7 +94,7 @@ inline void setValueFromOpcode(const Opcode& opcode, ValueType& target, const Ra } template -inline void setValueFromOpcode(const Opcode& opcode, std::optional& target, const Range& validRange) +inline void setValueFromOpcode(const Opcode& opcode, absl::optional& target, const Range& validRange) { auto value = readOpcode(opcode.value, validRange); if (!value) // Try and read a note rather than a number @@ -124,7 +124,7 @@ inline void setRangeStartFromOpcode(const Opcode& opcode, Range& targ } template -inline void setCCPairFromOpcode(const Opcode& opcode, std::optional& target, const Range& validRange) +inline void setCCPairFromOpcode(const Opcode& opcode, absl::optional& target, const Range& validRange) { auto value = readOpcode(opcode.value, validRange); if (value && opcode.parameter && Default::ccRange.containsWithEnd(*opcode.parameter)) diff --git a/sfizz/Parser.cpp b/sfizz/Parser.cpp index 64551cee..d3d8e471 100644 --- a/sfizz/Parser.cpp +++ b/sfizz/Parser.cpp @@ -28,12 +28,13 @@ #include #include -using svregex_iterator = std::regex_iterator; -using svmatch_results = std::match_results; +using svregex_iterator = std::regex_iterator; +using svmatch_results = std::match_results; -void removeCommentOnLine(std::string_view& line) +void removeCommentOnLine(absl::string_view& line) { - if (auto position = line.find("//"); position != line.npos) + auto position = line.find("//"); + if (position != line.npos) line.remove_suffix(line.size() - position); } @@ -48,7 +49,7 @@ bool sfz::Parser::loadSfzFile(const std::filesystem::path& file) readSfzFile(file, lines); aggregatedContent = absl::StrJoin(lines, " "); - const std::string_view aggregatedView { aggregatedContent }; + const absl::string_view aggregatedView { aggregatedContent }; svregex_iterator headerIterator(aggregatedView.cbegin(), aggregatedView.cend(), sfz::Regexes::headers); const auto regexEnd = svregex_iterator(); @@ -59,15 +60,15 @@ bool sfz::Parser::loadSfzFile(const std::filesystem::path& file) svmatch_results headerMatch = *headerIterator; // Can't use uniform initialization here because it generates narrowing conversions - const std::string_view header(&*headerMatch[1].first, headerMatch[1].length()); - const std::string_view members(&*headerMatch[2].first, headerMatch[2].length()); + const absl::string_view header(&*headerMatch[1].first, headerMatch[1].length()); + const absl::string_view members(&*headerMatch[2].first, headerMatch[2].length()); auto paramIterator = svregex_iterator(members.cbegin(), members.cend(), sfz::Regexes::members); // Store or handle members for (; paramIterator != regexEnd; ++paramIterator) { const svmatch_results paramMatch = *paramIterator; - const std::string_view opcode(&*paramMatch[1].first, paramMatch[1].length()); - const std::string_view value(&*paramMatch[2].first, paramMatch[2].length()); + const absl::string_view opcode(&*paramMatch[1].first, paramMatch[1].length()); + const absl::string_view value(&*paramMatch[2].first, paramMatch[2].length()); currentMembers.emplace_back(opcode, value); } callback(header, currentMembers); @@ -89,7 +90,7 @@ void sfz::Parser::readSfzFile(const std::filesystem::path& fileName, std::vector std::string tmpString; while (std::getline(fileStream, tmpString)) { - std::string_view tmpView { tmpString }; + absl::string_view tmpView { tmpString }; removeCommentOnLine(tmpView); trimInPlace(tmpView); @@ -152,4 +153,4 @@ void sfz::Parser::readSfzFile(const std::filesystem::path& fileName, std::vector newString += tmpView.substr(lastPos); lines.push_back(std::move(newString)); } -} \ No newline at end of file +} diff --git a/sfizz/Parser.h b/sfizz/Parser.h index ce94bad6..009c360e 100644 --- a/sfizz/Parser.h +++ b/sfizz/Parser.h @@ -47,7 +47,7 @@ public: void disableRecursiveIncludeGuard() { recursiveIncludeGuard = false; } void enableRecursiveIncludeGuard() { recursiveIncludeGuard = true; } protected: - virtual void callback(std::string_view header, const std::vector& members) = 0; + virtual void callback(absl::string_view header, const std::vector& members) = 0; std::filesystem::path rootDirectory { std::filesystem::current_path() }; private: bool recursiveIncludeGuard { false }; diff --git a/sfizz/Range.h b/sfizz/Range.h index 087fd112..dc56f057 100644 --- a/sfizz/Range.h +++ b/sfizz/Range.h @@ -22,7 +22,7 @@ // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #pragma once -#include +#include "compat/algorithm.h" #include #include @@ -108,4 +108,4 @@ template bool operator==(const std::pair& lhs, const Range& rhs) { return rhs == lhs; -} \ No newline at end of file +} diff --git a/sfizz/Region.h b/sfizz/Region.h index 352b8798..61a9a6e1 100644 --- a/sfizz/Region.h +++ b/sfizz/Region.h @@ -29,7 +29,7 @@ #include "Opcode.h" #include "AudioBuffer.h" #include -#include +#include #include #include #include @@ -73,13 +73,13 @@ struct Region { uint32_t offset { Default::offset }; // offset uint32_t offsetRandom { Default::offsetRandom }; // offset_random uint32_t sampleEnd { Default::sampleEndRange.getEnd() }; // end - std::optional sampleCount {}; // count + absl::optional sampleCount {}; // count SfzLoopMode loopMode { Default::loopMode }; // loopmode Range loopRange { Default::loopRange }; //loopstart and loopend // Instrument settings: voice lifecycle uint32_t group { Default::group }; // group - std::optional offBy {}; // off_by + absl::optional offBy {}; // off_by SfzOffMode offMode { Default::offMode }; // off_mode // Region logic: key mapping @@ -91,10 +91,10 @@ struct Region { Range bendRange { Default::bendRange }; // hibend and lobend CCMap> ccConditions { Default::ccRange }; Range keyswitchRange { Default::keyRange }; // sw_hikey and sw_lokey - std::optional keyswitch {}; // sw_last - std::optional keyswitchUp {}; // sw_up - std::optional keyswitchDown {}; // sw_down - std::optional previousNote {}; // sw_previous + absl::optional keyswitch {}; // sw_last + absl::optional keyswitchUp {}; // sw_up + absl::optional keyswitchDown {}; // sw_down + absl::optional previousNote {}; // sw_previous SfzVelocityOverride velocityOverride { Default::velocityOverride }; // sw_vel bool checkSustain { Default::checkSustain }; // sustain_sw bool checkSostenuto { Default::checkSostenuto }; // sostenuto_sw @@ -116,11 +116,11 @@ struct Region { float pan { Default::pan }; // pan float width { Default::width }; // width float position { Default::position }; // position - std::optional volumeCC; // volume_oncc - std::optional amplitudeCC; // amplitude_oncc - std::optional panCC; // pan_oncc - std::optional widthCC; // width_oncc - std::optional positionCC; // position_oncc + absl::optional volumeCC; // volume_oncc + absl::optional amplitudeCC; // amplitude_oncc + absl::optional panCC; // pan_oncc + absl::optional widthCC; // width_oncc + absl::optional positionCC; // position_oncc uint8_t ampKeycenter { Default::ampKeycenter }; // amp_keycenter float ampKeytrack { Default::ampKeytrack }; // amp_keytrack float ampVeltrack { Default::ampVeltrack }; // amp_keytrack diff --git a/sfizz/SfzHelpers.cpp b/sfizz/SfzHelpers.cpp index 2a08b833..f72278bd 100644 --- a/sfizz/SfzHelpers.cpp +++ b/sfizz/SfzHelpers.cpp @@ -24,7 +24,7 @@ #include "SfzHelpers.h" #include "StringViewHelpers.h" -std::optional sfz::readNoteValue(const std::string_view& value) +absl::optional sfz::readNoteValue(const absl::string_view& value) { switch(hash(value)) { diff --git a/sfizz/SfzHelpers.h b/sfizz/SfzHelpers.h index eedb3039..10151814 100644 --- a/sfizz/SfzHelpers.h +++ b/sfizz/SfzHelpers.h @@ -22,8 +22,9 @@ // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #pragma once -#include -#include +#include +#include +//#include #include #include @@ -59,7 +60,7 @@ inline constexpr float normalizeNegativePercents(T percentValue) return std::min(std::max(static_cast(percentValue), -100.0f), 100.0f) / 100.0f; } -inline float ccSwitchedValue(const CCValueArray& ccValues, const std::optional& ccSwitch, float value) noexcept +inline float ccSwitchedValue(const CCValueArray& ccValues, const absl::optional& ccSwitch, float value) noexcept { if (ccSwitch) return value + ccSwitch->second * normalizeCC(ccValues[ccSwitch->first]); @@ -67,7 +68,7 @@ inline float ccSwitchedValue(const CCValueArray& ccValues, const std::optional readNoteValue(const std::string_view& value); +absl::optional readNoteValue(const absl::string_view& value); } // namespace sfz diff --git a/sfizz/StringViewHelpers.h b/sfizz/StringViewHelpers.h index 039f4c3f..22b127ab 100644 --- a/sfizz/StringViewHelpers.h +++ b/sfizz/StringViewHelpers.h @@ -24,7 +24,7 @@ #pragma once #include -inline void trimInPlace(std::string_view& s) +inline void trimInPlace(absl::string_view& s) { const auto leftPosition = s.find_first_not_of(" \r\t\n\f\v"); if (leftPosition != s.npos) { @@ -36,7 +36,7 @@ inline void trimInPlace(std::string_view& s) } } -inline std::string_view trim(std::string_view s) +inline absl::string_view trim(absl::string_view s) { const auto leftPosition = s.find_first_not_of(" \r\t\n\f\v"); if (leftPosition != s.npos) { @@ -52,7 +52,7 @@ inline std::string_view trim(std::string_view s) inline constexpr uint64_t Fnv1aBasis = 0x811C9DC5; inline constexpr uint64_t Fnv1aPrime = 0x01000193; -inline constexpr uint64_t hash(std::string_view s, uint64_t h = Fnv1aBasis) +inline constexpr uint64_t hash(absl::string_view s, uint64_t h = Fnv1aBasis) { if (s.length() > 0) return hash( { s.data() + 1, s.length() - 1 }, (h ^ s.front()) * Fnv1aPrime ); diff --git a/sfizz/Synth.cpp b/sfizz/Synth.cpp index ec5f7f52..4ef6eaef 100644 --- a/sfizz/Synth.cpp +++ b/sfizz/Synth.cpp @@ -41,7 +41,7 @@ sfz::Synth::Synth() voiceViewArray.reserve(config::numVoices); } -void sfz::Synth::callback(std::string_view header, const std::vector& members) +void sfz::Synth::callback(absl::string_view header, const std::vector& members) { switch (hash(header)) { case hash("global"): @@ -87,7 +87,7 @@ void sfz::Synth::buildRegion(const std::vector& regionOpcodes) auto parseOpcodes = [&](const auto& opcodes) { for (auto& opcode : opcodes) { - const auto unknown = absl::c_find_if(unknownOpcodes, [&](std::string_view sv) { return sv.compare(opcode.opcode) == 0; }); + const auto unknown = absl::c_find_if(unknownOpcodes, [&](absl::string_view sv) { return sv.compare(opcode.opcode) == 0; }); if (unknown != unknownOpcodes.end()) { continue; } @@ -113,7 +113,7 @@ void sfz::Synth::clear() numMasters = 0; numCurves = 0; fileTicket = -1; - defaultSwitch = std::nullopt; + defaultSwitch = absl::nullopt; for (auto& state : ccState) state = 0; ccNames.clear(); @@ -423,11 +423,11 @@ const sfz::Region* sfz::Synth::getRegionView(int idx) const noexcept { return (size_t)idx < regions.size() ? regions[idx].get() : nullptr; } -std::set sfz::Synth::getUnknownOpcodes() const noexcept +std::set sfz::Synth::getUnknownOpcodes() const noexcept { return unknownOpcodes; } size_t sfz::Synth::getNumPreloadedSamples() const noexcept { return filePool.getNumPreloadedSamples(); -} \ No newline at end of file +} diff --git a/sfizz/Synth.h b/sfizz/Synth.h index 4954b37a..80f45343 100644 --- a/sfizz/Synth.h +++ b/sfizz/Synth.h @@ -28,7 +28,7 @@ #include "LeakDetector.h" #include "AudioSpan.h" #include "absl/types/span.h" -#include +#include #include #include #include @@ -46,7 +46,7 @@ public: int getNumMasters() const noexcept; int getNumCurves() const noexcept; const Region* getRegionView(int idx) const noexcept; - std::set getUnknownOpcodes() const noexcept; + std::set getUnknownOpcodes() const noexcept; size_t getNumPreloadedSamples() const noexcept; void setSamplesPerBlock(int samplesPerBlock) noexcept; @@ -62,7 +62,7 @@ public: void getNumActiveVoices() const noexcept; void garbageCollect() noexcept; protected: - void callback(std::string_view header, const std::vector& members) final; + void callback(absl::string_view header, const std::vector& members) final; private: bool hasGlobal { false }; @@ -83,8 +83,8 @@ private: CCValueArray ccState; Voice* findFreeVoice() noexcept; std::vector ccNames; - std::optional defaultSwitch; - std::set unknownOpcodes; + absl::optional defaultSwitch; + std::set unknownOpcodes; using RegionPtrVector = std::vector; using VoicePtrVector = std::vector; std::vector> regions; diff --git a/sfizz/compat/algorithm.h b/sfizz/compat/algorithm.h new file mode 100644 index 00000000..0993c4b8 --- /dev/null +++ b/sfizz/compat/algorithm.h @@ -0,0 +1,39 @@ +// Copyright (c) 2019, Paul Ferrand +// All rights reserved. + +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: + +// 1. Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. + +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +// 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. + +#pragma once + +#include + +#if __cplusplus <= 201402L + #include + namespace std + { + template + constexpr const T& clamp( const T& v, const T& lo, const T& hi ) + { + assert( !(hi < lo) ); + return (v < lo) ? lo : (hi < v) ? hi : v; + } + } +#endif // lower than C++17 diff --git a/sfizz/filesystem.h b/sfizz/filesystem.h index 3ad22a65..7d5f5c14 100644 --- a/sfizz/filesystem.h +++ b/sfizz/filesystem.h @@ -24,12 +24,12 @@ #pragma once #if defined(__cpp_lib_filesystem) || (defined(__has_include) && __has_include()) -#include -#elif defined(__cpp_lib_experimental_filesystem) || (defined(__has_include) && __has_include()) -#include -namespace std { - namespace filesystem = std::experimental::filesystem; -} + #include +#elif __cplusplus >= 201103L + #include + namespace std { + namespace filesystem = std::experimental::filesystem; + } #else -#error no filesystem support + #error no filesystem support #endif From 4ae5cbe4d398340433787486d6ba6ede926444a2 Mon Sep 17 00:00:00 2001 From: redtide Date: Thu, 19 Sep 2019 02:20:52 +0200 Subject: [PATCH 15/26] Added EditorConfig support. --- .editorconfig | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..44554ce7 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,14 @@ +# EditorConfig configuration +# http://editorconfig.org + +# Top-most EditorConfig file +root = true + +# No trailing whitespaces, but with a newline ending every file, +# UTF-8 charset, set indent to spaces with width of four +[*] +insert_final_newline = true +trim_trailing_whitespace = true +charset = utf-8 +indent_style = space +indent_size = 4 From ca5b08077e1e4764048c4a1936c9cbc5080fb9d8 Mon Sep 17 00:00:00 2001 From: redtide Date: Thu, 19 Sep 2019 02:24:46 +0200 Subject: [PATCH 16/26] Moved filesystem.h in the compat folder with other C++14 compatibility related files, adapted macro, removed unnecessary license header for those files. --- sfizz/compat/algorithm.h | 23 ----------------------- sfizz/compat/filesystem.h | 15 +++++++++++++++ sfizz/compat/inline.h | 11 +++++++++++ 3 files changed, 26 insertions(+), 23 deletions(-) create mode 100644 sfizz/compat/filesystem.h create mode 100644 sfizz/compat/inline.h diff --git a/sfizz/compat/algorithm.h b/sfizz/compat/algorithm.h index 0993c4b8..df07f01c 100644 --- a/sfizz/compat/algorithm.h +++ b/sfizz/compat/algorithm.h @@ -1,26 +1,3 @@ -// Copyright (c) 2019, Paul Ferrand -// All rights reserved. - -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: - -// 1. Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. - -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -// 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. - #pragma once #include diff --git a/sfizz/compat/filesystem.h b/sfizz/compat/filesystem.h new file mode 100644 index 00000000..d3103fe6 --- /dev/null +++ b/sfizz/compat/filesystem.h @@ -0,0 +1,15 @@ +#pragma once + +#ifdef __cplusplus + #if (__cplusplus >= 201703L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201402L) + #include + #elif (__cplusplus >= 201402L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) + #warning std::experimental::filesystem in use + #include + namespace std { + namespace filesystem = std::experimental::filesystem; + } + #endif +#else + #error no filesystem support +#endif diff --git a/sfizz/compat/inline.h b/sfizz/compat/inline.h new file mode 100644 index 00000000..6faf861a --- /dev/null +++ b/sfizz/compat/inline.h @@ -0,0 +1,11 @@ +#pragma once + +#ifdef __cplusplus + #if (__cplusplus >= 201703L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201402L) + #define SFZ_INLINE inline + #else + #define SFZ_INLINE + #endif +#else + #error unknown error +#endif From 7193bba69300952b9474b14bfe7b7384bcafee56 Mon Sep 17 00:00:00 2001 From: redtide Date: Thu, 19 Sep 2019 02:29:43 +0200 Subject: [PATCH 17/26] Fixing files. --- clients/sfzprint.cpp | 2 +- sfizz/FilePool.h | 2 +- sfizz/LeakDetector.h | 5 +++-- sfizz/MathHelpers.h | 7 ++++--- sfizz/MidiState.h | 8 ++++---- sfizz/Opcode.cpp | 5 +++-- sfizz/Parser.cpp | 4 ++-- sfizz/Parser.h | 12 ++++++------ sfizz/Region.cpp | 5 +++-- sfizz/StringViewHelpers.h | 4 ++-- sfizz/Synth.cpp | 8 +++++--- sfizz/filesystem.h | 35 ----------------------------------- 12 files changed, 34 insertions(+), 63 deletions(-) delete mode 100644 sfizz/filesystem.h diff --git a/clients/sfzprint.cpp b/clients/sfzprint.cpp index 5a15f833..91ab76ff 100644 --- a/clients/sfzprint.cpp +++ b/clients/sfzprint.cpp @@ -23,7 +23,7 @@ #include "Parser.h" #include "StringViewHelpers.h" -#include "filesystem.h" +#include "compat/filesystem.h" #include #include #include diff --git a/sfizz/FilePool.h b/sfizz/FilePool.h index 69f5c7cf..1c6c7f59 100644 --- a/sfizz/FilePool.h +++ b/sfizz/FilePool.h @@ -27,7 +27,7 @@ #include "LeakDetector.h" #include "AudioBuffer.h" #include "Voice.h" -#include "filesystem.h" +#include "compat/filesystem.h" #include "readerwriterqueue.h" #include #include diff --git a/sfizz/LeakDetector.h b/sfizz/LeakDetector.h index 948c374a..9d50500d 100644 --- a/sfizz/LeakDetector.h +++ b/sfizz/LeakDetector.h @@ -24,6 +24,7 @@ #pragma once #include #include "Debug.h" +#include "compat/inline.h" template class LeakDetector { @@ -59,7 +60,7 @@ private: }; std::atomic count { 0 }; }; - static inline ObjectCounter objectCounter; + static SFZ_INLINE ObjectCounter objectCounter; }; #ifndef NDEBUG @@ -69,4 +70,4 @@ private: LeakDetector leakDetector; #else #define LEAK_DETECTOR(Class) -#endif \ No newline at end of file +#endif diff --git a/sfizz/MathHelpers.h b/sfizz/MathHelpers.h index e67acb5b..7452eb20 100644 --- a/sfizz/MathHelpers.h +++ b/sfizz/MathHelpers.h @@ -22,6 +22,7 @@ // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #pragma once +#include "compat/inline.h" #include #include #include @@ -59,8 +60,8 @@ inline constexpr Type mag2db(Type in) } namespace Random { -static inline std::random_device randomDevice; -static inline std::mt19937 randomGenerator { randomDevice() }; +static SFZ_INLINE std::random_device randomDevice; +static SFZ_INLINE std::mt19937 randomGenerator { randomDevice() }; } // namespace Random inline float midiNoteFrequency(const int noteNumber) @@ -79,4 +80,4 @@ constexpr Type piFour { pi / 4 }; template constexpr Type sqrtTwo { 1.414213562373095048801688724209698078569671875376948073176 }; template -constexpr Type sqrtTwoInv { 0.707106781186547524400844362104849039284835937688474036588 }; \ No newline at end of file +constexpr Type sqrtTwoInv { 0.707106781186547524400844362104849039284835937688474036588 }; diff --git a/sfizz/MidiState.h b/sfizz/MidiState.h index ea8a178e..84eab5d5 100644 --- a/sfizz/MidiState.h +++ b/sfizz/MidiState.h @@ -1,10 +1,10 @@ #include #include - +#include "compat/inline.h" namespace sfz { - inline std::array noteOnTimes { }; - inline std::array lastNoteVelocities { }; + SFZ_INLINE std::array noteOnTimes { }; + SFZ_INLINE std::array lastNoteVelocities { }; inline void noteOn(int noteNumber, uint8_t velocity) { if (noteNumber >= 0 && noteNumber < 128) { @@ -31,4 +31,4 @@ namespace sfz return 0; } -} \ No newline at end of file +} diff --git a/sfizz/Opcode.cpp b/sfizz/Opcode.cpp index f75ce0e9..3b502c57 100644 --- a/sfizz/Opcode.cpp +++ b/sfizz/Opcode.cpp @@ -28,7 +28,8 @@ sfz::Opcode::Opcode(absl::string_view inputOpcode, absl::string_view inputValue) : opcode(inputOpcode) , value(inputValue) { - if (const auto lastCharIndex = inputOpcode.find_last_not_of("1234567890"); lastCharIndex != inputOpcode.npos) { + const auto lastCharIndex = inputOpcode.find_last_not_of("1234567890"); + if (lastCharIndex != inputOpcode.npos) { int returnedValue; absl::string_view parameterView = inputOpcode; parameterView.remove_prefix(lastCharIndex + 1); @@ -39,4 +40,4 @@ sfz::Opcode::Opcode(absl::string_view inputOpcode, absl::string_view inputValue) } trimInPlace(value); trimInPlace(opcode); -} \ No newline at end of file +} diff --git a/sfizz/Parser.cpp b/sfizz/Parser.cpp index d3d8e471..60e3716b 100644 --- a/sfizz/Parser.cpp +++ b/sfizz/Parser.cpp @@ -33,8 +33,8 @@ using svmatch_results = std::match_results; void removeCommentOnLine(absl::string_view& line) { - auto position = line.find("//"); - if (position != line.npos) + auto position = line.find("//"); + if (position != line.npos) line.remove_suffix(line.size() - position); } diff --git a/sfizz/Parser.h b/sfizz/Parser.h index 009c360e..7c300a25 100644 --- a/sfizz/Parser.h +++ b/sfizz/Parser.h @@ -23,7 +23,7 @@ #pragma once #include "Opcode.h" -#include "filesystem.h" +#include "compat/filesystem.h" #include #include #include @@ -32,11 +32,11 @@ namespace sfz { namespace Regexes { - inline static std::regex includes { R"V(#include\s*"(.*?)".*$)V", std::regex::optimize }; - inline static std::regex defines { R"(#define\s*(\$[a-zA-Z0-9]+)\s+([a-zA-Z0-9]+)(?=\s|$))", std::regex::optimize }; - inline static std::regex headers { R"(<(.*?)>(.*?)(?=<|$))", std::regex::optimize }; - inline static std::regex members { R"(([a-zA-Z0-9_]+)=([a-zA-Z0-9-_#.&\/\s\\\(\),\*]+)(?![a-zA-Z0-9_]*=))", std::regex::optimize }; - inline static std::regex opcodeParameters { R"(([a-zA-Z0-9_]+?)([0-9]+)$)", std::regex::optimize }; + SFZ_INLINE static std::regex includes { R"V(#include\s*"(.*?)".*$)V", std::regex::optimize }; + SFZ_INLINE static std::regex defines { R"(#define\s*(\$[a-zA-Z0-9]+)\s+([a-zA-Z0-9]+)(?=\s|$))", std::regex::optimize }; + SFZ_INLINE static std::regex headers { R"(<(.*?)>(.*?)(?=<|$))", std::regex::optimize }; + SFZ_INLINE static std::regex members { R"(([a-zA-Z0-9_]+)=([a-zA-Z0-9-_#.&\/\s\\\(\),\*]+)(?![a-zA-Z0-9_]*=))", std::regex::optimize }; + SFZ_INLINE static std::regex opcodeParameters { R"(([a-zA-Z0-9_]+?)([0-9]+)$)", std::regex::optimize }; } class Parser { diff --git a/sfizz/Region.cpp b/sfizz/Region.cpp index d9f98b62..e6126be5 100644 --- a/sfizz/Region.cpp +++ b/sfizz/Region.cpp @@ -298,7 +298,8 @@ bool sfz::Region::parseOpcode(const Opcode& opcode) break; case hash("amp_velcurve_"): if (opcode.parameter && Default::ccRange.containsWithEnd(*opcode.parameter)) { - if (auto value = readOpcode(opcode.value, Default::ampVelcurveRange); value) + auto value = readOpcode(opcode.value, Default::ampVelcurveRange); + if (value) velocityPoints.emplace_back(*opcode.parameter, *value); } break; @@ -771,4 +772,4 @@ float sfz::Region::velocityCurve(uint8_t velocity) const noexcept } return gain; -} \ No newline at end of file +} diff --git a/sfizz/StringViewHelpers.h b/sfizz/StringViewHelpers.h index 22b127ab..d4a5add0 100644 --- a/sfizz/StringViewHelpers.h +++ b/sfizz/StringViewHelpers.h @@ -49,8 +49,8 @@ inline absl::string_view trim(absl::string_view s) return s; } -inline constexpr uint64_t Fnv1aBasis = 0x811C9DC5; -inline constexpr uint64_t Fnv1aPrime = 0x01000193; +constexpr uint64_t Fnv1aBasis = 0x811C9DC5; +constexpr uint64_t Fnv1aPrime = 0x01000193; inline constexpr uint64_t hash(absl::string_view s, uint64_t h = Fnv1aBasis) { diff --git a/sfizz/Synth.cpp b/sfizz/Synth.cpp index 4ef6eaef..b1aade21 100644 --- a/sfizz/Synth.cpp +++ b/sfizz/Synth.cpp @@ -113,7 +113,7 @@ void sfz::Synth::clear() numMasters = 0; numCurves = 0; fileTicket = -1; - defaultSwitch = absl::nullopt; + defaultSwitch = absl::nullopt; for (auto& state : ccState) state = 0; ccNames.clear(); @@ -150,10 +150,12 @@ void sfz::Synth::handleControlOpcodes(const std::vector& members) ccNames.emplace_back(*member.parameter, member.value); break; case hash("Default_path"): [[fallthrough]]; - case hash("default_path"): - if (auto newPath = std::filesystem::path(member.value); std::filesystem::exists(newPath)) + case hash("default_path"): { + auto newPath = std::filesystem::path(member.value); + if (std::filesystem::exists(newPath)) rootDirectory = newPath; break; + } default: // Unsupported control opcode ASSERTFALSE; diff --git a/sfizz/filesystem.h b/sfizz/filesystem.h deleted file mode 100644 index 7d5f5c14..00000000 --- a/sfizz/filesystem.h +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) 2019, Paul Ferrand -// All rights reserved. - -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: - -// 1. Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. - -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -// 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. - -#pragma once - -#if defined(__cpp_lib_filesystem) || (defined(__has_include) && __has_include()) - #include -#elif __cplusplus >= 201103L - #include - namespace std { - namespace filesystem = std::experimental::filesystem; - } -#else - #error no filesystem support -#endif From 960e2e55553deb8b8d7536c6a78cae7be8165f71 Mon Sep 17 00:00:00 2001 From: redtide Date: Thu, 19 Sep 2019 16:45:57 +0200 Subject: [PATCH 18/26] WIP code update. --- sfizz/FilePool.cpp | 8 ++++---- sfizz/LeakDetector.h | 2 +- sfizz/MathHelpers.h | 2 +- sfizz/MidiState.h | 2 +- sfizz/compat/filesystem.h | 4 ++-- sfizz/compat/{inline.h => utils.h} | 4 +++- 6 files changed, 12 insertions(+), 10 deletions(-) rename sfizz/compat/{inline.h => utils.h} (71%) diff --git a/sfizz/FilePool.cpp b/sfizz/FilePool.cpp index 26662030..5681d098 100644 --- a/sfizz/FilePool.cpp +++ b/sfizz/FilePool.cpp @@ -131,9 +131,9 @@ void sfz::FilePool::loadingThread() noexcept SndfileHandle sndFile(reinterpret_cast(file.c_str())); - std::lock_guard guard { fileHandleMutex }; - auto newHandle = fileHandles.emplace_back(readFromFile(sndFile, fileToLoad.numFrames)); - fileToLoad.voice->setFileData(newHandle, fileToLoad.ticket); + std::lock_guard guard { fileHandleMutex }; + fileHandles.emplace_back(readFromFile(sndFile, fileToLoad.numFrames)); + fileToLoad.voice->setFileData(fileHandles.back(), fileToLoad.ticket); } } @@ -143,7 +143,7 @@ void sfz::FilePool::garbageThread() noexcept for (auto handle = fileHandles.begin(); handle < fileHandles.end();) { if (handle->use_count() == 1) { handle->reset(); - std::lock_guard guard { fileHandleMutex }; + std::lock_guard guard { fileHandleMutex }; std::iter_swap(handle, fileHandles.end() - 1); fileHandles.pop_back(); } else { diff --git a/sfizz/LeakDetector.h b/sfizz/LeakDetector.h index 9d50500d..a6f007e5 100644 --- a/sfizz/LeakDetector.h +++ b/sfizz/LeakDetector.h @@ -24,7 +24,7 @@ #pragma once #include #include "Debug.h" -#include "compat/inline.h" +#include "compat/utils.h" template class LeakDetector { diff --git a/sfizz/MathHelpers.h b/sfizz/MathHelpers.h index 7452eb20..b4b1a953 100644 --- a/sfizz/MathHelpers.h +++ b/sfizz/MathHelpers.h @@ -22,7 +22,7 @@ // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #pragma once -#include "compat/inline.h" +#include "compat/utils.h" #include #include #include diff --git a/sfizz/MidiState.h b/sfizz/MidiState.h index 84eab5d5..fd575529 100644 --- a/sfizz/MidiState.h +++ b/sfizz/MidiState.h @@ -1,6 +1,6 @@ #include #include -#include "compat/inline.h" +#include "compat/utils.h" namespace sfz { SFZ_INLINE std::array noteOnTimes { }; diff --git a/sfizz/compat/filesystem.h b/sfizz/compat/filesystem.h index d3103fe6..6b040bf7 100644 --- a/sfizz/compat/filesystem.h +++ b/sfizz/compat/filesystem.h @@ -1,9 +1,9 @@ #pragma once #ifdef __cplusplus - #if (__cplusplus >= 201703L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201402L) + #if (__cplusplus >= 201703L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) #include - #elif (__cplusplus >= 201402L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) + #elif (__cplusplus >= 201402L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201402L) #warning std::experimental::filesystem in use #include namespace std { diff --git a/sfizz/compat/inline.h b/sfizz/compat/utils.h similarity index 71% rename from sfizz/compat/inline.h rename to sfizz/compat/utils.h index 6faf861a..0d053c0e 100644 --- a/sfizz/compat/inline.h +++ b/sfizz/compat/utils.h @@ -1,9 +1,11 @@ #pragma once #ifdef __cplusplus - #if (__cplusplus >= 201703L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201402L) + #if (__cplusplus >= 201703L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) + #define SFZ_HAVE_CXX17 1 #define SFZ_INLINE inline #else + #define SFZ_HAVE_CXX17 0 #define SFZ_INLINE #endif #else From 40cfc638e9088ceba322278b400e98f9d9589be2 Mon Sep 17 00:00:00 2001 From: paulfd Date: Fri, 20 Sep 2019 22:50:34 +0200 Subject: [PATCH 19/26] Used abseil's concatenation for string views --- sfizz/Parser.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sfizz/Parser.cpp b/sfizz/Parser.cpp index 60e3716b..e5b18ab4 100644 --- a/sfizz/Parser.cpp +++ b/sfizz/Parser.cpp @@ -25,6 +25,7 @@ #include "Config.h" #include "StringViewHelpers.h" #include "absl/strings/str_join.h" +#include "absl/strings/str_cat.h" #include #include @@ -128,7 +129,7 @@ void sfz::Parser::readSfzFile(const std::filesystem::path& fileName, std::vector std::string::size_type findPos = tmpView.find(sfz::config::defineCharacter, lastPos); while (findPos < tmpView.npos) { - newString.append(tmpView, lastPos, findPos - lastPos); + absl::StrAppend(&newString, tmpView.substr(lastPos, findPos - lastPos)); const auto defineEnd = tmpView.find_first_of("= \r\t\n\f\v", findPos); const auto candidate = tmpView.substr(findPos, defineEnd - findPos); @@ -150,7 +151,7 @@ void sfz::Parser::readSfzFile(const std::filesystem::path& fileName, std::vector } // Copy the rest of the string - newString += tmpView.substr(lastPos); + absl::StrAppend(&newString, tmpView.substr(lastPos)); lines.push_back(std::move(newString)); } } From d6b4678582c34f5a5efd963fe91638b10a984ddc Mon Sep 17 00:00:00 2001 From: paulfd Date: Fri, 20 Sep 2019 22:58:26 +0200 Subject: [PATCH 20/26] Use SFINAE to replace if constexpr --- sfizz/Opcode.h | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/sfizz/Opcode.h b/sfizz/Opcode.h index f392e45d..79694ca5 100644 --- a/sfizz/Opcode.h +++ b/sfizz/Opcode.h @@ -29,6 +29,7 @@ #include "StringViewHelpers.h" #include #include +#include // charconv support is still sketchy with clang/gcc so we use abseil's numbers #include "absl/strings/numbers.h" @@ -44,10 +45,9 @@ struct Opcode { LEAK_DETECTOR(Opcode); }; -template +template ::value, int> = 0> inline absl::optional readOpcode(absl::string_view value, const Range& validRange) { - if constexpr (std::is_integral::value) { int64_t returnedValue; if (!absl::SimpleAtoi(value, &returnedValue)) { float floatValue; @@ -62,13 +62,16 @@ inline absl::optional readOpcode(absl::string_view value, const Range returnedValue = std::numeric_limits::min(); return validRange.clamp(static_cast(returnedValue)); - } else { - float returnedValue; - if (!absl::SimpleAtof(value, &returnedValue)) - return absl::nullopt; +} - return validRange.clamp(returnedValue); - } +template ::value, int> = 0> +inline absl::optional readOpcode(absl::string_view value, const Range& validRange) +{ + float returnedValue; + if (!absl::SimpleAtof(value, &returnedValue)) + return absl::nullopt; + + return validRange.clamp(returnedValue); } inline absl::optional readBooleanFromOpcode(const Opcode& opcode) From 695ec6ed54c379b68a21d0d563e1a19549ec15e4 Mon Sep 17 00:00:00 2001 From: paulfd Date: Fri, 20 Sep 2019 23:10:09 +0200 Subject: [PATCH 21/26] Used SFINAE except of if constexpr for the AudioSpan constructor --- sfizz/AudioSpan.h | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/sfizz/AudioSpan.h b/sfizz/AudioSpan.h index aa2e3332..7fe56593 100644 --- a/sfizz/AudioSpan.h +++ b/sfizz/AudioSpan.h @@ -28,8 +28,8 @@ #include "Debug.h" #include "LeakDetector.h" #include "SIMDHelpers.h" -#include #include +#include #include template @@ -76,19 +76,24 @@ public: } } + template , typename = std::enable_if_t::value, int>> + AudioSpan(AudioBuffer& audioBuffer) + : numFrames(audioBuffer.getNumFrames()) + , numChannels(audioBuffer.getNumChannels()) + { + for (int i = 0; i < numChannels; i++) { + this->spans[i] = audioBuffer.channelReader(i); + } + } template > AudioSpan(AudioBuffer& audioBuffer) : numFrames(audioBuffer.getNumFrames()) , numChannels(audioBuffer.getNumChannels()) { for (int i = 0; i < numChannels; i++) { - if constexpr (std::is_const::value) - this->spans[i] = audioBuffer.channelReader(i); - else - this->spans[i] = audioBuffer.channelWriter(i); + this->spans[i] = audioBuffer.channelWriter(i); } } - template > AudioSpan(const AudioSpan& other) : numFrames(other.getNumFrames()) From a913556389db38a20f5cf9855c532c0cdf445338 Mon Sep 17 00:00:00 2001 From: paulfd Date: Fri, 20 Sep 2019 23:24:39 +0200 Subject: [PATCH 22/26] String view and filesystem are not happy neighbors --- sfizz/FilePool.cpp | 15 ++++++++++----- sfizz/FilePool.h | 6 +++--- sfizz/Synth.cpp | 9 +++++---- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/sfizz/FilePool.cpp b/sfizz/FilePool.cpp index 5681d098..9eaa35a2 100644 --- a/sfizz/FilePool.cpp +++ b/sfizz/FilePool.cpp @@ -48,7 +48,7 @@ std::unique_ptr> readFromFile(SndfileHandle& sndFile, int numFram return std::move(returnedBuffer); } -absl::optional sfz::FilePool::getFileInformation(absl::string_view filename, uint32_t offset) noexcept +absl::optional sfz::FilePool::getFileInformation(const std::string& filename, uint32_t offset) noexcept { std::filesystem::path file { rootDirectory / filename }; if (!std::filesystem::exists(file)) @@ -102,7 +102,7 @@ absl::optional sfz::FilePool::getFileInformation return returnedValue; } -void sfz::FilePool::enqueueLoading(Voice* voice, absl::string_view sample, int numFrames, unsigned ticket) noexcept +void sfz::FilePool::enqueueLoading(Voice* voice, const std::string* sample, int numFrames, unsigned ticket) noexcept { if (!loadingQueue.try_enqueue({ voice, sample, numFrames, ticket })) { DBG("Problem enqueuing a file read for file " << sample); @@ -122,10 +122,15 @@ void sfz::FilePool::loadingThread() noexcept continue; } - DBG("Background loading of: " << fileToLoad.sample); - std::filesystem::path file { rootDirectory / fileToLoad.sample }; + if (fileToLoad.sample == nullptr) { + DBG("Background thread error: sample is null."); + continue; + } + + DBG("Background loading of: " << *fileToLoad.sample); + std::filesystem::path file { rootDirectory / *fileToLoad.sample }; if (!std::filesystem::exists(file)) { - DBG("Background thread: no file " << fileToLoad.sample << " exists."); + DBG("Background thread: no file " << *fileToLoad.sample << " exists."); continue; } diff --git a/sfizz/FilePool.h b/sfizz/FilePool.h index 1c6c7f59..dad2e0f7 100644 --- a/sfizz/FilePool.h +++ b/sfizz/FilePool.h @@ -60,14 +60,14 @@ public: double sampleRate { config::defaultSampleRate }; std::shared_ptr> preloadedData; }; - absl::optional getFileInformation(absl::string_view filename, uint32_t offset) noexcept; - void enqueueLoading(Voice* voice, absl::string_view sample, int numFrames, unsigned ticket) noexcept; + absl::optional getFileInformation(const std::string& filename, uint32_t offset) noexcept; + void enqueueLoading(Voice* voice, const std::string* sample, int numFrames, unsigned ticket) noexcept; void clear(); private: std::filesystem::path rootDirectory; struct FileLoadingInformation { Voice* voice; - absl::string_view sample; + const std::string* sample; int numFrames; unsigned ticket; }; diff --git a/sfizz/Synth.cpp b/sfizz/Synth.cpp index b1aade21..87a647c2 100644 --- a/sfizz/Synth.cpp +++ b/sfizz/Synth.cpp @@ -151,7 +151,8 @@ void sfz::Synth::handleControlOpcodes(const std::vector& members) break; case hash("Default_path"): [[fallthrough]]; case hash("default_path"): { - auto newPath = std::filesystem::path(member.value); + auto stringPath = std::string(member.value.begin(), member.value.end()); + auto newPath = std::filesystem::path(stringPath); if (std::filesystem::exists(newPath)) rootDirectory = newPath; break; @@ -349,7 +350,7 @@ void sfz::Synth::noteOn(int delay, int channel, int noteNumber, uint8_t velocity voice->startVoice(region, delay, channel, noteNumber, velocity, Voice::TriggerType::NoteOn); if (!region->isGenerator()) { voice->expectFileData(fileTicket); - filePool.enqueueLoading(voice, region->sample, region->trueSampleEnd(), fileTicket++); + filePool.enqueueLoading(voice, ®ion->sample, region->trueSampleEnd(), fileTicket++); } } } @@ -374,7 +375,7 @@ void sfz::Synth::noteOff(int delay, int channel, int noteNumber, uint8_t velocit voice->startVoice(region, delay, channel, noteNumber, replacedVelocity, Voice::TriggerType::NoteOff); if (!region->isGenerator()) { voice->expectFileData(fileTicket); - filePool.enqueueLoading(voice, region->sample, region->trueSampleEnd(), fileTicket++); + filePool.enqueueLoading(voice, ®ion->sample, region->trueSampleEnd(), fileTicket++); } } } @@ -399,7 +400,7 @@ void sfz::Synth::cc(int delay, int channel, int ccNumber, uint8_t ccValue) noexc voice->startVoice(region, delay, channel, ccNumber, ccValue, Voice::TriggerType::CC); if (!region->isGenerator()) { voice->expectFileData(fileTicket); - filePool.enqueueLoading(voice, region->sample, region->trueSampleEnd(), fileTicket++); + filePool.enqueueLoading(voice, ®ion->sample, region->trueSampleEnd(), fileTicket++); } } } From ecfed7f41bbd54908d7c50a195049c3b55fd391d Mon Sep 17 00:00:00 2001 From: paulfd Date: Fri, 20 Sep 2019 23:24:51 +0200 Subject: [PATCH 23/26] Added abseil string views in the helpers --- sfizz/StringViewHelpers.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sfizz/StringViewHelpers.h b/sfizz/StringViewHelpers.h index d4a5add0..4b3ad8d0 100644 --- a/sfizz/StringViewHelpers.h +++ b/sfizz/StringViewHelpers.h @@ -22,7 +22,7 @@ // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #pragma once -#include +#include "absl/strings/string_view.h" inline void trimInPlace(absl::string_view& s) { From 098bf5231dd01d36df146820af6c139cc2ae42cd Mon Sep 17 00:00:00 2001 From: paulfd Date: Fri, 20 Sep 2019 23:32:05 +0200 Subject: [PATCH 24/26] Removed structured bindings from the filters --- sfizz/OnePoleFilter.h | 44 +++++++++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/sfizz/OnePoleFilter.h b/sfizz/OnePoleFilter.h index 809c7b36..6c147199 100644 --- a/sfizz/OnePoleFilter.h +++ b/sfizz/OnePoleFilter.h @@ -53,42 +53,58 @@ public: int processLowpass(absl::Span input, absl::Span lowpass) { - for (auto [in, out] = std::pair(input.begin(), lowpass.begin()); - in < input.end() && out < lowpass.end(); in++, out++) { + auto in = input.begin(); + auto out = lowpass.begin(); + auto size = std::min(input.size(), lowpass.size()); + auto sentinel = in.begin() + size; + while (in < sentinel) { oneLowpass(in, out); + in++; + out++; } - return std::min(input.size(), lowpass.size()); + return size; } int processHighpass(absl::Span input, absl::Span highpass) { - for (auto [in, out] = std::pair(input.begin(), highpass.begin()); - in < input.end() && out < highpass.end(); in++, out++) { + auto in = input.begin(); + auto out = highpass.begin(); + auto size = std::min(input.size(), highpass.size()); + auto sentinel = in.begin() + size; + while (in < sentinel) { oneHighpass(in, out); + in++; + out++; } - return std::min(input.size(), highpass.size()); + return size; } int processLowpassVariableGain(absl::Span input, absl::Span lowpass, absl::Span gain) { - for (auto [in, out, g] = std::tuple(input.begin(), lowpass.begin(), gain.begin()); - in < input.end() && out < lowpass.end() && g < gain.end(); in++, out++, g++) { + auto in = input.begin(); + auto out = lowpass.begin(); + auto g = gain.begin(); + auto size = min(input.size(), lowpass.size(), gain.size()); + auto sentinel = in.begin() + size; + while (in < sentinel) { setGain(*g); oneLowpass(in, out); } - - return std::min({ input.size(), lowpass.size(), gain.size() }); + return size; } int processHighpassVariableGain(absl::Span input, absl::Span highpass, absl::Span gain) { - for (auto [in, out, g] = std::tuple(input.begin(), highpass.begin(), gain.begin()); - in < input.end() && out < highpass.end() && g < gain.end(); in++, out++, g++) { + auto in = input.begin(); + auto out = highpass.begin(); + auto g = gain.begin(); + auto size = min(input.size(), highpass.size(), gain.size()); + auto sentinel = in.begin() + size; + while (in < sentinel) { setGain(*g); oneHighpass(in, out); } - - return std::min({ input.size(), highpass.size(), gain.size() }); + return size; } void reset() { state = 0.0; } From 5250756fd130479ef94932aa8d3edbbd75fac4f0 Mon Sep 17 00:00:00 2001 From: paulfd Date: Fri, 20 Sep 2019 23:32:22 +0200 Subject: [PATCH 25/26] Removed usage of string-view literals --- tests/HelpersT.cpp | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/tests/HelpersT.cpp b/tests/HelpersT.cpp index c470b37c..07004b5a 100644 --- a/tests/HelpersT.cpp +++ b/tests/HelpersT.cpp @@ -23,36 +23,35 @@ #include "StringViewHelpers.h" #include "catch2/catch.hpp" -#include +#include "absl/strings/string_view.h" using namespace Catch::literals; -using namespace std::literals::string_view_literals; TEST_CASE("[Helpers] trimInPlace") { SECTION("Trim nothing") { - auto input { "view"sv }; + absl::string_view input { "view" }; trimInPlace(input); - REQUIRE(input == "view"sv); + REQUIRE(input == "view"); } SECTION("Trim spaces") { - auto input { " view "sv }; + absl::string_view input { " view " }; trimInPlace(input); - REQUIRE(input == "view"sv); + REQUIRE(input == "view"); } SECTION("Trim other chars") { - auto input { " \tview \t"sv }; + absl::string_view input { " \tview \t" }; trimInPlace(input); - REQUIRE(input == "view"sv); + REQUIRE(input == "view"); } SECTION("Empty view") { - auto input { " "sv }; + absl::string_view input { " " }; trimInPlace(input); REQUIRE(input.empty()); } @@ -62,25 +61,25 @@ TEST_CASE("[Helpers] trim") { SECTION("Trim nothing") { - auto input { "view"sv }; - REQUIRE(trim(input) == "view"sv); + absl::string_view input { "view" }; + REQUIRE(trim(input) == "view"); } SECTION("Trim spaces") { - auto input { " view "sv }; - REQUIRE(trim(input) == "view"sv); + absl::string_view input { " view " }; + REQUIRE(trim(input) == "view"); } SECTION("Trim other chars") { - auto input { " \tview \t"sv }; - REQUIRE(trim(input) == "view"sv); + absl::string_view input { " \tview \t" }; + REQUIRE(trim(input) == "view"); } SECTION("Empty view") { - auto input { " "sv }; + absl::string_view input { " " }; REQUIRE(trim(input).empty()); } } \ No newline at end of file From bd8a565cef0f3b08170c323f4f10f190459366e1 Mon Sep 17 00:00:00 2001 From: paulfd Date: Fri, 20 Sep 2019 23:35:25 +0200 Subject: [PATCH 26/26] Cleaning up the filters' compilation errors --- sfizz/OnePoleFilter.h | 10 +++++----- tests/OnePoleFilterT.cpp | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/sfizz/OnePoleFilter.h b/sfizz/OnePoleFilter.h index 6c147199..14d080ac 100644 --- a/sfizz/OnePoleFilter.h +++ b/sfizz/OnePoleFilter.h @@ -56,7 +56,7 @@ public: auto in = input.begin(); auto out = lowpass.begin(); auto size = std::min(input.size(), lowpass.size()); - auto sentinel = in.begin() + size; + auto sentinel = in + size; while (in < sentinel) { oneLowpass(in, out); in++; @@ -70,7 +70,7 @@ public: auto in = input.begin(); auto out = highpass.begin(); auto size = std::min(input.size(), highpass.size()); - auto sentinel = in.begin() + size; + auto sentinel = in + size; while (in < sentinel) { oneHighpass(in, out); in++; @@ -85,7 +85,7 @@ public: auto out = lowpass.begin(); auto g = gain.begin(); auto size = min(input.size(), lowpass.size(), gain.size()); - auto sentinel = in.begin() + size; + auto sentinel = in + size; while (in < sentinel) { setGain(*g); oneLowpass(in, out); @@ -99,10 +99,10 @@ public: auto out = highpass.begin(); auto g = gain.begin(); auto size = min(input.size(), highpass.size(), gain.size()); - auto sentinel = in.begin() + size; + auto sentinel = in + size; while (in < sentinel) { setGain(*g); - oneHighpass(in, out); + oneLowpass(in, out); } return size; } diff --git a/tests/OnePoleFilterT.cpp b/tests/OnePoleFilterT.cpp index 56fe281c..14cadcaf 100644 --- a/tests/OnePoleFilterT.cpp +++ b/tests/OnePoleFilterT.cpp @@ -24,9 +24,9 @@ #include "OnePoleFilter.h" #include "catch2/catch.hpp" #include "cnpy.h" +#include "../sfizz/compat/filesystem.h" #include #include -#include #include using namespace Catch::literals; @@ -67,7 +67,7 @@ void testLowpass(const std::filesystem::path& inputNumpyFile, const std::filesys for (auto& data : outputSpan) expectedData.push_back(static_cast(data)); - OnePoleFilter filter { gain }; + OnePoleFilter filter { gain }; std::vector outputData(size); filter.processLowpass(inputData, absl::MakeSpan(outputData)); REQUIRE(approxEqual(outputData, expectedData)); @@ -102,7 +102,7 @@ void testHighpass(const std::filesystem::path& inputNumpyFile, const std::filesy for (auto& data : outputSpan) expectedData.push_back(static_cast(data)); - OnePoleFilter filter { gain }; + OnePoleFilter filter { gain }; std::vector outputData(size); filter.processHighpass(inputData, absl::MakeSpan(outputData)); REQUIRE(approxEqual(outputData, expectedData));