Merge branch 'doxygen-fix' of github.com:sfztools/sfizz into doxygen-fix
This commit is contained in:
commit
3aef3819f6
91 changed files with 6890 additions and 534 deletions
|
|
@ -1,4 +1,5 @@
|
|||
---
|
||||
---
|
||||
BasedOnStyle: WebKit
|
||||
SortIncludes: false
|
||||
|
||||
...
|
||||
|
|
|
|||
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -32,3 +32,6 @@ node_modules/
|
|||
*.lock
|
||||
*.sublime-*
|
||||
*.code-*
|
||||
|
||||
/vst/download
|
||||
/vst/external/VST_SDK
|
||||
|
|
|
|||
60
.travis.yml
60
.travis.yml
|
|
@ -1,20 +1,21 @@
|
|||
language: cpp
|
||||
|
||||
jobs:
|
||||
include:
|
||||
- os: linux
|
||||
stage: "Build"
|
||||
name: "Windows mingw32"
|
||||
env:
|
||||
- CROSS_COMPILE=mingw32
|
||||
- CONTAINER=cross
|
||||
- INSTALL_DIR="sfizz-${TRAVIS_BRANCH}-mingw32"
|
||||
|
||||
- os: linux
|
||||
name: "Windows mingw64"
|
||||
env:
|
||||
- CROSS_COMPILE=mingw64
|
||||
- CONTAINER=cross
|
||||
- INSTALL_DIR="sfizz-${TRAVIS_BRANCH}-mingw64"
|
||||
|
||||
- os: linux
|
||||
name: "Linux amd64 library"
|
||||
arch: amd64
|
||||
dist: bionic
|
||||
env:
|
||||
|
|
@ -23,11 +24,8 @@ jobs:
|
|||
apt:
|
||||
sources:
|
||||
- sourceline: 'ppa:ubuntu-toolchain-r/test'
|
||||
|
||||
packages:
|
||||
- doxygen
|
||||
|
||||
- os: linux
|
||||
name: "Linux arm64 library"
|
||||
arch: arm64
|
||||
dist: bionic
|
||||
env:
|
||||
|
|
@ -36,8 +34,8 @@ jobs:
|
|||
apt:
|
||||
sources:
|
||||
- sourceline: 'ppa:ubuntu-toolchain-r/test'
|
||||
|
||||
- os: linux
|
||||
name: "Linux arm64 static LV2"
|
||||
arch: arm64
|
||||
dist: bionic
|
||||
env:
|
||||
|
|
@ -47,9 +45,8 @@ jobs:
|
|||
apt:
|
||||
sources:
|
||||
- sourceline: 'ppa:ubuntu-toolchain-r/test'
|
||||
|
||||
- os: linux
|
||||
arch: amd64
|
||||
name: "Linux amd64 static LV2"
|
||||
dist: bionic
|
||||
env:
|
||||
- BUILD_TYPE=lv2
|
||||
|
|
@ -58,13 +55,15 @@ jobs:
|
|||
apt:
|
||||
sources:
|
||||
- sourceline: 'ppa:ubuntu-toolchain-r/test'
|
||||
|
||||
- os: osx
|
||||
name: "macOS"
|
||||
osx_image: xcode10.1
|
||||
env:
|
||||
- INSTALL_DIR="sfizz-${TRAVIS_BRANCH}-${TRAVIS_OS_NAME}-${TRAVIS_CPU_ARCH}"
|
||||
|
||||
- os: linux
|
||||
stage: "Deploy"
|
||||
name: "Source packaging"
|
||||
env:
|
||||
- BUILD_TYPE=source
|
||||
- INSTALL_DIR="sfizz-${TRAVIS_BRANCH}-src"
|
||||
|
|
@ -72,22 +71,49 @@ jobs:
|
|||
apt:
|
||||
packages:
|
||||
- python-pip
|
||||
|
||||
before_install:
|
||||
- true
|
||||
|
||||
install:
|
||||
- sudo pip install git-archive-all
|
||||
|
||||
script:
|
||||
- git-archive-all --prefix="sfizz-${TRAVIS_BRANCH}/" -9 "${INSTALL_DIR}.tar.gz"
|
||||
|
||||
after_failure:
|
||||
- true
|
||||
|
||||
after_success:
|
||||
- true
|
||||
|
||||
- os: linux
|
||||
name: "Generate documentation"
|
||||
dist: bionic
|
||||
if: (tag IS present) AND (branch = master)
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- doxygen
|
||||
- cmake
|
||||
- libsndfile-dev
|
||||
before_install:
|
||||
- true
|
||||
install:
|
||||
- true
|
||||
script:
|
||||
- .travis/update_dox.sh
|
||||
after_failure:
|
||||
- true
|
||||
after_success:
|
||||
- true
|
||||
- os: linux
|
||||
name: "Discord Webhook"
|
||||
dist: bionic
|
||||
before_install:
|
||||
- true
|
||||
install:
|
||||
- true
|
||||
script:
|
||||
- true
|
||||
after_success:
|
||||
- bash ${TRAVIS_BUILD_DIR}/.travis/discord_webhook.sh success
|
||||
|
||||
before_install:
|
||||
- bash ${TRAVIS_BUILD_DIR}/.travis/before_install.sh
|
||||
|
||||
|
|
@ -101,8 +127,6 @@ after_failure:
|
|||
- bash ${TRAVIS_BUILD_DIR}/.travis/discord_webhook.sh failure
|
||||
|
||||
after_success:
|
||||
- bash ${TRAVIS_BUILD_DIR}/.travis/discord_webhook.sh success
|
||||
- bash ${TRAVIS_BUILD_DIR}/.travis/update_dox.sh
|
||||
- bash ${TRAVIS_BUILD_DIR}/.travis/after_success.sh
|
||||
|
||||
deploy:
|
||||
|
|
|
|||
|
|
@ -3,11 +3,7 @@
|
|||
set -x # No fail, we need to go back to the original branch at the end
|
||||
. .travis/environment.sh
|
||||
|
||||
# Build documentation only from Linux x86_64 builds
|
||||
if [[ ${TRAVIS_CPU_ARCH} != "amd64" || ${TRAVIS_OS_NAME} != "linux" || "${CROSS_COMPILE}" != "" || ${TRAVIS_TAG} == "" ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
mkdir build && cd build && cmake -DSFIZZ_JACK=OFF -DSFIZZ_SHARED=OFF -DSFIZZ_LV2=OFF .. && cd ..
|
||||
doxygen Doxyfile
|
||||
git fetch --depth=1 https://github.com/${TRAVIS_REPO_SLUG}.git refs/heads/gh-pages:refs/remotes/origin/gh-pages
|
||||
git checkout origin/gh-pages
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ endif()
|
|||
option (ENABLE_LTO "Enable Link Time Optimization [default: ON]" ON)
|
||||
option (SFIZZ_JACK "Enable JACK stand-alone build [default: ON]" ON)
|
||||
option (SFIZZ_LV2 "Enable LV2 plug-in build [default: ON]" ON)
|
||||
option (SFIZZ_VST "Enable VST plug-in build [default: OFF]" OFF)
|
||||
option (SFIZZ_BENCHMARKS "Enable benchmarks build [default: OFF]" OFF)
|
||||
option (SFIZZ_TESTS "Enable tests build [default: OFF]" OFF)
|
||||
option (SFIZZ_SHARED "Enable shared library build [default: ON]" ON)
|
||||
|
|
@ -51,6 +52,10 @@ if (SFIZZ_LV2)
|
|||
add_subdirectory (lv2)
|
||||
endif()
|
||||
|
||||
if (SFIZZ_VST)
|
||||
add_subdirectory (vst)
|
||||
endif()
|
||||
|
||||
if (SFIZZ_BENCHMARKS)
|
||||
add_subdirectory (benchmarks)
|
||||
endif()
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ platform:
|
|||
- x64
|
||||
cache:
|
||||
- c:\tools\vcpkg\installed\ -> appveyor.yml
|
||||
- vst\download
|
||||
|
||||
install:
|
||||
- cmd: choco install -y innosetup
|
||||
|
|
@ -18,9 +19,7 @@ before_build:
|
|||
- cmd: git submodule update --init
|
||||
- cmd: mkdir CMakeBuild
|
||||
- cmd: cd CMakeBuild
|
||||
- cmd: if %platform%==Win32 set CMAKE_GENERATOR=Visual Studio 15 2017
|
||||
- cmd: if %platform%==x64 set CMAKE_GENERATOR=Visual Studio 15 2017 Win64
|
||||
- cmd: cmake .. -G"%CMAKE_GENERATOR%" -DSFIZZ_JACK=OFF -DSFIZZ_BENCHMARKS=OFF -DSFIZZ_TESTS=OFF -DSFIZZ_LV2=ON -DCMAKE_BUILD_TYPE=Release -DVCPKG_TARGET_TRIPLET=%VCPKG_TRIPLET% -DCMAKE_TOOLCHAIN_FILE=C:/Tools/vcpkg/scripts/buildsystems/vcpkg.cmake
|
||||
- cmd: cmake .. -G"Visual Studio 15 2017" -A"%platform%" -DSFIZZ_JACK=OFF -DSFIZZ_BENCHMARKS=OFF -DSFIZZ_TESTS=OFF -DSFIZZ_LV2=ON -DSFIZZ_VST=ON -DCMAKE_BUILD_TYPE=Release -DVCPKG_TARGET_TRIPLET=%VCPKG_TRIPLET% -DCMAKE_TOOLCHAIN_FILE=C:/Tools/vcpkg/scripts/buildsystems/vcpkg.cmake
|
||||
|
||||
build_script:
|
||||
- cmd: cmake --build . --config Release -j
|
||||
|
|
@ -31,6 +30,7 @@ after_build:
|
|||
- cmd: if %platform%==Win32 set RELEASE_ARCH=x86
|
||||
- cmd: if %platform%==x64 set RELEASE_ARCH=x64
|
||||
- cmd: 7z a sfizz-lv2-%APPVEYOR_REPO_TAG_NAME%-%RELEASE_ARCH%-msvc.zip sfizz.lv2
|
||||
- cmd: 7z a sfizz-vst3-%APPVEYOR_REPO_TAG_NAME%-%RELEASE_ARCH%-msvc.zip sfizz.vst3
|
||||
- cmd: 7z a sfizz-lib-%APPVEYOR_REPO_TAG_NAME%-%RELEASE_ARCH%-msvc.zip src/Release/sfizz*
|
||||
- cmd: iscc.exe /dARCH=%RELEASE_ARCH% innosetup.iss
|
||||
|
||||
|
|
|
|||
350
benchmarks/BM_maps.cpp
Normal file
350
benchmarks/BM_maps.cpp
Normal file
|
|
@ -0,0 +1,350 @@
|
|||
// SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
// This code is part of the sfizz library and is licensed under a BSD 2-clause
|
||||
// license. You should have receive a LICENSE.md file along with the code.
|
||||
// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz
|
||||
|
||||
#include <benchmark/benchmark.h>
|
||||
#include <vector>
|
||||
#include <numeric>
|
||||
#include <random>
|
||||
#include "../src/sfizz/Range.h"
|
||||
#include <absl/container/flat_hash_map.h>
|
||||
#include <absl/algorithm/container.h>
|
||||
|
||||
constexpr int maxCC { 256 };
|
||||
|
||||
class MyFixture : public benchmark::Fixture {
|
||||
public:
|
||||
void SetUp(const ::benchmark::State& state)
|
||||
{
|
||||
std::random_device rd {};
|
||||
std::mt19937 gen { rd() };
|
||||
std::uniform_real_distribution<float> distFloat { 0.1f, 1.0f };
|
||||
std::uniform_int_distribution<int> distInt { 1, maxCC };
|
||||
floats = std::vector<float>(state.range(0));
|
||||
ccs = std::vector<int>(state.range(0));
|
||||
ranges = std::vector<sfz::Range<int>>(state.range(0));
|
||||
absl::c_generate(floats, [&]() {
|
||||
return distFloat(gen);
|
||||
});
|
||||
absl::c_generate(ccs, [&]() {
|
||||
return distInt(gen);
|
||||
});
|
||||
absl::c_generate(ranges, [&]() {
|
||||
return sfz::Range<int>(distInt(gen), distInt(gen));
|
||||
});
|
||||
}
|
||||
|
||||
void TearDown(const ::benchmark::State& state [[maybe_unused]])
|
||||
{
|
||||
}
|
||||
|
||||
std::vector<int> ccs;
|
||||
std::vector<sfz::Range<int>> ranges;
|
||||
std::vector<float> floats;
|
||||
};
|
||||
|
||||
template<class ValueType>
|
||||
struct CCValuePair {
|
||||
int cc;
|
||||
ValueType value;
|
||||
};
|
||||
|
||||
template<class ValueType, bool CompareValue = false>
|
||||
struct CCValuePairComparator {
|
||||
bool operator()(const CCValuePair<ValueType>& valuePair, const int& cc)
|
||||
{
|
||||
return (valuePair.cc < cc);
|
||||
}
|
||||
|
||||
bool operator()(const int& cc, const CCValuePair<ValueType>& valuePair)
|
||||
{
|
||||
return (cc < valuePair.cc);
|
||||
}
|
||||
|
||||
bool operator()(const CCValuePair<ValueType>& lhs, const CCValuePair<ValueType>& rhs)
|
||||
{
|
||||
return (lhs.cc < rhs.cc);
|
||||
}
|
||||
};
|
||||
|
||||
template<class ValueType>
|
||||
struct CCValuePairComparator<ValueType, true> {
|
||||
bool operator()(const CCValuePair<ValueType>& valuePair, const ValueType& value)
|
||||
{
|
||||
return (valuePair.value < value);
|
||||
}
|
||||
|
||||
bool operator()(const ValueType& value, const CCValuePair<ValueType>& valuePair)
|
||||
{
|
||||
return (value < valuePair.value);
|
||||
}
|
||||
|
||||
bool operator()(const CCValuePair<ValueType>& lhs, const CCValuePair<ValueType>& rhs)
|
||||
{
|
||||
return (lhs.value < rhs.value);
|
||||
}
|
||||
};
|
||||
|
||||
template <class ValueType>
|
||||
class CCMap {
|
||||
public:
|
||||
CCMap() = delete;
|
||||
/**
|
||||
* @brief Construct a new CCMap object with the specified default value.
|
||||
*
|
||||
* @param defaultValue
|
||||
*/
|
||||
CCMap(const ValueType& defaultValue)
|
||||
: defaultValue(defaultValue)
|
||||
{
|
||||
}
|
||||
CCMap(CCMap&&) = default;
|
||||
CCMap(const CCMap&) = default;
|
||||
~CCMap() = default;
|
||||
|
||||
/**
|
||||
* @brief Returns the held object at the index, or a default value if not present
|
||||
*
|
||||
* @param index
|
||||
* @return const ValueType&
|
||||
*/
|
||||
const ValueType& getWithDefault(int index) const noexcept
|
||||
{
|
||||
auto it = absl::c_lower_bound(container, index, CCValuePairComparator<ValueType>{});
|
||||
if (it == container.end() || it->cc != index) {
|
||||
return defaultValue;
|
||||
} else {
|
||||
return it->value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the value at index or emplace a new one if not present
|
||||
*
|
||||
* @param index the index of the element
|
||||
* @return ValueType&
|
||||
*/
|
||||
ValueType& operator[](const int& index) noexcept
|
||||
{
|
||||
auto it = absl::c_lower_bound(container, index, CCValuePairComparator<ValueType>{});
|
||||
if (it == container.end() || it->cc != index) {
|
||||
auto inserted = container.insert(it, { index, defaultValue });
|
||||
return inserted->value;
|
||||
} else {
|
||||
return it->value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Is the container empty
|
||||
*
|
||||
* @return true
|
||||
* @return false
|
||||
*/
|
||||
inline bool empty() const { return container.empty(); }
|
||||
/**
|
||||
* @brief Returns true if the container containers an element at index
|
||||
*
|
||||
* @param index
|
||||
* @return true
|
||||
* @return false
|
||||
*/
|
||||
bool contains(int index) const noexcept
|
||||
{
|
||||
return absl::c_binary_search(container, index, CCValuePairComparator<ValueType>{});
|
||||
}
|
||||
typename std::vector<CCValuePair<ValueType>>::const_iterator begin() const { return container.cbegin(); }
|
||||
typename std::vector<CCValuePair<ValueType>>::const_iterator end() const { return container.cend(); }
|
||||
private:
|
||||
// typename std::vector<std::pair<int, ValueType>>::iterator begin() { return container.begin(); }
|
||||
// typename std::vector<std::pair<int, ValueType>>::iterator end() { return container.end(); }
|
||||
|
||||
const ValueType defaultValue;
|
||||
std::vector<CCValuePair<ValueType>> container;
|
||||
};
|
||||
|
||||
BENCHMARK_DEFINE_F(MyFixture, FillVector_Float)
|
||||
(benchmark::State& state)
|
||||
{
|
||||
for (auto _ : state) {
|
||||
CCMap<float> map { 0 };
|
||||
for (int i = 0; i < state.range(0); ++i)
|
||||
map[ccs[i]] = floats[i];
|
||||
}
|
||||
}
|
||||
|
||||
BENCHMARK_DEFINE_F(MyFixture, FillVector_Range)
|
||||
(benchmark::State& state)
|
||||
{
|
||||
for (auto _ : state) {
|
||||
CCMap<sfz::Range<int>> map { sfz::Range<int>(0, 127) };
|
||||
for (int i = 0; i < state.range(0); ++i)
|
||||
map[ccs[i]] = ranges[i];
|
||||
}
|
||||
}
|
||||
|
||||
BENCHMARK_DEFINE_F(MyFixture, FillAbseilFlatHM_Float)
|
||||
(benchmark::State& state)
|
||||
{
|
||||
for (auto _ : state) {
|
||||
absl::flat_hash_map<int, float> map;
|
||||
for (int i = 0; i < state.range(0); ++i)
|
||||
map[ccs[i]] = floats[i];
|
||||
}
|
||||
}
|
||||
|
||||
BENCHMARK_DEFINE_F(MyFixture, FillAbseilFlatHM_Range)
|
||||
(benchmark::State& state)
|
||||
{
|
||||
for (auto _ : state) {
|
||||
absl::flat_hash_map<int, sfz::Range<int>> map;
|
||||
for (int i = 0; i < state.range(0); ++i)
|
||||
map[ccs[i]] = ranges[i];
|
||||
}
|
||||
}
|
||||
|
||||
BENCHMARK_DEFINE_F(MyFixture, LookupBaseline_Float)
|
||||
(benchmark::State& state)
|
||||
{
|
||||
std::vector<float> output;
|
||||
output.resize(state.range(0));
|
||||
|
||||
std::vector<float> map;
|
||||
output.reserve(state.range(0));
|
||||
for (int i = 0; i < state.range(0); ++i)
|
||||
map.push_back(floats[i]);
|
||||
|
||||
for (auto _ : state) {
|
||||
for (int i = 0; i < state.range(0); ++i)
|
||||
output[i] = map[i];
|
||||
}
|
||||
}
|
||||
|
||||
BENCHMARK_DEFINE_F(MyFixture, LookupBaseline_Range)
|
||||
(benchmark::State& state)
|
||||
{
|
||||
std::vector<sfz::Range<int>> output;
|
||||
output.resize(state.range(0));
|
||||
|
||||
std::vector<sfz::Range<int>> map;
|
||||
output.reserve(state.range(0));
|
||||
for (int i = 0; i < state.range(0); ++i)
|
||||
map.push_back(ranges[i]);
|
||||
|
||||
for (auto _ : state) {
|
||||
for (int i = 0; i < state.range(0); ++i)
|
||||
output[i] = map[i];
|
||||
}
|
||||
}
|
||||
|
||||
BENCHMARK_DEFINE_F(MyFixture, LookupVector_Float)
|
||||
(benchmark::State& state)
|
||||
{
|
||||
std::vector<float> output;
|
||||
output.resize(state.range(0));
|
||||
|
||||
CCMap<float> map { 0 };
|
||||
for (int i = 0; i < state.range(0); ++i)
|
||||
map[ccs[i]] = floats[i];
|
||||
|
||||
for (auto _ : state) {
|
||||
for (int i = 0; i < state.range(0); ++i)
|
||||
output[i] = map[ccs[i]];
|
||||
}
|
||||
}
|
||||
|
||||
BENCHMARK_DEFINE_F(MyFixture, LookupVector_Range)
|
||||
(benchmark::State& state)
|
||||
{
|
||||
std::vector<sfz::Range<int>> output;
|
||||
output.resize(state.range(0));
|
||||
|
||||
CCMap<sfz::Range<int>> map { sfz::Range<int>(0, 127) };
|
||||
for (int i = 0; i < state.range(0); ++i)
|
||||
map[ccs[i]] = ranges[i];
|
||||
|
||||
for (auto _ : state) {
|
||||
for (int i = 0; i < state.range(0); ++i)
|
||||
output[i] = map[ccs[i]];
|
||||
}
|
||||
}
|
||||
|
||||
BENCHMARK_DEFINE_F(MyFixture, LookupAbseilFlatHM_Float)
|
||||
(benchmark::State& state)
|
||||
{
|
||||
std::vector<float> output;
|
||||
output.resize(state.range(0));
|
||||
|
||||
absl::flat_hash_map<int, float> map;
|
||||
for (int i = 0; i < state.range(0); ++i)
|
||||
map[ccs[i]] = floats[i];
|
||||
for (auto _ : state) {
|
||||
for (int i = 0; i < state.range(0); ++i)
|
||||
output[i] = map[ccs[i]];
|
||||
}
|
||||
}
|
||||
|
||||
BENCHMARK_DEFINE_F(MyFixture, LookupAbseilFlatHM_Range)
|
||||
(benchmark::State& state)
|
||||
{
|
||||
std::vector<sfz::Range<int>> output;
|
||||
output.resize(state.range(0));
|
||||
|
||||
absl::flat_hash_map<int, sfz::Range<int>> map;
|
||||
for (int i = 0; i < state.range(0); ++i)
|
||||
map[ccs[i]] = ranges[i];
|
||||
|
||||
for (auto _ : state) {
|
||||
for (int i = 0; i < state.range(0); ++i)
|
||||
output[i] = map[ccs[i]];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BENCHMARK_DEFINE_F(MyFixture, IterateVector_Float)
|
||||
(benchmark::State& state)
|
||||
{
|
||||
std::vector<float> output;
|
||||
output.reserve(maxCC);
|
||||
|
||||
CCMap<float> map { 0 };
|
||||
for (int i = 0; i < state.range(0); ++i)
|
||||
map[ccs[i]] = floats[i];
|
||||
|
||||
for (auto _ : state) {
|
||||
for (auto& pair: map)
|
||||
output.push_back(pair.value);
|
||||
}
|
||||
}
|
||||
|
||||
BENCHMARK_DEFINE_F(MyFixture, IterateAbseilFlatHM_Float)
|
||||
(benchmark::State& state)
|
||||
{
|
||||
std::vector<float> output;
|
||||
output.reserve(maxCC);
|
||||
|
||||
absl::flat_hash_map<int, float> map;
|
||||
for (int i = 0; i < state.range(0); ++i)
|
||||
map[ccs[i]] = floats[i];
|
||||
for (auto _ : state) {
|
||||
for (auto& pair: map)
|
||||
output.push_back(pair.second);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BENCHMARK_REGISTER_F(MyFixture, FillVector_Float)->RangeMultiplier(2)->Range(16, 512);
|
||||
// BENCHMARK_REGISTER_F(MyFixture, FillVector_Range)->RangeMultiplier(2)->Range(16, 512);
|
||||
BENCHMARK_REGISTER_F(MyFixture, FillAbseilFlatHM_Float)->RangeMultiplier(2)->Range(16, 512);
|
||||
// BENCHMARK_REGISTER_F(MyFixture, FillAbseilFlatHM_Range)->RangeMultiplier(2)->Range(16, 512);
|
||||
BENCHMARK_REGISTER_F(MyFixture, LookupBaseline_Float)->RangeMultiplier(2)->Range(16, 512);
|
||||
// BENCHMARK_REGISTER_F(MyFixture, LookupBaseline_Range)->RangeMultiplier(2)->Range(16, 512);
|
||||
BENCHMARK_REGISTER_F(MyFixture, LookupVector_Float)->RangeMultiplier(2)->Range(16, 512);
|
||||
// BENCHMARK_REGISTER_F(MyFixture, LookupVector_Range)->RangeMultiplier(2)->Range(16, 512);
|
||||
BENCHMARK_REGISTER_F(MyFixture, LookupAbseilFlatHM_Float)->RangeMultiplier(2)->Range(16, 512);
|
||||
// BENCHMARK_REGISTER_F(MyFixture, LookupAbseilFlatHM_Range)->RangeMultiplier(2)->Range(16, 512);
|
||||
BENCHMARK_REGISTER_F(MyFixture, IterateVector_Float)->Range(maxCC, maxCC);
|
||||
BENCHMARK_REGISTER_F(MyFixture, IterateAbseilFlatHM_Float)->Range(maxCC, maxCC);
|
||||
BENCHMARK_MAIN();
|
||||
84
benchmarks/BM_multiplyAddFixedGain.cpp
Normal file
84
benchmarks/BM_multiplyAddFixedGain.cpp
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
// SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
// This code is part of the sfizz library and is licensed under a BSD 2-clause
|
||||
// license. You should have receive a LICENSE.md file along with the code.
|
||||
// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz
|
||||
|
||||
#include "SIMDHelpers.h"
|
||||
#include <benchmark/benchmark.h>
|
||||
#include <random>
|
||||
#include <numeric>
|
||||
#include <vector>
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
|
||||
class MultiplyAddFixedGain : public benchmark::Fixture {
|
||||
public:
|
||||
void SetUp(const ::benchmark::State& state)
|
||||
{
|
||||
std::random_device rd {};
|
||||
std::mt19937 gen { rd() };
|
||||
std::uniform_real_distribution<float> dist { 0, 1 };
|
||||
input = std::vector<float>(state.range(0));
|
||||
output = std::vector<float>(state.range(0));
|
||||
gain = dist(gen);
|
||||
std::fill(output.begin(), output.end(), 1.0f);
|
||||
std::generate(input.begin(), input.end(), [&]() { return dist(gen); });
|
||||
}
|
||||
|
||||
void TearDown(const ::benchmark::State& state [[maybe_unused]])
|
||||
{
|
||||
}
|
||||
|
||||
float gain = {};
|
||||
std::vector<float> input;
|
||||
std::vector<float> output;
|
||||
};
|
||||
|
||||
BENCHMARK_DEFINE_F(MultiplyAddFixedGain, Straight)
|
||||
(benchmark::State& state)
|
||||
{
|
||||
for (auto _ : state) {
|
||||
for (int i = 0; i < state.range(0); ++i)
|
||||
output[i] += gain * input[i];
|
||||
}
|
||||
}
|
||||
|
||||
BENCHMARK_DEFINE_F(MultiplyAddFixedGain, Scalar)
|
||||
(benchmark::State& state)
|
||||
{
|
||||
for (auto _ : state) {
|
||||
sfz::multiplyAdd<float, false>(gain, input, absl::MakeSpan(output));
|
||||
}
|
||||
}
|
||||
|
||||
BENCHMARK_DEFINE_F(MultiplyAddFixedGain, SIMD)
|
||||
(benchmark::State& state)
|
||||
{
|
||||
for (auto _ : state) {
|
||||
sfz::multiplyAdd<float, true>(gain, input, absl::MakeSpan(output));
|
||||
}
|
||||
}
|
||||
|
||||
BENCHMARK_DEFINE_F(MultiplyAddFixedGain, Scalar_Unaligned)
|
||||
(benchmark::State& state)
|
||||
{
|
||||
for (auto _ : state) {
|
||||
sfz::multiplyAdd<float, false>(gain, absl::MakeSpan(input).subspan(1), absl::MakeSpan(output).subspan(1));
|
||||
}
|
||||
}
|
||||
|
||||
BENCHMARK_DEFINE_F(MultiplyAddFixedGain, SIMD_Unaligned)
|
||||
(benchmark::State& state)
|
||||
{
|
||||
for (auto _ : state) {
|
||||
sfz::multiplyAdd<float, true>(gain, absl::MakeSpan(input).subspan(1), absl::MakeSpan(output).subspan(1));
|
||||
}
|
||||
}
|
||||
|
||||
BENCHMARK_REGISTER_F(MultiplyAddFixedGain, Straight)->RangeMultiplier(4)->Range(1 << 2, 1 << 12);
|
||||
BENCHMARK_REGISTER_F(MultiplyAddFixedGain, Scalar)->RangeMultiplier(4)->Range(1 << 2, 1 << 12);
|
||||
BENCHMARK_REGISTER_F(MultiplyAddFixedGain, SIMD)->RangeMultiplier(4)->Range(1 << 2, 1 << 12);
|
||||
BENCHMARK_REGISTER_F(MultiplyAddFixedGain, Scalar_Unaligned)->RangeMultiplier(4)->Range(1 << 2, 1 << 12);
|
||||
BENCHMARK_REGISTER_F(MultiplyAddFixedGain, SIMD_Unaligned)->RangeMultiplier(4)->Range(1 << 2, 1 << 12);
|
||||
BENCHMARK_MAIN();
|
||||
|
|
@ -27,7 +27,10 @@ macro(sfizz_add_benchmark TARGET)
|
|||
target_link_libraries("${TARGET}"
|
||||
PRIVATE absl::span absl::algorithm
|
||||
PRIVATE benchmark::benchmark benchmark::benchmark_main
|
||||
PRIVATE bm_simd bm_ftz)
|
||||
PRIVATE bm_simd bm_ftz)
|
||||
if (LIBATOMIC_FOUND)
|
||||
target_link_libraries ("${TARGET}" PRIVATE atomic)
|
||||
endif()
|
||||
target_include_directories("${TARGET}" PRIVATE ../src/sfizz ../src/external)
|
||||
endmacro()
|
||||
|
||||
|
|
@ -47,6 +50,7 @@ target_link_libraries(bm_ADSR PRIVATE sfizz::sfizz)
|
|||
|
||||
sfizz_add_benchmark(bm_add BM_add.cpp)
|
||||
sfizz_add_benchmark(bm_multiplyAdd BM_multiplyAdd.cpp)
|
||||
sfizz_add_benchmark(bm_multiplyAddFixedGain BM_multiplyAddFixedGain.cpp)
|
||||
sfizz_add_benchmark(bm_subtract BM_subtract.cpp)
|
||||
sfizz_add_benchmark(bm_copy BM_copy.cpp)
|
||||
sfizz_add_benchmark(bm_pan BM_pan.cpp)
|
||||
|
|
@ -57,6 +61,8 @@ sfizz_add_benchmark(bm_diff BM_diff.cpp)
|
|||
sfizz_add_benchmark(bm_widthPos BM_widthPos.cpp)
|
||||
sfizz_add_benchmark(bm_interpolationCast BM_interpolationCast.cpp)
|
||||
sfizz_add_benchmark(bm_pointerIterationOrOffsets BM_pointerIterationOrOffsets.cpp)
|
||||
sfizz_add_benchmark(bm_maps BM_maps.cpp)
|
||||
target_link_libraries(bm_maps PRIVATE absl::flat_hash_map)
|
||||
|
||||
sfizz_add_benchmark(bm_logger BM_logger.cpp)
|
||||
target_link_libraries(bm_logger PRIVATE sfizz::sfizz)
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ set (LV2PLUGIN_COMMENT "SFZ sampler")
|
|||
set (LV2PLUGIN_URI "http://sfztools.github.io/sfizz")
|
||||
set (LV2PLUGIN_REPOSITORY "https://github.com/sfztools/sfizz")
|
||||
set (LV2PLUGIN_AUTHOR "Paul Ferrand")
|
||||
set (LV2PLUGIN_EMAIL "paul at ferrand dot cc")
|
||||
set (LV2PLUGIN_EMAIL "paul@ferrand.cc")
|
||||
if (SFIZZ_USE_VCPKG)
|
||||
set (LV2PLUGIN_SPDX_LICENSE_ID "LGPL-3.0-only")
|
||||
else()
|
||||
|
|
|
|||
|
|
@ -12,9 +12,9 @@ set (CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|||
set (CMAKE_CXX_VISIBILITY_PRESET hidden)
|
||||
set (CMAKE_VISIBILITY_INLINES_HIDDEN ON)
|
||||
|
||||
# Set Windows compatibility level to Vista
|
||||
# Set Windows compatibility level to 7
|
||||
if (WIN32)
|
||||
add_compile_definitions(_WIN32_WINNT=0x600)
|
||||
add_compile_definitions(_WIN32_WINNT=0x601)
|
||||
endif()
|
||||
|
||||
# Add required flags for the builds
|
||||
|
|
@ -66,6 +66,11 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT ANDROID)
|
|||
endif()
|
||||
endif()
|
||||
|
||||
include (CheckLibraryExists)
|
||||
if (UNIX AND NOT APPLE)
|
||||
check_library_exists(atomic __atomic_load "" LIBATOMIC_FOUND)
|
||||
endif()
|
||||
|
||||
# Don't show build information when building a different project
|
||||
function (show_build_info_if_needed)
|
||||
if (CMAKE_PROJECT_NAME STREQUAL "sfizz")
|
||||
|
|
|
|||
36
cmake/VSTConfig.cmake
Normal file
36
cmake/VSTConfig.cmake
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
set (VSTPLUGIN_NAME "sfizz")
|
||||
set (VSTPLUGIN_VENDOR "Paul Ferrand")
|
||||
set (VSTPLUGIN_URL "http://sfztools.github.io/sfizz")
|
||||
set (VSTPLUGIN_EMAIL "paul@ferrand.cc")
|
||||
|
||||
# The variable CMAKE_SYSTEM_PROCESSOR is incorrect on Visual studio...
|
||||
# see https://gitlab.kitware.com/cmake/cmake/issues/15170
|
||||
|
||||
if(MSVC)
|
||||
set(VST3_SYSTEM_PROCESSOR "${MSVC_CXX_ARCHITECTURE_ID}")
|
||||
else()
|
||||
set(VST3_SYSTEM_PROCESSOR "${CMAKE_SYSTEM_PROCESSOR}")
|
||||
endif()
|
||||
|
||||
message(STATUS "The system architecture is: ${VST3_SYSTEM_PROCESSOR}")
|
||||
|
||||
# --- VST3 Bundle architecture ---
|
||||
if(NOT VST3_PACKAGE_ARCHITECTURE)
|
||||
if(APPLE)
|
||||
# VST3 packages are universal on Apple, architecture string not needed
|
||||
else()
|
||||
if(VST3_SYSTEM_PROCESSOR MATCHES "^(x86_64|amd64|AMD64|x64|X64)$")
|
||||
set(VST3_PACKAGE_ARCHITECTURE "x86_64")
|
||||
elseif(VST3_SYSTEM_PROCESSOR MATCHES "^(i.86|x86|X86)$")
|
||||
if(WIN32)
|
||||
set(VST3_PACKAGE_ARCHITECTURE "x86")
|
||||
else()
|
||||
set(VST3_PACKAGE_ARCHITECTURE "i386")
|
||||
endif()
|
||||
else()
|
||||
message(FATAL_ERROR "We don't know this architecture for VST3: ${VST3_SYSTEM_PROCESSOR}.")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
message(STATUS "The VST3 architecture is deduced as: ${VST3_PACKAGE_ARCHITECTURE}")
|
||||
|
|
@ -5,6 +5,7 @@
|
|||
@prefix lv2: <http://lv2plug.in/ns/lv2core#> .
|
||||
@prefix midi: <http://lv2plug.in/ns/ext/midi#> .
|
||||
@prefix opts: <http://lv2plug.in/ns/ext/options#> .
|
||||
@prefix param: <http://lv2plug.in/ns/ext/parameters#> .
|
||||
@prefix patch: <http://lv2plug.in/ns/ext/patch#> .
|
||||
@prefix pg: <http://lv2plug.in/ns/ext/port-groups#> .
|
||||
@prefix pprop: <http://lv2plug.in/ns/ext/port-props#> .
|
||||
|
|
@ -57,7 +58,7 @@ midnam:update a lv2:Feature .
|
|||
doap:maintainer [
|
||||
foaf:name "@LV2PLUGIN_AUTHOR@" ;
|
||||
foaf:homepage <@LV2PLUGIN_URI@> ;
|
||||
foaf:email "@LV2PLUGIN_EMAIL@";
|
||||
foaf:mbox <mailto:@LV2PLUGIN_EMAIL@> ;
|
||||
] ;
|
||||
rdfs:comment "@LV2PLUGIN_COMMENT@",
|
||||
"Campionatore SFZ"@it ;
|
||||
|
|
@ -72,6 +73,9 @@ midnam:update a lv2:Feature .
|
|||
lv2:optionalFeature midnam:update ;
|
||||
lv2:extensionData midnam:interface ;
|
||||
|
||||
opts:supportedOption param:sampleRate ;
|
||||
opts:supportedOption bufsize:maxBlockLength, bufsize:nominalBlockLength ;
|
||||
|
||||
patch:writable <@LV2PLUGIN_URI@:sfzfile> ;
|
||||
|
||||
lv2:port [
|
||||
|
|
|
|||
18
scripts/create_mac_icon.sh
Executable file
18
scripts/create_mac_icon.sh
Executable file
|
|
@ -0,0 +1,18 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
svg_file="$1"
|
||||
test -z "$svg_file" && exit 1
|
||||
|
||||
sizes="32 48 128 256"
|
||||
|
||||
rm -f "$svg_file".icon.*.png
|
||||
|
||||
for size in $sizes; do
|
||||
png_file="$svg_file".icon."$size".png
|
||||
inkscape -e "$png_file" "$svg_file" -w "$size" -h "$size"
|
||||
optipng "$png_file"
|
||||
done
|
||||
|
||||
png2icns "$svg_file".icns "$svg_file".icon.*.png
|
||||
rm -f "$svg_file".icon.*.png
|
||||
18
scripts/create_windows_icon.sh
Executable file
18
scripts/create_windows_icon.sh
Executable file
|
|
@ -0,0 +1,18 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
svg_file="$1"
|
||||
test -z "$svg_file" && exit 1
|
||||
|
||||
sizes="32 48 128 256"
|
||||
|
||||
rm -f "$svg_file".icon.*.png
|
||||
|
||||
for size in $sizes; do
|
||||
png_file="$svg_file".icon."$size".png
|
||||
inkscape -e "$png_file" "$svg_file" -w "$size" -h "$size"
|
||||
optipng "$png_file"
|
||||
done
|
||||
|
||||
icotool -c -o "$svg_file".ico "$svg_file".icon.*.png
|
||||
rm -f "$svg_file".icon.*.png
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
#define MyAppName "sfizz-lv2"
|
||||
; -*- mode: iss; -*-
|
||||
#define MyAppName "sfizz"
|
||||
#define MyAppVersion "@PROJECT_VERSION@"
|
||||
#define MyAppPublisher "sfizz Team"
|
||||
#define MyAppURL "https://sfztools.github.io/sfizz/"
|
||||
|
|
@ -28,25 +29,35 @@ ArchitecturesInstallIn64BitMode={#Arch}
|
|||
|
||||
Compression=lzma
|
||||
SolidCompression=yes
|
||||
DefaultDirName={commoncf}\LV2
|
||||
DefaultDirName={commonpf}\{#MyAppName}
|
||||
DefaultGroupName={#MyAppPublisher}
|
||||
DisableDirPage=yes
|
||||
;DisableDirPage=yes
|
||||
LicenseFile="sfizz.lv2\LICENSE.md"
|
||||
OutputBaseFileName={#MyAppName}-{#MyAppVersion}-{#Arch}-msvc-setup
|
||||
OutputDir=.
|
||||
UninstallFilesDir={commonpf}\{#MyAppName}
|
||||
UninstallFilesDir={app}
|
||||
WizardImageFile="C:\Program Files (x86)\Inno Setup 6\WizModernImage-IS.bmp"
|
||||
WizardSmallImageFile="C:\Program Files (x86)\Inno Setup 6\WizModernSmallImage-IS.bmp"
|
||||
|
||||
[Languages]
|
||||
Name: "english"; MessagesFile: "compiler:Default.isl"
|
||||
|
||||
[Components]
|
||||
Name: "main"; Description: "Shared files"; Types: full custom; Flags: fixed
|
||||
Name: "lv2"; Description: "LV2 plugin"; Types: full custom;
|
||||
Name: "vst3"; Description: "VST3 plugin"; Types: full custom;
|
||||
|
||||
[Files]
|
||||
Source: "sfizz.lv2\sfizz.dll"; DestDir: {commoncf}\LV2\sfizz.lv2; Flags: ignoreversion
|
||||
Source: "sfizz.lv2\manifest.ttl"; DestDir: {commoncf}\LV2\sfizz.lv2
|
||||
Source: "sfizz.lv2\sfizz.ttl"; DestDir: {commoncf}\LV2\sfizz.lv2
|
||||
Source: "sfizz.lv2\lgpl-3.0.txt"; DestDir: {commonpf}\{#MyAppName}
|
||||
Source: "sfizz.lv2\LICENSE.md"; DestDir: {commonpf}\{#MyAppName}
|
||||
Source: "sfizz.lv2\sfizz.dll"; Components: lv2; DestDir: "{commoncf}\LV2\sfizz.lv2"; Flags: ignoreversion
|
||||
Source: "sfizz.lv2\manifest.ttl"; Components: lv2; DestDir: "{commoncf}\LV2\sfizz.lv2"
|
||||
Source: "sfizz.lv2\sfizz.ttl"; Components: lv2; DestDir: "{commoncf}\LV2\sfizz.lv2"
|
||||
Source: "sfizz.lv2\lgpl-3.0.txt"; Components: main; DestDir: "{app}"
|
||||
Source: "sfizz.lv2\LICENSE.md"; Components: main; DestDir: "{app}"
|
||||
Source: "sfizz.vst3\desktop.ini"; Components: vst3; DestDir: "{commoncf}\VST3\sfizz.vst3"
|
||||
Source: "sfizz.vst3\Contents\@VST3_PACKAGE_ARCHITECTURE@-win\sfizz.vst3"; Components: vst3; DestDir: "{commoncf}\VST3\sfizz.vst3\Contents\@VST3_PACKAGE_ARCHITECTURE@-win"; Flags: ignoreversion
|
||||
Source: "sfizz.vst3\Contents\Resources\logo.png"; Components: vst3; DestDir: "{commoncf}\VST3\sfizz.vst3\Contents\Resources"
|
||||
Source: "sfizz.vst3\Plugin.ico"; Components: vst3; DestDir: "{commoncf}\VST3\sfizz.vst3"
|
||||
Source: "sfizz.vst3\gpl-3.0.txt"; Components: main; DestDir: "{app}"
|
||||
;Source: "setup\vc_redist.x64.exe"; DestDir: {tmp}; Flags: deleteafterinstall
|
||||
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
|
||||
|
||||
|
|
|
|||
261
scripts/performance_report.py
Executable file
261
scripts/performance_report.py
Executable file
|
|
@ -0,0 +1,261 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
import os
|
||||
from bokeh.io import output_file, show
|
||||
from bokeh.plotting import figure
|
||||
from bokeh.layouts import column, row
|
||||
from bokeh.palettes import Dark2_5 as palette
|
||||
from bokeh.models.widgets import Div
|
||||
from bokeh.models import ColumnDataSource
|
||||
import itertools
|
||||
import argparse
|
||||
|
||||
# Constant things
|
||||
callback_log_suffix = "_callback_log.csv"
|
||||
file_log_suffix = "_file_log.csv"
|
||||
file_prefix_length = 14 # length of the pointer prefix
|
||||
|
||||
# sfizz 0.3.0 logs
|
||||
callback_log_columns = ['Dispatch', 'RenderMethod', 'Data', 'Amplitude', 'Filters', 'Panning', 'NumVoices', 'NumSamples']
|
||||
file_log_columns = ['WaitDuration', 'LoadDuration', 'FileSize', 'FileName']
|
||||
|
||||
# Helper functions
|
||||
def scale_columns(dataframe, column_list, scale_factor):
|
||||
"""Scale the columns of a pandas Dataframe
|
||||
|
||||
Arguments:
|
||||
dataframe {pandas Dataframe} -- a dataframe
|
||||
column_list {list of strings} -- the list of column names to scale
|
||||
scale_factor {arithmetic type} -- the scaling factor
|
||||
"""
|
||||
for column in column_list:
|
||||
dataframe[column] *= scale_factor
|
||||
|
||||
def html_list(string_list):
|
||||
"""Returns an HTML list from a list of strings
|
||||
|
||||
Arguments:
|
||||
string_list {list of strings} -- the input list
|
||||
|
||||
Returns:
|
||||
string -- the list of string formatted as an HTML list
|
||||
"""
|
||||
returned_string = "<ul>"
|
||||
for string in string_list:
|
||||
returned_string += f"<li>{string}</li>"
|
||||
returned_string += "</ul>"
|
||||
return returned_string
|
||||
|
||||
def print_summary_to_console(title, lines):
|
||||
"""Prints a multi-line summary to the console
|
||||
|
||||
Arguments:
|
||||
title {string} -- The summary title
|
||||
lines {list of strings} -- The summary lines
|
||||
"""
|
||||
print(title)
|
||||
print('- ', end='')
|
||||
print('\n- '.join(lines))
|
||||
print('\n')
|
||||
|
||||
def extract_file_name_and_prefix(file_name):
|
||||
"""From a file name formatted as "0xAE152342334152_sfzFileName_...", extract the sfz file name and the pointer prefix
|
||||
|
||||
Arguments:
|
||||
file_name {string} -- The mangled sfizz log filename
|
||||
|
||||
Returns:
|
||||
(string, string) -- File name and file prefix
|
||||
"""
|
||||
file_prefix = file_name[:file_prefix_length]
|
||||
|
||||
if file.endswith(file_log_suffix):
|
||||
suffix_length = len(file_log_suffix)
|
||||
elif file.endswith(callback_log_suffix):
|
||||
suffix_length = len(callback_log_suffix)
|
||||
else:
|
||||
suffix_length = 0
|
||||
|
||||
sfz_file_name = file_name[file_prefix_length + 1:-suffix_length]
|
||||
if sfz_file_name == '':
|
||||
sfz_file_name = "Empty filename"
|
||||
|
||||
return sfz_file_name, file_prefix
|
||||
|
||||
def set_axis_and_legend(figure, xlabel=None, ylabel=None, hide_on_click=True):
|
||||
"""Generic way to set the axis labels and enable clicking on the legend to hide the plot
|
||||
|
||||
Arguments:
|
||||
figure {Bokeh figure}
|
||||
|
||||
Keyword Arguments:
|
||||
xlabel {string} -- the x label (default: {None})
|
||||
ylabel {string} -- the y label (default: {None})
|
||||
hide_on_click {bool} -- whether to hide the legend when clicking (default: {True})
|
||||
"""
|
||||
if xlabel is not None:
|
||||
figure.xaxis.axis_label = xlabel
|
||||
if ylabel is not None:
|
||||
figure.yaxis.axis_label = ylabel
|
||||
if hide_on_click:
|
||||
figure.legend.click_policy = "hide"
|
||||
|
||||
# Argument parser
|
||||
parser = argparse.ArgumentParser(description="Plot performance summary and generate a detailed report on sfizz's performance")
|
||||
parser.add_argument("files", nargs="+", type=str, help="The csv log files to consider")
|
||||
parser.add_argument("--output", type=str, default="report.html", help="The detailed output report file name")
|
||||
parser.add_argument("--title", type=str, default="sfizz's performance report", help="The report title")
|
||||
parser.add_argument("-v", "--verbose", action='store_true', help="Verbose console output")
|
||||
args = parser.parse_args()
|
||||
|
||||
# Check that all input files are here
|
||||
for file in args.files:
|
||||
assert os.path.exists(file), f'Cannot find {file}'
|
||||
|
||||
if args.verbose:
|
||||
print(f'Input files:', args.files)
|
||||
print(f'Output file:', args.output)
|
||||
|
||||
output_file(args.output, args.title)
|
||||
|
||||
# Dispatch files into their respective lists
|
||||
file_log_list = [file for file in args.files if file.endswith(file_log_suffix)]
|
||||
callback_log_list = [file for file in args.files if file.endswith(callback_log_suffix)]
|
||||
|
||||
# Plot the render duration and number of voices for all callback files
|
||||
fig_num_voices = figure(plot_width=600, plot_height=400, title="Number of voices")
|
||||
fig_callback_duration = figure(plot_width=600, plot_height=400, title="Render method")
|
||||
colors = itertools.cycle(palette)
|
||||
for file_name in callback_log_list:
|
||||
sfz_file_name, file_prefix = extract_file_name_and_prefix(file_name)
|
||||
csv_data = pd.read_csv(file_name)
|
||||
assert (csv_data.columns == callback_log_columns).all(), f"Column mismatch for {file_name}"
|
||||
|
||||
color = next(colors)
|
||||
fig_num_voices.line(csv_data.index, csv_data['NumVoices'], legend_label=f"{sfz_file_name} ({file_prefix[-4:]})", color=color)
|
||||
fig_callback_duration.line(csv_data.index, csv_data['RenderMethod'] * 1e6, legend_label=f"{sfz_file_name} ({file_prefix[-4:]})", color=color)
|
||||
set_axis_and_legend(fig_num_voices, 'Callback index', 'Number of voices')
|
||||
set_axis_and_legend(fig_callback_duration, 'Callback index', 'Callback duration (µs)')
|
||||
|
||||
# Callback breakdowns plots per file
|
||||
callback_figures = []
|
||||
for file_name in callback_log_list:
|
||||
file_prefix = file_name[:file_prefix_length]
|
||||
sfz_file_name = file_name[file_prefix_length + 1:-len(callback_log_suffix)]
|
||||
if sfz_file_name == '':
|
||||
sfz_file_name = "Empty filename"
|
||||
csv_data = pd.read_csv(file_name)
|
||||
|
||||
# Scale the data and add some columns
|
||||
scale_columns(csv_data, ['Dispatch', 'RenderMethod', 'Data', 'Amplitude', 'Panning', 'Filters'], 1e6)
|
||||
csv_data['DataPerVoice'] = csv_data['Data'] / csv_data['NumVoices']
|
||||
csv_data['AmplitudePerVoice'] = csv_data['Amplitude'] / csv_data['NumVoices']
|
||||
csv_data['FiltersPerVoice'] = csv_data['Filters'] / csv_data['NumVoices']
|
||||
csv_data['PanningPerVoice'] = csv_data['Panning'] / csv_data['NumVoices']
|
||||
csv_data['Residual'] = (csv_data['RenderMethod'] - csv_data['Panning'] - csv_data['Filters'] - csv_data['Amplitude'] - csv_data['Data']) / csv_data['NumVoices']
|
||||
|
||||
# Prep the summary
|
||||
summary_title = f"Callback statistics summary for {sfz_file_name} ({file_prefix[-4:]})"
|
||||
summary_lines = [
|
||||
f"Samples per callback (avg/max): {csv_data['NumSamples'].mean():.1f}/{csv_data['NumSamples'].max()}",
|
||||
f"Active voices (avg/max): {csv_data['NumVoices'].mean():.1f}/{csv_data['NumVoices'].max()}",
|
||||
f"Dispatch duration (avg/max): {csv_data['Dispatch'].mean():.2f}/{csv_data['Dispatch'].max():.2f} µs",
|
||||
f"Render duration (avg/max): {csv_data['RenderMethod'].mean():.2f}/{csv_data['RenderMethod'].max():.2f} µs",
|
||||
f"Source data reading/generation (avg/max): {csv_data['Data'].mean():.2f}/{csv_data['Data'].max():.2f} µs",
|
||||
f"Amplitude processing (avg/max): {csv_data['Amplitude'].mean():.2f}/{csv_data['Amplitude'].max():.2f} µs",
|
||||
f"Panning processing (avg/max): {csv_data['Panning'].mean():.2f}/{csv_data['Panning'].max():.2f} µs",
|
||||
f"Filter processing (avg/max): {csv_data['Filters'].mean():.2f}/{csv_data['Filters'].max():.2f} µs"
|
||||
]
|
||||
callback_figures.append(Div(text=f"<h3>{summary_title}</h3>" + html_list(summary_lines), width=600))
|
||||
if args.verbose:
|
||||
print_summary_to_console(summary_title, summary_lines)
|
||||
|
||||
# Callback breakdown figure
|
||||
stacked_column_names = ['DataPerVoice', 'AmplitudePerVoice', 'FiltersPerVoice', 'PanningPerVoice', 'Residual']
|
||||
stacked_column_legends = ['Data', 'Amplitude', 'Filters', 'Panning', 'Residual']
|
||||
source = ColumnDataSource(csv_data)
|
||||
source.add(csv_data.index, 'index')
|
||||
|
||||
fig_breakdown = figure(plot_width=600, plot_height=400, title=f"{sfz_file_name} - Callback breakdown")
|
||||
fig_breakdown.varea_stack(stacked_column_names, x='index', source=source, legend_label=stacked_column_legends, color=palette[:5])
|
||||
set_axis_and_legend(fig_breakdown, 'Callback index', 'Aggregate duration (per voice, average, µs)')
|
||||
|
||||
# Breakdown histogram figure
|
||||
fig_histogram = figure(plot_width=600, plot_height=400, title=f"{sfz_file_name} - Callback breakdown histogram")
|
||||
histogram_bins = np.linspace(0, csv_data['Residual'].max(), 300)
|
||||
for idx, (column_name, legend_label) in enumerate(zip(stacked_column_names, stacked_column_legends)):
|
||||
bins, edges = np.histogram(csv_data[column_name], bins=histogram_bins, density=True)
|
||||
fig_histogram.quad(bottom=0, top=bins, left=edges[:-1], right=edges[1:], legend_label=legend_label, alpha=0.5, color=palette[idx])
|
||||
set_axis_and_legend(fig_histogram, 'Processing duration (per voice, average, µs)')
|
||||
|
||||
# Add a row to the report
|
||||
callback_figures.append(row(fig_breakdown, fig_histogram))
|
||||
|
||||
# File timing plots
|
||||
file_figures = []
|
||||
for file_name in file_log_list:
|
||||
sfz_file_name, file_prefix = extract_file_name_and_prefix(file_name)
|
||||
csv_data = pd.read_csv(file_name)
|
||||
assert (csv_data.columns == file_log_columns).all(), f"Column mismatch for {file_name}"
|
||||
scale_columns(csv_data, ['WaitDuration', 'LoadDuration'], 1e6)
|
||||
normalized_load_duration = csv_data['LoadDuration'] / csv_data['FileSize']
|
||||
|
||||
# Prep and print the summary
|
||||
summary_title = f"File loading statistics summary for {sfz_file_name} ({file_prefix[-4:]})"
|
||||
summary_lines = [
|
||||
f"Waiting duration (avg/max): {csv_data['WaitDuration'].mean():.2f}/{csv_data['WaitDuration'].max():.2f} µs",
|
||||
f"Loading duration (avg/max): {csv_data['LoadDuration'].mean():.2f}/{csv_data['LoadDuration'].max():.2f} µs",
|
||||
f"Normalized loading duration (avg/max): {normalized_load_duration.mean():.5f}/{normalized_load_duration.max():.5f} µs"
|
||||
]
|
||||
file_figures.append(Div(text=f"<h3>{summary_title}</h3>" + html_list(summary_lines), width=600))
|
||||
if args.verbose:
|
||||
print_summary_to_console(summary_title, summary_lines)
|
||||
|
||||
# Split the loading duration depending on the file extension
|
||||
norm_load_times = {}
|
||||
load_times = {}
|
||||
for idx, csv_row in csv_data.iterrows():
|
||||
file_extension = csv_row['FileName'].split('.')[-1]
|
||||
if file_extension not in load_times:
|
||||
load_times[file_extension] = []
|
||||
if file_extension not in norm_load_times:
|
||||
norm_load_times[file_extension] = []
|
||||
norm_load_times[file_extension].append(csv_row['LoadDuration'] / csv_row['FileSize'])
|
||||
load_times[file_extension].append(csv_row['LoadDuration'])
|
||||
|
||||
# Waiting time histogram
|
||||
fig_wait_times = figure(plot_width=400, plot_height=400, title=f"{sfz_file_name} - Wait times")
|
||||
hist_wait, edges_wait = np.histogram(csv_data['WaitDuration'], bins=100, density=True)
|
||||
fig_wait_times.quad(top=hist_wait, bottom=0, left=edges_wait[:-1], right=edges_wait[1:], fill_color=palette[0], alpha=0.5)
|
||||
set_axis_and_legend(fig_wait_times, 'Wait time (µs)', hide_on_click=False)
|
||||
|
||||
# Normalized load time histogram
|
||||
colors = itertools.cycle(palette)
|
||||
fig_norm_load_times = figure(plot_width=400, plot_height=400, title=f"{sfz_file_name} - Normalized load times")
|
||||
for extension in load_times:
|
||||
hist, edges = np.histogram(np.array(norm_load_times[extension]), bins=100, density=True)
|
||||
fig_norm_load_times.quad(top=hist, bottom=0, left=edges[:-1], right=edges[1:],
|
||||
fill_color=next(colors), alpha=0.5, legend_label=extension)
|
||||
set_axis_and_legend(fig_norm_load_times, 'Load time per sample (µs)')
|
||||
|
||||
# Load time histogram
|
||||
colors = itertools.cycle(palette)
|
||||
fig_load_times = figure(plot_width=400, plot_height=400, title=f"{sfz_file_name} - Load times")
|
||||
for extension in load_times:
|
||||
hist, edges = np.histogram(np.array(load_times[extension]), bins=100, density=True)
|
||||
fig_load_times.quad(top=hist, bottom=0, left=edges[:-1], right=edges[1:],
|
||||
fill_color=next(colors), alpha=0.5, legend_label=extension)
|
||||
set_axis_and_legend(fig_load_times, 'Load time (µs)')
|
||||
|
||||
# Add a row to the report
|
||||
file_figures.append(row(fig_wait_times, fig_load_times, fig_norm_load_times))
|
||||
|
||||
# Show the output
|
||||
show(column(
|
||||
Div(text=f"<h1>{args.title}</h1> Input files: {html_list(args.files)}"),
|
||||
row(fig_num_voices, fig_callback_duration),
|
||||
*callback_figures,
|
||||
*file_figures
|
||||
))
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
include (GNUInstallDirs)
|
||||
include (CheckLibraryExists)
|
||||
|
||||
set (SFIZZ_SOURCES
|
||||
sfizz/Synth.cpp
|
||||
|
|
@ -15,6 +14,9 @@ set (SFIZZ_SOURCES
|
|||
sfizz/FloatEnvelopes.cpp
|
||||
sfizz/Logger.cpp
|
||||
sfizz/SfzFilter.cpp
|
||||
sfizz/Effects.cpp
|
||||
sfizz/effects/Nothing.cpp
|
||||
sfizz/effects/Lofi.cpp
|
||||
)
|
||||
include (SfizzSIMDSourceFiles)
|
||||
|
||||
|
|
@ -27,12 +29,15 @@ target_link_libraries (sfizz_parser PUBLIC absl::strings)
|
|||
|
||||
# Sfizz static library
|
||||
add_library(sfizz_static STATIC)
|
||||
target_sources(sfizz_static PRIVATE ${SFIZZ_SOURCES} sfizz/sfizz_wrapper.cpp)
|
||||
target_sources(sfizz_static PRIVATE ${SFIZZ_SOURCES} sfizz/sfizz_wrapper.cpp sfizz/sfizz.cpp)
|
||||
target_include_directories (sfizz_static PUBLIC .)
|
||||
target_include_directories (sfizz_static PUBLIC external)
|
||||
target_link_libraries (sfizz_static PUBLIC absl::strings absl::span)
|
||||
target_link_libraries (sfizz_static PRIVATE sfizz_parser absl::flat_hash_map Threads::Threads sfizz-sndfile sfizz-pugixml)
|
||||
set_target_properties (sfizz_static PROPERTIES OUTPUT_NAME sfizz PUBLIC_HEADER "sfizz.h;sfizz.hpp")
|
||||
if (WIN32)
|
||||
target_compile_definitions (sfizz_static PRIVATE _USE_MATH_DEFINES)
|
||||
endif()
|
||||
|
||||
if (NOT MSVC)
|
||||
install (TARGETS sfizz_static
|
||||
|
|
@ -41,7 +46,9 @@ if (NOT MSVC)
|
|||
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
||||
|
||||
configure_file (${PROJECT_SOURCE_DIR}/scripts/sfizz.pc.in sfizz.pc @ONLY)
|
||||
else()
|
||||
endif()
|
||||
if(WIN32)
|
||||
include(VSTConfig)
|
||||
configure_file (${PROJECT_SOURCE_DIR}/scripts/innosetup.iss.in ${PROJECT_BINARY_DIR}/innosetup.iss @ONLY)
|
||||
endif()
|
||||
|
||||
|
|
@ -49,11 +56,8 @@ configure_file (${PROJECT_SOURCE_DIR}/scripts/Doxyfile.in ${PROJECT_SOURCE_DIR}/
|
|||
|
||||
add_library (sfizz::parser ALIAS sfizz_parser)
|
||||
add_library (sfizz::sfizz ALIAS sfizz_static)
|
||||
if (UNIX AND NOT APPLE)
|
||||
check_library_exists(atomic __atomic_load "" LIBATOMIC_FOUND)
|
||||
if (LIBATOMIC_FOUND)
|
||||
target_link_libraries (sfizz_static PRIVATE atomic)
|
||||
endif()
|
||||
if (LIBATOMIC_FOUND)
|
||||
target_link_libraries (sfizz_static PRIVATE atomic)
|
||||
endif()
|
||||
|
||||
# Shared library and installation target
|
||||
|
|
@ -63,6 +67,9 @@ if (SFIZZ_SHARED)
|
|||
target_include_directories (sfizz_shared PRIVATE .)
|
||||
target_include_directories (sfizz_shared PRIVATE external)
|
||||
target_link_libraries (sfizz_shared PRIVATE absl::strings absl::span sfizz_parser absl::flat_hash_map Threads::Threads sfizz-sndfile sfizz-pugixml)
|
||||
if (WIN32)
|
||||
target_compile_definitions (sfizz_shared PRIVATE _USE_MATH_DEFINES)
|
||||
endif()
|
||||
target_compile_definitions(sfizz_shared PRIVATE SFIZZ_EXPORT_SYMBOLS)
|
||||
set_target_properties (sfizz_shared PROPERTIES OUTPUT_NAME sfizz PUBLIC_HEADER "sfizz.h;sfizz.hpp")
|
||||
set_property (TARGET sfizz_shared PROPERTY SOVERSION ${PROJECT_VERSION_MAJOR})
|
||||
|
|
|
|||
115
src/external/hiir/Downsampler2xFpu.h
vendored
Normal file
115
src/external/hiir/Downsampler2xFpu.h
vendored
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
/*****************************************************************************
|
||||
|
||||
Downsampler2xFpu.h
|
||||
Author: Laurent de Soras, 2005
|
||||
|
||||
Downsamples by a factor 2 the input signal, using FPU.
|
||||
|
||||
Template parameters:
|
||||
- NC: number of coefficients, > 0
|
||||
|
||||
--- Legal stuff ---
|
||||
|
||||
This program is free software. It comes without any warranty, to
|
||||
the extent permitted by applicable law. You can redistribute it
|
||||
and/or modify it under the terms of the Do What The Fuck You Want
|
||||
To Public License, Version 2, as published by Sam Hocevar. See
|
||||
http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
|
||||
*Tab=3***********************************************************************/
|
||||
|
||||
|
||||
|
||||
#if ! defined (hiir_Downsampler2xFpu_HEADER_INCLUDED)
|
||||
#define hiir_Downsampler2xFpu_HEADER_INCLUDED
|
||||
|
||||
#if defined (_MSC_VER)
|
||||
#pragma once
|
||||
#pragma warning (4 : 4250) // "Inherits via dominance."
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
|
||||
|
||||
#include "hiir/def.h"
|
||||
|
||||
#include <array>
|
||||
|
||||
|
||||
|
||||
namespace hiir
|
||||
{
|
||||
|
||||
|
||||
|
||||
template <int NC>
|
||||
class Downsampler2xFpu
|
||||
{
|
||||
|
||||
static_assert ((NC > 0), "Number of coefficient must be positive.");
|
||||
|
||||
/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
|
||||
|
||||
public:
|
||||
|
||||
enum { NBR_COEFS = NC };
|
||||
|
||||
Downsampler2xFpu ();
|
||||
|
||||
void set_coefs (const double coef_arr []);
|
||||
|
||||
hiir_FORCEINLINE float
|
||||
process_sample (const float in_ptr [2]);
|
||||
void process_block (float out_ptr [], const float in_ptr [], long nbr_spl);
|
||||
|
||||
hiir_FORCEINLINE void
|
||||
process_sample_split (float &low, float &high, const float in_ptr [2]);
|
||||
void process_block_split (float out_l_ptr [], float out_h_ptr [], const float in_ptr [], long nbr_spl);
|
||||
|
||||
void clear_buffers ();
|
||||
|
||||
|
||||
|
||||
/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
|
||||
|
||||
private:
|
||||
|
||||
typedef std::array <float, NBR_COEFS> HyperGluar;
|
||||
|
||||
HyperGluar _coef;
|
||||
HyperGluar _x;
|
||||
HyperGluar _y;
|
||||
|
||||
|
||||
|
||||
/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
|
||||
|
||||
private:
|
||||
|
||||
bool operator == (const Downsampler2xFpu <NC> &other);
|
||||
bool operator != (const Downsampler2xFpu <NC> &other);
|
||||
|
||||
}; // class Downsampler2xFpu
|
||||
|
||||
|
||||
|
||||
} // namespace hiir
|
||||
|
||||
|
||||
|
||||
#include "hiir/Downsampler2xFpu.hpp"
|
||||
|
||||
|
||||
|
||||
#endif // hiir_Downsampler2xFpu_HEADER_INCLUDED
|
||||
|
||||
|
||||
|
||||
/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
|
||||
303
src/external/hiir/Downsampler2xFpu.hpp
vendored
Normal file
303
src/external/hiir/Downsampler2xFpu.hpp
vendored
Normal file
|
|
@ -0,0 +1,303 @@
|
|||
/*****************************************************************************
|
||||
|
||||
Downsampler2xFpu.hpp
|
||||
Author: Laurent de Soras, 2005
|
||||
|
||||
--- Legal stuff ---
|
||||
|
||||
This program is free software. It comes without any warranty, to
|
||||
the extent permitted by applicable law. You can redistribute it
|
||||
and/or modify it under the terms of the Do What The Fuck You Want
|
||||
To Public License, Version 2, as published by Sam Hocevar. See
|
||||
http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
|
||||
*Tab=3***********************************************************************/
|
||||
|
||||
|
||||
|
||||
#if defined (hiir_Downsampler2xFpu_CURRENT_CODEHEADER)
|
||||
#error Recursive inclusion of Downsampler2xFpu code header.
|
||||
#endif
|
||||
#define hiir_Downsampler2xFpu_CURRENT_CODEHEADER
|
||||
|
||||
#if ! defined (hiir_Downsampler2xFpu_CODEHEADER_INCLUDED)
|
||||
#define hiir_Downsampler2xFpu_CODEHEADER_INCLUDED
|
||||
|
||||
|
||||
|
||||
/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
|
||||
|
||||
#include "hiir/StageProcFpu.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
|
||||
|
||||
namespace hiir
|
||||
{
|
||||
|
||||
|
||||
|
||||
/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
|
||||
|
||||
|
||||
|
||||
/*
|
||||
==============================================================================
|
||||
Name: ctor
|
||||
Throws: Nothing
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
template <int NC>
|
||||
Downsampler2xFpu <NC>::Downsampler2xFpu ()
|
||||
: _coef ()
|
||||
, _x ()
|
||||
, _y ()
|
||||
{
|
||||
for (int i = 0; i < NBR_COEFS; ++i)
|
||||
{
|
||||
_coef [i] = 0;
|
||||
}
|
||||
clear_buffers ();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
==============================================================================
|
||||
Name: set_coefs
|
||||
Description:
|
||||
Sets filter coefficients. Generate them with the PolyphaseIir2Designer
|
||||
class.
|
||||
Call this function before doing any processing.
|
||||
Input parameters:
|
||||
- coef_arr: Array of coefficients. There should be as many coefficients as
|
||||
mentioned in the class template parameter.
|
||||
Throws: Nothing
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
template <int NC>
|
||||
void Downsampler2xFpu <NC>::set_coefs (const double coef_arr [])
|
||||
{
|
||||
assert (coef_arr != 0);
|
||||
|
||||
for (int i = 0; i < NBR_COEFS; ++i)
|
||||
{
|
||||
_coef [i] = float (coef_arr [i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
==============================================================================
|
||||
Name: process_sample
|
||||
Description:
|
||||
Downsamples (x2) one pair of samples, to generate one output sample.
|
||||
Input parameters:
|
||||
- in_ptr: pointer on the two samples to decimate
|
||||
Returns: Samplerate-reduced sample.
|
||||
Throws: Nothing
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
template <int NC>
|
||||
float Downsampler2xFpu <NC>::process_sample (const float in_ptr [2])
|
||||
{
|
||||
assert (in_ptr != 0);
|
||||
|
||||
float spl_0 (in_ptr [1]);
|
||||
float spl_1 (in_ptr [0]);
|
||||
|
||||
#if defined (_MSC_VER)
|
||||
#pragma inline_depth (255)
|
||||
#endif // _MSC_VER
|
||||
|
||||
StageProcFpu <NBR_COEFS>::process_sample_pos (
|
||||
NBR_COEFS,
|
||||
spl_0,
|
||||
spl_1,
|
||||
&_coef [0],
|
||||
&_x [0],
|
||||
&_y [0]
|
||||
);
|
||||
|
||||
return 0.5f * (spl_0 + spl_1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
==============================================================================
|
||||
Name: process_block
|
||||
Description:
|
||||
Downsamples (x2) a block of samples.
|
||||
Input and output blocks may overlap, see assert() for details.
|
||||
Input parameters:
|
||||
- in_ptr: Input array, containing nbr_spl * 2 samples.
|
||||
- nbr_spl: Number of samples to output, > 0
|
||||
Output parameters:
|
||||
- out_ptr: Array for the output samples, capacity: nbr_spl samples.
|
||||
Throws: Nothing
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
template <int NC>
|
||||
void Downsampler2xFpu <NC>::process_block (float out_ptr [], const float in_ptr [], long nbr_spl)
|
||||
{
|
||||
assert (in_ptr != 0);
|
||||
assert (out_ptr != 0);
|
||||
assert (out_ptr <= in_ptr || out_ptr >= in_ptr + nbr_spl * 2);
|
||||
assert (nbr_spl > 0);
|
||||
|
||||
long pos = 0;
|
||||
do
|
||||
{
|
||||
out_ptr [pos] = process_sample (&in_ptr [pos * 2]);
|
||||
++pos;
|
||||
}
|
||||
while (pos < nbr_spl);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
==============================================================================
|
||||
Name: process_sample_split
|
||||
Description:
|
||||
Split (spectrum-wise) in half a pair of samples. The lower part of the
|
||||
spectrum is a classic downsampling, equivalent to the output of
|
||||
process_sample().
|
||||
The higher part is the complementary signal: original filter response
|
||||
is flipped from left to right, becoming a high-pass filter with the same
|
||||
cutoff frequency. This signal is then critically sampled (decimation by 2),
|
||||
flipping the spectrum: Fs/4...Fs/2 becomes Fs/4...0.
|
||||
Input parameters:
|
||||
- in_ptr: pointer on the pair of input samples
|
||||
Output parameters:
|
||||
- low: output sample, lower part of the spectrum (downsampling)
|
||||
- high: output sample, higher part of the spectrum.
|
||||
Throws: Nothing
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
template <int NC>
|
||||
void Downsampler2xFpu <NC>::process_sample_split (float &low, float &high, const float in_ptr [2])
|
||||
{
|
||||
assert (in_ptr != 0);
|
||||
|
||||
float spl_0 = in_ptr [1];
|
||||
float spl_1 = in_ptr [0];
|
||||
|
||||
#if defined (_MSC_VER)
|
||||
#pragma inline_depth (255)
|
||||
#endif // _MSC_VER
|
||||
|
||||
StageProcFpu <NBR_COEFS>::process_sample_pos (
|
||||
NBR_COEFS,
|
||||
spl_0,
|
||||
spl_1,
|
||||
&_coef [0],
|
||||
&_x [0],
|
||||
&_y [0]
|
||||
);
|
||||
|
||||
low = (spl_0 + spl_1) * 0.5f;
|
||||
high = spl_0 - low; // (spl_0 - spl_1) * 0.5f;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
==============================================================================
|
||||
Name: process_block_split
|
||||
Description:
|
||||
Split (spectrum-wise) in half a block of samples. The lower part of the
|
||||
spectrum is a classic downsampling, equivalent to the output of
|
||||
process_block().
|
||||
The higher part is the complementary signal: original filter response
|
||||
is flipped from left to right, becoming a high-pass filter with the same
|
||||
cutoff frequency. This signal is then critically sampled (decimation by 2),
|
||||
flipping the spectrum: Fs/4...Fs/2 becomes Fs/4...0.
|
||||
Input and output blocks may overlap, see assert() for details.
|
||||
Input parameters:
|
||||
- in_ptr: Input array, containing nbr_spl * 2 samples.
|
||||
- nbr_spl: Number of samples for each output, > 0
|
||||
Output parameters:
|
||||
- out_l_ptr: Array for the output samples, lower part of the spectrum
|
||||
(downsampling). Capacity: nbr_spl samples.
|
||||
- out_h_ptr: Array for the output samples, higher part of the spectrum.
|
||||
Capacity: nbr_spl samples.
|
||||
Throws: Nothing
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
template <int NC>
|
||||
void Downsampler2xFpu <NC>::process_block_split (float out_l_ptr [], float out_h_ptr [], const float in_ptr [], long nbr_spl)
|
||||
{
|
||||
assert (in_ptr != 0);
|
||||
assert (out_l_ptr != 0);
|
||||
assert (out_l_ptr <= in_ptr || out_l_ptr >= in_ptr + nbr_spl * 2);
|
||||
assert (out_h_ptr != 0);
|
||||
assert (out_h_ptr <= in_ptr || out_h_ptr >= in_ptr + nbr_spl * 2);
|
||||
assert (out_h_ptr != out_l_ptr);
|
||||
assert (nbr_spl > 0);
|
||||
|
||||
long pos = 0;
|
||||
do
|
||||
{
|
||||
process_sample_split (
|
||||
out_l_ptr [pos],
|
||||
out_h_ptr [pos],
|
||||
&in_ptr [pos * 2]
|
||||
);
|
||||
++pos;
|
||||
}
|
||||
while (pos < nbr_spl);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
==============================================================================
|
||||
Name: clear_buffers
|
||||
Description:
|
||||
Clears filter memory, as if it processed silence since an infinite amount
|
||||
of time.
|
||||
Throws: Nothing
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
template <int NC>
|
||||
void Downsampler2xFpu <NC>::clear_buffers ()
|
||||
{
|
||||
for (int i = 0; i < NBR_COEFS; ++i)
|
||||
{
|
||||
_x [i] = 0;
|
||||
_y [i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
|
||||
|
||||
|
||||
|
||||
/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
|
||||
|
||||
|
||||
|
||||
} // namespace hiir
|
||||
|
||||
|
||||
|
||||
#endif // hiir_Downsampler2xFpu_CODEHEADER_INCLUDED
|
||||
|
||||
#undef hiir_Downsampler2xFpu_CURRENT_CODEHEADER
|
||||
|
||||
|
||||
|
||||
/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
|
||||
126
src/external/hiir/Downsampler2xNeon.h
vendored
Normal file
126
src/external/hiir/Downsampler2xNeon.h
vendored
Normal file
|
|
@ -0,0 +1,126 @@
|
|||
/*****************************************************************************
|
||||
|
||||
Downsampler2xNeon.h
|
||||
Author: Laurent de Soras, 2016
|
||||
|
||||
Downsamples by a factor 2 the input signal, using NEON instruction set.
|
||||
|
||||
This object must be aligned on a 16-byte boundary!
|
||||
|
||||
If the number of coefficients is 2 or 3 modulo 4, the output is delayed from
|
||||
1 sample, compared to the theoretical formula (or FPU implementation).
|
||||
|
||||
Template parameters:
|
||||
- NC: number of coefficients, > 0
|
||||
|
||||
--- Legal stuff ---
|
||||
|
||||
This program is free software. It comes without any warranty, to
|
||||
the extent permitted by applicable law. You can redistribute it
|
||||
and/or modify it under the terms of the Do What The Fuck You Want
|
||||
To Public License, Version 2, as published by Sam Hocevar. See
|
||||
http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
|
||||
*Tab=3***********************************************************************/
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
#if ! defined (hiir_Downsampler2xNeon_HEADER_INCLUDED)
|
||||
#define hiir_Downsampler2xNeon_HEADER_INCLUDED
|
||||
|
||||
#if defined (_MSC_VER)
|
||||
#pragma warning (4 : 4250)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
|
||||
|
||||
#include "hiir/def.h"
|
||||
#include "hiir/StageDataNeon.h"
|
||||
|
||||
#include <array>
|
||||
|
||||
|
||||
|
||||
namespace hiir
|
||||
{
|
||||
|
||||
|
||||
|
||||
template <int NC>
|
||||
class Downsampler2xNeon
|
||||
{
|
||||
|
||||
static_assert ((NC > 0), "Number of coefficient must be positive.");
|
||||
|
||||
/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
|
||||
|
||||
public:
|
||||
|
||||
enum { NBR_COEFS = NC };
|
||||
|
||||
Downsampler2xNeon ();
|
||||
Downsampler2xNeon (const Downsampler2xNeon &other) = default;
|
||||
|
||||
Downsampler2xNeon &
|
||||
operator = (const Downsampler2xNeon &other) = default;
|
||||
|
||||
void set_coefs (const double coef_arr []);
|
||||
|
||||
hiir_FORCEINLINE float
|
||||
process_sample (const float in_ptr [2]);
|
||||
void process_block (float out_ptr [], const float in_ptr [], long nbr_spl);
|
||||
|
||||
hiir_FORCEINLINE void
|
||||
process_sample_split (float &low, float &high, const float in_ptr [2]);
|
||||
void process_block_split (float out_l_ptr [], float out_h_ptr [], const float in_ptr [], long nbr_spl);
|
||||
|
||||
void clear_buffers ();
|
||||
|
||||
|
||||
|
||||
/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
|
||||
|
||||
private:
|
||||
|
||||
enum { STAGE_WIDTH = 4 };
|
||||
enum { NBR_STAGES = (NBR_COEFS + STAGE_WIDTH - 1) / STAGE_WIDTH };
|
||||
|
||||
typedef std::array <StageDataNeon, NBR_STAGES + 1> Filter; // Stage 0 contains only input memory
|
||||
|
||||
Filter _filter; // Should be the first member (thus easier to align)
|
||||
|
||||
|
||||
|
||||
/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
|
||||
|
||||
private:
|
||||
|
||||
bool operator == (const Downsampler2xNeon <NC> &other) const = delete;
|
||||
bool operator != (const Downsampler2xNeon <NC> &other) const = delete;
|
||||
|
||||
}; // class Downsampler2xNeon
|
||||
|
||||
|
||||
|
||||
} // namespace hiir
|
||||
|
||||
|
||||
|
||||
#include "hiir/Downsampler2xNeon.hpp"
|
||||
|
||||
|
||||
|
||||
#endif // hiir_Downsampler2xNeon_HEADER_INCLUDED
|
||||
|
||||
|
||||
|
||||
/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
|
||||
299
src/external/hiir/Downsampler2xNeon.hpp
vendored
Normal file
299
src/external/hiir/Downsampler2xNeon.hpp
vendored
Normal file
|
|
@ -0,0 +1,299 @@
|
|||
/*****************************************************************************
|
||||
|
||||
Downsampler2xNeon.hpp
|
||||
Author: Laurent de Soras, 2016
|
||||
|
||||
--- Legal stuff ---
|
||||
|
||||
This program is free software. It comes without any warranty, to
|
||||
the extent permitted by applicable law. You can redistribute it
|
||||
and/or modify it under the terms of the Do What The Fuck You Want
|
||||
To Public License, Version 2, as published by Sam Hocevar. See
|
||||
http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
|
||||
*Tab=3***********************************************************************/
|
||||
|
||||
|
||||
|
||||
#if ! defined (hiir_Downsampler2xNeon_CODEHEADER_INCLUDED)
|
||||
#define hiir_Downsampler2xNeon_CODEHEADER_INCLUDED
|
||||
|
||||
|
||||
|
||||
/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
|
||||
|
||||
#include "hiir/StageProcNeon.h"
|
||||
|
||||
#include <arm_neon.h>
|
||||
|
||||
#include <cassert>
|
||||
|
||||
|
||||
|
||||
namespace hiir
|
||||
{
|
||||
|
||||
|
||||
|
||||
/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
|
||||
|
||||
|
||||
|
||||
/*
|
||||
==============================================================================
|
||||
Name: ctor
|
||||
Throws: Nothing
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
template <int NC>
|
||||
Downsampler2xNeon <NC>::Downsampler2xNeon ()
|
||||
: _filter ()
|
||||
{
|
||||
for (int i = 0; i < NBR_STAGES + 1; ++i)
|
||||
{
|
||||
_filter [i]._mem4 = vdupq_n_f32 (0);
|
||||
}
|
||||
if ((NBR_COEFS & 1) != 0)
|
||||
{
|
||||
const int pos = (NBR_COEFS ^ 1) & (STAGE_WIDTH - 1);
|
||||
_filter [NBR_STAGES]._coef [pos] = 1;
|
||||
}
|
||||
|
||||
clear_buffers ();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
==============================================================================
|
||||
Name: set_coefs
|
||||
Description:
|
||||
Sets filter coefficients. Generate them with the PolyphaseIir2Designer
|
||||
class.
|
||||
Call this function before doing any processing.
|
||||
Input parameters:
|
||||
- coef_arr: Array of coefficients. There should be as many coefficients as
|
||||
mentioned in the class template parameter.
|
||||
Throws: Nothing
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
template <int NC>
|
||||
void Downsampler2xNeon <NC>::set_coefs (const double coef_arr [])
|
||||
{
|
||||
assert (coef_arr != 0);
|
||||
|
||||
for (int i = 0; i < NBR_COEFS; ++i)
|
||||
{
|
||||
const int stage = (i / STAGE_WIDTH) + 1;
|
||||
const int pos = (i ^ 1) & (STAGE_WIDTH - 1);
|
||||
_filter [stage]._coef [pos] = float (coef_arr [i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
==============================================================================
|
||||
Name: process_sample
|
||||
Description:
|
||||
Downsamples (x2) one pair of samples, to generate one output sample.
|
||||
Input parameters:
|
||||
- in_ptr: pointer on the two samples to decimate
|
||||
Returns: Samplerate-reduced sample.
|
||||
Throws: Nothing
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
template <int NC>
|
||||
float Downsampler2xNeon <NC>::process_sample (const float in_ptr [2])
|
||||
{
|
||||
assert (in_ptr != 0);
|
||||
|
||||
// Combines two input samples and two mid-processing data
|
||||
const float32x2_t spl_in = vreinterpret_f32_u8 (
|
||||
vld1_u8 (reinterpret_cast <const uint8_t *> (in_ptr))
|
||||
);
|
||||
const float32x2_t spl_mid = vget_low_f32 (_filter [NBR_STAGES]._mem4);
|
||||
float32x4_t y = vcombine_f32 (spl_in, spl_mid);
|
||||
float32x4_t mem = _filter [0]._mem4;
|
||||
|
||||
// Processes each stage
|
||||
StageProcNeon <NBR_STAGES>::process_sample_pos (&_filter [0], y, mem);
|
||||
_filter [NBR_STAGES]._mem4 = y;
|
||||
|
||||
// Averages both paths and outputs the result
|
||||
const float out_0 = vgetq_lane_f32 (y, 3);
|
||||
const float out_1 = vgetq_lane_f32 (y, 2);
|
||||
const float out = (out_0 + out_1) * 0.5f;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
==============================================================================
|
||||
Name: process_block
|
||||
Description:
|
||||
Downsamples (x2) a block of samples.
|
||||
Input and output blocks may overlap, see assert() for details.
|
||||
Input parameters:
|
||||
- in_ptr: Input array, containing nbr_spl * 2 samples.
|
||||
- nbr_spl: Number of samples to output, > 0
|
||||
Output parameters:
|
||||
- out_ptr: Array for the output samples, capacity: nbr_spl samples.
|
||||
Throws: Nothing
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
template <int NC>
|
||||
void Downsampler2xNeon <NC>::process_block (float out_ptr [], const float in_ptr [], long nbr_spl)
|
||||
{
|
||||
assert (in_ptr != 0);
|
||||
assert (out_ptr != 0);
|
||||
assert (out_ptr <= in_ptr || out_ptr >= in_ptr + nbr_spl * 2);
|
||||
assert (nbr_spl > 0);
|
||||
|
||||
long pos = 0;
|
||||
do
|
||||
{
|
||||
out_ptr [pos] = process_sample (in_ptr + pos * 2);
|
||||
++ pos;
|
||||
}
|
||||
while (pos < nbr_spl);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
==============================================================================
|
||||
Name: process_sample_split
|
||||
Description:
|
||||
Split (spectrum-wise) in half a pair of samples. The lower part of the
|
||||
spectrum is a classic downsampling, equivalent to the output of
|
||||
process_sample().
|
||||
The higher part is the complementary signal: original filter response
|
||||
is flipped from left to right, becoming a high-pass filter with the same
|
||||
cutoff frequency. This signal is then critically sampled (decimation by 2),
|
||||
flipping the spectrum: Fs/4...Fs/2 becomes Fs/4...0.
|
||||
Input parameters:
|
||||
- in_ptr: pointer on the pair of input samples
|
||||
Output parameters:
|
||||
- low: output sample, lower part of the spectrum (downsampling)
|
||||
- high: output sample, higher part of the spectrum.
|
||||
Throws: Nothing
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
template <int NC>
|
||||
void Downsampler2xNeon <NC>::process_sample_split (float &low, float &high, const float in_ptr [2])
|
||||
{
|
||||
assert (in_ptr != 0);
|
||||
|
||||
// Combines two input samples and two mid-processing data
|
||||
const float32x2_t spl_in = vreinterpret_f32_u8 (
|
||||
vld1_u8 (reinterpret_cast <const uint8_t *> (in_ptr))
|
||||
);
|
||||
const float32x2_t spl_mid = vget_low_f32 (_filter [NBR_STAGES]._mem4);
|
||||
float32x4_t y = vcombine_f32 (spl_in, spl_mid);
|
||||
float32x4_t mem = _filter [0]._mem4;
|
||||
|
||||
// Processes each stage
|
||||
StageProcNeon <NBR_STAGES>::process_sample_pos (&_filter [0], y, mem);
|
||||
_filter [NBR_STAGES]._mem4 = y;
|
||||
|
||||
// Outputs the result
|
||||
const float out_0 = vgetq_lane_f32 (y, 3);
|
||||
const float out_1 = vgetq_lane_f32 (y, 2);
|
||||
low = (out_0 + out_1) * 0.5f;
|
||||
high = out_0 - low;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
==============================================================================
|
||||
Name: process_block_split
|
||||
Description:
|
||||
Split (spectrum-wise) in half a block of samples. The lower part of the
|
||||
spectrum is a classic downsampling, equivalent to the output of
|
||||
process_block().
|
||||
The higher part is the complementary signal: original filter response
|
||||
is flipped from left to right, becoming a high-pass filter with the same
|
||||
cutoff frequency. This signal is then critically sampled (decimation by 2),
|
||||
flipping the spectrum: Fs/4...Fs/2 becomes Fs/4...0.
|
||||
Input and output blocks may overlap, see assert() for details.
|
||||
Input parameters:
|
||||
- in_ptr: Input array, containing nbr_spl * 2 samples.
|
||||
- nbr_spl: Number of samples for each output, > 0
|
||||
Output parameters:
|
||||
- out_l_ptr: Array for the output samples, lower part of the spectrum
|
||||
(downsampling). Capacity: nbr_spl samples.
|
||||
- out_h_ptr: Array for the output samples, higher part of the spectrum.
|
||||
Capacity: nbr_spl samples.
|
||||
Throws: Nothing
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
template <int NC>
|
||||
void Downsampler2xNeon <NC>::process_block_split (float out_l_ptr [], float out_h_ptr [], const float in_ptr [], long nbr_spl)
|
||||
{
|
||||
assert (in_ptr != 0);
|
||||
assert (out_l_ptr != 0);
|
||||
assert (out_l_ptr <= in_ptr || out_l_ptr >= in_ptr + nbr_spl * 2);
|
||||
assert (out_h_ptr != 0);
|
||||
assert (out_h_ptr <= in_ptr || out_h_ptr >= in_ptr + nbr_spl * 2);
|
||||
assert (out_h_ptr != out_l_ptr);
|
||||
assert (nbr_spl > 0);
|
||||
|
||||
long pos = 0;
|
||||
do
|
||||
{
|
||||
process_sample_split (out_l_ptr [pos], out_h_ptr [pos], in_ptr + pos * 2);
|
||||
++ pos;
|
||||
}
|
||||
while (pos < nbr_spl);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
==============================================================================
|
||||
Name: clear_buffers
|
||||
Description:
|
||||
Clears filter memory, as if it processed silence since an infinite amount
|
||||
of time.
|
||||
Throws: Nothing
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
template <int NC>
|
||||
void Downsampler2xNeon <NC>::clear_buffers ()
|
||||
{
|
||||
for (int i = 0; i < NBR_STAGES + 1; ++i)
|
||||
{
|
||||
_filter [i]._mem4 = vdupq_n_f32 (0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
|
||||
|
||||
|
||||
|
||||
/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
|
||||
|
||||
|
||||
|
||||
} // namespace hiir
|
||||
|
||||
|
||||
|
||||
#endif // hiir_Downsampler2xNeon_CODEHEADER_INCLUDED
|
||||
|
||||
|
||||
|
||||
/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
|
||||
126
src/external/hiir/Downsampler2xSse.h
vendored
Normal file
126
src/external/hiir/Downsampler2xSse.h
vendored
Normal file
|
|
@ -0,0 +1,126 @@
|
|||
/*****************************************************************************
|
||||
|
||||
Downsampler2xSse.h
|
||||
Author: Laurent de Soras, 2005
|
||||
|
||||
Downsamples by a factor 2 the input signal, using SSE instruction set.
|
||||
|
||||
This object must be aligned on a 16-byte boundary!
|
||||
|
||||
If the number of coefficients is 2 or 3 modulo 4, the output is delayed from
|
||||
1 sample, compared to the theoretical formula (or FPU implementation).
|
||||
|
||||
Template parameters:
|
||||
- NC: number of coefficients, > 0
|
||||
|
||||
--- Legal stuff ---
|
||||
|
||||
This program is free software. It comes without any warranty, to
|
||||
the extent permitted by applicable law. You can redistribute it
|
||||
and/or modify it under the terms of the Do What The Fuck You Want
|
||||
To Public License, Version 2, as published by Sam Hocevar. See
|
||||
http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
|
||||
*Tab=3***********************************************************************/
|
||||
|
||||
|
||||
|
||||
#if ! defined (hiir_Downsampler2xSse_HEADER_INCLUDED)
|
||||
#define hiir_Downsampler2xSse_HEADER_INCLUDED
|
||||
|
||||
#if defined (_MSC_VER)
|
||||
#pragma once
|
||||
#pragma warning (4 : 4250) // "Inherits via dominance."
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
|
||||
|
||||
#include "hiir/def.h"
|
||||
#include "hiir/StageDataSse.h"
|
||||
|
||||
#include <array>
|
||||
|
||||
|
||||
|
||||
namespace hiir
|
||||
{
|
||||
|
||||
|
||||
|
||||
template <int NC>
|
||||
class Downsampler2xSse
|
||||
{
|
||||
|
||||
static_assert ((NC > 0), "Number of coefficient must be positive.");
|
||||
|
||||
/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
|
||||
|
||||
public:
|
||||
|
||||
enum { NBR_COEFS = NC };
|
||||
|
||||
Downsampler2xSse ();
|
||||
Downsampler2xSse (const Downsampler2xSse &other) = default;
|
||||
|
||||
Downsampler2xSse &
|
||||
operator = (const Downsampler2xSse &other) = default;
|
||||
|
||||
void set_coefs (const double coef_arr []);
|
||||
|
||||
hiir_FORCEINLINE float
|
||||
process_sample (const float in_ptr [2]);
|
||||
void process_block (float out_ptr [], const float in_ptr [], long nbr_spl);
|
||||
|
||||
hiir_FORCEINLINE void
|
||||
process_sample_split (float &low, float &high, const float in_ptr [2]);
|
||||
void process_block_split (float out_l_ptr [], float out_h_ptr [], const float in_ptr [], long nbr_spl);
|
||||
|
||||
void clear_buffers ();
|
||||
|
||||
|
||||
|
||||
/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
|
||||
|
||||
private:
|
||||
|
||||
enum { STAGE_WIDTH = 4 };
|
||||
enum { NBR_STAGES = (NBR_COEFS + STAGE_WIDTH - 1) / STAGE_WIDTH };
|
||||
|
||||
typedef std::array <StageDataSse, NBR_STAGES + 1> Filter; // Stage 0 contains only input memory
|
||||
|
||||
Filter _filter; // Should be the first member (thus easier to align)
|
||||
|
||||
|
||||
|
||||
/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
|
||||
|
||||
private:
|
||||
|
||||
bool operator == (const Downsampler2xSse <NC> &other) = delete;
|
||||
bool operator != (const Downsampler2xSse <NC> &other) = delete;
|
||||
|
||||
}; // class Downsampler2xSse
|
||||
|
||||
|
||||
|
||||
} // namespace hiir
|
||||
|
||||
|
||||
|
||||
#include "hiir/Downsampler2xSse.hpp"
|
||||
|
||||
|
||||
|
||||
#endif // hiir_Downsampler2xSse_HEADER_INCLUDED
|
||||
|
||||
|
||||
|
||||
/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
|
||||
322
src/external/hiir/Downsampler2xSse.hpp
vendored
Normal file
322
src/external/hiir/Downsampler2xSse.hpp
vendored
Normal file
|
|
@ -0,0 +1,322 @@
|
|||
/*****************************************************************************
|
||||
|
||||
Downsampler2xSse.hpp
|
||||
Author: Laurent de Soras, 2005
|
||||
|
||||
--- Legal stuff ---
|
||||
|
||||
This program is free software. It comes without any warranty, to
|
||||
the extent permitted by applicable law. You can redistribute it
|
||||
and/or modify it under the terms of the Do What The Fuck You Want
|
||||
To Public License, Version 2, as published by Sam Hocevar. See
|
||||
http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
|
||||
*Tab=3***********************************************************************/
|
||||
|
||||
|
||||
|
||||
#if defined (hiir_Downsampler2xSse_CURRENT_CODEHEADER)
|
||||
#error Recursive inclusion of Downsampler2xSse code header.
|
||||
#endif
|
||||
#define hiir_Downsampler2xSse_CURRENT_CODEHEADER
|
||||
|
||||
#if ! defined (hiir_Downsampler2xSse_CODEHEADER_INCLUDED)
|
||||
#define hiir_Downsampler2xSse_CODEHEADER_INCLUDED
|
||||
|
||||
|
||||
|
||||
/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
|
||||
|
||||
#include "hiir/StageProcSse.h"
|
||||
|
||||
#include <xmmintrin.h>
|
||||
|
||||
#include <cassert>
|
||||
|
||||
|
||||
|
||||
namespace hiir
|
||||
{
|
||||
|
||||
|
||||
|
||||
/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
|
||||
|
||||
|
||||
|
||||
/*
|
||||
==============================================================================
|
||||
Name: ctor
|
||||
Throws: Nothing
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
template <int NC>
|
||||
Downsampler2xSse <NC>::Downsampler2xSse ()
|
||||
: _filter ()
|
||||
{
|
||||
for (int i = 0; i < NBR_STAGES + 1; ++i)
|
||||
{
|
||||
_filter [i]._coef [0] = 0;
|
||||
_filter [i]._coef [1] = 0;
|
||||
_filter [i]._coef [2] = 0;
|
||||
_filter [i]._coef [3] = 0;
|
||||
}
|
||||
if ((NBR_COEFS & 1) != 0)
|
||||
{
|
||||
const int pos = (NBR_COEFS ^ 1) & (STAGE_WIDTH - 1);
|
||||
_filter [NBR_STAGES]._coef [pos] = 1;
|
||||
}
|
||||
|
||||
clear_buffers ();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
==============================================================================
|
||||
Name: set_coefs
|
||||
Description:
|
||||
Sets filter coefficients. Generate them with the PolyphaseIir2Designer
|
||||
class.
|
||||
Call this function before doing any processing.
|
||||
Input parameters:
|
||||
- coef_arr: Array of coefficients. There should be as many coefficients as
|
||||
mentioned in the class template parameter.
|
||||
Throws: Nothing
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
template <int NC>
|
||||
void Downsampler2xSse <NC>::set_coefs (const double coef_arr [])
|
||||
{
|
||||
assert (coef_arr != 0);
|
||||
|
||||
for (int i = 0; i < NBR_COEFS; ++i)
|
||||
{
|
||||
const int stage = (i / STAGE_WIDTH) + 1;
|
||||
const int pos = (i ^ 1) & (STAGE_WIDTH - 1);
|
||||
_filter [stage]._coef [pos] = float (coef_arr [i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
==============================================================================
|
||||
Name: process_sample
|
||||
Description:
|
||||
Downsamples (x2) one pair of samples, to generate one output sample.
|
||||
Input parameters:
|
||||
- in_ptr: pointer on the two samples to decimate
|
||||
Returns: Samplerate-reduced sample.
|
||||
Throws: Nothing
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
template <int NC>
|
||||
float Downsampler2xSse <NC>::process_sample (const float in_ptr [2])
|
||||
{
|
||||
assert (in_ptr != 0);
|
||||
|
||||
// Combines two input samples and two mid-processing data
|
||||
const __m128 spl_in = _mm_loadu_ps (in_ptr);
|
||||
const __m128 spl_mid = _mm_load_ps (_filter [NBR_STAGES]._mem);
|
||||
__m128 y = _mm_shuffle_ps (spl_in, spl_mid, 0x44);
|
||||
|
||||
__m128 mem = _mm_load_ps (_filter [0]._mem);
|
||||
|
||||
// Processes each stage
|
||||
StageProcSse <NBR_STAGES>::process_sample_pos (&_filter [0], y, mem);
|
||||
|
||||
_mm_store_ps (_filter [NBR_STAGES]._mem, y);
|
||||
|
||||
// Averages both paths and outputs the result
|
||||
const __m128 dup_y = y;
|
||||
y = _mm_shuffle_ps (y, y, 0x80);
|
||||
y = _mm_add_ps (y, dup_y);
|
||||
y = _mm_shuffle_ps (y, y, 3);
|
||||
y = _mm_mul_ss (y, _mm_set_ss (0.5f));
|
||||
float result;
|
||||
_mm_store_ss (&result, y);
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
==============================================================================
|
||||
Name: process_block
|
||||
Description:
|
||||
Downsamples (x2) a block of samples.
|
||||
Input and output blocks may overlap, see assert() for details.
|
||||
Input parameters:
|
||||
- in_ptr: Input array, containing nbr_spl * 2 samples.
|
||||
- nbr_spl: Number of samples to output, > 0
|
||||
Output parameters:
|
||||
- out_ptr: Array for the output samples, capacity: nbr_spl samples.
|
||||
Throws: Nothing
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
template <int NC>
|
||||
void Downsampler2xSse <NC>::process_block (float out_ptr [], const float in_ptr [], long nbr_spl)
|
||||
{
|
||||
assert (in_ptr != 0);
|
||||
assert (out_ptr != 0);
|
||||
assert (out_ptr <= in_ptr || out_ptr >= in_ptr + nbr_spl * 2);
|
||||
assert (nbr_spl > 0);
|
||||
|
||||
long pos = 0;
|
||||
do
|
||||
{
|
||||
out_ptr [pos] = process_sample (in_ptr + pos * 2);
|
||||
++ pos;
|
||||
}
|
||||
while (pos < nbr_spl);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
==============================================================================
|
||||
Name: process_sample_split
|
||||
Description:
|
||||
Split (spectrum-wise) in half a pair of samples. The lower part of the
|
||||
spectrum is a classic downsampling, equivalent to the output of
|
||||
process_sample().
|
||||
The higher part is the complementary signal: original filter response
|
||||
is flipped from left to right, becoming a high-pass filter with the same
|
||||
cutoff frequency. This signal is then critically sampled (decimation by 2),
|
||||
flipping the spectrum: Fs/4...Fs/2 becomes Fs/4...0.
|
||||
Input parameters:
|
||||
- in_ptr: pointer on the pair of input samples
|
||||
Output parameters:
|
||||
- low: output sample, lower part of the spectrum (downsampling)
|
||||
- high: output sample, higher part of the spectrum.
|
||||
Throws: Nothing
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
template <int NC>
|
||||
void Downsampler2xSse <NC>::process_sample_split (float &low, float &high, const float in_ptr [2])
|
||||
{
|
||||
assert (in_ptr != 0);
|
||||
|
||||
// Combines two input samples and two mid-processing data
|
||||
const __m128 spl_in = _mm_loadu_ps (in_ptr);
|
||||
const __m128 spl_mid = _mm_load_ps (_filter [NBR_STAGES]._mem);
|
||||
__m128 y = _mm_shuffle_ps (spl_in, spl_mid, 0x44);
|
||||
|
||||
__m128 mem = _mm_load_ps (_filter [0]._mem);
|
||||
|
||||
// Processes each stage
|
||||
StageProcSse <NBR_STAGES>::process_sample_pos (&_filter [0], y, mem);
|
||||
|
||||
_mm_store_ps (_filter [NBR_STAGES]._mem, y);
|
||||
|
||||
//Outputs the result
|
||||
__m128 dup_y = y;
|
||||
y = _mm_shuffle_ps (y, y, 0x80);
|
||||
y = _mm_add_ps (y, dup_y);
|
||||
y = _mm_shuffle_ps (y, y, 3);
|
||||
y = _mm_mul_ss (y, _mm_set_ss (0.5f));
|
||||
_mm_store_ss (&low, y);
|
||||
|
||||
dup_y = _mm_shuffle_ps (dup_y, dup_y, 3);
|
||||
dup_y = _mm_sub_ps (dup_y, y);
|
||||
_mm_store_ss (&high, dup_y);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
==============================================================================
|
||||
Name: process_block_split
|
||||
Description:
|
||||
Split (spectrum-wise) in half a block of samples. The lower part of the
|
||||
spectrum is a classic downsampling, equivalent to the output of
|
||||
process_block().
|
||||
The higher part is the complementary signal: original filter response
|
||||
is flipped from left to right, becoming a high-pass filter with the same
|
||||
cutoff frequency. This signal is then critically sampled (decimation by 2),
|
||||
flipping the spectrum: Fs/4...Fs/2 becomes Fs/4...0.
|
||||
Input and output blocks may overlap, see assert() for details.
|
||||
Input parameters:
|
||||
- in_ptr: Input array, containing nbr_spl * 2 samples.
|
||||
- nbr_spl: Number of samples for each output, > 0
|
||||
Output parameters:
|
||||
- out_l_ptr: Array for the output samples, lower part of the spectrum
|
||||
(downsampling). Capacity: nbr_spl samples.
|
||||
- out_h_ptr: Array for the output samples, higher part of the spectrum.
|
||||
Capacity: nbr_spl samples.
|
||||
Throws: Nothing
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
template <int NC>
|
||||
void Downsampler2xSse <NC>::process_block_split (float out_l_ptr [], float out_h_ptr [], const float in_ptr [], long nbr_spl)
|
||||
{
|
||||
assert (in_ptr != 0);
|
||||
assert (out_l_ptr != 0);
|
||||
assert (out_l_ptr <= in_ptr || out_l_ptr >= in_ptr + nbr_spl * 2);
|
||||
assert (out_h_ptr != 0);
|
||||
assert (out_h_ptr <= in_ptr || out_h_ptr >= in_ptr + nbr_spl * 2);
|
||||
assert (out_h_ptr != out_l_ptr);
|
||||
assert (nbr_spl > 0);
|
||||
|
||||
long pos = 0;
|
||||
do
|
||||
{
|
||||
process_sample_split (out_l_ptr [pos], out_h_ptr [pos], in_ptr + pos * 2);
|
||||
++ pos;
|
||||
}
|
||||
while (pos < nbr_spl);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
==============================================================================
|
||||
Name: clear_buffers
|
||||
Description:
|
||||
Clears filter memory, as if it processed silence since an infinite amount
|
||||
of time.
|
||||
Throws: Nothing
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
template <int NC>
|
||||
void Downsampler2xSse <NC>::clear_buffers ()
|
||||
{
|
||||
for (int i = 0; i < NBR_STAGES + 1; ++i)
|
||||
{
|
||||
_filter [i]._mem [0] = 0;
|
||||
_filter [i]._mem [1] = 0;
|
||||
_filter [i]._mem [2] = 0;
|
||||
_filter [i]._mem [3] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
|
||||
|
||||
|
||||
|
||||
/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
|
||||
|
||||
|
||||
|
||||
} // namespace hiir
|
||||
|
||||
|
||||
|
||||
#endif // hiir_Downsampler2xSse_CODEHEADER_INCLUDED
|
||||
|
||||
#undef hiir_Downsampler2xSse_CURRENT_CODEHEADER
|
||||
|
||||
|
||||
|
||||
/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
|
||||
|
|
@ -11,6 +11,7 @@
|
|||
#include "Debug.h"
|
||||
#include "LeakDetector.h"
|
||||
#include "SIMDHelpers.h"
|
||||
#include "absl/types/span.h"
|
||||
#include <array>
|
||||
#include <initializer_list>
|
||||
#include <type_traits>
|
||||
|
|
@ -208,6 +209,22 @@ public:
|
|||
return {};
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Convert implicitly to a pointer of channels
|
||||
*/
|
||||
operator const float* const*() const noexcept
|
||||
{
|
||||
return spans.data();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Convert implicitly to a pointer of channels
|
||||
*/
|
||||
operator float* const*() noexcept
|
||||
{
|
||||
return spans.data();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get a Span<Type> corresponding to a specific channel
|
||||
*
|
||||
|
|
@ -306,6 +323,43 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Add another AudioSpan with a compatible number of channels to the current
|
||||
* AudioSpan, applying an elementwise gain to the operand.
|
||||
*
|
||||
* @param other the other AudioSpan
|
||||
* @param gain the gain to apply
|
||||
*/
|
||||
template <class U, size_t N, typename = std::enable_if<N <= MaxChannels>>
|
||||
void multiplyAdd(AudioSpan<U, N>& other, absl::Span<const Type> gain)
|
||||
{
|
||||
static_assert(!std::is_const<Type>::value, "Can't allow mutating operations on const AudioSpans");
|
||||
ASSERT(other.getNumChannels() == numChannels);
|
||||
ASSERT(gain.size() == numFrames);
|
||||
if (other.getNumChannels() == numChannels) {
|
||||
for (size_t i = 0; i < numChannels; ++i)
|
||||
sfz::multiplyAdd(gain, other.getConstSpan(i), getSpan(i));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Add another AudioSpan with a compatible number of channels to the current
|
||||
* AudioSpan, applying a fixed gain to the operand.
|
||||
*
|
||||
* @param other the other AudioSpan
|
||||
* @param gain the gain to apply
|
||||
*/
|
||||
template <class U, size_t N, typename = std::enable_if<N <= MaxChannels>>
|
||||
void multiplyAdd(AudioSpan<U, N>& other, const Type gain)
|
||||
{
|
||||
static_assert(!std::is_const<Type>::value, "Can't allow mutating operations on const AudioSpans");
|
||||
ASSERT(other.getNumChannels() == numChannels);
|
||||
if (other.getNumChannels() == numChannels) {
|
||||
for (size_t i = 0; i < numChannels; ++i)
|
||||
sfz::multiplyAdd(gain, other.getConstSpan(i), getSpan(i));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Copy the elements of another AudioSpan with a compatible number of channels
|
||||
* to the current AudioSpan.
|
||||
|
|
|
|||
|
|
@ -6,7 +6,9 @@
|
|||
|
||||
#pragma once
|
||||
#include "LeakDetector.h"
|
||||
#include <map>
|
||||
#include "SfzHelpers.h"
|
||||
#include <vector>
|
||||
#include <absl/algorithm/container.h>
|
||||
|
||||
namespace sfz {
|
||||
/**
|
||||
|
|
@ -42,25 +44,29 @@ public:
|
|||
*/
|
||||
const ValueType& getWithDefault(int index) const noexcept
|
||||
{
|
||||
auto it = container.find(index);
|
||||
if (it == container.end()) {
|
||||
auto it = absl::c_lower_bound(container, index, CCValuePairComparator<ValueType>{});
|
||||
if (it == container.end() || it->cc != index) {
|
||||
return defaultValue;
|
||||
} else {
|
||||
return it->second;
|
||||
return it->value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the value at index key or emplace a new one if not present
|
||||
* @brief Get the value at index or emplace a new one if not present
|
||||
*
|
||||
* @param key the index of the element
|
||||
* @param index the index of the element
|
||||
* @return ValueType&
|
||||
*/
|
||||
ValueType& operator[](const int& key) noexcept
|
||||
ValueType& operator[](const int& index) noexcept
|
||||
{
|
||||
if (!contains(key))
|
||||
container.emplace(key, defaultValue);
|
||||
return container.operator[](key);
|
||||
auto it = absl::c_lower_bound(container, index, CCValuePairComparator<ValueType>{});
|
||||
if (it == container.end() || it->cc != index) {
|
||||
auto inserted = container.insert(it, { index, defaultValue });
|
||||
return inserted->value;
|
||||
} else {
|
||||
return it->value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -70,13 +76,6 @@ public:
|
|||
* @return false
|
||||
*/
|
||||
inline bool empty() const { return container.empty(); }
|
||||
/**
|
||||
* @brief Returns the value at index with bounds checking (and possibly exceptions)
|
||||
*
|
||||
* @param index
|
||||
* @return const ValueType&
|
||||
*/
|
||||
const ValueType& at(int index) const { return container.at(index); }
|
||||
/**
|
||||
* @brief Returns true if the container containers an element at index
|
||||
*
|
||||
|
|
@ -84,14 +83,18 @@ public:
|
|||
* @return true
|
||||
* @return false
|
||||
*/
|
||||
bool contains(int index) const noexcept { return container.find(index) != container.end(); }
|
||||
typename std::map<int, ValueType>::iterator begin() { return container.begin(); }
|
||||
typename std::map<int, ValueType>::const_iterator begin() const { return container.cbegin(); }
|
||||
typename std::map<int, ValueType>::iterator end() { return container.end(); }
|
||||
typename std::map<int, ValueType>::const_iterator end() const { return container.cend(); }
|
||||
bool contains(int index) const noexcept
|
||||
{
|
||||
return absl::c_binary_search(container, index, CCValuePairComparator<ValueType>{});
|
||||
}
|
||||
typename std::vector<CCValuePair<ValueType>>::const_iterator begin() const { return container.cbegin(); }
|
||||
typename std::vector<CCValuePair<ValueType>>::const_iterator end() const { return container.cend(); }
|
||||
private:
|
||||
// typename std::vector<std::pair<int, ValueType>>::iterator begin() { return container.begin(); }
|
||||
// typename std::vector<std::pair<int, ValueType>>::iterator end() { return container.end(); }
|
||||
|
||||
const ValueType defaultValue;
|
||||
std::map<int, ValueType> container;
|
||||
std::vector<CCValuePair<ValueType>> container;
|
||||
LEAK_DETECTOR(CCMap);
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,6 +69,10 @@ namespace config {
|
|||
*/
|
||||
const absl::string_view midnamManufacturer { "The Sfizz authors" };
|
||||
const absl::string_view midnamModel { "Sfizz" };
|
||||
/**
|
||||
Limit of how many "fxN" buses are accepted (in SFZv2, maximum is 4)
|
||||
*/
|
||||
constexpr int maxEffectBuses { 256 };
|
||||
} // namespace config
|
||||
|
||||
// Enable or disable SIMD accelerators by default
|
||||
|
|
|
|||
|
|
@ -64,13 +64,13 @@ struct EGDescription
|
|||
float vel2sustain { Default::vel2sustain };
|
||||
int vel2depth { Default::depth };
|
||||
|
||||
absl::optional<CCValuePair> ccAttack;
|
||||
absl::optional<CCValuePair> ccDecay;
|
||||
absl::optional<CCValuePair> ccDelay;
|
||||
absl::optional<CCValuePair> ccHold;
|
||||
absl::optional<CCValuePair> ccRelease;
|
||||
absl::optional<CCValuePair> ccStart;
|
||||
absl::optional<CCValuePair> ccSustain;
|
||||
absl::optional<CCValuePair<float>> ccAttack;
|
||||
absl::optional<CCValuePair<float>> ccDecay;
|
||||
absl::optional<CCValuePair<float>> ccDelay;
|
||||
absl::optional<CCValuePair<float>> ccHold;
|
||||
absl::optional<CCValuePair<float>> ccRelease;
|
||||
absl::optional<CCValuePair<float>> ccStart;
|
||||
absl::optional<CCValuePair<float>> ccSustain;
|
||||
|
||||
/**
|
||||
* @brief Get the attack with possibly a CC modifier and a velocity modifier
|
||||
|
|
|
|||
146
src/sfizz/Effects.cpp
Normal file
146
src/sfizz/Effects.cpp
Normal file
|
|
@ -0,0 +1,146 @@
|
|||
// SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
// This code is part of the sfizz library and is licensed under a BSD 2-clause
|
||||
// license. You should have receive a LICENSE.md file along with the code.
|
||||
// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz
|
||||
|
||||
#include "Effects.h"
|
||||
#include "AudioSpan.h"
|
||||
#include "Opcode.h"
|
||||
#include "SIMDHelpers.h"
|
||||
#include "Config.h"
|
||||
#include "effects/Nothing.h"
|
||||
#include "effects/Lofi.h"
|
||||
#include <algorithm>
|
||||
|
||||
namespace sfz {
|
||||
|
||||
void EffectFactory::registerStandardEffectTypes()
|
||||
{
|
||||
// TODO
|
||||
registerEffectType("lofi", fx::Lofi::makeInstance);
|
||||
}
|
||||
|
||||
void EffectFactory::registerEffectType(absl::string_view name, Effect::MakeInstance& make)
|
||||
{
|
||||
FactoryEntry ent;
|
||||
ent.name = std::string(name);
|
||||
ent.make = &make;
|
||||
_entries.push_back(std::move(ent));
|
||||
}
|
||||
|
||||
std::unique_ptr<Effect> EffectFactory::makeEffect(absl::Span<const Opcode> members)
|
||||
{
|
||||
const Opcode* opcode = nullptr;
|
||||
|
||||
for (auto it = members.rbegin(); it != members.rend() && !opcode; ++it) {
|
||||
if (it->lettersOnlyHash == hash("type"))
|
||||
opcode = &*it;
|
||||
}
|
||||
|
||||
if (!opcode) {
|
||||
DBG("The effect does not specify a type");
|
||||
return std::make_unique<sfz::fx::Nothing>();
|
||||
}
|
||||
|
||||
const absl::string_view type = opcode->value;
|
||||
|
||||
const auto it = absl::c_find_if(_entries, [&](auto&& entry) { return entry.name == type; });
|
||||
if (it == _entries.end()) {
|
||||
DBG("Unsupported effect type: " << type);
|
||||
return std::make_unique<sfz::fx::Nothing>();
|
||||
}
|
||||
|
||||
auto fx = it->make(members);
|
||||
if (!fx) {
|
||||
DBG("Could not instantiate effect of type: " << type);
|
||||
return std::make_unique<sfz::fx::Nothing>();
|
||||
}
|
||||
|
||||
return fx;
|
||||
}
|
||||
|
||||
///
|
||||
EffectBus::EffectBus()
|
||||
{
|
||||
}
|
||||
|
||||
EffectBus::~EffectBus()
|
||||
{
|
||||
}
|
||||
|
||||
void EffectBus::addEffect(std::unique_ptr<Effect> fx)
|
||||
{
|
||||
_effects.emplace_back(std::move(fx));
|
||||
}
|
||||
|
||||
void EffectBus::clearInputs(unsigned nframes)
|
||||
{
|
||||
AudioSpan<float>(_inputs).first(nframes).fill(0.0f);
|
||||
AudioSpan<float>(_outputs).first(nframes).fill(0.0f);
|
||||
}
|
||||
|
||||
void EffectBus::addToInputs(const float* const addInput[], float addGain, unsigned nframes)
|
||||
{
|
||||
if (addGain == 0)
|
||||
return;
|
||||
|
||||
for (unsigned c = 0; c < EffectChannels; ++c) {
|
||||
absl::Span<const float> addIn { addInput[c], nframes };
|
||||
sfz::multiplyAdd(addGain, addIn, _inputs.getSpan(c));
|
||||
}
|
||||
}
|
||||
|
||||
void EffectBus::setSampleRate(double sampleRate)
|
||||
{
|
||||
for (const auto& effectPtr : _effects)
|
||||
effectPtr->setSampleRate(sampleRate);
|
||||
}
|
||||
|
||||
void EffectBus::clear()
|
||||
{
|
||||
for (const auto& effectPtr : _effects)
|
||||
effectPtr->clear();
|
||||
}
|
||||
|
||||
void EffectBus::process(unsigned nframes)
|
||||
{
|
||||
size_t numEffects = _effects.size();
|
||||
|
||||
if (numEffects > 0 && hasNonZeroOutput()) {
|
||||
_effects[0]->process(
|
||||
AudioSpan<float>(_inputs), AudioSpan<float>(_outputs), nframes);
|
||||
for (size_t i = 1; i < numEffects; ++i)
|
||||
_effects[i]->process(
|
||||
AudioSpan<float>(_outputs), AudioSpan<float>(_outputs), nframes);
|
||||
} else
|
||||
fx::Nothing().process(
|
||||
AudioSpan<float>(_inputs), AudioSpan<float>(_outputs), nframes);
|
||||
}
|
||||
|
||||
void EffectBus::mixOutputsTo(float* const mainOutput[], float* const mixOutput[], unsigned nframes)
|
||||
{
|
||||
const float gainToMain = _gainToMain;
|
||||
const float gainToMix = _gainToMix;
|
||||
|
||||
for (unsigned c = 0; c < EffectChannels; ++c) {
|
||||
auto fxOut = _outputs.getConstSpan(c);
|
||||
sfz::multiplyAdd(gainToMain, fxOut, absl::Span<float>(mainOutput[c], nframes));
|
||||
sfz::multiplyAdd(gainToMix, fxOut, absl::Span<float>(mixOutput[c], nframes));
|
||||
}
|
||||
}
|
||||
|
||||
size_t EffectBus::numEffects() const noexcept
|
||||
{
|
||||
return _effects.size();
|
||||
}
|
||||
void EffectBus::setSamplesPerBlock(int samplesPerBlock) noexcept
|
||||
{
|
||||
_inputs.resize(samplesPerBlock);
|
||||
_outputs.resize(samplesPerBlock);
|
||||
|
||||
for (const auto& effectPtr : _effects)
|
||||
effectPtr->setSamplesPerBlock(samplesPerBlock);
|
||||
}
|
||||
|
||||
} // namespace sfz
|
||||
180
src/sfizz/Effects.h
Normal file
180
src/sfizz/Effects.h
Normal file
|
|
@ -0,0 +1,180 @@
|
|||
// SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
// This code is part of the sfizz library and is licensed under a BSD 2-clause
|
||||
// license. You should have receive a LICENSE.md file along with the code.
|
||||
// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz
|
||||
|
||||
#pragma once
|
||||
#include "AudioBuffer.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "absl/types/span.h"
|
||||
#include <array>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
namespace sfz {
|
||||
struct Opcode;
|
||||
|
||||
enum {
|
||||
// Number of channels processed by effects
|
||||
EffectChannels = 2,
|
||||
};
|
||||
|
||||
/**
|
||||
@brief Abstract base of SFZ effects
|
||||
*/
|
||||
class Effect {
|
||||
public:
|
||||
virtual ~Effect() {}
|
||||
|
||||
/**
|
||||
@brief Initializes with the given sample rate.
|
||||
*/
|
||||
virtual void setSampleRate(double sampleRate) = 0;
|
||||
|
||||
/**
|
||||
* @brief Sets the maximum number of frames to render at a time. The actual
|
||||
* value can be lower but should never be higher.
|
||||
*/
|
||||
virtual void setSamplesPerBlock(int samplesPerBlock) = 0;
|
||||
|
||||
/**
|
||||
@brief Reset the state to initial.
|
||||
*/
|
||||
virtual void clear() = 0;
|
||||
|
||||
/**
|
||||
@brief Computes a cycle of the effect in stereo.
|
||||
*/
|
||||
virtual void process(const float* const inputs[], float* const outputs[], unsigned nframes) = 0;
|
||||
|
||||
/**
|
||||
@brief Type of the factory function used to instantiate an effect given
|
||||
the contents of the <effect> block
|
||||
*/
|
||||
typedef std::unique_ptr<Effect>(MakeInstance)(absl::Span<const Opcode> members);
|
||||
};
|
||||
|
||||
/**
|
||||
@brief SFZ effects factory
|
||||
*/
|
||||
class EffectFactory {
|
||||
public:
|
||||
/**
|
||||
@brief Registers all available standard effects into the factory.
|
||||
*/
|
||||
void registerStandardEffectTypes();
|
||||
|
||||
/**
|
||||
@brief Registers a user-defined effect into the factory.
|
||||
*/
|
||||
void registerEffectType(absl::string_view name, Effect::MakeInstance& make);
|
||||
|
||||
/**
|
||||
@brief Instantiates an effect given the contents of the <effect> block.
|
||||
*/
|
||||
std::unique_ptr<Effect> makeEffect(absl::Span<const Opcode> members);
|
||||
|
||||
private:
|
||||
struct FactoryEntry {
|
||||
std::string name;
|
||||
Effect::MakeInstance* make;
|
||||
};
|
||||
|
||||
std::vector<FactoryEntry> _entries;
|
||||
};
|
||||
|
||||
/**
|
||||
@brief Sequence of effects processed in series
|
||||
*/
|
||||
class EffectBus {
|
||||
public:
|
||||
EffectBus();
|
||||
~EffectBus();
|
||||
|
||||
/**
|
||||
@brief Adds an effect at the end of the bus.
|
||||
*/
|
||||
void addEffect(std::unique_ptr<Effect> fx);
|
||||
|
||||
/**
|
||||
@brief Checks whether this bus can produce output.
|
||||
*/
|
||||
bool hasNonZeroOutput() const { return _gainToMain != 0 || _gainToMix != 0; }
|
||||
|
||||
/**
|
||||
@brief Sets the amount of effect output going to the main.
|
||||
*/
|
||||
void setGainToMain(float gain) { _gainToMain = gain; }
|
||||
|
||||
/**
|
||||
@brief Sets the amount of effect output going to the mix.
|
||||
*/
|
||||
void setGainToMix(float gain) { _gainToMix = gain; }
|
||||
|
||||
/**
|
||||
* @brief Returns the gain for the main out
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
float gainToMain() const { return _gainToMain; }
|
||||
|
||||
/**
|
||||
* @brief Returns the gain for the mix out
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
float gainToMix() const { return _gainToMix; }
|
||||
|
||||
/**
|
||||
@brief Resets the input buffers to zero.
|
||||
*/
|
||||
void clearInputs(unsigned nframes);
|
||||
|
||||
/**
|
||||
@brief Adds some audio into the input buffer.
|
||||
*/
|
||||
void addToInputs(const float* const addInput[], float addGain, unsigned nframes);
|
||||
|
||||
/**
|
||||
@brief Initializes all effects in the bus with the given sample rate.
|
||||
*/
|
||||
void setSampleRate(double sampleRate);
|
||||
|
||||
/**
|
||||
@brief Resets the state of all effects in the bus.
|
||||
*/
|
||||
void clear();
|
||||
|
||||
/**
|
||||
@brief Computes a cycle of the effect bus.
|
||||
*/
|
||||
void process(unsigned nframes);
|
||||
|
||||
/**
|
||||
@brief Mixes the outputs into a pair of stereo signals: Main and Mix.
|
||||
*/
|
||||
void mixOutputsTo(float* const mainOutput[], float* const mixOutput[], unsigned nframes);
|
||||
|
||||
/**
|
||||
* @brief Sets the maximum number of frames to render at a time. The actual value can be lower
|
||||
* but should never be higher.
|
||||
*
|
||||
*/
|
||||
void setSamplesPerBlock(int samplesPerBlock) noexcept;
|
||||
|
||||
/**
|
||||
* @brief Return the number of effects in the bus
|
||||
*
|
||||
* @return size_t
|
||||
*/
|
||||
size_t numEffects() const noexcept;
|
||||
private:
|
||||
std::vector<std::unique_ptr<Effect>> _effects;
|
||||
AudioBuffer<float> _inputs { EffectChannels, config::defaultSamplesPerBlock };
|
||||
AudioBuffer<float> _outputs { EffectChannels, config::defaultSamplesPerBlock };
|
||||
float _gainToMain = 0.0;
|
||||
float _gainToMix = 0.0;
|
||||
};
|
||||
|
||||
} // namespace sfz
|
||||
|
|
@ -83,7 +83,7 @@ sfz::Logger::~Logger()
|
|||
fs::path callbackLogPath{ fs::current_path() / callbackLogFilename.str() };
|
||||
std::cout << "Logging " << callbackTimes.size() << " callback times to " << callbackLogPath.filename() << '\n';
|
||||
std::ofstream callbackLogFile { callbackLogPath.string() };
|
||||
callbackLogFile << "Dispatch,RenderMethod,Data,Amplitude,Filters,Panning,NumVoices,NumSamples" << '\n';
|
||||
callbackLogFile << "Dispatch,RenderMethod,Data,Amplitude,Filters,Panning,Effects,NumVoices,NumSamples" << '\n';
|
||||
for (auto& time: callbackTimes)
|
||||
callbackLogFile << time.breakdown.dispatch.count() << ','
|
||||
<< time.breakdown.renderMethod.count() << ','
|
||||
|
|
@ -91,6 +91,7 @@ sfz::Logger::~Logger()
|
|||
<< time.breakdown.amplitude.count() << ','
|
||||
<< time.breakdown.filters.count() << ','
|
||||
<< time.breakdown.panning.count() << ','
|
||||
<< time.breakdown.effects.count() << ','
|
||||
<< time.numVoices << ','
|
||||
<< time.numSamples << '\n';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ struct CallbackBreakdown
|
|||
Duration amplitude { 0 };
|
||||
Duration filters { 0 };
|
||||
Duration panning { 0 };
|
||||
Duration effects { 0 };
|
||||
};
|
||||
|
||||
struct CallbackTime
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@
|
|||
|
||||
sfz::MidiState::MidiState()
|
||||
{
|
||||
reset();
|
||||
reset(0);
|
||||
}
|
||||
|
||||
void sfz::MidiState::noteOnEvent(int noteNumber, uint8_t velocity) noexcept
|
||||
void sfz::MidiState::noteOnEvent(int delay, int noteNumber, uint8_t velocity) noexcept
|
||||
{
|
||||
ASSERT(noteNumber >= 0 && noteNumber <= 127);
|
||||
ASSERT(velocity >= 0 && velocity <= 127);
|
||||
|
|
@ -25,7 +25,7 @@ void sfz::MidiState::noteOnEvent(int noteNumber, uint8_t velocity) noexcept
|
|||
|
||||
}
|
||||
|
||||
void sfz::MidiState::noteOffEvent(int noteNumber, uint8_t velocity [[maybe_unused]]) noexcept
|
||||
void sfz::MidiState::noteOffEvent(int delay, int noteNumber, uint8_t velocity [[maybe_unused]]) noexcept
|
||||
{
|
||||
ASSERT(noteNumber >= 0 && noteNumber <= 127);
|
||||
ASSERT(velocity >= 0 && velocity <= 127);
|
||||
|
|
@ -57,7 +57,7 @@ uint8_t sfz::MidiState::getNoteVelocity(int noteNumber) const noexcept
|
|||
return lastNoteVelocities[noteNumber];
|
||||
}
|
||||
|
||||
void sfz::MidiState::pitchBendEvent(int pitchBendValue) noexcept
|
||||
void sfz::MidiState::pitchBendEvent(int delay, int pitchBendValue) noexcept
|
||||
{
|
||||
ASSERT(pitchBendValue >= -8192 && pitchBendValue <= 8192);
|
||||
|
||||
|
|
@ -69,7 +69,7 @@ int sfz::MidiState::getPitchBend() const noexcept
|
|||
return pitchBend;
|
||||
}
|
||||
|
||||
void sfz::MidiState::ccEvent(int ccNumber, uint8_t ccValue) noexcept
|
||||
void sfz::MidiState::ccEvent(int delay, int ccNumber, uint8_t ccValue) noexcept
|
||||
{
|
||||
ASSERT(ccNumber >= 0 && ccNumber < config::numCCs);
|
||||
ASSERT(ccValue >= 0 && ccValue <= 127);
|
||||
|
|
@ -89,7 +89,7 @@ const sfz::SfzCCArray& sfz::MidiState::getCCArray() const noexcept
|
|||
return cc;
|
||||
}
|
||||
|
||||
void sfz::MidiState::reset() noexcept
|
||||
void sfz::MidiState::reset(int delay) noexcept
|
||||
{
|
||||
for (auto& velocity: lastNoteVelocities)
|
||||
velocity = 0;
|
||||
|
|
@ -101,7 +101,7 @@ void sfz::MidiState::reset() noexcept
|
|||
activeNotes = 0;
|
||||
}
|
||||
|
||||
void sfz::MidiState::resetAllControllers() noexcept
|
||||
void sfz::MidiState::resetAllControllers(int delay) noexcept
|
||||
{
|
||||
for (int idx = 0; idx < config::numCCs; idx++)
|
||||
cc[idx] = 0;
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ public:
|
|||
* @param noteNumber
|
||||
* @param velocity
|
||||
*/
|
||||
void noteOnEvent(int noteNumber, uint8_t velocity) noexcept;
|
||||
void noteOnEvent(int delay, int noteNumber, uint8_t velocity) noexcept;
|
||||
|
||||
/**
|
||||
* @brief Update the state after a note off event
|
||||
|
|
@ -37,7 +37,7 @@ public:
|
|||
* @param noteNumber
|
||||
* @param velocity
|
||||
*/
|
||||
void noteOffEvent(int noteNumber, uint8_t velocity) noexcept;
|
||||
void noteOffEvent(int delay, int noteNumber, uint8_t velocity) noexcept;
|
||||
|
||||
int getActiveNotes() const noexcept { return activeNotes; }
|
||||
|
||||
|
|
@ -62,7 +62,7 @@ public:
|
|||
*
|
||||
* @param pitchBendValue
|
||||
*/
|
||||
void pitchBendEvent(int pitchBendValue) noexcept;
|
||||
void pitchBendEvent(int delay, int pitchBendValue) noexcept;
|
||||
|
||||
/**
|
||||
* @brief Get the pitch bend status
|
||||
|
|
@ -77,7 +77,7 @@ public:
|
|||
* @param ccNumber
|
||||
* @param ccValue
|
||||
*/
|
||||
void ccEvent(int ccNumber, uint8_t ccValue) noexcept;
|
||||
void ccEvent(int delay, int ccNumber, uint8_t ccValue) noexcept;
|
||||
|
||||
/**
|
||||
* @brief Get the CC value for CC number
|
||||
|
|
@ -98,12 +98,12 @@ public:
|
|||
* @brief Reset the midi state (does not impact the last note on time)
|
||||
*
|
||||
*/
|
||||
void reset() noexcept;
|
||||
void reset(int delay) noexcept;
|
||||
|
||||
/**
|
||||
* @brief Reset all the controllers
|
||||
*/
|
||||
void resetAllControllers() noexcept;
|
||||
void resetAllControllers(int delay) noexcept;
|
||||
|
||||
/**
|
||||
* @brief Modulate a value using the last entered CCs in the midiState
|
||||
|
|
@ -120,7 +120,7 @@ public:
|
|||
T modulate(T value, const CCMap<U>& modifiers, const Range<T>& validRange, const modFunction<T, U>& lambda = addToBase<T>) const noexcept
|
||||
{
|
||||
for (auto& mod: modifiers) {
|
||||
lambda(value, normalizeCC(getCCValue(mod.first)) * mod.second);
|
||||
lambda(value, normalizeCC(getCCValue(mod.cc)) * mod.value);
|
||||
}
|
||||
return validRange.clamp(value);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,15 +20,13 @@ sfz::Opcode::Opcode(absl::string_view inputOpcode, absl::string_view inputValue)
|
|||
while (nextNumIndex != opcode.npos) {
|
||||
const auto numLetters = nextNumIndex - nextCharIndex;
|
||||
parameterPosition += numLetters;
|
||||
lettersOnlyHash = hash(opcode.substr(nextCharIndex, numLetters), lettersOnlyHash);
|
||||
lettersOnlyHash = hashNoAmpersand(opcode.substr(nextCharIndex, numLetters), lettersOnlyHash);
|
||||
nextCharIndex = opcode.find_first_not_of("1234567890", nextNumIndex);
|
||||
|
||||
uint32_t returnedValue;
|
||||
hasBackParameter = (nextCharIndex == opcode.npos);
|
||||
const auto numDigits = hasBackParameter ? opcode.npos : nextCharIndex - nextNumIndex;
|
||||
const auto numDigits = (nextCharIndex == opcode.npos) ? opcode.npos : nextCharIndex - nextNumIndex;
|
||||
if (absl::SimpleAtoi(opcode.substr(nextNumIndex, numDigits), &returnedValue)) {
|
||||
// ASSERT(returnedValue < std::numeric_limits<uint8_t>::max());
|
||||
parameterPositions.push_back(parameterPosition);
|
||||
lettersOnlyHash = hash("&", lettersOnlyHash);
|
||||
parameters.push_back(returnedValue);
|
||||
}
|
||||
|
||||
|
|
@ -36,35 +34,5 @@ sfz::Opcode::Opcode(absl::string_view inputOpcode, absl::string_view inputValue)
|
|||
}
|
||||
|
||||
if (nextCharIndex != opcode.npos)
|
||||
lettersOnlyHash = hash(opcode.substr(nextCharIndex), lettersOnlyHash);
|
||||
}
|
||||
|
||||
absl::optional<uint8_t> sfz::Opcode::backParameter() const noexcept
|
||||
{
|
||||
if (hasBackParameter && !parameters.empty())
|
||||
return parameters.back();
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
absl::optional<uint8_t> sfz::Opcode::firstParameter() const noexcept
|
||||
{
|
||||
if (!hasBackParameter && !parameters.empty())
|
||||
return parameters.front();
|
||||
|
||||
if (hasBackParameter && parameters.size() > 1)
|
||||
return parameters.front();
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
absl::optional<uint8_t> sfz::Opcode::middleParameter() const noexcept
|
||||
{
|
||||
if (!hasBackParameter && parameters.size() > 1)
|
||||
return parameters[1];
|
||||
|
||||
if (hasBackParameter && parameters.size() > 2)
|
||||
return parameters[1];
|
||||
|
||||
return {};
|
||||
lettersOnlyHash = hashNoAmpersand(opcode.substr(nextCharIndex), lettersOnlyHash);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,17 +26,12 @@ namespace sfz {
|
|||
*/
|
||||
struct Opcode {
|
||||
Opcode() = delete;
|
||||
absl::optional<uint8_t> backParameter() const noexcept;
|
||||
absl::optional<uint8_t> firstParameter() const noexcept;
|
||||
absl::optional<uint8_t> middleParameter() const noexcept;
|
||||
Opcode(absl::string_view inputOpcode, absl::string_view inputValue);
|
||||
absl::string_view opcode {};
|
||||
absl::string_view value {};
|
||||
uint64_t lettersOnlyHash { Fnv1aBasis };
|
||||
// This is to handle the integer parameters of some opcodes
|
||||
std::vector<uint8_t> parameters;
|
||||
std::vector<int> parameterPositions;
|
||||
bool hasBackParameter { false };
|
||||
std::vector<uint16_t> parameters;
|
||||
LEAK_DETECTOR(Opcode);
|
||||
};
|
||||
|
||||
|
|
@ -189,12 +184,11 @@ inline void setRangeStartFromOpcode(const Opcode& opcode, Range<ValueType>& targ
|
|||
* @param validRange the range of admitted values used to clamp the opcode
|
||||
*/
|
||||
template <class ValueType>
|
||||
inline void setCCPairFromOpcode(const Opcode& opcode, absl::optional<CCValuePair>& target, const Range<ValueType>& validRange)
|
||||
inline void setCCPairFromOpcode(const Opcode& opcode, absl::optional<CCValuePair<ValueType>>& target, const Range<ValueType>& validRange)
|
||||
{
|
||||
auto value = readOpcode(opcode.value, validRange);
|
||||
const auto backParameter = opcode.backParameter();
|
||||
if (value && backParameter && Default::ccNumberRange.containsWithEnd(*backParameter))
|
||||
target = std::make_pair(*backParameter, *value);
|
||||
if (value && Default::ccNumberRange.containsWithEnd(opcode.parameters.back()))
|
||||
target = { opcode.parameters.back(), *value };
|
||||
else
|
||||
target = {};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,27 +22,12 @@ class Range {
|
|||
|
||||
public:
|
||||
constexpr Range() = default;
|
||||
// constexpr Range(std::initializer_list<Type> list)
|
||||
// {
|
||||
// switch(list.size())
|
||||
// {
|
||||
// case 0:
|
||||
// break;
|
||||
// case 1:
|
||||
// _start = *list.begin();
|
||||
// _end = _start;
|
||||
// break;
|
||||
// default:
|
||||
// _start = *list.begin();
|
||||
// _end = *(list.begin() + 1);
|
||||
// }
|
||||
// }
|
||||
constexpr Range(Type start, Type end) noexcept
|
||||
: _start(start)
|
||||
, _end(std::max(start, end))
|
||||
{
|
||||
|
||||
}
|
||||
~Range() = default;
|
||||
Type getStart() const noexcept { return _start; }
|
||||
Type getEnd() const noexcept { return _end; }
|
||||
/**
|
||||
|
|
@ -51,8 +36,6 @@ public:
|
|||
* @return std::pair<Type, Type>
|
||||
*/
|
||||
std::pair<Type, Type> getPair() const noexcept { return std::make_pair<Type, Type>(_start, _end); }
|
||||
Range(const Range<Type>& range) = default;
|
||||
Range(Range<Type>&& range) = default;
|
||||
constexpr Type length() const { return _end - _start; }
|
||||
void setStart(Type start) noexcept
|
||||
{
|
||||
|
|
|
|||
|
|
@ -32,13 +32,6 @@ bool extendIfNecessary(std::vector<T>& vec, unsigned size, unsigned defaultCapac
|
|||
|
||||
bool sfz::Region::parseOpcode(const Opcode& opcode)
|
||||
{
|
||||
const auto backParameter = opcode.backParameter();
|
||||
// Check that the parameter is well formed
|
||||
if (backParameter && !sfz::Default::ccNumberRange.containsWithEnd(*backParameter)) {
|
||||
DBG("Wrong parameter value (" << std::to_string(*backParameter) << ") for opcode " << opcode.opcode);
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (opcode.lettersOnlyHash) {
|
||||
// Sound source: sample playback
|
||||
case hash("sample"):
|
||||
|
|
@ -73,7 +66,7 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
|
|||
case hash("count"):
|
||||
setValueFromOpcode(opcode, sampleCount, Default::sampleCountRange);
|
||||
break;
|
||||
case hash("loopmode"):
|
||||
case hash("loopmode"): [[fallthrough]];
|
||||
case hash("loop_mode"):
|
||||
switch (hash(opcode.value)) {
|
||||
case hash("no_loop"):
|
||||
|
|
@ -92,21 +85,21 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
|
|||
DBG("Unkown loop mode:" << std::string(opcode.value));
|
||||
}
|
||||
break;
|
||||
case hash("loopend"):
|
||||
case hash("loopend"): [[fallthrough]];
|
||||
case hash("loop_end"):
|
||||
setRangeEndFromOpcode(opcode, loopRange, Default::loopRange);
|
||||
break;
|
||||
case hash("loopstart"):
|
||||
case hash("loopstart"): [[fallthrough]];
|
||||
case hash("loop_start"):
|
||||
setRangeStartFromOpcode(opcode, loopRange, Default::loopRange);
|
||||
break;
|
||||
|
||||
// Instrument settings: voice lifecycle
|
||||
case hash("group"):
|
||||
case hash("group"): [[fallthrough]];
|
||||
case hash("polyphony_group"):
|
||||
setValueFromOpcode(opcode, group, Default::groupRange);
|
||||
break;
|
||||
case hash("offby"):
|
||||
case hash("offby"): [[fallthrough]];
|
||||
case hash("off_by"):
|
||||
setValueFromOpcode(opcode, offBy, Default::groupRange);
|
||||
break;
|
||||
|
|
@ -150,14 +143,11 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
|
|||
case hash("hibend"):
|
||||
setRangeEndFromOpcode(opcode, bendRange, Default::bendRange);
|
||||
break;
|
||||
case hash("locc"):
|
||||
if (backParameter) {
|
||||
setRangeStartFromOpcode(opcode, ccConditions[*backParameter], Default::ccValueRange);
|
||||
}
|
||||
case hash("locc&"):
|
||||
setRangeStartFromOpcode(opcode, ccConditions[opcode.parameters.back()], Default::ccValueRange);
|
||||
break;
|
||||
case hash("hicc"):
|
||||
if (backParameter)
|
||||
setRangeEndFromOpcode(opcode, ccConditions[*backParameter], Default::ccValueRange);
|
||||
case hash("hicc&"):
|
||||
setRangeEndFromOpcode(opcode, ccConditions[opcode.parameters.back()], Default::ccValueRange);
|
||||
break;
|
||||
case hash("sw_lokey"):
|
||||
setRangeStartFromOpcode(opcode, keyswitchRange, Default::keyRange);
|
||||
|
|
@ -247,49 +237,47 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
|
|||
DBG("Unknown trigger mode: " << std::string(opcode.value));
|
||||
}
|
||||
break;
|
||||
case hash("on_locc"):
|
||||
case hash("start_locc"):
|
||||
if (backParameter)
|
||||
setRangeStartFromOpcode(opcode, ccTriggers[*backParameter], Default::ccTriggerValueRange);
|
||||
case hash("on_locc&"): [[fallthrough]];
|
||||
case hash("start_locc&"):
|
||||
setRangeStartFromOpcode(opcode, ccTriggers[opcode.parameters.back()], Default::ccTriggerValueRange);
|
||||
break;
|
||||
case hash("on_hicc"):
|
||||
case hash("start_hicc"):
|
||||
if (backParameter)
|
||||
setRangeEndFromOpcode(opcode, ccTriggers[*backParameter], Default::ccTriggerValueRange);
|
||||
case hash("on_hicc&"): [[fallthrough]];
|
||||
case hash("start_hicc&"):
|
||||
setRangeEndFromOpcode(opcode, ccTriggers[opcode.parameters.back()], Default::ccTriggerValueRange);
|
||||
break;
|
||||
|
||||
// Performance parameters: amplifier
|
||||
case hash("volume"):
|
||||
setValueFromOpcode(opcode, volume, Default::volumeRange);
|
||||
break;
|
||||
case hash("gain_cc"):
|
||||
case hash("gain_oncc"):
|
||||
case hash("volume_oncc"):
|
||||
case hash("gain_cc&"): [[fallthrough]];
|
||||
case hash("gain_oncc&"): [[fallthrough]];
|
||||
case hash("volume_oncc&"):
|
||||
setCCPairFromOpcode(opcode, volumeCC, Default::volumeCCRange);
|
||||
break;
|
||||
case hash("amplitude"):
|
||||
setValueFromOpcode(opcode, amplitude, Default::amplitudeRange);
|
||||
break;
|
||||
case hash("amplitude_cc"):
|
||||
case hash("amplitude_oncc"):
|
||||
case hash("amplitude_cc&"): [[fallthrough]];
|
||||
case hash("amplitude_oncc&"):
|
||||
setCCPairFromOpcode(opcode, amplitudeCC, Default::amplitudeRange);
|
||||
break;
|
||||
case hash("pan"):
|
||||
setValueFromOpcode(opcode, pan, Default::panRange);
|
||||
break;
|
||||
case hash("pan_oncc"):
|
||||
case hash("pan_oncc&"):
|
||||
setCCPairFromOpcode(opcode, panCC, Default::panCCRange);
|
||||
break;
|
||||
case hash("position"):
|
||||
setValueFromOpcode(opcode, position, Default::positionRange);
|
||||
break;
|
||||
case hash("position_oncc"):
|
||||
case hash("position_oncc&"):
|
||||
setCCPairFromOpcode(opcode, positionCC, Default::positionCCRange);
|
||||
break;
|
||||
case hash("width"):
|
||||
setValueFromOpcode(opcode, width, Default::widthRange);
|
||||
break;
|
||||
case hash("width_oncc"):
|
||||
case hash("width_oncc&"):
|
||||
setCCPairFromOpcode(opcode, widthCC, Default::widthCCRange);
|
||||
break;
|
||||
case hash("amp_keycenter"):
|
||||
|
|
@ -305,11 +293,11 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
|
|||
setValueFromOpcode(opcode, ampRandom, Default::ampRandomRange);
|
||||
volumeDistribution.param(std::uniform_real_distribution<float>::param_type(0, ampRandom));
|
||||
break;
|
||||
case hash("amp_velcurve_"):
|
||||
case hash("amp_velcurve_&"):
|
||||
{
|
||||
auto value = readOpcode(opcode.value, Default::ampVelcurveRange);
|
||||
if (value)
|
||||
velocityPoints.emplace_back(*backParameter, *value);
|
||||
velocityPoints.emplace_back(opcode.parameters.back(), *value);
|
||||
}
|
||||
break;
|
||||
case hash("xfin_lokey"):
|
||||
|
|
@ -360,25 +348,17 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
|
|||
DBG("Unknown crossfade power curve: " << std::string(opcode.value));
|
||||
}
|
||||
break;
|
||||
case hash("xfin_locc"):
|
||||
if (backParameter) {
|
||||
setRangeStartFromOpcode(opcode, crossfadeCCInRange[*backParameter], Default::ccValueRange);
|
||||
}
|
||||
case hash("xfin_locc&"):
|
||||
setRangeStartFromOpcode(opcode, crossfadeCCInRange[opcode.parameters.back()], Default::ccValueRange);
|
||||
break;
|
||||
case hash("xfin_hicc"):
|
||||
if (backParameter) {
|
||||
setRangeEndFromOpcode(opcode, crossfadeCCInRange[*backParameter], Default::ccValueRange);
|
||||
}
|
||||
case hash("xfin_hicc&"):
|
||||
setRangeEndFromOpcode(opcode, crossfadeCCInRange[opcode.parameters.back()], Default::ccValueRange);
|
||||
break;
|
||||
case hash("xfout_locc"):
|
||||
if (backParameter) {
|
||||
setRangeStartFromOpcode(opcode, crossfadeCCOutRange[*backParameter], Default::ccValueRange);
|
||||
}
|
||||
case hash("xfout_locc&"):
|
||||
setRangeStartFromOpcode(opcode, crossfadeCCOutRange[opcode.parameters.back()], Default::ccValueRange);
|
||||
break;
|
||||
case hash("xfout_hicc"):
|
||||
if (backParameter) {
|
||||
setRangeEndFromOpcode(opcode, crossfadeCCOutRange[*backParameter], Default::ccValueRange);
|
||||
}
|
||||
case hash("xfout_hicc&"):
|
||||
setRangeEndFromOpcode(opcode, crossfadeCCOutRange[opcode.parameters.back()], Default::ccValueRange);
|
||||
break;
|
||||
case hash("xf_cccurve"):
|
||||
switch (hash(opcode.value)) {
|
||||
|
|
@ -397,120 +377,124 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
|
|||
break;
|
||||
|
||||
// Performance parameters: filters
|
||||
case hash("cutoff"):
|
||||
case hash("cutoff"): [[fallthrough]];
|
||||
case hash("cutoff&"):
|
||||
{
|
||||
const auto filterIndex { backParameter.value_or(1) - 1 };
|
||||
const auto filterIndex = opcode.parameters.empty() ? 0 : (opcode.parameters.back() - 1);
|
||||
if (!extendIfNecessary(filters, filterIndex + 1, Default::numFilters))
|
||||
return false;
|
||||
setValueFromOpcode(opcode, filters[filterIndex].cutoff, Default::filterCutoffRange);
|
||||
}
|
||||
break;
|
||||
case hash("resonance"):
|
||||
case hash("resonance"): [[fallthrough]];
|
||||
case hash("resonance&"):
|
||||
{
|
||||
const auto filterIndex { backParameter.value_or(1) - 1 };
|
||||
const auto filterIndex = opcode.parameters.empty() ? 0 : (opcode.parameters.back() - 1);
|
||||
if (!extendIfNecessary(filters, filterIndex + 1, Default::numFilters))
|
||||
return false;
|
||||
setValueFromOpcode(opcode, filters[filterIndex].resonance, Default::filterResonanceRange);
|
||||
}
|
||||
break;
|
||||
case hash("cutoff_oncc"):
|
||||
case hash("cutoff_cc"):
|
||||
case hash("cutoff_oncc&"): [[fallthrough]];
|
||||
case hash("cutoff_cc&"): [[fallthrough]];
|
||||
case hash("cutoff&_oncc&"): [[fallthrough]];
|
||||
case hash("cutoff&_cc&"):
|
||||
{
|
||||
if (!backParameter)
|
||||
return false;
|
||||
|
||||
const auto filterIndex { opcode.firstParameter().value_or(1) - 1 };
|
||||
const auto filterIndex = opcode.parameters.size() == 1 ? 0 : (opcode.parameters.front() - 1);
|
||||
if (!extendIfNecessary(filters, filterIndex + 1, Default::numFilters))
|
||||
return false;
|
||||
|
||||
setValueFromOpcode(
|
||||
opcode,
|
||||
filters[filterIndex].cutoffCC[*backParameter],
|
||||
filters[filterIndex].cutoffCC[opcode.parameters.back()],
|
||||
Default::filterCutoffModRange
|
||||
);
|
||||
}
|
||||
break;
|
||||
case hash("resonance_oncc"):
|
||||
case hash("resonance_cc"):
|
||||
case hash("resonance&_oncc&"): [[fallthrough]];
|
||||
case hash("resonance&_cc&"): [[fallthrough]];
|
||||
case hash("resonance_oncc&"): [[fallthrough]];
|
||||
case hash("resonance_cc&"):
|
||||
{
|
||||
if (!backParameter)
|
||||
return false;
|
||||
|
||||
const auto filterIndex { opcode.firstParameter().value_or(1) - 1 };
|
||||
const auto filterIndex = opcode.parameters.size() == 1 ? 0 : (opcode.parameters.front() - 1);
|
||||
if (!extendIfNecessary(filters, filterIndex + 1, Default::numFilters))
|
||||
return false;
|
||||
|
||||
setValueFromOpcode(
|
||||
opcode,
|
||||
filters[filterIndex].resonanceCC[*backParameter],
|
||||
filters[filterIndex].resonanceCC[opcode.parameters.back()],
|
||||
Default::filterResonanceModRange
|
||||
);
|
||||
}
|
||||
break;
|
||||
case hash("fil_keytrack"):
|
||||
case hash("fil_keytrack"): [[fallthrough]];
|
||||
case hash("fil&_keytrack"):
|
||||
{
|
||||
const auto filterIndex { opcode.firstParameter().value_or(1) - 1 };
|
||||
const auto filterIndex = opcode.parameters.empty() ? 0 : (opcode.parameters.front() - 1);
|
||||
if (!extendIfNecessary(filters, filterIndex + 1, Default::numFilters))
|
||||
return false;
|
||||
|
||||
setValueFromOpcode(opcode, filters[filterIndex].keytrack, Default::filterKeytrackRange);
|
||||
}
|
||||
break;
|
||||
case hash("fil_keycenter"):
|
||||
case hash("fil_keycenter"): [[fallthrough]];
|
||||
case hash("fil&_keycenter"):
|
||||
{
|
||||
const auto filterIndex { opcode.firstParameter().value_or(1) - 1 };
|
||||
const auto filterIndex = opcode.parameters.empty() ? 0 : (opcode.parameters.front() - 1);
|
||||
if (!extendIfNecessary(filters, filterIndex + 1, Default::numFilters))
|
||||
return false;
|
||||
|
||||
setValueFromOpcode(opcode, filters[filterIndex].keycenter, Default::keyRange);
|
||||
}
|
||||
break;
|
||||
case hash("fil_veltrack"):
|
||||
case hash("fil_veltrack"): [[fallthrough]];
|
||||
case hash("fil&_veltrack"):
|
||||
{
|
||||
const auto filterIndex { opcode.firstParameter().value_or(1) - 1 };
|
||||
const auto filterIndex = opcode.parameters.empty() ? 0 : (opcode.parameters.front() - 1);
|
||||
if (!extendIfNecessary(filters, filterIndex + 1, Default::numFilters))
|
||||
return false;
|
||||
|
||||
setValueFromOpcode(opcode, filters[filterIndex].veltrack, Default::filterVeltrackRange);
|
||||
}
|
||||
break;
|
||||
case hash("fil_random"):
|
||||
case hash("fil_random"): [[fallthrough]];
|
||||
case hash("fil&_random"):
|
||||
{
|
||||
const auto filterIndex { opcode.firstParameter().value_or(1) - 1 };
|
||||
const auto filterIndex = opcode.parameters.empty() ? 0 : (opcode.parameters.front() - 1);
|
||||
if (!extendIfNecessary(filters, filterIndex + 1, Default::numFilters))
|
||||
return false;
|
||||
|
||||
setValueFromOpcode(opcode, filters[filterIndex].random, Default::filterRandomRange);
|
||||
}
|
||||
break;
|
||||
case hash("fil_gain"):
|
||||
case hash("fil_gain"): [[fallthrough]];
|
||||
case hash("fil&_gain"):
|
||||
{
|
||||
const auto filterIndex { opcode.firstParameter().value_or(1) - 1 };
|
||||
const auto filterIndex = opcode.parameters.empty() ? 0 : (opcode.parameters.front() - 1);
|
||||
if (!extendIfNecessary(filters, filterIndex + 1, Default::numFilters))
|
||||
return false;
|
||||
|
||||
setValueFromOpcode(opcode, filters[filterIndex].gain, Default::filterGainRange);
|
||||
}
|
||||
break;
|
||||
case hash("fil_gaincc"):
|
||||
case hash("fil_gaincc&"): [[fallthrough]];
|
||||
case hash("fil&_gaincc&"):
|
||||
{
|
||||
if (!backParameter)
|
||||
return false;
|
||||
|
||||
const auto filterIndex { opcode.firstParameter().value_or(1) - 1 };
|
||||
const auto filterIndex = opcode.parameters.size() == 1 ? 0 : (opcode.parameters.front() - 1);
|
||||
if (!extendIfNecessary(filters, filterIndex + 1, Default::numFilters))
|
||||
return false;
|
||||
|
||||
setValueFromOpcode(
|
||||
opcode,
|
||||
filters[filterIndex].gainCC[*backParameter],
|
||||
filters[filterIndex].gainCC[opcode.parameters.back()],
|
||||
Default::filterGainModRange
|
||||
);
|
||||
}
|
||||
break;
|
||||
case hash("fil_type"):
|
||||
case hash("fil_type"): [[fallthrough]];
|
||||
case hash("fil&_type"):
|
||||
{
|
||||
const auto filterIndex { opcode.firstParameter().value_or(1) - 1 };
|
||||
const auto filterIndex = opcode.parameters.empty() ? 0 : (opcode.parameters.front() - 1);
|
||||
if (!extendIfNecessary(filters, filterIndex + 1, Default::numFilters))
|
||||
return false;
|
||||
|
||||
|
|
@ -545,104 +529,96 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
|
|||
break;
|
||||
|
||||
// Performance parameters: EQ
|
||||
case hash("eq_bw"):
|
||||
case hash("eq&_bw"):
|
||||
{
|
||||
const auto eqNumber = opcode.firstParameter();
|
||||
if (!eqNumber || *eqNumber == 0)
|
||||
const auto eqNumber = opcode.parameters.front();
|
||||
if (eqNumber == 0)
|
||||
return false;
|
||||
if (!extendIfNecessary(equalizers, *eqNumber, Default::numEQs))
|
||||
if (!extendIfNecessary(equalizers, eqNumber, Default::numEQs))
|
||||
return false;
|
||||
setValueFromOpcode(opcode, equalizers[*eqNumber - 1].bandwidth, Default::eqBandwidthRange);
|
||||
setValueFromOpcode(opcode, equalizers[eqNumber - 1].bandwidth, Default::eqBandwidthRange);
|
||||
}
|
||||
break;
|
||||
case hash("eq_bw_oncc"): [[fallthrough]];
|
||||
case hash("eq_bwcc"):
|
||||
case hash("eq&_bw_oncc&"): [[fallthrough]];
|
||||
case hash("eq&_bwcc&"):
|
||||
{
|
||||
const auto eqNumber = opcode.firstParameter();
|
||||
if (!eqNumber || *eqNumber == 0)
|
||||
const auto eqNumber = opcode.parameters.front();
|
||||
if (eqNumber == 0)
|
||||
return false;
|
||||
if (!backParameter)
|
||||
return false;
|
||||
if (!extendIfNecessary(equalizers, *eqNumber, Default::numEQs))
|
||||
if (!extendIfNecessary(equalizers, eqNumber, Default::numEQs))
|
||||
return false;
|
||||
|
||||
setValueFromOpcode(opcode, equalizers[*eqNumber - 1].bandwidthCC[*backParameter], Default::eqBandwidthModRange);
|
||||
setValueFromOpcode(opcode, equalizers[eqNumber - 1].bandwidthCC[opcode.parameters.back()], Default::eqBandwidthModRange);
|
||||
}
|
||||
break;
|
||||
case hash("eq_freq"):
|
||||
case hash("eq&_freq"):
|
||||
{
|
||||
const auto eqNumber = opcode.firstParameter();
|
||||
if (!eqNumber || *eqNumber == 0)
|
||||
const auto eqNumber = opcode.parameters.front();
|
||||
if (eqNumber == 0)
|
||||
return false;
|
||||
if (!extendIfNecessary(equalizers, *eqNumber, Default::numEQs))
|
||||
if (!extendIfNecessary(equalizers, eqNumber, Default::numEQs))
|
||||
return false;
|
||||
setValueFromOpcode(opcode, equalizers[*eqNumber - 1].frequency, Default::eqFrequencyRange);
|
||||
setValueFromOpcode(opcode, equalizers[eqNumber - 1].frequency, Default::eqFrequencyRange);
|
||||
}
|
||||
break;
|
||||
case hash("eq_freq_oncc"): [[fallthrough]];
|
||||
case hash("eq_freqcc"):
|
||||
case hash("eq&_freq_oncc&"): [[fallthrough]];
|
||||
case hash("eq&_freqcc&"):
|
||||
{
|
||||
const auto eqNumber = opcode.firstParameter();
|
||||
if (!eqNumber || *eqNumber == 0)
|
||||
const auto eqNumber = opcode.parameters.front();
|
||||
if (eqNumber == 0)
|
||||
return false;
|
||||
if (!backParameter)
|
||||
return false;
|
||||
if (!extendIfNecessary(equalizers, *eqNumber, Default::numEQs))
|
||||
if (!extendIfNecessary(equalizers, eqNumber, Default::numEQs))
|
||||
return false;
|
||||
|
||||
setValueFromOpcode(opcode, equalizers[*eqNumber - 1].frequencyCC[*backParameter], Default::eqFrequencyModRange);
|
||||
setValueFromOpcode(opcode, equalizers[eqNumber - 1].frequencyCC[opcode.parameters.back()], Default::eqFrequencyModRange);
|
||||
}
|
||||
break;
|
||||
case hash("eq_velfreq"):
|
||||
case hash("eq&_vel&freq"):
|
||||
{
|
||||
const auto eqNumber = opcode.firstParameter();
|
||||
const auto check2 = opcode.middleParameter();
|
||||
if (!eqNumber || *eqNumber == 0)
|
||||
const auto eqNumber = opcode.parameters.front();
|
||||
if (eqNumber == 0)
|
||||
return false;
|
||||
if (!check2 || *check2 != 2 || opcode.parameterPositions[1] != 6)
|
||||
if (opcode.parameters[1] != 2)
|
||||
return false; // was eqN_vel3freq or something else than eqN_vel2freq
|
||||
if (!extendIfNecessary(equalizers, *eqNumber, Default::numEQs))
|
||||
if (!extendIfNecessary(equalizers, eqNumber, Default::numEQs))
|
||||
return false;
|
||||
|
||||
setValueFromOpcode(opcode, equalizers[*eqNumber - 1].vel2frequency, Default::eqFrequencyModRange);
|
||||
setValueFromOpcode(opcode, equalizers[eqNumber - 1].vel2frequency, Default::eqFrequencyModRange);
|
||||
}
|
||||
break;
|
||||
case hash("eq_gain"):
|
||||
case hash("eq&_gain"):
|
||||
{
|
||||
const auto eqNumber = opcode.firstParameter();
|
||||
if (!eqNumber || *eqNumber == 0)
|
||||
const auto eqNumber = opcode.parameters.front();
|
||||
if (eqNumber == 0)
|
||||
return false;
|
||||
if (!extendIfNecessary(equalizers, *eqNumber, Default::numEQs))
|
||||
if (!extendIfNecessary(equalizers, eqNumber, Default::numEQs))
|
||||
return false;
|
||||
setValueFromOpcode(opcode, equalizers[*eqNumber - 1].gain, Default::eqGainRange);
|
||||
setValueFromOpcode(opcode, equalizers[eqNumber - 1].gain, Default::eqGainRange);
|
||||
}
|
||||
break;
|
||||
case hash("eq_gain_oncc"): [[fallthrough]];
|
||||
case hash("eq_gaincc"):
|
||||
case hash("eq&_gain_oncc&"): [[fallthrough]];
|
||||
case hash("eq&_gaincc&"):
|
||||
{
|
||||
const auto eqNumber = opcode.firstParameter();
|
||||
if (!eqNumber || *eqNumber == 0)
|
||||
const auto eqNumber = opcode.parameters.front();
|
||||
if (eqNumber == 0)
|
||||
return false;
|
||||
if (!backParameter)
|
||||
return false;
|
||||
if (!extendIfNecessary(equalizers, *eqNumber, Default::numEQs))
|
||||
if (!extendIfNecessary(equalizers, eqNumber, Default::numEQs))
|
||||
return false;
|
||||
|
||||
setValueFromOpcode(opcode, equalizers[*eqNumber - 1].gainCC[*backParameter], Default::eqGainModRange);
|
||||
setValueFromOpcode(opcode, equalizers[eqNumber - 1].gainCC[opcode.parameters.back()], Default::eqGainModRange);
|
||||
}
|
||||
break;
|
||||
case hash("eq_velgain"):
|
||||
case hash("eq&_vel&gain"):
|
||||
{
|
||||
const auto eqNumber = opcode.firstParameter();
|
||||
const auto check2 = opcode.middleParameter();
|
||||
if (!eqNumber || *eqNumber == 0)
|
||||
const auto eqNumber = opcode.parameters.front();
|
||||
if (eqNumber == 0)
|
||||
return false;
|
||||
if (!check2 || *check2 != 2 || opcode.parameterPositions[1] != 6)
|
||||
return false; // was eqN_vel3gain or something else than eqN_vel2gain
|
||||
if (!extendIfNecessary(equalizers, *eqNumber, Default::numEQs))
|
||||
if (opcode.parameters[1] != 2)
|
||||
return false; // was eqN_vel3gain or something else than eqN_vel2gain
|
||||
if (!extendIfNecessary(equalizers, eqNumber, Default::numEQs))
|
||||
return false;
|
||||
|
||||
setValueFromOpcode(opcode, equalizers[*eqNumber - 1].vel2gain, Default::eqGainModRange);
|
||||
setValueFromOpcode(opcode, equalizers[eqNumber - 1].vel2gain, Default::eqGainModRange);
|
||||
}
|
||||
break;
|
||||
// Performance parameters: pitch
|
||||
|
|
@ -662,7 +638,7 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
|
|||
case hash("transpose"):
|
||||
setValueFromOpcode(opcode, transpose, Default::transposeRange);
|
||||
break;
|
||||
case hash("tune"):
|
||||
case hash("tune"): [[fallthrough]];
|
||||
case hash("pitch"):
|
||||
setValueFromOpcode(opcode, tune, Default::tuneRange);
|
||||
break;
|
||||
|
|
@ -698,64 +674,84 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
|
|||
case hash("ampeg_sustain"):
|
||||
setValueFromOpcode(opcode, amplitudeEG.sustain, Default::egPercentRange);
|
||||
break;
|
||||
case hash("ampeg_velattack"):
|
||||
if (!opcode.parameters.empty() && opcode.parameters.front() == 2)
|
||||
setValueFromOpcode(opcode, amplitudeEG.vel2attack, Default::egOnCCTimeRange);
|
||||
case hash("ampeg_vel&attack"):
|
||||
if (opcode.parameters.front() != 2)
|
||||
return false; // Was not vel2...
|
||||
setValueFromOpcode(opcode, amplitudeEG.vel2attack, Default::egOnCCTimeRange);
|
||||
break;
|
||||
case hash("ampeg_veldecay"):
|
||||
if (!opcode.parameters.empty() && opcode.parameters.front() == 2)
|
||||
setValueFromOpcode(opcode, amplitudeEG.vel2decay, Default::egOnCCTimeRange);
|
||||
case hash("ampeg_vel&decay"):
|
||||
if (opcode.parameters.front() != 2)
|
||||
return false; // Was not vel2...
|
||||
setValueFromOpcode(opcode, amplitudeEG.vel2decay, Default::egOnCCTimeRange);
|
||||
break;
|
||||
case hash("ampeg_veldelay"):
|
||||
if (!opcode.parameters.empty() && opcode.parameters.front() == 2)
|
||||
setValueFromOpcode(opcode, amplitudeEG.vel2delay, Default::egOnCCTimeRange);
|
||||
case hash("ampeg_vel&delay"):
|
||||
if (opcode.parameters.front() != 2)
|
||||
return false; // Was not vel2...
|
||||
setValueFromOpcode(opcode, amplitudeEG.vel2delay, Default::egOnCCTimeRange);
|
||||
break;
|
||||
case hash("ampeg_velhold"):
|
||||
if (!opcode.parameters.empty() && opcode.parameters.front() == 2)
|
||||
setValueFromOpcode(opcode, amplitudeEG.vel2hold, Default::egOnCCTimeRange);
|
||||
case hash("ampeg_vel&hold"):
|
||||
if (opcode.parameters.front() != 2)
|
||||
return false; // Was not vel2...
|
||||
setValueFromOpcode(opcode, amplitudeEG.vel2hold, Default::egOnCCTimeRange);
|
||||
break;
|
||||
case hash("ampeg_velrelease"):
|
||||
if (!opcode.parameters.empty() && opcode.parameters.front() == 2)
|
||||
setValueFromOpcode(opcode, amplitudeEG.vel2release, Default::egOnCCTimeRange);
|
||||
case hash("ampeg_vel&release"):
|
||||
if (opcode.parameters.front() != 2)
|
||||
return false; // Was not vel2...
|
||||
setValueFromOpcode(opcode, amplitudeEG.vel2release, Default::egOnCCTimeRange);
|
||||
break;
|
||||
case hash("ampeg_velsustain"):
|
||||
if (!opcode.parameters.empty() && opcode.parameters.front() == 2)
|
||||
setValueFromOpcode(opcode, amplitudeEG.vel2sustain, Default::egOnCCPercentRange);
|
||||
case hash("ampeg_vel&sustain"):
|
||||
if (opcode.parameters.front() != 2)
|
||||
return false; // Was not vel2...
|
||||
setValueFromOpcode(opcode, amplitudeEG.vel2sustain, Default::egOnCCPercentRange);
|
||||
break;
|
||||
case hash("ampeg_attackcc"):
|
||||
case hash("ampeg_attack_oncc"):
|
||||
case hash("ampeg_attackcc&"): [[fallthrough]];
|
||||
case hash("ampeg_attack_oncc&"):
|
||||
setCCPairFromOpcode(opcode, amplitudeEG.ccAttack, Default::egOnCCTimeRange);
|
||||
break;
|
||||
case hash("ampeg_decaycc"):
|
||||
case hash("ampeg_decay_oncc"):
|
||||
case hash("ampeg_decaycc&"): [[fallthrough]];
|
||||
case hash("ampeg_decay_oncc&"):
|
||||
setCCPairFromOpcode(opcode, amplitudeEG.ccDecay, Default::egOnCCTimeRange);
|
||||
break;
|
||||
case hash("ampeg_delaycc"):
|
||||
case hash("ampeg_delay_oncc"):
|
||||
case hash("ampeg_delaycc&"): [[fallthrough]];
|
||||
case hash("ampeg_delay_oncc&"):
|
||||
setCCPairFromOpcode(opcode, amplitudeEG.ccDelay, Default::egOnCCTimeRange);
|
||||
break;
|
||||
case hash("ampeg_holdcc"):
|
||||
case hash("ampeg_hold_oncc"):
|
||||
case hash("ampeg_holdcc&"): [[fallthrough]];
|
||||
case hash("ampeg_hold_oncc&"):
|
||||
setCCPairFromOpcode(opcode, amplitudeEG.ccHold, Default::egOnCCTimeRange);
|
||||
break;
|
||||
case hash("ampeg_releasecc"):
|
||||
case hash("ampeg_release_oncc"):
|
||||
case hash("ampeg_releasecc&"): [[fallthrough]];
|
||||
case hash("ampeg_release_oncc&"):
|
||||
setCCPairFromOpcode(opcode, amplitudeEG.ccRelease, Default::egOnCCTimeRange);
|
||||
break;
|
||||
case hash("ampeg_startcc"):
|
||||
case hash("ampeg_start_oncc"):
|
||||
case hash("ampeg_startcc&"): [[fallthrough]];
|
||||
case hash("ampeg_start_oncc&"):
|
||||
setCCPairFromOpcode(opcode, amplitudeEG.ccStart, Default::egOnCCPercentRange);
|
||||
break;
|
||||
case hash("ampeg_sustaincc"):
|
||||
case hash("ampeg_sustain_oncc"):
|
||||
case hash("ampeg_sustaincc&"): [[fallthrough]];
|
||||
case hash("ampeg_sustain_oncc&"):
|
||||
setCCPairFromOpcode(opcode, amplitudeEG.ccSustain, Default::egOnCCPercentRange);
|
||||
break;
|
||||
|
||||
case hash("effect&"):
|
||||
{
|
||||
const auto effectNumber = opcode.parameters.back();
|
||||
if (!effectNumber || effectNumber < 1 || effectNumber > config::maxEffectBuses)
|
||||
break;
|
||||
auto value = readOpcode<float>(opcode.value, { 0, 100 });
|
||||
if (!value)
|
||||
break;
|
||||
if (static_cast<size_t>(effectNumber + 1) > gainToEffect.size())
|
||||
gainToEffect.resize(effectNumber + 1);
|
||||
gainToEffect[effectNumber] = *value / 100;
|
||||
break;
|
||||
}
|
||||
|
||||
// Ignored opcodes
|
||||
case hash("hichan"):
|
||||
case hash("lochan"):
|
||||
case hash("ampeg_depth"):
|
||||
case hash("ampeg_vel2depth"):
|
||||
case hash("ampeg_vel&depth"):
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
|
|
@ -858,7 +854,7 @@ bool sfz::Region::registerCC(int ccNumber, uint8_t ccValue) noexcept
|
|||
if (!triggerOnCC)
|
||||
return false;
|
||||
|
||||
if (ccTriggers.contains(ccNumber) && ccTriggers.at(ccNumber).containsWithEnd(ccValue))
|
||||
if (ccTriggers.contains(ccNumber) && ccTriggers[ccNumber].containsWithEnd(ccValue))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
|
|
@ -996,14 +992,14 @@ float sfz::Region::getCrossfadeGain(const sfz::SfzCCArray& ccState) noexcept
|
|||
|
||||
// Crossfades due to CC states
|
||||
for (const auto& valuePair : crossfadeCCInRange) {
|
||||
const auto ccValue = ccState[valuePair.first];
|
||||
const auto crossfadeRange = valuePair.second;
|
||||
const auto ccValue = ccState[valuePair.cc];
|
||||
const auto crossfadeRange = valuePair.value;
|
||||
gain *= crossfadeIn(crossfadeRange, ccValue, crossfadeCCCurve);
|
||||
}
|
||||
|
||||
for (const auto& valuePair : crossfadeCCOutRange) {
|
||||
const auto ccValue = ccState[valuePair.first];
|
||||
const auto crossfadeRange = valuePair.second;
|
||||
const auto ccValue = ccState[valuePair.cc];
|
||||
const auto crossfadeRange = valuePair.value;
|
||||
gain *= crossfadeOut(crossfadeRange, ccValue, crossfadeCCCurve);
|
||||
}
|
||||
|
||||
|
|
@ -1091,3 +1087,11 @@ void sfz::Region::offsetAllKeys(int offset) noexcept
|
|||
crossfadeKeyOutRange.setEnd(offsetAndClamp(end, offset, Default::keyRange));
|
||||
}
|
||||
}
|
||||
|
||||
float sfz::Region::getGainToEffectBus(unsigned number) const noexcept
|
||||
{
|
||||
if (number >= gainToEffect.size())
|
||||
return 0.0;
|
||||
|
||||
return gainToEffect[number];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,6 +39,9 @@ struct Region {
|
|||
: midiState(midiState), defaultPath(std::move(defaultPath))
|
||||
{
|
||||
ccSwitched.set();
|
||||
|
||||
gainToEffect.reserve(5); // sufficient room for main and fx1-4
|
||||
gainToEffect.push_back(1.0); // contribute 100% into the main bus
|
||||
}
|
||||
Region(const Region&) = default;
|
||||
~Region() = default;
|
||||
|
|
@ -206,6 +209,12 @@ struct Region {
|
|||
|
||||
bool hasKeyswitches() const noexcept { return keyswitchDown || keyswitchUp || keyswitch || previousNote; }
|
||||
|
||||
/**
|
||||
* @brief Get the gain this region contributes into the input of the Nth
|
||||
* effect bus
|
||||
*/
|
||||
float getGainToEffectBus(unsigned number) const noexcept;
|
||||
|
||||
// Sound source: sample playback
|
||||
std::string sample {}; // Sample
|
||||
float delay { Default::delay }; // delay
|
||||
|
|
@ -255,11 +264,11 @@ struct Region {
|
|||
float pan { Default::pan }; // pan
|
||||
float width { Default::width }; // width
|
||||
float position { Default::position }; // position
|
||||
absl::optional<CCValuePair> volumeCC; // volume_oncc
|
||||
absl::optional<CCValuePair> amplitudeCC; // amplitude_oncc
|
||||
absl::optional<CCValuePair> panCC; // pan_oncc
|
||||
absl::optional<CCValuePair> widthCC; // width_oncc
|
||||
absl::optional<CCValuePair> positionCC; // position_oncc
|
||||
absl::optional<CCValuePair<float>> volumeCC; // volume_oncc
|
||||
absl::optional<CCValuePair<float>> amplitudeCC; // amplitude_oncc
|
||||
absl::optional<CCValuePair<float>> panCC; // pan_oncc
|
||||
absl::optional<CCValuePair<float>> widthCC; // width_oncc
|
||||
absl::optional<CCValuePair<float>> positionCC; // position_oncc
|
||||
uint8_t ampKeycenter { Default::ampKeycenter }; // amp_keycenter
|
||||
float ampKeytrack { Default::ampKeytrack }; // amp_keytrack
|
||||
float ampVeltrack { Default::ampVeltrack }; // amp_keytrack
|
||||
|
|
@ -297,6 +306,10 @@ struct Region {
|
|||
EGDescription filterEG;
|
||||
|
||||
bool isStereo { false };
|
||||
|
||||
// Effects
|
||||
std::vector<float> gainToEffect;
|
||||
|
||||
private:
|
||||
const MidiState& midiState;
|
||||
bool keySwitched { true };
|
||||
|
|
|
|||
|
|
@ -76,6 +76,12 @@ void sfz::multiplyAdd<float, true>(absl::Span<const float> gain, absl::Span<cons
|
|||
multiplyAdd<float, false>(gain, input, output);
|
||||
}
|
||||
|
||||
template <>
|
||||
void sfz::multiplyAdd<float, true>(const float gain, absl::Span<const float> input, absl::Span<float> output) noexcept
|
||||
{
|
||||
multiplyAdd<float, false>(gain, input, output);
|
||||
}
|
||||
|
||||
template <>
|
||||
float sfz::loopingSFZIndex<float, true>(absl::Span<const float> jumps, absl::Span<float> leftCoeff, absl::Span<float> rightCoeff, absl::Span<int> indices, float floatIndex, float loopEnd, float loopStart) noexcept
|
||||
{
|
||||
|
|
|
|||
|
|
@ -491,6 +491,12 @@ namespace _internals {
|
|||
{
|
||||
*output++ += (*gain++) * (*input++);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline void snippetMultiplyAdd(const T gain, const T*& input, T*& output)
|
||||
{
|
||||
*output++ += gain * (*input++);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -520,6 +526,20 @@ void multiplyAdd(absl::Span<const T> gain, absl::Span<const T> input, absl::Span
|
|||
template <>
|
||||
void multiplyAdd<float, true>(absl::Span<const float> gain, absl::Span<const float> input, absl::Span<float> output) noexcept;
|
||||
|
||||
template <class T, bool SIMD = SIMDConfig::multiplyAdd>
|
||||
void multiplyAdd(const T gain, absl::Span<const T> input, absl::Span<T> output) noexcept
|
||||
{
|
||||
ASSERT(input.size() <= output.size());
|
||||
auto* in = input.begin();
|
||||
auto* out = output.begin();
|
||||
auto* sentinel = out + std::min(output.size(), input.size());
|
||||
while (out < sentinel)
|
||||
_internals::snippetMultiplyAdd<T>(gain, in, out);
|
||||
}
|
||||
|
||||
template <>
|
||||
void multiplyAdd<float, true>(const float gain, absl::Span<const float> input, absl::Span<float> output) noexcept;
|
||||
|
||||
namespace _internals {
|
||||
template <class T>
|
||||
inline void snippetRampLinear(T*& output, T& value, T step)
|
||||
|
|
|
|||
|
|
@ -316,6 +316,29 @@ void sfz::multiplyAdd<float, true>(absl::Span<const float> gain, absl::Span<cons
|
|||
_internals::snippetMultiplyAdd<float>(g, in, out);
|
||||
}
|
||||
|
||||
template <>
|
||||
void sfz::multiplyAdd<float, true>(const float gain, absl::Span<const float> input, absl::Span<float> output) noexcept
|
||||
{
|
||||
auto* in = input.begin();
|
||||
auto* out = output.begin();
|
||||
const auto size = std::min(output.size(), input.size());
|
||||
const auto* lastAligned = prevAligned(output.begin() + size);
|
||||
|
||||
while (unaligned(out, in) && out < lastAligned)
|
||||
_internals::snippetMultiplyAdd<float>(gain, in, out);
|
||||
|
||||
auto mmGain = _mm_set1_ps(gain);
|
||||
while (out < lastAligned) {
|
||||
auto mmOut = _mm_load_ps(out);
|
||||
mmOut = _mm_add_ps(_mm_mul_ps(mmGain, _mm_load_ps(in)), mmOut);
|
||||
_mm_store_ps(out, mmOut);
|
||||
incrementAll<TypeAlignment>(in, out);
|
||||
}
|
||||
|
||||
while (out < output.end())
|
||||
_internals::snippetMultiplyAdd<float>(gain, in, out);
|
||||
}
|
||||
|
||||
template <>
|
||||
float sfz::loopingSFZIndex<float, true>(absl::Span<const float> jumps,
|
||||
absl::Span<float> leftCoeffs,
|
||||
|
|
|
|||
|
|
@ -16,9 +16,50 @@ namespace sfz
|
|||
{
|
||||
|
||||
using SfzCCArray = std::array<uint8_t, config::numCCs>;
|
||||
using CCValuePair = std::pair<uint8_t, float> ;
|
||||
using CCNamePair = std::pair<uint8_t, std::string>;
|
||||
|
||||
template<class ValueType>
|
||||
struct CCValuePair {
|
||||
int cc;
|
||||
ValueType value;
|
||||
};
|
||||
|
||||
template<class ValueType, bool CompareValue = false>
|
||||
struct CCValuePairComparator {
|
||||
bool operator()(const CCValuePair<ValueType>& valuePair, const int& cc)
|
||||
{
|
||||
return (valuePair.cc < cc);
|
||||
}
|
||||
|
||||
bool operator()(const int& cc, const CCValuePair<ValueType>& valuePair)
|
||||
{
|
||||
return (cc < valuePair.cc);
|
||||
}
|
||||
|
||||
bool operator()(const CCValuePair<ValueType>& lhs, const CCValuePair<ValueType>& rhs)
|
||||
{
|
||||
return (lhs.cc < rhs.cc);
|
||||
}
|
||||
};
|
||||
|
||||
template<class ValueType>
|
||||
struct CCValuePairComparator<ValueType, true> {
|
||||
bool operator()(const CCValuePair<ValueType>& valuePair, const ValueType& value)
|
||||
{
|
||||
return (valuePair.value < value);
|
||||
}
|
||||
|
||||
bool operator()(const ValueType& value, const CCValuePair<ValueType>& valuePair)
|
||||
{
|
||||
return (value < valuePair.value);
|
||||
}
|
||||
|
||||
bool operator()(const CCValuePair<ValueType>& lhs, const CCValuePair<ValueType>& rhs)
|
||||
{
|
||||
return (lhs.value < rhs.value);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Converts cents to a pitch ratio
|
||||
*
|
||||
|
|
@ -94,10 +135,10 @@ constexpr float normalizeBend(float bendValue)
|
|||
* @param value
|
||||
* @return float
|
||||
*/
|
||||
inline float ccSwitchedValue(const SfzCCArray& ccValues, const absl::optional<CCValuePair>& ccSwitch, float value) noexcept
|
||||
inline float ccSwitchedValue(const SfzCCArray& ccValues, const absl::optional<CCValuePair<float>>& ccSwitch, float value) noexcept
|
||||
{
|
||||
if (ccSwitch)
|
||||
return value + ccSwitch->second * normalizeCC(ccValues[ccSwitch->first]);
|
||||
return value + ccSwitch->value * normalizeCC(ccValues[ccSwitch->cc]);
|
||||
else
|
||||
return value;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,3 +66,24 @@ constexpr uint64_t hash(absl::string_view s, uint64_t h = Fnv1aBasis)
|
|||
|
||||
return h;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Same function as `hash()` but ignores ampersands (&)
|
||||
*
|
||||
* See e.g. the Region.cpp file
|
||||
*
|
||||
* @param s the input string to be hashed
|
||||
* @param h the hashing seed to use
|
||||
* @return uint64_t
|
||||
*/
|
||||
constexpr uint64_t hashNoAmpersand(absl::string_view s, uint64_t h = Fnv1aBasis)
|
||||
{
|
||||
if (s.length() > 0) {
|
||||
if (s.front() == '&')
|
||||
return hashNoAmpersand( { s.data() + 1, s.length() - 1 }, h );
|
||||
else
|
||||
return hashNoAmpersand( { s.data() + 1, s.length() - 1 }, (h ^ s.front()) * Fnv1aPrime );
|
||||
}
|
||||
|
||||
return h;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,12 +21,16 @@
|
|||
using namespace std::literals;
|
||||
|
||||
sfz::Synth::Synth()
|
||||
: Synth(config::numVoices)
|
||||
{
|
||||
resetVoices(this->numVoices);
|
||||
}
|
||||
|
||||
sfz::Synth::Synth(int numVoices)
|
||||
{
|
||||
effectFactory.registerStandardEffectTypes();
|
||||
|
||||
effectBuses.reserve(5); // sufficient room for main and fx1-4
|
||||
|
||||
resetVoices(numVoices);
|
||||
}
|
||||
|
||||
|
|
@ -70,7 +74,7 @@ void sfz::Synth::callback(absl::string_view header, const std::vector<Opcode>& m
|
|||
numCurves++;
|
||||
break;
|
||||
case hash("effect"):
|
||||
// TODO: implement effects
|
||||
handleEffectOpcodes(members);
|
||||
break;
|
||||
default:
|
||||
std::cerr << "Unknown header: " << header << '\n';
|
||||
|
|
@ -118,6 +122,11 @@ void sfz::Synth::clear()
|
|||
for (auto& list: ccActivationLists)
|
||||
list.clear();
|
||||
regions.clear();
|
||||
effectBuses.clear();
|
||||
effectBuses.emplace_back(new EffectBus);
|
||||
effectBuses[0]->setGainToMain(1.0);
|
||||
effectBuses[0]->setSamplesPerBlock(samplesPerBlock);
|
||||
effectBuses[0]->setSampleRate(sampleRate);
|
||||
resources.filePool.clear();
|
||||
resources.logger.clear();
|
||||
numGroups = 0;
|
||||
|
|
@ -126,7 +135,7 @@ void sfz::Synth::clear()
|
|||
fileTicket = -1;
|
||||
defaultSwitch = absl::nullopt;
|
||||
defaultPath = "";
|
||||
resources.midiState.reset();
|
||||
resources.midiState.reset(0);
|
||||
ccNames.clear();
|
||||
globalOpcodes.clear();
|
||||
masterOpcodes.clear();
|
||||
|
|
@ -153,21 +162,18 @@ void sfz::Synth::handleGlobalOpcodes(const std::vector<Opcode>& members)
|
|||
void sfz::Synth::handleControlOpcodes(const std::vector<Opcode>& members)
|
||||
{
|
||||
for (auto& member : members) {
|
||||
const auto backParameter = member.backParameter();
|
||||
switch (member.lettersOnlyHash) {
|
||||
case hash("Set_cc"):
|
||||
[[fallthrough]];
|
||||
case hash("set_cc"):
|
||||
if (backParameter && Default::ccNumberRange.containsWithEnd(*backParameter)) {
|
||||
case hash("Set_cc&"): [[fallthrough]];
|
||||
case hash("set_cc&"):
|
||||
if (Default::ccNumberRange.containsWithEnd(member.parameters.back())) {
|
||||
const auto ccValue = readOpcode(member.value, Default::ccValueRange).value_or(0);
|
||||
resources.midiState.ccEvent(*backParameter, ccValue);
|
||||
resources.midiState.ccEvent(0, member.parameters.back(), ccValue);
|
||||
}
|
||||
break;
|
||||
case hash("Label_cc"):
|
||||
[[fallthrough]];
|
||||
case hash("label_cc"):
|
||||
if (backParameter && Default::ccNumberRange.containsWithEnd(*backParameter))
|
||||
ccNames.emplace_back(*backParameter, std::string(member.value));
|
||||
case hash("Label_cc&"): [[fallthrough]];
|
||||
case hash("label_cc&"):
|
||||
if (Default::ccNumberRange.containsWithEnd(member.parameters.back()))
|
||||
ccNames.emplace_back(member.parameters.back(), std::string(member.value));
|
||||
break;
|
||||
case hash("Default_path"):
|
||||
[[fallthrough]];
|
||||
|
|
@ -188,6 +194,68 @@ void sfz::Synth::handleControlOpcodes(const std::vector<Opcode>& members)
|
|||
}
|
||||
}
|
||||
|
||||
void sfz::Synth::handleEffectOpcodes(const std::vector<Opcode>& members)
|
||||
{
|
||||
absl::string_view busName = "main";
|
||||
|
||||
auto getOrCreateBus = [this](unsigned index) -> EffectBus& {
|
||||
if (index + 1 > effectBuses.size())
|
||||
effectBuses.resize(index + 1);
|
||||
EffectBusPtr& bus = effectBuses[index];
|
||||
if (!bus) {
|
||||
bus.reset(new EffectBus);
|
||||
bus->setSampleRate(sampleRate);
|
||||
bus->setSamplesPerBlock(samplesPerBlock);
|
||||
}
|
||||
return *bus;
|
||||
};
|
||||
|
||||
for (const Opcode& opcode : members) {
|
||||
switch (opcode.lettersOnlyHash) {
|
||||
case hash("bus"):
|
||||
busName = opcode.value;
|
||||
break;
|
||||
|
||||
// note(jpc): gain opcodes are linear volumes in % units
|
||||
|
||||
case hash("directtomain"):
|
||||
if (auto valueOpt = readOpcode<float>(opcode.value, { 0, 100 }))
|
||||
getOrCreateBus(0).setGainToMain(*valueOpt / 100);
|
||||
break;
|
||||
|
||||
case hash("fx&tomain"): // fx&tomain
|
||||
if (opcode.parameters.front() < 1 || opcode.parameters.front() > config::maxEffectBuses)
|
||||
break;
|
||||
if (auto valueOpt = readOpcode<float>(opcode.value, { 0, 100 }))
|
||||
getOrCreateBus(opcode.parameters.front()).setGainToMain(*valueOpt / 100);
|
||||
break;
|
||||
|
||||
case hash("fx&tomix"): // fx&tomix
|
||||
if (opcode.parameters.front() < 1 || opcode.parameters.front() > config::maxEffectBuses)
|
||||
break;
|
||||
if (auto valueOpt = readOpcode<float>(opcode.value, { 0, 100 }))
|
||||
getOrCreateBus(opcode.parameters.front()).setGainToMix(*valueOpt / 100);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned busIndex;
|
||||
if (busName.empty() || busName == "main")
|
||||
busIndex = 0;
|
||||
else if (busName.size() > 2 && busName.substr(0, 2) == "fx" && absl::SimpleAtoi(busName.substr(2), &busIndex) && busIndex >= 1 && busIndex <= config::maxEffectBuses) {
|
||||
// an effect bus fxN, with N usually in [1,4]
|
||||
} else {
|
||||
DBG("Unsupported effect bus: " << busName);
|
||||
return;
|
||||
}
|
||||
|
||||
// create the effect and add it
|
||||
EffectBus& bus = getOrCreateBus(busIndex);
|
||||
auto fx = effectFactory.makeEffect(members);
|
||||
fx->setSampleRate(sampleRate);
|
||||
bus.addEffect(std::move(fx));
|
||||
}
|
||||
|
||||
void addEndpointsToVelocityCurve(sfz::Region& region)
|
||||
{
|
||||
if (region.velocityPoints.size() > 0) {
|
||||
|
|
@ -388,8 +456,14 @@ void sfz::Synth::setSamplesPerBlock(int samplesPerBlock) noexcept
|
|||
|
||||
this->samplesPerBlock = samplesPerBlock;
|
||||
this->tempBuffer.resize(samplesPerBlock);
|
||||
this->tempMixNodeBuffer.resize(samplesPerBlock);
|
||||
for (auto& voice : voices)
|
||||
voice->setSamplesPerBlock(samplesPerBlock);
|
||||
|
||||
for (auto& bus: effectBuses) {
|
||||
if (bus)
|
||||
bus->setSamplesPerBlock(samplesPerBlock);
|
||||
}
|
||||
}
|
||||
|
||||
void sfz::Synth::setSampleRate(float sampleRate) noexcept
|
||||
|
|
@ -405,13 +479,17 @@ void sfz::Synth::setSampleRate(float sampleRate) noexcept
|
|||
|
||||
resources.filterPool.setSampleRate(sampleRate);
|
||||
resources.eqPool.setSampleRate(sampleRate);
|
||||
|
||||
for (auto& bus: effectBuses) {
|
||||
if (bus)
|
||||
bus->setSampleRate(sampleRate);
|
||||
}
|
||||
}
|
||||
|
||||
void sfz::Synth::renderBlock(AudioSpan<float> buffer) noexcept
|
||||
{
|
||||
ScopedFTZ ftz;
|
||||
|
||||
|
||||
if (freeWheeling)
|
||||
resources.filePool.waitForBackgroundLoading();
|
||||
|
||||
|
|
@ -419,32 +497,77 @@ void sfz::Synth::renderBlock(AudioSpan<float> buffer) noexcept
|
|||
if (!canEnterCallback)
|
||||
return;
|
||||
|
||||
size_t numFrames = buffer.getNumFrames();
|
||||
auto temp = AudioSpan<float>(tempBuffer).first(numFrames);
|
||||
auto tempMixNode = AudioSpan<float>(tempMixNodeBuffer).first(numFrames);
|
||||
|
||||
CallbackBreakdown callbackBreakdown;
|
||||
|
||||
{ // Prepare the effect inputs. They are mixes of per-region outputs.
|
||||
ScopedTiming logger { callbackBreakdown.effects };
|
||||
for (auto& bus: effectBuses) {
|
||||
if (bus)
|
||||
bus->clearInputs(numFrames);
|
||||
}
|
||||
}
|
||||
|
||||
int numActiveVoices { 0 };
|
||||
{ // Main render block
|
||||
ScopedTiming logger { callbackBreakdown.renderMethod };
|
||||
buffer.fill(0.0f);
|
||||
tempMixNode.fill(0.0f);
|
||||
resources.filePool.cleanupPromises();
|
||||
|
||||
|
||||
auto tempSpan = AudioSpan<float>(tempBuffer).first(buffer.getNumFrames());
|
||||
for (auto& voice : voices) {
|
||||
if (!voice->isFree()) {
|
||||
numActiveVoices++;
|
||||
voice->renderBlock(tempSpan);
|
||||
buffer.add(tempSpan);
|
||||
callbackBreakdown.data += voice->getLastDataDuration();
|
||||
callbackBreakdown.amplitude += voice->getLastAmplitudeDuration();
|
||||
callbackBreakdown.filters += voice->getLastFilterDuration();
|
||||
callbackBreakdown.panning += voice->getLastPanningDuration();
|
||||
}
|
||||
}
|
||||
if (voice->isFree())
|
||||
continue;
|
||||
|
||||
buffer.applyGain(db2mag(volume));
|
||||
const Region* region = voice->getRegion();
|
||||
|
||||
numActiveVoices++;
|
||||
voice->renderBlock(temp);
|
||||
|
||||
{ // Add the output into the effects linked to this region
|
||||
ScopedTiming logger { callbackBreakdown.effects, ScopedTiming::Operation::addToDuration };
|
||||
for (size_t i = 0, n = effectBuses.size(); i < n; ++i) {
|
||||
if (auto& bus = effectBuses[i]) {
|
||||
float addGain = region->getGainToEffectBus(i);
|
||||
bus->addToInputs(temp, addGain, numFrames);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
callbackBreakdown.data += voice->getLastDataDuration();
|
||||
callbackBreakdown.amplitude += voice->getLastAmplitudeDuration();
|
||||
callbackBreakdown.filters += voice->getLastFilterDuration();
|
||||
callbackBreakdown.panning += voice->getLastPanningDuration();
|
||||
}
|
||||
}
|
||||
|
||||
{ // Apply effect buses
|
||||
// -- note(jpc) there is always a "main" bus which is initially empty.
|
||||
// without any <effect>, the signal is just going to flow through it.
|
||||
ScopedTiming logger { callbackBreakdown.effects, ScopedTiming::Operation::addToDuration };
|
||||
|
||||
for (auto& bus: effectBuses) {
|
||||
if (bus) {
|
||||
bus->process(numFrames);
|
||||
bus->mixOutputsTo(buffer, tempMixNode, numFrames);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add the Mix output (fxNtomix opcodes)
|
||||
// -- note(jpc) the purpose of the Mix output is not known.
|
||||
// perhaps it's designed as extension point for custom processing?
|
||||
// as default behavior, it adds itself to the Main signal.
|
||||
buffer.add(tempMixNode);
|
||||
|
||||
// Apply the master volume
|
||||
buffer.applyGain(db2mag(volume));
|
||||
|
||||
callbackBreakdown.dispatch = dispatchDuration;
|
||||
resources.logger.logCallbackTime(std::move(callbackBreakdown), numActiveVoices, buffer.getNumFrames());
|
||||
resources.logger.logCallbackTime(std::move(callbackBreakdown), numActiveVoices, numFrames);
|
||||
|
||||
// Reset the dispatch counter
|
||||
dispatchDuration = Duration(0);
|
||||
|
|
@ -456,7 +579,7 @@ void sfz::Synth::noteOn(int delay, int noteNumber, uint8_t velocity) noexcept
|
|||
ASSERT(noteNumber >= 0);
|
||||
|
||||
ScopedTiming logger { dispatchDuration, ScopedTiming::Operation::addToDuration };
|
||||
resources.midiState.noteOnEvent(noteNumber, velocity);
|
||||
resources.midiState.noteOnEvent(delay, noteNumber, velocity);
|
||||
|
||||
AtomicGuard callbackGuard { inCallback };
|
||||
if (!canEnterCallback)
|
||||
|
|
@ -471,7 +594,7 @@ void sfz::Synth::noteOff(int delay, int noteNumber, uint8_t velocity [[maybe_unu
|
|||
ASSERT(noteNumber >= 0);
|
||||
|
||||
ScopedTiming logger { dispatchDuration, ScopedTiming::Operation::addToDuration };
|
||||
resources.midiState.noteOffEvent(noteNumber, velocity);
|
||||
resources.midiState.noteOffEvent(delay, noteNumber, velocity);
|
||||
|
||||
AtomicGuard callbackGuard { inCallback };
|
||||
if (!canEnterCallback)
|
||||
|
|
@ -527,8 +650,7 @@ void sfz::Synth::cc(int delay, int ccNumber, uint8_t ccValue) noexcept
|
|||
ASSERT(ccNumber >= 0);
|
||||
|
||||
ScopedTiming logger { dispatchDuration, ScopedTiming::Operation::addToDuration };
|
||||
|
||||
resources.midiState.ccEvent(ccNumber, ccValue);
|
||||
resources.midiState.ccEvent(delay, ccNumber, ccValue);
|
||||
|
||||
AtomicGuard callbackGuard { inCallback };
|
||||
if (!canEnterCallback)
|
||||
|
|
@ -559,8 +681,7 @@ void sfz::Synth::pitchWheel(int delay, int pitch) noexcept
|
|||
ASSERT(pitch >= -8192);
|
||||
|
||||
ScopedTiming logger { dispatchDuration, ScopedTiming::Operation::addToDuration };
|
||||
|
||||
resources.midiState.pitchBendEvent(pitch);
|
||||
resources.midiState.pitchBendEvent(delay, pitch);
|
||||
|
||||
for (auto& region: regions) {
|
||||
region->registerPitchWheel(pitch);
|
||||
|
|
@ -686,6 +807,11 @@ const sfz::Region* sfz::Synth::getRegionView(int idx) const noexcept
|
|||
return (size_t)idx < regions.size() ? regions[idx].get() : nullptr;
|
||||
}
|
||||
|
||||
const sfz::EffectBus* sfz::Synth::getEffectBusView(int idx) const noexcept
|
||||
{
|
||||
return (size_t)idx < effectBuses.size() ? effectBuses[idx].get() : nullptr;
|
||||
}
|
||||
|
||||
const sfz::Voice* sfz::Synth::getVoiceView(int idx) const noexcept
|
||||
{
|
||||
return (size_t)idx < voices.size() ? voices[idx].get() : nullptr;
|
||||
|
|
@ -796,7 +922,7 @@ void sfz::Synth::resetAllControllers(int delay) noexcept
|
|||
if (!canEnterCallback)
|
||||
return;
|
||||
|
||||
resources.midiState.resetAllControllers();
|
||||
resources.midiState.resetAllControllers(delay);
|
||||
for (auto& voice: voices) {
|
||||
voice->registerPitchWheel(delay, 0);
|
||||
for (int cc = 0; cc < config::numCCs; ++cc)
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
#include "Parser.h"
|
||||
#include "Voice.h"
|
||||
#include "Region.h"
|
||||
#include "Effects.h"
|
||||
#include "LeakDetector.h"
|
||||
#include "MidiState.h"
|
||||
#include "AudioSpan.h"
|
||||
|
|
@ -131,6 +132,14 @@ public:
|
|||
* @return const Region*
|
||||
*/
|
||||
const Voice* getVoiceView(int idx) const noexcept;
|
||||
/**
|
||||
* @brief Get a raw view into a specific voice. This is mostly used
|
||||
* for testing.
|
||||
*
|
||||
* @param idx
|
||||
* @return const Region*
|
||||
*/
|
||||
const EffectBus* getEffectBusView(int idx) const noexcept;
|
||||
/**
|
||||
* @brief Get a list of unknown opcodes. The lifetime of the
|
||||
* string views in the code are linked to the currently loaded
|
||||
|
|
@ -400,6 +409,12 @@ private:
|
|||
* @param members the opcodes of the <control> block
|
||||
*/
|
||||
void handleControlOpcodes(const std::vector<Opcode>& members);
|
||||
/**
|
||||
* @brief Helper function to dispatch <effect> opcodes
|
||||
*
|
||||
* @param members the opcodes of the <effect> block
|
||||
*/
|
||||
void handleEffectOpcodes(const std::vector<Opcode>& members);
|
||||
/**
|
||||
* @brief Helper function to merge all the currently active opcodes
|
||||
* as set by the successive callbacks and create a new region to store
|
||||
|
|
@ -441,8 +456,14 @@ private:
|
|||
std::array<RegionPtrVector, 128> noteActivationLists;
|
||||
std::array<RegionPtrVector, config::numCCs> ccActivationLists;
|
||||
|
||||
// Internal temporary buffer
|
||||
// Effect factory and buses
|
||||
EffectFactory effectFactory;
|
||||
typedef std::unique_ptr<EffectBus> EffectBusPtr;
|
||||
std::vector<EffectBusPtr> effectBuses; // 0 is "main", 1-N are "fx1"-"fxN"
|
||||
|
||||
// Intermediate buffers
|
||||
AudioBuffer<float> tempBuffer { 2, config::defaultSamplesPerBlock };
|
||||
AudioBuffer<float> tempMixNodeBuffer { 2, config::defaultSamplesPerBlock };
|
||||
|
||||
int samplesPerBlock { config::defaultSamplesPerBlock };
|
||||
float sampleRate { config::defaultSampleRate };
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ void sfz::Voice::startVoice(Region* region, int delay, int number, uint8_t value
|
|||
baseVolumedB = region->getBaseVolumedB(number);
|
||||
auto volumedB { baseVolumedB };
|
||||
if (region->volumeCC)
|
||||
volumedB += normalizeCC(resources.midiState.getCCValue(region->volumeCC->first)) * region->volumeCC->second;
|
||||
volumedB += normalizeCC(resources.midiState.getCCValue(region->volumeCC->cc)) * region->volumeCC->value;
|
||||
volumeEnvelope.reset(db2mag(Default::volumeRange.clamp(volumedB)));
|
||||
|
||||
baseGain = region->getBaseGain();
|
||||
|
|
@ -56,7 +56,7 @@ void sfz::Voice::startVoice(Region* region, int delay, int number, uint8_t value
|
|||
|
||||
float gain { baseGain };
|
||||
if (region->amplitudeCC)
|
||||
gain += normalizeCC(resources.midiState.getCCValue(region->amplitudeCC->first)) * normalizePercents(region->amplitudeCC->second);
|
||||
gain += normalizeCC(resources.midiState.getCCValue(region->amplitudeCC->cc)) * normalizePercents(region->amplitudeCC->value);
|
||||
amplitudeEnvelope.reset(Default::normalizedRange.clamp(gain));
|
||||
|
||||
float crossfadeGain { region->getCrossfadeGain(resources.midiState.getCCArray()) };
|
||||
|
|
@ -65,19 +65,19 @@ void sfz::Voice::startVoice(Region* region, int delay, int number, uint8_t value
|
|||
basePan = normalizePercents(region->pan);
|
||||
auto pan { basePan };
|
||||
if (region->panCC)
|
||||
pan += normalizeCC(resources.midiState.getCCValue(region->panCC->first)) * normalizePercents(region->panCC->second);
|
||||
pan += normalizeCC(resources.midiState.getCCValue(region->panCC->cc)) * normalizePercents(region->panCC->value);
|
||||
panEnvelope.reset(Default::symmetricNormalizedRange.clamp(pan));
|
||||
|
||||
basePosition = normalizePercents(region->position);
|
||||
auto position { basePosition };
|
||||
if (region->positionCC)
|
||||
position += normalizeCC(resources.midiState.getCCValue(region->positionCC->first)) * normalizePercents(region->positionCC->second);
|
||||
position += normalizeCC(resources.midiState.getCCValue(region->positionCC->cc)) * normalizePercents(region->positionCC->value);
|
||||
positionEnvelope.reset(Default::symmetricNormalizedRange.clamp(position));
|
||||
|
||||
baseWidth = normalizePercents(region->width);
|
||||
auto width { baseWidth };
|
||||
if (region->widthCC)
|
||||
width += normalizeCC(resources.midiState.getCCValue(region->widthCC->first)) * normalizePercents(region->widthCC->second);
|
||||
width += normalizeCC(resources.midiState.getCCValue(region->widthCC->cc)) * normalizePercents(region->widthCC->value);
|
||||
widthEnvelope.reset(Default::symmetricNormalizedRange.clamp(width));
|
||||
|
||||
pitchBendEnvelope.setFunction([region](float pitchValue){
|
||||
|
|
@ -168,28 +168,28 @@ void sfz::Voice::registerCC(int delay, int ccNumber, uint8_t ccValue) noexcept
|
|||
// TODO: this feels like a hack, revisit this along with the smoothed envelopes...
|
||||
delay = max(delay, minEnvelopeDelay);
|
||||
|
||||
if (region->amplitudeCC && ccNumber == region->amplitudeCC->first) {
|
||||
const float newGain { baseGain + normalizeCC(ccValue) * normalizePercents(region->amplitudeCC->second) };
|
||||
if (region->amplitudeCC && ccNumber == region->amplitudeCC->cc) {
|
||||
const float newGain { baseGain + normalizeCC(ccValue) * normalizePercents(region->amplitudeCC->value) };
|
||||
amplitudeEnvelope.registerEvent(delay, Default::normalizedRange.clamp(newGain));
|
||||
}
|
||||
|
||||
if (region->volumeCC && ccNumber == region->volumeCC->first) {
|
||||
const float newVolumedB { baseVolumedB + normalizeCC(ccValue) * region->volumeCC->second };
|
||||
if (region->volumeCC && ccNumber == region->volumeCC->cc) {
|
||||
const float newVolumedB { baseVolumedB + normalizeCC(ccValue) * region->volumeCC->value };
|
||||
volumeEnvelope.registerEvent(delay, db2mag(Default::volumeRange.clamp(newVolumedB)));
|
||||
}
|
||||
|
||||
if (region->panCC && ccNumber == region->panCC->first) {
|
||||
const float newPan { basePan + normalizeCC(ccValue) * normalizePercents(region->panCC->second) };
|
||||
if (region->panCC && ccNumber == region->panCC->cc) {
|
||||
const float newPan { basePan + normalizeCC(ccValue) * normalizePercents(region->panCC->value) };
|
||||
panEnvelope.registerEvent(delay, Default::symmetricNormalizedRange.clamp(newPan));
|
||||
}
|
||||
|
||||
if (region->positionCC && ccNumber == region->positionCC->first) {
|
||||
const float newPosition { basePosition + normalizeCC(ccValue) * normalizePercents(region->positionCC->second) };
|
||||
if (region->positionCC && ccNumber == region->positionCC->cc) {
|
||||
const float newPosition { basePosition + normalizeCC(ccValue) * normalizePercents(region->positionCC->value) };
|
||||
positionEnvelope.registerEvent(delay, Default::symmetricNormalizedRange.clamp(newPosition));
|
||||
}
|
||||
|
||||
if (region->widthCC && ccNumber == region->widthCC->first) {
|
||||
const float newWidth { baseWidth + normalizeCC(ccValue) * normalizePercents(region->widthCC->second) };
|
||||
if (region->widthCC && ccNumber == region->widthCC->cc) {
|
||||
const float newWidth { baseWidth + normalizeCC(ccValue) * normalizePercents(region->widthCC->value) };
|
||||
widthEnvelope.registerEvent(delay, Default::symmetricNormalizedRange.clamp(newWidth));
|
||||
}
|
||||
|
||||
|
|
|
|||
212
src/sfizz/effects/Lofi.cpp
Normal file
212
src/sfizz/effects/Lofi.cpp
Normal file
|
|
@ -0,0 +1,212 @@
|
|||
// SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
// This code is part of the sfizz library and is licensed under a BSD 2-clause
|
||||
// license. You should have receive a LICENSE.md file along with the code.
|
||||
// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz
|
||||
|
||||
/**
|
||||
Note(jpc): implementation status
|
||||
|
||||
- [x] bitred
|
||||
- [ ] bitred_oncc
|
||||
- [ ] bitred_smoothcc
|
||||
- [ ] bitred_stepcc
|
||||
- [ ] bitred_curvecc
|
||||
|
||||
- [x] decim
|
||||
- [ ] decim_oncc
|
||||
- [ ] decim_smoothcc
|
||||
- [ ] decim_stepcc
|
||||
- [ ] decim_curvecc
|
||||
|
||||
- [ ] egN_bitred
|
||||
- [ ] egN_bitred_oncc
|
||||
- [ ] lfoN_bitred
|
||||
- [ ] lfoN_bitred_oncc
|
||||
- [ ] lfoN_bitred_smoothcc
|
||||
- [ ] lfoN_bitred_stepcc
|
||||
|
||||
- [ ] egN_decim
|
||||
- [ ] egN_decim_oncc
|
||||
- [ ] lfoN_decim
|
||||
- [ ] lfoN_decim_oncc
|
||||
- [ ] lfoN_decim_smoothcc
|
||||
- [ ] lfoN_decim_stepcc
|
||||
|
||||
*/
|
||||
|
||||
#include "Lofi.h"
|
||||
#include "Opcode.h"
|
||||
#include <memory>
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
#include <cmath>
|
||||
|
||||
namespace sfz {
|
||||
namespace fx {
|
||||
|
||||
void Lofi::setSampleRate(double sampleRate)
|
||||
{
|
||||
for (unsigned c = 0; c < EffectChannels; ++c) {
|
||||
_bitred[c].init(sampleRate);
|
||||
_decim[c].init(sampleRate);
|
||||
}
|
||||
}
|
||||
|
||||
void Lofi::setSamplesPerBlock(int samplesPerBlock)
|
||||
{
|
||||
(void)samplesPerBlock;
|
||||
}
|
||||
|
||||
void Lofi::clear()
|
||||
{
|
||||
for (unsigned c = 0; c < EffectChannels; ++c) {
|
||||
_bitred[c].clear();
|
||||
_decim[c].clear();
|
||||
}
|
||||
}
|
||||
|
||||
void Lofi::process(const float* const inputs[2], float* const outputs[2], unsigned nframes)
|
||||
{
|
||||
for (unsigned c = 0; c < EffectChannels; ++c) {
|
||||
_bitred[c].setDepth(_bitred_depth);
|
||||
_bitred[c].process(inputs[c], outputs[c], nframes);
|
||||
|
||||
_decim[c].setDepth(_decim_depth);
|
||||
_decim[c].process(outputs[c], outputs[c], nframes);
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<Effect> Lofi::makeInstance(absl::Span<const Opcode> members)
|
||||
{
|
||||
auto fx = std::make_unique<Lofi>();
|
||||
|
||||
for (const Opcode& opcode : members) {
|
||||
switch (opcode.lettersOnlyHash) {
|
||||
case hash("bitred"):
|
||||
setValueFromOpcode(opcode, fx->_bitred_depth, { 0.0, 100.0 });
|
||||
break;
|
||||
case hash("decim"):
|
||||
setValueFromOpcode(opcode, fx->_decim_depth, { 0.0, 100.0 });
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return fx;
|
||||
}
|
||||
|
||||
///
|
||||
void Lofi::Bitred::init(double sampleRate)
|
||||
{
|
||||
(void)sampleRate;
|
||||
|
||||
static constexpr double coefs2x[12] = { 0.036681502163648017, 0.13654762463195794, 0.27463175937945444, 0.42313861743656711, 0.56109869787919531, 0.67754004997416184, 0.76974183386322703, 0.83988962484963892, 0.89226081800387902, 0.9315419599631839, 0.96209454837808417, 0.98781637073289585 };
|
||||
fDownsampler2x.set_coefs(coefs2x);
|
||||
}
|
||||
|
||||
void Lofi::Bitred::clear()
|
||||
{
|
||||
fLastValue = 0.0;
|
||||
fDownsampler2x.clear_buffers();
|
||||
}
|
||||
|
||||
void Lofi::Bitred::setDepth(float depth)
|
||||
{
|
||||
fDepth = clamp(depth, 0.0f, 100.0f);
|
||||
}
|
||||
|
||||
void Lofi::Bitred::process(const float* in, float* out, uint32_t nframes)
|
||||
{
|
||||
if (fDepth == 0) {
|
||||
if (in != out)
|
||||
std::memcpy(out, in, nframes * sizeof(float));
|
||||
clear();
|
||||
return;
|
||||
}
|
||||
|
||||
float lastValue = fLastValue;
|
||||
|
||||
const float steps = (1.0f + (100.0f - fDepth)) * 0.75f;
|
||||
const float invSteps = 1.0f / steps;
|
||||
|
||||
for (uint32_t i = 0; i < nframes; ++i) {
|
||||
float x = in[i];
|
||||
|
||||
float y = std::copysign((int)(0.5f + std::fabs(x * steps)), x) * invSteps;
|
||||
|
||||
float y2x[2];
|
||||
y2x[0] = (y != lastValue) ? (0.5f * (y + lastValue)) : y;
|
||||
y2x[1] = y;
|
||||
|
||||
lastValue = y;
|
||||
|
||||
y = fDownsampler2x.process_sample(y2x);
|
||||
out[i] = y;
|
||||
}
|
||||
|
||||
fLastValue = lastValue;
|
||||
}
|
||||
|
||||
///
|
||||
void Lofi::Decim::init(double sampleRate)
|
||||
{
|
||||
fSampleTime = 1.0 / sampleRate;
|
||||
|
||||
static constexpr double coefs2x[12] = { 0.036681502163648017, 0.13654762463195794, 0.27463175937945444, 0.42313861743656711, 0.56109869787919531, 0.67754004997416184, 0.76974183386322703, 0.83988962484963892, 0.89226081800387902, 0.9315419599631839, 0.96209454837808417, 0.98781637073289585 };
|
||||
fDownsampler2x.set_coefs(coefs2x);
|
||||
}
|
||||
|
||||
void Lofi::Decim::clear()
|
||||
{
|
||||
fPhase = 0.0;
|
||||
fLastValue = 0.0;
|
||||
fDownsampler2x.clear_buffers();
|
||||
}
|
||||
|
||||
void Lofi::Decim::setDepth(float depth)
|
||||
{
|
||||
fDepth = clamp(depth, 0.0f, 100.0f);
|
||||
}
|
||||
|
||||
void Lofi::Decim::process(const float* in, float* out, uint32_t nframes)
|
||||
{
|
||||
if (fDepth == 0) {
|
||||
if (in != out)
|
||||
std::memcpy(out, in, nframes * sizeof(float));
|
||||
clear();
|
||||
return;
|
||||
}
|
||||
|
||||
const float dt = [this]() {
|
||||
// exponential curve fit
|
||||
const float a = 1.289079e+00, b = 1.384141e-01, c = 1.313298e-04;
|
||||
const float denom = std::pow(a, b * fDepth) * c - c;
|
||||
return fSampleTime / denom;
|
||||
}();
|
||||
|
||||
float phase = fPhase;
|
||||
float lastValue = fLastValue;
|
||||
|
||||
for (uint32_t i = 0; i < nframes; ++i) {
|
||||
float x = in[i];
|
||||
|
||||
phase += dt;
|
||||
float y = (phase > 1.0f) ? x : lastValue;
|
||||
phase -= static_cast<int>(phase);
|
||||
|
||||
float y2x[2];
|
||||
y2x[0] = (y != lastValue) ? (0.5f * (y + lastValue)) : y;
|
||||
y2x[1] = y;
|
||||
|
||||
lastValue = y;
|
||||
|
||||
y = fDownsampler2x.process_sample(y2x);
|
||||
out[i] = y;
|
||||
}
|
||||
|
||||
fPhase = phase;
|
||||
fLastValue = lastValue;
|
||||
}
|
||||
|
||||
} // namespace fx
|
||||
} // namespace sfz
|
||||
85
src/sfizz/effects/Lofi.h
Normal file
85
src/sfizz/effects/Lofi.h
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
// SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
// This code is part of the sfizz library and is licensed under a BSD 2-clause
|
||||
// license. You should have receive a LICENSE.md file along with the code.
|
||||
// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz
|
||||
|
||||
#pragma once
|
||||
#include "Effects.h"
|
||||
#include "hiir/Downsampler2xFpu.h"
|
||||
|
||||
namespace sfz {
|
||||
namespace fx {
|
||||
|
||||
/**
|
||||
* @brief Bit crushing effect
|
||||
*/
|
||||
class Lofi : public Effect {
|
||||
public:
|
||||
/**
|
||||
* @brief Initializes with the given sample rate.
|
||||
*/
|
||||
void setSampleRate(double sampleRate) override;
|
||||
|
||||
/**
|
||||
* @brief Sets the maximum number of frames to render at a time. The actual
|
||||
* value can be lower but should never be higher.
|
||||
*/
|
||||
void setSamplesPerBlock(int samplesPerBlock) override;
|
||||
|
||||
/**
|
||||
* @brief Reset the state to initial.
|
||||
*/
|
||||
void clear() override;
|
||||
|
||||
/**
|
||||
* @brief Computes a cycle of the effect in stereo.
|
||||
*/
|
||||
void process(const float* const inputs[], float* const outputs[], unsigned nframes) override;
|
||||
|
||||
/**
|
||||
* @brief Instantiates given the contents of the <effect> block.
|
||||
*/
|
||||
static std::unique_ptr<Effect> makeInstance(absl::Span<const Opcode> members);
|
||||
|
||||
private:
|
||||
float _bitred_depth = 0;
|
||||
float _decim_depth = 0;
|
||||
|
||||
///
|
||||
class Bitred {
|
||||
public:
|
||||
void init(double sampleRate);
|
||||
void clear();
|
||||
void setDepth(float depth);
|
||||
void process(const float* in, float* out, uint32_t nframes);
|
||||
|
||||
private:
|
||||
float fDepth = 0.0;
|
||||
float fLastValue = 0.0;
|
||||
hiir::Downsampler2xFpu<12> fDownsampler2x;
|
||||
};
|
||||
|
||||
///
|
||||
class Decim {
|
||||
public:
|
||||
void init(double sampleRate);
|
||||
void clear();
|
||||
void setDepth(float depth);
|
||||
void process(const float* in, float* out, uint32_t nframes);
|
||||
|
||||
private:
|
||||
float fSampleTime = 0.0;
|
||||
float fDepth = 0.0;
|
||||
float fPhase = 0.0;
|
||||
float fLastValue = 0.0;
|
||||
hiir::Downsampler2xFpu<12> fDownsampler2x;
|
||||
};
|
||||
|
||||
///
|
||||
Bitred _bitred[EffectChannels];
|
||||
Decim _decim[EffectChannels];
|
||||
};
|
||||
|
||||
} // namespace fx
|
||||
} // namespace sfz
|
||||
36
src/sfizz/effects/Nothing.cpp
Normal file
36
src/sfizz/effects/Nothing.cpp
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
// SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
// This code is part of the sfizz library and is licensed under a BSD 2-clause
|
||||
// license. You should have receive a LICENSE.md file along with the code.
|
||||
// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz
|
||||
|
||||
#include "Nothing.h"
|
||||
#include <cstring>
|
||||
|
||||
namespace sfz {
|
||||
namespace fx {
|
||||
|
||||
void Nothing::setSampleRate(double sampleRate)
|
||||
{
|
||||
(void)sampleRate;
|
||||
}
|
||||
|
||||
void Nothing::setSamplesPerBlock(int samplesPerBlock)
|
||||
{
|
||||
(void)samplesPerBlock;
|
||||
}
|
||||
|
||||
void Nothing::clear()
|
||||
{
|
||||
}
|
||||
|
||||
void Nothing::process(const float* const inputs[], float* const outputs[], unsigned nframes)
|
||||
{
|
||||
for (unsigned c = 0; c < EffectChannels; ++c) {
|
||||
if (inputs[c] != outputs[c])
|
||||
std::memcpy(outputs[c], inputs[c], nframes * sizeof(float));
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace fx
|
||||
} // namespace sfz
|
||||
41
src/sfizz/effects/Nothing.h
Normal file
41
src/sfizz/effects/Nothing.h
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
// SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
// This code is part of the sfizz library and is licensed under a BSD 2-clause
|
||||
// license. You should have receive a LICENSE.md file along with the code.
|
||||
// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz
|
||||
|
||||
#pragma once
|
||||
#include "Effects.h"
|
||||
|
||||
namespace sfz {
|
||||
namespace fx {
|
||||
|
||||
/**
|
||||
* @brief Effect which does nothing
|
||||
*/
|
||||
class Nothing : public Effect {
|
||||
public:
|
||||
/**
|
||||
* @brief Initializes with the given sample rate.
|
||||
*/
|
||||
void setSampleRate(double sampleRate) override;
|
||||
|
||||
/**
|
||||
* @brief Sets the maximum number of frames to render at a time. The actual
|
||||
* value can be lower but should never be higher.
|
||||
*/
|
||||
void setSamplesPerBlock(int samplesPerBlock) override;
|
||||
|
||||
/**
|
||||
* @brief Reset the state to initial.
|
||||
*/
|
||||
void clear() override;
|
||||
|
||||
/**
|
||||
* @brief Copy the input signal to the output
|
||||
*/
|
||||
void process(const float* const inputs[], float* const outputs[], unsigned nframes) override;
|
||||
};
|
||||
|
||||
} // namespace fx
|
||||
} // namespace sfz
|
||||
|
|
@ -306,8 +306,8 @@ TEST_CASE("[Files] wrong (overlapping) replacement for defines")
|
|||
REQUIRE( synth.getRegionView(1)->keyRange.getStart() == 57 );
|
||||
REQUIRE( synth.getRegionView(1)->keyRange.getEnd() == 57 );
|
||||
REQUIRE( synth.getRegionView(2)->amplitudeCC );
|
||||
REQUIRE( synth.getRegionView(2)->amplitudeCC->first == 10 );
|
||||
REQUIRE( synth.getRegionView(2)->amplitudeCC->second == 34.0f );
|
||||
REQUIRE( synth.getRegionView(2)->amplitudeCC->cc == 10 );
|
||||
REQUIRE( synth.getRegionView(2)->amplitudeCC->value == 34.0f );
|
||||
}
|
||||
|
||||
TEST_CASE("[Files] Specific bug: relative path with backslashes")
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@ TEST_CASE("[MidiState] Set and get CCs")
|
|||
{
|
||||
sfz::MidiState state;
|
||||
const auto& cc = state.getCCArray();
|
||||
state.ccEvent(24, 23);
|
||||
state.ccEvent(123, 124);
|
||||
state.ccEvent(0, 24, 23);
|
||||
state.ccEvent(0, 123, 124);
|
||||
REQUIRE(state.getCCValue(24) == 23);
|
||||
REQUIRE(cc[24] == 23);
|
||||
REQUIRE(state.getCCValue(123) == 124);
|
||||
|
|
@ -38,19 +38,19 @@ TEST_CASE("[MidiState] Set and get CCs")
|
|||
TEST_CASE("[MidiState] Set and get pitch bends")
|
||||
{
|
||||
sfz::MidiState state;
|
||||
state.pitchBendEvent(894);
|
||||
state.pitchBendEvent(0, 894);
|
||||
REQUIRE(state.getPitchBend() == 894);
|
||||
state.pitchBendEvent(0);
|
||||
state.pitchBendEvent(0, 0);
|
||||
REQUIRE(state.getPitchBend() == 0);
|
||||
}
|
||||
|
||||
TEST_CASE("[MidiState] Reset")
|
||||
{
|
||||
sfz::MidiState state;
|
||||
state.pitchBendEvent(894);
|
||||
state.noteOnEvent(64, 24);
|
||||
state.ccEvent(123, 124);
|
||||
state.reset();
|
||||
state.pitchBendEvent(0, 894);
|
||||
state.noteOnEvent(0, 64, 24);
|
||||
state.ccEvent(0, 123, 124);
|
||||
state.reset(0);
|
||||
REQUIRE(state.getPitchBend() == 0);
|
||||
REQUIRE(state.getNoteVelocity(64) == 0);
|
||||
REQUIRE(state.getCCValue(123) == 0);
|
||||
|
|
@ -59,9 +59,9 @@ TEST_CASE("[MidiState] Reset")
|
|||
TEST_CASE("[MidiState] Set and get note velocities")
|
||||
{
|
||||
sfz::MidiState state;
|
||||
state.noteOnEvent(64, 24);
|
||||
state.noteOnEvent(0, 64, 24);
|
||||
REQUIRE(+state.getNoteVelocity(64) == 24);
|
||||
state.noteOnEvent(64, 123);
|
||||
state.noteOnEvent(0, 64, 123);
|
||||
REQUIRE(+state.getNoteVelocity(64) == 123);
|
||||
}
|
||||
|
||||
|
|
@ -69,5 +69,5 @@ TEST_CASE("[MidiState] Extended CCs")
|
|||
{
|
||||
sfz::MidiState state;
|
||||
REQUIRE(state.getCCArray().size() >= 142);
|
||||
state.ccEvent(142, 64); // should not trap
|
||||
state.ccEvent(0, 142, 64); // should not trap
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,9 +17,6 @@ TEST_CASE("[Opcode] Construction")
|
|||
REQUIRE(opcode.lettersOnlyHash == hash("sample"));
|
||||
REQUIRE(opcode.parameters.empty());
|
||||
REQUIRE(opcode.value == "dummy");
|
||||
REQUIRE(!opcode.backParameter());
|
||||
REQUIRE(!opcode.firstParameter());
|
||||
REQUIRE(!opcode.middleParameter());
|
||||
}
|
||||
|
||||
SECTION("Normal construction with underscore")
|
||||
|
|
@ -29,56 +26,69 @@ TEST_CASE("[Opcode] Construction")
|
|||
REQUIRE(opcode.lettersOnlyHash == hash("sample_underscore"));
|
||||
REQUIRE(opcode.parameters.empty());
|
||||
REQUIRE(opcode.value == "dummy");
|
||||
REQUIRE(!opcode.backParameter());
|
||||
REQUIRE(!opcode.firstParameter());
|
||||
REQUIRE(!opcode.middleParameter());
|
||||
}
|
||||
|
||||
SECTION("Normal construction with ampersand")
|
||||
{
|
||||
sfz::Opcode opcode { "sample&_ampersand", "dummy" };
|
||||
REQUIRE(opcode.opcode == "sample&_ampersand");
|
||||
REQUIRE(opcode.lettersOnlyHash == hash("sample_ampersand"));
|
||||
REQUIRE(opcode.parameters.empty());
|
||||
REQUIRE(opcode.value == "dummy");
|
||||
}
|
||||
|
||||
SECTION("Normal construction with multiple ampersands")
|
||||
{
|
||||
sfz::Opcode opcode { "&sample&_ampersand&", "dummy" };
|
||||
REQUIRE(opcode.opcode == "&sample&_ampersand&");
|
||||
REQUIRE(opcode.lettersOnlyHash == hash("sample_ampersand"));
|
||||
REQUIRE(opcode.parameters.empty());
|
||||
REQUIRE(opcode.value == "dummy");
|
||||
}
|
||||
|
||||
SECTION("Parameterized opcode")
|
||||
{
|
||||
sfz::Opcode opcode { "sample123", "dummy" };
|
||||
REQUIRE(opcode.opcode == "sample123");
|
||||
REQUIRE(opcode.lettersOnlyHash == hash("sample"));
|
||||
REQUIRE(opcode.lettersOnlyHash == hash("sample&"));
|
||||
REQUIRE(opcode.value == "dummy");
|
||||
REQUIRE(opcode.parameters.size() == 1);
|
||||
REQUIRE(opcode.parameters == std::vector<uint8_t>({ 123 }));
|
||||
REQUIRE(opcode.parameterPositions == std::vector<int>({ 6 }));
|
||||
REQUIRE(opcode.backParameter());
|
||||
REQUIRE(*opcode.backParameter() == 123);
|
||||
REQUIRE(!opcode.firstParameter());
|
||||
REQUIRE(!opcode.middleParameter());
|
||||
REQUIRE(opcode.parameters == std::vector<uint16_t>({ 123 }));
|
||||
}
|
||||
|
||||
SECTION("Parameterized opcode with ampersand")
|
||||
{
|
||||
sfz::Opcode opcode { "sample&123", "dummy" };
|
||||
REQUIRE(opcode.opcode == "sample&123");
|
||||
REQUIRE(opcode.lettersOnlyHash == hash("sample&"));
|
||||
REQUIRE(opcode.value == "dummy");
|
||||
REQUIRE(opcode.parameters.size() == 1);
|
||||
REQUIRE(opcode.parameters == std::vector<uint16_t>({ 123 }));
|
||||
}
|
||||
|
||||
SECTION("Parameterized opcode with underscore")
|
||||
{
|
||||
sfz::Opcode opcode { "sample_underscore123", "dummy" };
|
||||
REQUIRE(opcode.opcode == "sample_underscore123");
|
||||
REQUIRE(opcode.lettersOnlyHash == hash("sample_underscore"));
|
||||
REQUIRE(opcode.lettersOnlyHash == hash("sample_underscore&"));
|
||||
REQUIRE(opcode.value == "dummy");
|
||||
REQUIRE(opcode.parameters == std::vector<uint8_t>({ 123 }));
|
||||
REQUIRE(opcode.parameterPositions == std::vector<int>({ 17 }));
|
||||
REQUIRE(opcode.backParameter());
|
||||
REQUIRE(*opcode.backParameter() == 123);
|
||||
REQUIRE(opcode.parameters == std::vector<uint16_t>({ 123 }));
|
||||
}
|
||||
|
||||
SECTION("Parameterized opcode within the opcode")
|
||||
{
|
||||
sfz::Opcode opcode { "sample1_underscore", "dummy" };
|
||||
REQUIRE(opcode.opcode == "sample1_underscore");
|
||||
REQUIRE(opcode.lettersOnlyHash == hash("sample_underscore"));
|
||||
REQUIRE(opcode.lettersOnlyHash == hash("sample&_underscore"));
|
||||
REQUIRE(opcode.value == "dummy");
|
||||
REQUIRE(opcode.parameters == std::vector<uint8_t>({ 1 }));
|
||||
REQUIRE(!opcode.backParameter());
|
||||
REQUIRE(opcode.firstParameter());
|
||||
REQUIRE(*opcode.firstParameter() == 1);
|
||||
REQUIRE(!opcode.middleParameter());
|
||||
REQUIRE(opcode.parameters == std::vector<uint16_t>({ 1 }));
|
||||
}
|
||||
|
||||
SECTION("Parameterized opcode within the opcode")
|
||||
{
|
||||
sfz::Opcode opcode { "sample123_underscore", "dummy" };
|
||||
REQUIRE(opcode.opcode == "sample123_underscore");
|
||||
REQUIRE(opcode.lettersOnlyHash == hash("sample_underscore"));
|
||||
REQUIRE(opcode.lettersOnlyHash == hash("sample&_underscore"));
|
||||
REQUIRE(opcode.value == "dummy");
|
||||
REQUIRE(opcode.parameters.size() == 1);
|
||||
REQUIRE(opcode.parameters[0] == 123);
|
||||
|
|
@ -88,35 +98,22 @@ TEST_CASE("[Opcode] Construction")
|
|||
{
|
||||
sfz::Opcode opcode { "sample123_double44_underscore", "dummy" };
|
||||
REQUIRE(opcode.opcode == "sample123_double44_underscore");
|
||||
REQUIRE(opcode.lettersOnlyHash == hash("sample_double_underscore"));
|
||||
REQUIRE(opcode.lettersOnlyHash == hash("sample&_double&_underscore"));
|
||||
REQUIRE(opcode.value == "dummy");
|
||||
REQUIRE(opcode.parameters.size() == 2);
|
||||
REQUIRE(opcode.parameters[0] == 123);
|
||||
REQUIRE(opcode.parameters[1] == 44);
|
||||
REQUIRE(opcode.parameters == std::vector<uint8_t>({ 123, 44 }));
|
||||
REQUIRE(opcode.parameterPositions == std::vector<int>({ 6, 13 }));
|
||||
REQUIRE(!opcode.backParameter());
|
||||
REQUIRE(opcode.firstParameter());
|
||||
REQUIRE(*opcode.firstParameter() == 123);
|
||||
REQUIRE(opcode.middleParameter());
|
||||
REQUIRE(*opcode.middleParameter() == 44);
|
||||
REQUIRE(opcode.parameters == std::vector<uint16_t>({ 123, 44 }));
|
||||
}
|
||||
|
||||
SECTION("Parameterized opcode within the opcode twice, with a back parameter")
|
||||
{
|
||||
sfz::Opcode opcode { "sample123_double44_underscore23", "dummy" };
|
||||
REQUIRE(opcode.opcode == "sample123_double44_underscore23");
|
||||
REQUIRE(opcode.lettersOnlyHash == hash("sample_double_underscore"));
|
||||
REQUIRE(opcode.lettersOnlyHash == hash("sample&_double&_underscore&"));
|
||||
REQUIRE(opcode.value == "dummy");
|
||||
REQUIRE(opcode.parameters.size() == 3);
|
||||
REQUIRE(opcode.parameters == std::vector<uint8_t>({ 123, 44, 23 }));
|
||||
REQUIRE(opcode.parameterPositions == std::vector<int>({ 6, 13, 24 }));
|
||||
REQUIRE(opcode.backParameter());
|
||||
REQUIRE(*opcode.backParameter() == 23);
|
||||
REQUIRE(opcode.firstParameter());
|
||||
REQUIRE(*opcode.firstParameter() == 123);
|
||||
REQUIRE(opcode.middleParameter());
|
||||
REQUIRE(*opcode.middleParameter() == 44);
|
||||
REQUIRE(opcode.parameters == std::vector<uint16_t>({ 123, 44, 23 }));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -464,8 +464,8 @@ TEST_CASE("[Region] Parsing opcodes")
|
|||
REQUIRE(!region.panCC);
|
||||
region.parseOpcode({ "pan_oncc45", "4.2" });
|
||||
REQUIRE(region.panCC);
|
||||
REQUIRE(region.panCC->first == 45);
|
||||
REQUIRE(region.panCC->second == 4.2f);
|
||||
REQUIRE(region.panCC->cc == 45);
|
||||
REQUIRE(region.panCC->value == 4.2f);
|
||||
}
|
||||
|
||||
SECTION("width")
|
||||
|
|
@ -486,8 +486,8 @@ TEST_CASE("[Region] Parsing opcodes")
|
|||
REQUIRE(!region.widthCC);
|
||||
region.parseOpcode({ "width_oncc45", "4.2" });
|
||||
REQUIRE(region.widthCC);
|
||||
REQUIRE(region.widthCC->first == 45);
|
||||
REQUIRE(region.widthCC->second == 4.2f);
|
||||
REQUIRE(region.widthCC->cc == 45);
|
||||
REQUIRE(region.widthCC->value == 4.2f);
|
||||
}
|
||||
|
||||
SECTION("position")
|
||||
|
|
@ -508,8 +508,8 @@ TEST_CASE("[Region] Parsing opcodes")
|
|||
REQUIRE(!region.positionCC);
|
||||
region.parseOpcode({ "position_oncc45", "4.2" });
|
||||
REQUIRE(region.positionCC);
|
||||
REQUIRE(region.positionCC->first == 45);
|
||||
REQUIRE(region.positionCC->second == 4.2f);
|
||||
REQUIRE(region.positionCC->cc == 45);
|
||||
REQUIRE(region.positionCC->value == 4.2f);
|
||||
}
|
||||
|
||||
SECTION("amp_keycenter")
|
||||
|
|
@ -964,20 +964,20 @@ TEST_CASE("[Region] Parsing opcodes")
|
|||
REQUIRE(region.amplitudeEG.ccRelease);
|
||||
REQUIRE(region.amplitudeEG.ccStart);
|
||||
REQUIRE(region.amplitudeEG.ccSustain);
|
||||
REQUIRE(region.amplitudeEG.ccAttack->first == 1);
|
||||
REQUIRE(region.amplitudeEG.ccDecay->first == 2);
|
||||
REQUIRE(region.amplitudeEG.ccDelay->first == 3);
|
||||
REQUIRE(region.amplitudeEG.ccHold->first == 4);
|
||||
REQUIRE(region.amplitudeEG.ccRelease->first == 5);
|
||||
REQUIRE(region.amplitudeEG.ccStart->first == 6);
|
||||
REQUIRE(region.amplitudeEG.ccSustain->first == 7);
|
||||
REQUIRE(region.amplitudeEG.ccAttack->second == 1.0f);
|
||||
REQUIRE(region.amplitudeEG.ccDecay->second == 2.0f);
|
||||
REQUIRE(region.amplitudeEG.ccDelay->second == 3.0f);
|
||||
REQUIRE(region.amplitudeEG.ccHold->second == 4.0f);
|
||||
REQUIRE(region.amplitudeEG.ccRelease->second == 5.0f);
|
||||
REQUIRE(region.amplitudeEG.ccStart->second == 6.0f);
|
||||
REQUIRE(region.amplitudeEG.ccSustain->second == 7.0f);
|
||||
REQUIRE(region.amplitudeEG.ccAttack->cc == 1);
|
||||
REQUIRE(region.amplitudeEG.ccDecay->cc == 2);
|
||||
REQUIRE(region.amplitudeEG.ccDelay->cc == 3);
|
||||
REQUIRE(region.amplitudeEG.ccHold->cc == 4);
|
||||
REQUIRE(region.amplitudeEG.ccRelease->cc == 5);
|
||||
REQUIRE(region.amplitudeEG.ccStart->cc == 6);
|
||||
REQUIRE(region.amplitudeEG.ccSustain->cc == 7);
|
||||
REQUIRE(region.amplitudeEG.ccAttack->value == 1.0f);
|
||||
REQUIRE(region.amplitudeEG.ccDecay->value == 2.0f);
|
||||
REQUIRE(region.amplitudeEG.ccDelay->value == 3.0f);
|
||||
REQUIRE(region.amplitudeEG.ccHold->value == 4.0f);
|
||||
REQUIRE(region.amplitudeEG.ccRelease->value == 5.0f);
|
||||
REQUIRE(region.amplitudeEG.ccStart->value == 6.0f);
|
||||
REQUIRE(region.amplitudeEG.ccSustain->value == 7.0f);
|
||||
//
|
||||
region.parseOpcode({ "ampeg_attack_oncc1", "101" });
|
||||
region.parseOpcode({ "ampeg_decay_oncc2", "101" });
|
||||
|
|
@ -986,13 +986,13 @@ TEST_CASE("[Region] Parsing opcodes")
|
|||
region.parseOpcode({ "ampeg_release_oncc5", "101" });
|
||||
region.parseOpcode({ "ampeg_start_oncc6", "101" });
|
||||
region.parseOpcode({ "ampeg_sustain_oncc7", "101" });
|
||||
REQUIRE(region.amplitudeEG.ccAttack->second == 100.0f);
|
||||
REQUIRE(region.amplitudeEG.ccDecay->second == 100.0f);
|
||||
REQUIRE(region.amplitudeEG.ccDelay->second == 100.0f);
|
||||
REQUIRE(region.amplitudeEG.ccHold->second == 100.0f);
|
||||
REQUIRE(region.amplitudeEG.ccRelease->second == 100.0f);
|
||||
REQUIRE(region.amplitudeEG.ccStart->second == 100.0f);
|
||||
REQUIRE(region.amplitudeEG.ccSustain->second == 100.0f);
|
||||
REQUIRE(region.amplitudeEG.ccAttack->value == 100.0f);
|
||||
REQUIRE(region.amplitudeEG.ccDecay->value == 100.0f);
|
||||
REQUIRE(region.amplitudeEG.ccDelay->value == 100.0f);
|
||||
REQUIRE(region.amplitudeEG.ccHold->value == 100.0f);
|
||||
REQUIRE(region.amplitudeEG.ccRelease->value == 100.0f);
|
||||
REQUIRE(region.amplitudeEG.ccStart->value == 100.0f);
|
||||
REQUIRE(region.amplitudeEG.ccSustain->value == 100.0f);
|
||||
//
|
||||
region.parseOpcode({ "ampeg_attack_oncc1", "-101" });
|
||||
region.parseOpcode({ "ampeg_decay_oncc2", "-101" });
|
||||
|
|
@ -1001,13 +1001,13 @@ TEST_CASE("[Region] Parsing opcodes")
|
|||
region.parseOpcode({ "ampeg_release_oncc5", "-101" });
|
||||
region.parseOpcode({ "ampeg_start_oncc6", "-101" });
|
||||
region.parseOpcode({ "ampeg_sustain_oncc7", "-101" });
|
||||
REQUIRE(region.amplitudeEG.ccAttack->second == -100.0f);
|
||||
REQUIRE(region.amplitudeEG.ccDecay->second == -100.0f);
|
||||
REQUIRE(region.amplitudeEG.ccDelay->second == -100.0f);
|
||||
REQUIRE(region.amplitudeEG.ccHold->second == -100.0f);
|
||||
REQUIRE(region.amplitudeEG.ccRelease->second == -100.0f);
|
||||
REQUIRE(region.amplitudeEG.ccStart->second == -100.0f);
|
||||
REQUIRE(region.amplitudeEG.ccSustain->second == -100.0f);
|
||||
REQUIRE(region.amplitudeEG.ccAttack->value == -100.0f);
|
||||
REQUIRE(region.amplitudeEG.ccDecay->value == -100.0f);
|
||||
REQUIRE(region.amplitudeEG.ccDelay->value == -100.0f);
|
||||
REQUIRE(region.amplitudeEG.ccHold->value == -100.0f);
|
||||
REQUIRE(region.amplitudeEG.ccRelease->value == -100.0f);
|
||||
REQUIRE(region.amplitudeEG.ccStart->value == -100.0f);
|
||||
REQUIRE(region.amplitudeEG.ccSustain->value == -100.0f);
|
||||
}
|
||||
|
||||
SECTION("sustain_sw and sostenuto_sw")
|
||||
|
|
@ -1350,6 +1350,23 @@ TEST_CASE("[Region] Parsing opcodes")
|
|||
region.parseOpcode({ "eq1_freqcc15", "50000" });
|
||||
REQUIRE(region.equalizers[0].frequencyCC[15] == 30000.0f);
|
||||
}
|
||||
|
||||
SECTION("Effects send")
|
||||
{
|
||||
REQUIRE(region.gainToEffect.size() == 1);
|
||||
REQUIRE(region.gainToEffect[0] == 1.0f);
|
||||
region.parseOpcode({ "effect1", "50.4" });
|
||||
REQUIRE(region.gainToEffect.size() == 2);
|
||||
REQUIRE(region.gainToEffect[1] == 0.504f);
|
||||
region.parseOpcode({ "effect3", "100" });
|
||||
REQUIRE(region.gainToEffect.size() == 4);
|
||||
REQUIRE(region.gainToEffect[2] == 0.0f);
|
||||
REQUIRE(region.gainToEffect[3] == 1.0f);
|
||||
region.parseOpcode({ "effect3", "150.1" });
|
||||
REQUIRE(region.gainToEffect[3] == 1.0f);
|
||||
region.parseOpcode({ "effect3", "-50.65" });
|
||||
REQUIRE(region.gainToEffect[3] == 0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
// Specific region bugs
|
||||
|
|
|
|||
|
|
@ -135,15 +135,15 @@ TEST_CASE("Legato triggers", "Region triggers")
|
|||
region.parseOpcode({ "lokey", "40" });
|
||||
region.parseOpcode({ "hikey", "50" });
|
||||
region.parseOpcode({ "trigger", "first" });
|
||||
midiState.noteOnEvent(40, 64);
|
||||
midiState.noteOnEvent(0, 40, 64);
|
||||
REQUIRE(region.registerNoteOn(40, 64, 0.5f));
|
||||
midiState.noteOnEvent(41, 64);
|
||||
midiState.noteOnEvent(0, 41, 64);
|
||||
REQUIRE(!region.registerNoteOn(41, 64, 0.5f));
|
||||
midiState.noteOffEvent(40, 0);
|
||||
midiState.noteOffEvent(0, 40, 0);
|
||||
region.registerNoteOff(40, 0, 0.5f);
|
||||
midiState.noteOffEvent(41, 0);
|
||||
midiState.noteOffEvent(0, 41, 0);
|
||||
region.registerNoteOff(41, 0, 0.5f);
|
||||
midiState.noteOnEvent(42, 64);
|
||||
midiState.noteOnEvent(0, 42, 64);
|
||||
REQUIRE(region.registerNoteOn(42, 64, 0.5f));
|
||||
}
|
||||
|
||||
|
|
@ -152,15 +152,15 @@ TEST_CASE("Legato triggers", "Region triggers")
|
|||
region.parseOpcode({ "lokey", "40" });
|
||||
region.parseOpcode({ "hikey", "50" });
|
||||
region.parseOpcode({ "trigger", "legato" });
|
||||
midiState.noteOnEvent(40, 64);
|
||||
midiState.noteOnEvent(0, 40, 64);
|
||||
REQUIRE(!region.registerNoteOn(40, 64, 0.5f));
|
||||
midiState.noteOnEvent(41, 64);
|
||||
midiState.noteOnEvent(0, 41, 64);
|
||||
REQUIRE(region.registerNoteOn(41, 64, 0.5f));
|
||||
midiState.noteOffEvent(40, 64);
|
||||
midiState.noteOffEvent(0, 40, 64);
|
||||
region.registerNoteOff(40, 0, 0.5f);
|
||||
midiState.noteOffEvent(41, 64);
|
||||
midiState.noteOffEvent(0, 41, 64);
|
||||
region.registerNoteOff(41, 0, 0.5f);
|
||||
midiState.noteOnEvent(42, 64);
|
||||
midiState.noteOnEvent(0, 42, 64);
|
||||
REQUIRE(!region.registerNoteOn(42, 64, 0.5f));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -166,13 +166,13 @@ TEST_CASE("[Region] Crossfade in on CC")
|
|||
region.parseOpcode({ "xfin_locc24", "20" });
|
||||
region.parseOpcode({ "xfin_hicc24", "24" });
|
||||
region.parseOpcode({ "amp_veltrack", "0" });
|
||||
midiState.ccEvent(24, 19); REQUIRE( region.getCrossfadeGain(midiState.getCCArray()) == 0.0_a );
|
||||
midiState.ccEvent(24, 20); REQUIRE( region.getCrossfadeGain(midiState.getCCArray()) == 0.0_a );
|
||||
midiState.ccEvent(24, 21); REQUIRE( region.getCrossfadeGain(midiState.getCCArray()) == 0.5_a );
|
||||
midiState.ccEvent(24, 22); REQUIRE( region.getCrossfadeGain(midiState.getCCArray()) == 0.70711_a );
|
||||
midiState.ccEvent(24, 23); REQUIRE( region.getCrossfadeGain(midiState.getCCArray()) == 0.86603_a );
|
||||
midiState.ccEvent(24, 24); REQUIRE( region.getCrossfadeGain(midiState.getCCArray()) == 1.0_a );
|
||||
midiState.ccEvent(24, 25); REQUIRE( region.getCrossfadeGain(midiState.getCCArray()) == 1.0_a );
|
||||
midiState.ccEvent(0, 24, 19); REQUIRE( region.getCrossfadeGain(midiState.getCCArray()) == 0.0_a );
|
||||
midiState.ccEvent(0, 24, 20); REQUIRE( region.getCrossfadeGain(midiState.getCCArray()) == 0.0_a );
|
||||
midiState.ccEvent(0, 24, 21); REQUIRE( region.getCrossfadeGain(midiState.getCCArray()) == 0.5_a );
|
||||
midiState.ccEvent(0, 24, 22); REQUIRE( region.getCrossfadeGain(midiState.getCCArray()) == 0.70711_a );
|
||||
midiState.ccEvent(0, 24, 23); REQUIRE( region.getCrossfadeGain(midiState.getCCArray()) == 0.86603_a );
|
||||
midiState.ccEvent(0, 24, 24); REQUIRE( region.getCrossfadeGain(midiState.getCCArray()) == 1.0_a );
|
||||
midiState.ccEvent(0, 24, 25); REQUIRE( region.getCrossfadeGain(midiState.getCCArray()) == 1.0_a );
|
||||
}
|
||||
|
||||
TEST_CASE("[Region] Crossfade in on CC - gain")
|
||||
|
|
@ -184,13 +184,13 @@ TEST_CASE("[Region] Crossfade in on CC - gain")
|
|||
region.parseOpcode({ "xfin_hicc24", "24" });
|
||||
region.parseOpcode({ "amp_veltrack", "0" });
|
||||
region.parseOpcode({ "xf_cccurve", "gain" });
|
||||
midiState.ccEvent(24, 19); REQUIRE( region.getCrossfadeGain(midiState.getCCArray()) == 0.0_a );
|
||||
midiState.ccEvent(24, 20); REQUIRE( region.getCrossfadeGain(midiState.getCCArray()) == 0.0_a );
|
||||
midiState.ccEvent(24, 21); REQUIRE( region.getCrossfadeGain(midiState.getCCArray()) == 0.25_a );
|
||||
midiState.ccEvent(24, 22); REQUIRE( region.getCrossfadeGain(midiState.getCCArray()) == 0.5_a );
|
||||
midiState.ccEvent(24, 23); REQUIRE( region.getCrossfadeGain(midiState.getCCArray()) == 0.75_a );
|
||||
midiState.ccEvent(24, 24); REQUIRE( region.getCrossfadeGain(midiState.getCCArray()) == 1.0_a );
|
||||
midiState.ccEvent(24, 25); REQUIRE( region.getCrossfadeGain(midiState.getCCArray()) == 1.0_a );
|
||||
midiState.ccEvent(0, 24, 19); REQUIRE( region.getCrossfadeGain(midiState.getCCArray()) == 0.0_a );
|
||||
midiState.ccEvent(0, 24, 20); REQUIRE( region.getCrossfadeGain(midiState.getCCArray()) == 0.0_a );
|
||||
midiState.ccEvent(0, 24, 21); REQUIRE( region.getCrossfadeGain(midiState.getCCArray()) == 0.25_a );
|
||||
midiState.ccEvent(0, 24, 22); REQUIRE( region.getCrossfadeGain(midiState.getCCArray()) == 0.5_a );
|
||||
midiState.ccEvent(0, 24, 23); REQUIRE( region.getCrossfadeGain(midiState.getCCArray()) == 0.75_a );
|
||||
midiState.ccEvent(0, 24, 24); REQUIRE( region.getCrossfadeGain(midiState.getCCArray()) == 1.0_a );
|
||||
midiState.ccEvent(0, 24, 25); REQUIRE( region.getCrossfadeGain(midiState.getCCArray()) == 1.0_a );
|
||||
}
|
||||
TEST_CASE("[Region] Crossfade out on CC")
|
||||
{
|
||||
|
|
@ -200,13 +200,13 @@ TEST_CASE("[Region] Crossfade out on CC")
|
|||
region.parseOpcode({ "xfout_locc24", "20" });
|
||||
region.parseOpcode({ "xfout_hicc24", "24" });
|
||||
region.parseOpcode({ "amp_veltrack", "0" });
|
||||
midiState.ccEvent(24, 19); REQUIRE( region.getCrossfadeGain(midiState.getCCArray()) == 1.0_a );
|
||||
midiState.ccEvent(24, 20); REQUIRE( region.getCrossfadeGain(midiState.getCCArray()) == 1.0_a );
|
||||
midiState.ccEvent(24, 21); REQUIRE( region.getCrossfadeGain(midiState.getCCArray()) == 0.86603_a );
|
||||
midiState.ccEvent(24, 22); REQUIRE( region.getCrossfadeGain(midiState.getCCArray()) == 0.70711_a );
|
||||
midiState.ccEvent(24, 23); REQUIRE( region.getCrossfadeGain(midiState.getCCArray()) == 0.5_a );
|
||||
midiState.ccEvent(24, 24); REQUIRE( region.getCrossfadeGain(midiState.getCCArray()) == 0.0_a );
|
||||
midiState.ccEvent(24, 25); REQUIRE( region.getCrossfadeGain(midiState.getCCArray()) == 0.0_a );
|
||||
midiState.ccEvent(0, 24, 19); REQUIRE( region.getCrossfadeGain(midiState.getCCArray()) == 1.0_a );
|
||||
midiState.ccEvent(0, 24, 20); REQUIRE( region.getCrossfadeGain(midiState.getCCArray()) == 1.0_a );
|
||||
midiState.ccEvent(0, 24, 21); REQUIRE( region.getCrossfadeGain(midiState.getCCArray()) == 0.86603_a );
|
||||
midiState.ccEvent(0, 24, 22); REQUIRE( region.getCrossfadeGain(midiState.getCCArray()) == 0.70711_a );
|
||||
midiState.ccEvent(0, 24, 23); REQUIRE( region.getCrossfadeGain(midiState.getCCArray()) == 0.5_a );
|
||||
midiState.ccEvent(0, 24, 24); REQUIRE( region.getCrossfadeGain(midiState.getCCArray()) == 0.0_a );
|
||||
midiState.ccEvent(0, 24, 25); REQUIRE( region.getCrossfadeGain(midiState.getCCArray()) == 0.0_a );
|
||||
}
|
||||
|
||||
TEST_CASE("[Region] Crossfade out on CC - gain")
|
||||
|
|
@ -218,13 +218,13 @@ TEST_CASE("[Region] Crossfade out on CC - gain")
|
|||
region.parseOpcode({ "xfout_hicc24", "24" });
|
||||
region.parseOpcode({ "amp_veltrack", "0" });
|
||||
region.parseOpcode({ "xf_cccurve", "gain" });
|
||||
midiState.ccEvent(24, 19); REQUIRE( region.getCrossfadeGain(midiState.getCCArray()) == 1.0_a );
|
||||
midiState.ccEvent(24, 20); REQUIRE( region.getCrossfadeGain(midiState.getCCArray()) == 1.0_a );
|
||||
midiState.ccEvent(24, 21); REQUIRE( region.getCrossfadeGain(midiState.getCCArray()) == 0.75_a );
|
||||
midiState.ccEvent(24, 22); REQUIRE( region.getCrossfadeGain(midiState.getCCArray()) == 0.5_a );
|
||||
midiState.ccEvent(24, 23); REQUIRE( region.getCrossfadeGain(midiState.getCCArray()) == 0.25_a );
|
||||
midiState.ccEvent(24, 24); REQUIRE( region.getCrossfadeGain(midiState.getCCArray()) == 0.0_a );
|
||||
midiState.ccEvent(24, 25); REQUIRE( region.getCrossfadeGain(midiState.getCCArray()) == 0.0_a );
|
||||
midiState.ccEvent(0, 24, 19); REQUIRE( region.getCrossfadeGain(midiState.getCCArray()) == 1.0_a );
|
||||
midiState.ccEvent(0, 24, 20); REQUIRE( region.getCrossfadeGain(midiState.getCCArray()) == 1.0_a );
|
||||
midiState.ccEvent(0, 24, 21); REQUIRE( region.getCrossfadeGain(midiState.getCCArray()) == 0.75_a );
|
||||
midiState.ccEvent(0, 24, 22); REQUIRE( region.getCrossfadeGain(midiState.getCCArray()) == 0.5_a );
|
||||
midiState.ccEvent(0, 24, 23); REQUIRE( region.getCrossfadeGain(midiState.getCCArray()) == 0.25_a );
|
||||
midiState.ccEvent(0, 24, 24); REQUIRE( region.getCrossfadeGain(midiState.getCCArray()) == 0.0_a );
|
||||
midiState.ccEvent(0, 24, 25); REQUIRE( region.getCrossfadeGain(midiState.getCCArray()) == 0.0_a );
|
||||
}
|
||||
|
||||
TEST_CASE("[Region] Velocity bug for extreme values - veltrack at 0")
|
||||
|
|
@ -265,15 +265,15 @@ TEST_CASE("[Region] rt_decay")
|
|||
region.parseOpcode({ "sample", "*sine" });
|
||||
region.parseOpcode({ "trigger", "release" });
|
||||
region.parseOpcode({ "rt_decay", "10" });
|
||||
midiState.noteOnEvent(64, 64);
|
||||
midiState.noteOnEvent(0, 64, 64);
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||
REQUIRE( region.getBaseVolumedB(64) == Approx(sfz::Default::volume - 1.0f).margin(0.1) );
|
||||
region.parseOpcode({ "rt_decay", "20" });
|
||||
midiState.noteOnEvent(64, 64);
|
||||
midiState.noteOnEvent(0, 64, 64);
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||
REQUIRE( region.getBaseVolumedB(64) == Approx(sfz::Default::volume - 2.0f).margin(0.1) );
|
||||
region.parseOpcode({ "trigger", "attack" });
|
||||
midiState.noteOnEvent(64, 64);
|
||||
midiState.noteOnEvent(0, 64, 64);
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||
REQUIRE( region.getBaseVolumedB(64) == Approx(sfz::Default::volume).margin(0.1) );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -606,6 +606,57 @@ TEST_CASE("[Helpers] Add (SIMD vs scalar)")
|
|||
REQUIRE(approxEqual<float>(outputScalar, outputSIMD));
|
||||
}
|
||||
|
||||
TEST_CASE("[Helpers] MultiplyAdd (SIMD)")
|
||||
{
|
||||
std::array<float, 5> gain { 0.0f, 0.1f, 0.2f, 0.3f, 0.4f };
|
||||
std::array<float, 5> input { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f };
|
||||
std::array<float, 5> output { 5.0f, 4.0f, 3.0f, 2.0f, 1.0f };
|
||||
std::array<float, 5> expected { 5.0f, 4.2f, 3.6f, 3.2f, 3.0f };
|
||||
sfz::multiplyAdd<float, true>(gain, input, absl::MakeSpan(output));
|
||||
REQUIRE(output == expected);
|
||||
}
|
||||
|
||||
TEST_CASE("[Helpers] MultiplyAdd (SIMD vs scalar)")
|
||||
{
|
||||
std::vector<float> gain(bigBufferSize);
|
||||
std::vector<float> input(bigBufferSize);
|
||||
std::vector<float> outputScalar(bigBufferSize);
|
||||
std::vector<float> outputSIMD(bigBufferSize);
|
||||
absl::c_iota(gain, 0.0f);
|
||||
absl::c_iota(input, 0.0f);
|
||||
absl::c_iota(outputScalar, 0.0f);
|
||||
absl::c_iota(outputSIMD, 0.0f);
|
||||
|
||||
sfz::multiplyAdd<float, false>(gain, input, absl::MakeSpan(outputScalar));
|
||||
sfz::multiplyAdd<float, true>(gain, input, absl::MakeSpan(outputSIMD));
|
||||
REQUIRE(approxEqual<float>(outputScalar, outputSIMD));
|
||||
}
|
||||
|
||||
TEST_CASE("[Helpers] MultiplyAdd fixed gain (SIMD)")
|
||||
{
|
||||
float gain = 0.3f;
|
||||
std::array<float, 5> input { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f };
|
||||
std::array<float, 5> output { 5.0f, 4.0f, 3.0f, 2.0f, 1.0f };
|
||||
std::array<float, 5> expected { 5.3f, 4.6f, 3.9f, 3.2f, 2.5f };
|
||||
sfz::multiplyAdd<float, true>(gain, input, absl::MakeSpan(output));
|
||||
REQUIRE(output == expected);
|
||||
}
|
||||
|
||||
TEST_CASE("[Helpers] MultiplyAdd fixed gain (SIMD vs scalar)")
|
||||
{
|
||||
float gain = 0.3f;
|
||||
std::vector<float> input(bigBufferSize);
|
||||
std::vector<float> outputScalar(bigBufferSize);
|
||||
std::vector<float> outputSIMD(bigBufferSize);
|
||||
absl::c_iota(input, 0.0f);
|
||||
absl::c_iota(outputScalar, 0.0f);
|
||||
absl::c_iota(outputSIMD, 0.0f);
|
||||
|
||||
sfz::multiplyAdd<float, false>(gain, input, absl::MakeSpan(outputScalar));
|
||||
sfz::multiplyAdd<float, true>(gain, input, absl::MakeSpan(outputSIMD));
|
||||
REQUIRE(approxEqual<float>(outputScalar, outputSIMD));
|
||||
}
|
||||
|
||||
TEST_CASE("[Helpers] Subtract")
|
||||
{
|
||||
std::array<float, 5> input { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f };
|
||||
|
|
@ -717,7 +768,7 @@ TEST_CASE("[Helpers] Mean Squared (SIMD vs scalar)")
|
|||
REQUIRE(sfz::meanSquared<float, false>(input) == sfz::meanSquared<float, true>(input));
|
||||
}
|
||||
|
||||
TEST_CASE("[Helpers] Cumulative sum ")
|
||||
TEST_CASE("[Helpers] Cumulative sum")
|
||||
{
|
||||
std::array<float, 6> input { 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f }; // 1.1 2.3 3.6 5.0f 6.5 8.1
|
||||
std::array<float, 6> output;
|
||||
|
|
@ -737,7 +788,7 @@ TEST_CASE("[Helpers] Cumulative sum (SIMD vs Scalar)")
|
|||
REQUIRE(approxEqual<float>(outputScalar, outputSIMD));
|
||||
}
|
||||
|
||||
TEST_CASE("[Helpers] Diff ")
|
||||
TEST_CASE("[Helpers] Diff")
|
||||
{
|
||||
std::array<float, 6> input { 1.1f, 2.3f, 3.6f, 5.0f, 6.5f, 8.1f };
|
||||
std::array<float, 6> output;
|
||||
|
|
|
|||
115
tests/SynthT.cpp
115
tests/SynthT.cpp
|
|
@ -13,7 +13,7 @@ constexpr int blockSize { 256 };
|
|||
TEST_CASE("[Synth] Play and check active voices")
|
||||
{
|
||||
sfz::Synth synth;
|
||||
synth.setSamplesPerBlock(256);
|
||||
synth.setSamplesPerBlock(blockSize);
|
||||
sfz::AudioBuffer<float> buffer { 2, blockSize };
|
||||
synth.loadSfzFile(fs::current_path() / "tests/TestFiles/groups_avl.sfz");
|
||||
|
||||
|
|
@ -29,7 +29,7 @@ TEST_CASE("[Synth] Play and check active voices")
|
|||
TEST_CASE("[Synth] Change the number of voice while playing")
|
||||
{
|
||||
sfz::Synth synth;
|
||||
synth.setSamplesPerBlock(256);
|
||||
synth.setSamplesPerBlock(blockSize);
|
||||
sfz::AudioBuffer<float> buffer { 2, blockSize };
|
||||
synth.loadSfzFile(fs::current_path() / "tests/TestFiles/groups_avl.sfz");
|
||||
|
||||
|
|
@ -77,6 +77,7 @@ TEST_CASE("[Synth] Check that we can change the size of the preload before and a
|
|||
{
|
||||
sfz::Synth synth;
|
||||
synth.setPreloadSize(512);
|
||||
synth.setSamplesPerBlock(blockSize);
|
||||
sfz::AudioBuffer<float> buffer { 2, blockSize };
|
||||
synth.loadSfzFile(fs::current_path() / "tests/TestFiles/groups_avl.sfz");
|
||||
synth.setPreloadSize(1024);
|
||||
|
|
@ -92,6 +93,7 @@ TEST_CASE("[Synth] Check that we can change the oversampling factor before and a
|
|||
{
|
||||
sfz::Synth synth;
|
||||
synth.setOversamplingFactor(sfz::Oversampling::x2);
|
||||
synth.setSamplesPerBlock(blockSize);
|
||||
sfz::AudioBuffer<float> buffer { 2, blockSize };
|
||||
synth.loadSfzFile(fs::current_path() / "tests/TestFiles/groups_avl.sfz");
|
||||
synth.setOversamplingFactor(sfz::Oversampling::x4);
|
||||
|
|
@ -208,3 +210,112 @@ TEST_CASE("[Synth] Trigger=release_key and an envelope properly kills the voice
|
|||
synth.renderBlock(buffer);
|
||||
REQUIRE( synth.getVoiceView(0)->isFree() );
|
||||
}
|
||||
|
||||
TEST_CASE("[Synth] Number of effect buses and resetting behavior")
|
||||
{
|
||||
sfz::Synth synth;
|
||||
synth.setSamplesPerBlock(blockSize);
|
||||
sfz::AudioBuffer<float> buffer { 2, blockSize };
|
||||
|
||||
REQUIRE( synth.getEffectBusView(0) == nullptr); // No effects at first
|
||||
synth.loadSfzFile(fs::current_path() / "tests/TestFiles/Effects/base.sfz");
|
||||
REQUIRE( synth.getEffectBusView(0) != nullptr); // We have a main bus
|
||||
// Check that we can render blocks
|
||||
for (int i = 0; i < 100; ++i)
|
||||
synth.renderBlock(buffer);
|
||||
|
||||
synth.loadSfzFile(fs::current_path() / "tests/TestFiles/Effects/bitcrusher_2.sfz");
|
||||
REQUIRE( synth.getEffectBusView(0) != nullptr); // We have a main bus
|
||||
REQUIRE( synth.getEffectBusView(1) != nullptr); // and an FX bus
|
||||
// Check that we can render blocks
|
||||
for (int i = 0; i < 100; ++i)
|
||||
synth.renderBlock(buffer);
|
||||
|
||||
synth.loadSfzFile(fs::current_path() / "tests/TestFiles/Effects/base.sfz");
|
||||
REQUIRE( synth.getEffectBusView(0) != nullptr); // We have a main bus
|
||||
REQUIRE( synth.getEffectBusView(1) == nullptr); // and no FX bus
|
||||
// Check that we can render blocks
|
||||
for (int i = 0; i < 100; ++i)
|
||||
synth.renderBlock(buffer);
|
||||
|
||||
synth.loadSfzFile(fs::current_path() / "tests/TestFiles/Effects/bitcrusher_3.sfz");
|
||||
REQUIRE( synth.getEffectBusView(0) != nullptr); // We have a main bus
|
||||
REQUIRE( synth.getEffectBusView(1) == nullptr); // empty/uninitialized fx bus
|
||||
REQUIRE( synth.getEffectBusView(2) == nullptr); // empty/uninitialized fx bus
|
||||
REQUIRE( synth.getEffectBusView(3) != nullptr); // and an FX bus (because we built up to fx3)
|
||||
REQUIRE( synth.getEffectBusView(3)->numEffects() == 1);
|
||||
// Check that we can render blocks
|
||||
for (int i = 0; i < 100; ++i)
|
||||
synth.renderBlock(buffer);
|
||||
}
|
||||
|
||||
TEST_CASE("[Synth] No effect in the main bus")
|
||||
{
|
||||
sfz::Synth synth;
|
||||
synth.loadSfzFile(fs::current_path() / "tests/TestFiles/Effects/base.sfz");
|
||||
auto bus = synth.getEffectBusView(0);
|
||||
REQUIRE( bus != nullptr); // We have a main bus
|
||||
REQUIRE( bus->numEffects() == 0 );
|
||||
REQUIRE( bus->gainToMain() == 1 );
|
||||
REQUIRE( bus->gainToMix() == 0 );
|
||||
}
|
||||
|
||||
TEST_CASE("[Synth] One effect")
|
||||
{
|
||||
sfz::Synth synth;
|
||||
synth.loadSfzFile(fs::current_path() / "tests/TestFiles/Effects/bitcrusher_1.sfz");
|
||||
auto bus = synth.getEffectBusView(0);
|
||||
REQUIRE( bus != nullptr); // We have a main bus
|
||||
REQUIRE( bus->numEffects() == 1 );
|
||||
REQUIRE( bus->gainToMain() == 1 );
|
||||
REQUIRE( bus->gainToMix() == 0 );
|
||||
}
|
||||
|
||||
TEST_CASE("[Synth] Effect on a second bus")
|
||||
{
|
||||
sfz::Synth synth;
|
||||
synth.loadSfzFile(fs::current_path() / "tests/TestFiles/Effects/bitcrusher_2.sfz");
|
||||
auto bus = synth.getEffectBusView(0);
|
||||
REQUIRE( bus != nullptr); // We have a main bus
|
||||
REQUIRE( bus->numEffects() == 0 );
|
||||
REQUIRE( bus->gainToMain() == 0.5 );
|
||||
REQUIRE( bus->gainToMix() == 0 );
|
||||
bus = synth.getEffectBusView(1);
|
||||
REQUIRE( bus != nullptr);
|
||||
REQUIRE( bus->numEffects() == 1 );
|
||||
REQUIRE( bus->gainToMain() == 0.5 );
|
||||
REQUIRE( bus->gainToMix() == 0 );
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE("[Synth] Effect on a third bus")
|
||||
{
|
||||
sfz::Synth synth;
|
||||
synth.loadSfzFile(fs::current_path() / "tests/TestFiles/Effects/bitcrusher_3.sfz");
|
||||
auto bus = synth.getEffectBusView(0);
|
||||
REQUIRE( bus != nullptr); // We have a main bus
|
||||
REQUIRE( bus->numEffects() == 0 );
|
||||
REQUIRE( bus->gainToMain() == 0.5 );
|
||||
REQUIRE( bus->gainToMix() == 0 );
|
||||
bus = synth.getEffectBusView(3);
|
||||
REQUIRE( bus != nullptr);
|
||||
REQUIRE( bus->numEffects() == 1 );
|
||||
REQUIRE( bus->gainToMain() == 0.5 );
|
||||
REQUIRE( bus->gainToMix() == 0 );
|
||||
}
|
||||
|
||||
TEST_CASE("[Synth] Gain to mix")
|
||||
{
|
||||
sfz::Synth synth;
|
||||
synth.loadSfzFile(fs::current_path() / "tests/TestFiles/Effects/to_mix.sfz");
|
||||
auto bus = synth.getEffectBusView(0);
|
||||
REQUIRE( bus != nullptr); // We have a main bus
|
||||
REQUIRE( bus->numEffects() == 0 );
|
||||
REQUIRE( bus->gainToMain() == 1 );
|
||||
REQUIRE( bus->gainToMix() == 0 );
|
||||
bus = synth.getEffectBusView(1);
|
||||
REQUIRE( bus != nullptr);
|
||||
REQUIRE( bus->numEffects() == 1 );
|
||||
REQUIRE( bus->gainToMain() == 0 );
|
||||
REQUIRE( bus->gainToMix() == 0.5 );
|
||||
}
|
||||
|
|
|
|||
4
tests/TestFiles/Effects/base.sfz
Normal file
4
tests/TestFiles/Effects/base.sfz
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<region>
|
||||
lokey=0
|
||||
hikey=127
|
||||
sample=*sine
|
||||
9
tests/TestFiles/Effects/bitcrusher_1.sfz
Normal file
9
tests/TestFiles/Effects/bitcrusher_1.sfz
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<region>
|
||||
lokey=0
|
||||
hikey=127
|
||||
sample=*sine
|
||||
|
||||
<effect>
|
||||
type=lofi
|
||||
bitred=90
|
||||
decim=10
|
||||
13
tests/TestFiles/Effects/bitcrusher_2.sfz
Normal file
13
tests/TestFiles/Effects/bitcrusher_2.sfz
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<region>
|
||||
lokey=0
|
||||
hikey=127
|
||||
sample=*sine
|
||||
effect1=100
|
||||
|
||||
<effect>
|
||||
directtomain=50
|
||||
fx1tomain=50
|
||||
type=lofi
|
||||
bus=fx1
|
||||
bitred=90
|
||||
decim=10
|
||||
13
tests/TestFiles/Effects/bitcrusher_3.sfz
Normal file
13
tests/TestFiles/Effects/bitcrusher_3.sfz
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<region>
|
||||
lokey=0
|
||||
hikey=127
|
||||
sample=*sine
|
||||
effect1=100
|
||||
|
||||
<effect>
|
||||
directtomain=50
|
||||
fx3tomain=50
|
||||
type=lofi
|
||||
bus=fx3
|
||||
bitred=90
|
||||
decim=10
|
||||
12
tests/TestFiles/Effects/to_mix.sfz
Normal file
12
tests/TestFiles/Effects/to_mix.sfz
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<region>
|
||||
lokey=0
|
||||
hikey=127
|
||||
sample=*sine
|
||||
effect1=100
|
||||
|
||||
<effect>
|
||||
fx1tomix=50
|
||||
bus=fx1
|
||||
type=lofi
|
||||
bitred=90
|
||||
decim=10
|
||||
122
vst/CMakeLists.txt
Normal file
122
vst/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,122 @@
|
|||
set (VSTPLUGIN_PRJ_NAME "${PROJECT_NAME}_vst3")
|
||||
set (VSTPLUGIN_BUNDLE_NAME "${PROJECT_NAME}.vst3")
|
||||
|
||||
set (VST3SDK_BASEDIR "${CMAKE_CURRENT_SOURCE_DIR}/external/VST_SDK/VST3_SDK")
|
||||
set (VST3SDK_ARCHIVE "vst-sdk_3.6.14_build-24_2019-11-29.zip")
|
||||
|
||||
if (NOT EXISTS "${VST3SDK_BASEDIR}")
|
||||
message (STATUS "VST3 SDK is not found, downloading")
|
||||
|
||||
execute_process (
|
||||
COMMAND "${CMAKE_COMMAND}" -E make_directory "${CMAKE_CURRENT_SOURCE_DIR}/download")
|
||||
|
||||
if (NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/download/${VST3SDK_ARCHIVE}")
|
||||
file (DOWNLOAD
|
||||
"https://download.steinberg.net/sdk_downloads/${VST3SDK_ARCHIVE}"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/download/${VST3SDK_ARCHIVE}"
|
||||
SHOW_PROGRESS)
|
||||
endif()
|
||||
|
||||
execute_process (
|
||||
COMMAND "${CMAKE_COMMAND}" -E make_directory "${CMAKE_CURRENT_SOURCE_DIR}/external"
|
||||
COMMAND "${CMAKE_COMMAND}" -E tar xf "../download/${VST3SDK_ARCHIVE}"
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/external")
|
||||
endif()
|
||||
|
||||
# stop trying to include this atrocity.. build it ourselves
|
||||
#add_subdirectory("${VST3SDK_BASEDIR}" EXCLUDE_FROM_ALL)
|
||||
|
||||
# VST plugin specific settings
|
||||
include (VSTConfig)
|
||||
|
||||
configure_file (VstPluginDefs.h.in "${CMAKE_CURRENT_BINARY_DIR}/VstPluginDefs.h")
|
||||
|
||||
# Build VST3 SDK
|
||||
include("cmake/Vst3.cmake")
|
||||
|
||||
# Build the plugin
|
||||
add_library(${VSTPLUGIN_PRJ_NAME} MODULE
|
||||
SfizzVstProcessor.cpp
|
||||
SfizzVstController.cpp
|
||||
SfizzVstEditor.cpp
|
||||
SfizzVstState.cpp
|
||||
GUIComponents.cpp
|
||||
VstPluginFactory.cpp)
|
||||
|
||||
if(WIN32)
|
||||
target_sources(${VSTPLUGIN_PRJ_NAME} PRIVATE vst3.def)
|
||||
endif()
|
||||
target_link_libraries(${VSTPLUGIN_PRJ_NAME}
|
||||
PRIVATE ${PROJECT_NAME}::${PROJECT_NAME})
|
||||
target_include_directories(${VSTPLUGIN_PRJ_NAME}
|
||||
PRIVATE "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
set_target_properties(${VSTPLUGIN_PRJ_NAME} PROPERTIES
|
||||
OUTPUT_NAME "${PROJECT_NAME}"
|
||||
PREFIX "")
|
||||
|
||||
plugin_add_vst3sdk(${VSTPLUGIN_PRJ_NAME})
|
||||
plugin_add_vstgui(${VSTPLUGIN_PRJ_NAME})
|
||||
|
||||
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
target_link_libraries(${VSTPLUGIN_PRJ_NAME} PRIVATE
|
||||
"-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/vst3.version")
|
||||
endif()
|
||||
sfizz_enable_lto_if_needed (${VSTPLUGIN_PRJ_NAME})
|
||||
if (MINGW)
|
||||
set_target_properties (${VSTPLUGIN_PRJ_NAME} PROPERTIES LINK_FLAGS "-static")
|
||||
endif()
|
||||
|
||||
# Create the bundle (see "VST 3 Locations / Format")
|
||||
execute_process (
|
||||
COMMAND "${CMAKE_COMMAND}" -E make_directory "${PROJECT_BINARY_DIR}/${VSTPLUGIN_BUNDLE_NAME}/Contents/Resources")
|
||||
file (COPY "${CMAKE_CURRENT_SOURCE_DIR}/resources/logo.png"
|
||||
DESTINATION "${PROJECT_BINARY_DIR}/${VSTPLUGIN_BUNDLE_NAME}/Contents/Resources")
|
||||
if(WIN32)
|
||||
set_target_properties(${VSTPLUGIN_PRJ_NAME} PROPERTIES
|
||||
SUFFIX ".vst3"
|
||||
LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/${VSTPLUGIN_BUNDLE_NAME}/Contents/${VST3_PACKAGE_ARCHITECTURE}-win")
|
||||
foreach(config ${CMAKE_CONFIGURATION_TYPES})
|
||||
string(TOUPPER "${config}" config)
|
||||
set_target_properties(${VSTPLUGIN_PRJ_NAME} PROPERTIES
|
||||
"LIBRARY_OUTPUT_DIRECTORY_${config}" "${PROJECT_BINARY_DIR}/${VSTPLUGIN_BUNDLE_NAME}/Contents/${VST3_PACKAGE_ARCHITECTURE}-win")
|
||||
endforeach()
|
||||
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/win/Plugin.ico"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/win/desktop.ini"
|
||||
DESTINATION "${PROJECT_BINARY_DIR}/${VSTPLUGIN_BUNDLE_NAME}")
|
||||
elseif(APPLE)
|
||||
set_target_properties(${VSTPLUGIN_PRJ_NAME} PROPERTIES
|
||||
SUFFIX ""
|
||||
LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/${VSTPLUGIN_BUNDLE_NAME}/Contents/MacOS")
|
||||
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/mac/PkgInfo"
|
||||
DESTINATION "${PROJECT_BINARY_DIR}/${VSTPLUGIN_BUNDLE_NAME}/Contents")
|
||||
set(SFIZZ_VST3_BUNDLE_EXECUTABLE "${PROJECT_NAME}")
|
||||
set(SFIZZ_VST3_BUNDLE_VERSION "${PROJECT_VERSION}")
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/mac/Info.plist"
|
||||
"${PROJECT_BINARY_DIR}/${VSTPLUGIN_BUNDLE_NAME}/Contents/Info.plist" @ONLY)
|
||||
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/mac/Plugin.icns"
|
||||
DESTINATION "${PROJECT_BINARY_DIR}/${VSTPLUGIN_BUNDLE_NAME}/Contents/Resources")
|
||||
else()
|
||||
set_target_properties(${VSTPLUGIN_PRJ_NAME} PROPERTIES
|
||||
LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/${VSTPLUGIN_BUNDLE_NAME}/Contents/${VST3_PACKAGE_ARCHITECTURE}-linux")
|
||||
endif()
|
||||
|
||||
file(COPY "gpl-3.0.txt"
|
||||
DESTINATION "${PROJECT_BINARY_DIR}/${VSTPLUGIN_BUNDLE_NAME}")
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
|
||||
target_compile_options(${VSTPLUGIN_PRJ_NAME} PRIVATE
|
||||
"-Wno-extra"
|
||||
"-Wno-multichar"
|
||||
"-Wno-reorder"
|
||||
"-Wno-class-memaccess"
|
||||
"-Wno-ignored-qualifiers"
|
||||
"-Wno-unknown-pragmas"
|
||||
"-Wno-unused-function"
|
||||
"-Wno-unused-parameter"
|
||||
"-Wno-unused-variable")
|
||||
endif()
|
||||
|
||||
# To help debugging the link only
|
||||
if (FALSE)
|
||||
target_link_options(${VSTPLUGIN_PRJ_NAME} PRIVATE "-Wl,-no-undefined")
|
||||
endif()
|
||||
33
vst/GUIComponents.cpp
Normal file
33
vst/GUIComponents.cpp
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
// SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
// This code is part of the sfizz library and is licensed under a BSD 2-clause
|
||||
// license. You should have receive a LICENSE.md file along with the code.
|
||||
// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz
|
||||
|
||||
#include "GUIComponents.h"
|
||||
#include "vstgui/lib/cdrawcontext.h"
|
||||
|
||||
SimpleSlider::SimpleSlider(const CRect& bounds, IControlListener* listener, int32_t tag)
|
||||
: CSliderBase(bounds, listener, tag)
|
||||
{
|
||||
setStyle(kHorizontal|kLeft);
|
||||
|
||||
CPoint offsetHandle(2.0, 2.0);
|
||||
setOffsetHandle(offsetHandle);
|
||||
|
||||
CCoord handleSize = 20.0;
|
||||
setHandleSizePrivate(handleSize, bounds.bottom - bounds.top - 2 * offsetHandle.y);
|
||||
setHandleRangePrivate(bounds.right - bounds.left - handleSize - 2 * offsetHandle.x);
|
||||
}
|
||||
|
||||
void SimpleSlider::draw(CDrawContext* dc)
|
||||
{
|
||||
CRect bounds = getViewSize();
|
||||
CRect handle = calculateHandleRect(getValueNormalized());
|
||||
|
||||
dc->setFrameColor(_frame);
|
||||
dc->drawRect(bounds, kDrawStroked);
|
||||
|
||||
dc->setFillColor(_fill);
|
||||
dc->drawRect(handle, kDrawFilled);
|
||||
}
|
||||
23
vst/GUIComponents.h
Normal file
23
vst/GUIComponents.h
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
// SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
// This code is part of the sfizz library and is licensed under a BSD 2-clause
|
||||
// license. You should have receive a LICENSE.md file along with the code.
|
||||
// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz
|
||||
|
||||
#pragma once
|
||||
#include "vstgui/lib/controls/cslider.h"
|
||||
#include "vstgui/lib/ccolor.h"
|
||||
|
||||
using namespace VSTGUI;
|
||||
|
||||
class SimpleSlider : public CSliderBase {
|
||||
public:
|
||||
SimpleSlider(const CRect& bounds, IControlListener* listener, int32_t tag);
|
||||
void draw(CDrawContext* dc) override;
|
||||
|
||||
CLASS_METHODS(SimpleSlider, CSliderBase)
|
||||
|
||||
private:
|
||||
CColor _frame = CColor(0x00, 0x00, 0x00);
|
||||
CColor _fill = CColor(0x00, 0x00, 0x00);
|
||||
};
|
||||
167
vst/RTSemaphore.h
Normal file
167
vst/RTSemaphore.h
Normal file
|
|
@ -0,0 +1,167 @@
|
|||
// Copyright Jean Pierre Cimalando 2018-2020.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#pragma once
|
||||
#if defined(__APPLE__)
|
||||
#include <mach/mach.h>
|
||||
#elif defined(_WIN32)
|
||||
#include <limits.h>
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <semaphore.h>
|
||||
#include <errno.h>
|
||||
#endif
|
||||
#include <stdexcept>
|
||||
|
||||
class RTSemaphore {
|
||||
public:
|
||||
explicit RTSemaphore(unsigned value = 0);
|
||||
~RTSemaphore();
|
||||
|
||||
RTSemaphore(const RTSemaphore &) = delete;
|
||||
RTSemaphore &operator=(const RTSemaphore &) = delete;
|
||||
|
||||
void post();
|
||||
void wait();
|
||||
bool try_wait();
|
||||
|
||||
private:
|
||||
#if defined(__APPLE__)
|
||||
semaphore_t sem_;
|
||||
#elif defined(_WIN32)
|
||||
HANDLE sem_;
|
||||
#else
|
||||
sem_t sem_;
|
||||
#endif
|
||||
};
|
||||
|
||||
#if defined(__APPLE__)
|
||||
inline RTSemaphore::RTSemaphore(unsigned value)
|
||||
{
|
||||
if (semaphore_create(mach_task_self(), &sem_, SYNC_POLICY_FIFO, value) != 0)
|
||||
throw std::runtime_error("RTSemaphore::RTSemaphore");
|
||||
}
|
||||
|
||||
inline RTSemaphore::~RTSemaphore()
|
||||
{
|
||||
semaphore_destroy(mach_task_self(), sem_);
|
||||
}
|
||||
|
||||
inline void RTSemaphore::post()
|
||||
{
|
||||
if (semaphore_signal(sem_) != KERN_SUCCESS)
|
||||
throw std::runtime_error("RTSemaphore::post");
|
||||
}
|
||||
|
||||
inline void RTSemaphore::wait()
|
||||
{
|
||||
do {
|
||||
switch (semaphore_wait(sem_)) {
|
||||
case KERN_SUCCESS:
|
||||
return;
|
||||
case KERN_ABORTED:
|
||||
break;
|
||||
default:
|
||||
throw std::runtime_error("RTSemaphore::wait");
|
||||
}
|
||||
} while (1);
|
||||
}
|
||||
|
||||
inline bool RTSemaphore::try_wait()
|
||||
{
|
||||
do {
|
||||
const mach_timespec_t timeout = {0, 0};
|
||||
switch (semaphore_timedwait(sem_, timeout)) {
|
||||
case KERN_SUCCESS:
|
||||
return true;
|
||||
case KERN_OPERATION_TIMED_OUT:
|
||||
return false;
|
||||
case KERN_ABORTED:
|
||||
break;
|
||||
default:
|
||||
throw std::runtime_error("RTSemaphore::try_wait");
|
||||
}
|
||||
} while (1);
|
||||
}
|
||||
#elif defined(_WIN32)
|
||||
inline RTSemaphore::RTSemaphore(unsigned value)
|
||||
{
|
||||
sem_ = CreateSemaphore(nullptr, value, LONG_MAX, nullptr);
|
||||
if (!sem_)
|
||||
throw std::runtime_error("RTSemaphore::RTSemaphore");
|
||||
}
|
||||
|
||||
inline RTSemaphore::~RTSemaphore()
|
||||
{
|
||||
CloseHandle(sem_);
|
||||
}
|
||||
|
||||
inline void RTSemaphore::post()
|
||||
{
|
||||
if (!ReleaseSemaphore(sem_, 1, nullptr))
|
||||
throw std::runtime_error("RTSemaphore::post");
|
||||
}
|
||||
|
||||
inline void RTSemaphore::wait()
|
||||
{
|
||||
if (WaitForSingleObject(sem_, INFINITE) != WAIT_OBJECT_0)
|
||||
throw std::runtime_error("RTSemaphore::wait");
|
||||
}
|
||||
|
||||
inline bool RTSemaphore::try_wait()
|
||||
{
|
||||
switch (WaitForSingleObject(sem_, 0)) {
|
||||
case WAIT_OBJECT_0:
|
||||
return true;
|
||||
case WAIT_TIMEOUT:
|
||||
return false;
|
||||
default:
|
||||
throw std::runtime_error("RTSemaphore::try_wait");
|
||||
}
|
||||
}
|
||||
#else
|
||||
inline RTSemaphore::RTSemaphore(unsigned value)
|
||||
{
|
||||
if (sem_init(&sem_, 0, value) != 0)
|
||||
throw std::runtime_error("RTSemaphore::RTSemaphore");
|
||||
}
|
||||
|
||||
inline RTSemaphore::~RTSemaphore()
|
||||
{
|
||||
sem_destroy(&sem_);
|
||||
}
|
||||
|
||||
inline void RTSemaphore::post()
|
||||
{
|
||||
while (sem_post(&sem_) != 0) {
|
||||
if (errno != EINTR)
|
||||
throw std::runtime_error("RTSemaphore::post");
|
||||
}
|
||||
}
|
||||
|
||||
inline void RTSemaphore::wait()
|
||||
{
|
||||
while (sem_wait(&sem_) != 0) {
|
||||
if (errno != EINTR)
|
||||
throw std::runtime_error("RTSemaphore::wait");
|
||||
}
|
||||
}
|
||||
|
||||
inline bool RTSemaphore::try_wait()
|
||||
{
|
||||
do {
|
||||
if (sem_trywait(&sem_) == 0)
|
||||
return true;
|
||||
switch (errno) {
|
||||
case EINTR:
|
||||
break;
|
||||
case EAGAIN:
|
||||
return false;
|
||||
default:
|
||||
throw std::runtime_error("RTSemaphore::try_wait");
|
||||
}
|
||||
} while (1);
|
||||
}
|
||||
#endif
|
||||
248
vst/SfizzVstController.cpp
Normal file
248
vst/SfizzVstController.cpp
Normal file
|
|
@ -0,0 +1,248 @@
|
|||
// SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
// This code is part of the sfizz library and is licensed under a BSD 2-clause
|
||||
// license. You should have receive a LICENSE.md file along with the code.
|
||||
// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz
|
||||
|
||||
#include "SfizzVstController.h"
|
||||
#include "SfizzVstEditor.h"
|
||||
#include "base/source/fstreamer.h"
|
||||
#include "pluginterfaces/vst/ivstmidicontrollers.h"
|
||||
|
||||
tresult PLUGIN_API SfizzVstControllerNoUi::initialize(FUnknown* context)
|
||||
{
|
||||
tresult result = EditController::initialize(context);
|
||||
if (result != kResultTrue)
|
||||
return result;
|
||||
|
||||
Vst::ParamID pid = 0;
|
||||
|
||||
// Ordinary parameters
|
||||
parameters.addParameter(
|
||||
kParamVolumeRange.createParameter(
|
||||
Steinberg::String("Volume"), pid++, Steinberg::String("dB"),
|
||||
0, Vst::ParameterInfo::kCanAutomate, Vst::kRootUnitId));
|
||||
parameters.addParameter(
|
||||
kParamNumVoicesRange.createParameter(
|
||||
Steinberg::String("Polyphony"), pid++, nullptr,
|
||||
0, Vst::ParameterInfo::kNoFlags, Vst::kRootUnitId));
|
||||
parameters.addParameter(
|
||||
kParamOversamplingRange.createParameter(
|
||||
Steinberg::String("Oversampling"), pid++, nullptr,
|
||||
0, Vst::ParameterInfo::kNoFlags, Vst::kRootUnitId));
|
||||
parameters.addParameter(
|
||||
kParamPreloadSizeRange.createParameter(
|
||||
Steinberg::String("Preload size"), pid++, nullptr,
|
||||
0, Vst::ParameterInfo::kNoFlags, Vst::kRootUnitId));
|
||||
|
||||
// MIDI special controllers
|
||||
parameters.addParameter(Steinberg::String("Aftertouch"), nullptr, 0, 0.5, 0, pid++, Vst::kRootUnitId);
|
||||
parameters.addParameter(Steinberg::String("Pitch Bend"), nullptr, 0, 0.5, 0, pid++, Vst::kRootUnitId);
|
||||
|
||||
// MIDI controllers
|
||||
for (unsigned i = 0; i < kNumControllerParams; ++i) {
|
||||
Steinberg::String title;
|
||||
Steinberg::String shortTitle;
|
||||
title.printf("Controller %u", i);
|
||||
shortTitle.printf("CC%u", i);
|
||||
|
||||
parameters.addParameter(
|
||||
title, nullptr, 0, 0, Vst::ParameterInfo::kCanAutomate,
|
||||
pid++, Vst::kRootUnitId, shortTitle);
|
||||
}
|
||||
|
||||
return kResultTrue;
|
||||
}
|
||||
|
||||
tresult PLUGIN_API SfizzVstControllerNoUi::terminate()
|
||||
{
|
||||
return EditController::terminate();
|
||||
}
|
||||
|
||||
tresult PLUGIN_API SfizzVstControllerNoUi::getMidiControllerAssignment(int32 busIndex, int16 channel, Vst::CtrlNumber midiControllerNumber, Vst::ParamID& id)
|
||||
{
|
||||
switch (midiControllerNumber) {
|
||||
case Vst::kAfterTouch:
|
||||
id = kPidMidiAftertouch;
|
||||
return kResultTrue;
|
||||
|
||||
case Vst::kPitchBend:
|
||||
id = kPidMidiPitchBend;
|
||||
return kResultTrue;
|
||||
|
||||
default:
|
||||
if (midiControllerNumber < 0 || midiControllerNumber >= kNumControllerParams)
|
||||
return kResultFalse;
|
||||
|
||||
id = kPidMidiCC0 + midiControllerNumber;
|
||||
return kResultTrue;
|
||||
}
|
||||
}
|
||||
|
||||
tresult PLUGIN_API SfizzVstControllerNoUi::getParamStringByValue(Vst::ParamID tag, Vst::ParamValue valueNormalized, Vst::String128 string)
|
||||
{
|
||||
switch (tag) {
|
||||
case kPidOversampling:
|
||||
{
|
||||
int factorLog2 = kParamOversamplingRange.denormalize(valueNormalized);
|
||||
Steinberg::String buf;
|
||||
buf.printf("%dX", 1 << factorLog2);
|
||||
buf.copyTo(string);
|
||||
return kResultTrue;
|
||||
}
|
||||
}
|
||||
|
||||
return EditController::getParamStringByValue(tag, valueNormalized, string);
|
||||
}
|
||||
|
||||
tresult PLUGIN_API SfizzVstControllerNoUi::getParamValueByString(Vst::ParamID tag, Vst::TChar* string, Vst::ParamValue& valueNormalized)
|
||||
{
|
||||
switch (tag) {
|
||||
case kPidOversampling:
|
||||
{
|
||||
int32 factor;
|
||||
if (!Steinberg::String::scanInt32(string, factor, false) || factor < 1)
|
||||
factor = 1;
|
||||
|
||||
int32 log2Factor = 0;
|
||||
for (int32 f = factor; f > 1; f /= 2)
|
||||
++log2Factor;
|
||||
|
||||
valueNormalized = kParamOversamplingRange.normalize(log2Factor);
|
||||
return kResultTrue;
|
||||
}
|
||||
}
|
||||
|
||||
return EditController::getParamValueByString(tag, string, valueNormalized);
|
||||
}
|
||||
|
||||
// --- Controller with UI --- //
|
||||
|
||||
IPlugView* PLUGIN_API SfizzVstController::createView(FIDString _name)
|
||||
{
|
||||
ConstString name(_name);
|
||||
|
||||
fprintf(stderr, "[sfizz] about to create view: %s\n", _name);
|
||||
|
||||
if (name != Vst::ViewType::kEditor)
|
||||
return nullptr;
|
||||
|
||||
return new SfizzVstEditor(this);
|
||||
}
|
||||
|
||||
tresult PLUGIN_API SfizzVstController::setParamNormalized(Vst::ParamID tag, Vst::ParamValue normValue)
|
||||
{
|
||||
tresult r = SfizzVstControllerNoUi::setParamNormalized(tag, normValue);
|
||||
if (r != kResultTrue)
|
||||
return r;
|
||||
|
||||
float *slotF32 = nullptr;
|
||||
int32 *slotI32 = nullptr;
|
||||
float value = 0;
|
||||
|
||||
switch (tag) {
|
||||
case kPidVolume: {
|
||||
slotF32 = &_state.volume;
|
||||
value = kParamVolumeRange.denormalize(normValue);
|
||||
break;
|
||||
}
|
||||
case kPidNumVoices: {
|
||||
slotI32 = &_state.numVoices;
|
||||
value = kParamNumVoicesRange.denormalize(normValue);
|
||||
break;
|
||||
}
|
||||
case kPidOversampling: {
|
||||
slotI32 = &_state.oversamplingLog2;
|
||||
value = kParamOversamplingRange.denormalize(normValue);
|
||||
break;
|
||||
}
|
||||
case kPidPreloadSize: {
|
||||
slotI32 = &_state.preloadSize;
|
||||
value = kParamPreloadSizeRange.denormalize(normValue);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool update = false;
|
||||
|
||||
if (slotF32 && *slotF32 != value) {
|
||||
*slotF32 = value;
|
||||
update = true;
|
||||
}
|
||||
else if (slotI32 && *slotI32 != (int32)value) {
|
||||
*slotI32 = (int32)value;
|
||||
update = true;
|
||||
}
|
||||
|
||||
if (update) {
|
||||
for (StateListener* listener : _stateListeners)
|
||||
listener->onStateChanged();
|
||||
}
|
||||
|
||||
return kResultTrue;
|
||||
}
|
||||
|
||||
tresult PLUGIN_API SfizzVstController::setState(IBStream* state)
|
||||
{
|
||||
SfizzUiState s;
|
||||
|
||||
tresult r = s.load(state);
|
||||
if (r != kResultTrue)
|
||||
return r;
|
||||
|
||||
_uiState = s;
|
||||
|
||||
for (StateListener* listener : _stateListeners)
|
||||
listener->onStateChanged();
|
||||
|
||||
return kResultTrue;
|
||||
}
|
||||
|
||||
tresult PLUGIN_API SfizzVstController::getState(IBStream* state)
|
||||
{
|
||||
return _uiState.store(state);
|
||||
}
|
||||
|
||||
tresult PLUGIN_API SfizzVstController::setComponentState(IBStream* state)
|
||||
{
|
||||
SfizzVstState s;
|
||||
|
||||
tresult r = s.load(state);
|
||||
if (r != kResultTrue)
|
||||
return r;
|
||||
|
||||
_state = s;
|
||||
|
||||
setParamNormalized(kPidVolume, kParamVolumeRange.normalize(s.volume));
|
||||
setParamNormalized(kPidNumVoices, kParamNumVoicesRange.normalize(s.numVoices));
|
||||
setParamNormalized(kPidOversampling, kParamOversamplingRange.normalize(s.oversamplingLog2));
|
||||
setParamNormalized(kPidPreloadSize, kParamPreloadSizeRange.normalize(s.preloadSize));
|
||||
|
||||
for (StateListener* listener : _stateListeners)
|
||||
listener->onStateChanged();
|
||||
|
||||
return kResultTrue;
|
||||
}
|
||||
|
||||
void SfizzVstController::addSfizzStateListener(StateListener* listener)
|
||||
{
|
||||
_stateListeners.push_back(listener);
|
||||
}
|
||||
|
||||
void SfizzVstController::removeSfizzStateListener(StateListener* listener)
|
||||
{
|
||||
auto it = std::find(_stateListeners.begin(), _stateListeners.end(), listener);
|
||||
if (it != _stateListeners.end())
|
||||
_stateListeners.erase(it);
|
||||
}
|
||||
|
||||
FUnknown* SfizzVstController::createInstance(void*)
|
||||
{
|
||||
return static_cast<Vst::IEditController*>(new SfizzVstController);
|
||||
}
|
||||
|
||||
/*
|
||||
Note(jpc) Generated at random with uuidgen.
|
||||
Can't find docs on it... maybe it's to register somewhere?
|
||||
*/
|
||||
FUID SfizzVstController::cid(0x7129736c, 0xbc784134, 0xbb899d56, 0x2ebafe4f);
|
||||
69
vst/SfizzVstController.h
Normal file
69
vst/SfizzVstController.h
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
// SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
// This code is part of the sfizz library and is licensed under a BSD 2-clause
|
||||
// license. You should have receive a LICENSE.md file along with the code.
|
||||
// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz
|
||||
|
||||
#pragma once
|
||||
#include "SfizzVstState.h"
|
||||
#include "public.sdk/source/vst/vsteditcontroller.h"
|
||||
#include "public.sdk/source/vst/vstparameters.h"
|
||||
#include "vstgui/plugin-bindings/vst3editor.h"
|
||||
class SfizzVstState;
|
||||
|
||||
using namespace Steinberg;
|
||||
using namespace VSTGUI;
|
||||
|
||||
class SfizzVstControllerNoUi : public Vst::EditController,
|
||||
public Vst::IMidiMapping {
|
||||
public:
|
||||
virtual ~SfizzVstControllerNoUi() {}
|
||||
|
||||
tresult PLUGIN_API initialize(FUnknown* context) override;
|
||||
tresult PLUGIN_API terminate() override;
|
||||
|
||||
tresult PLUGIN_API getMidiControllerAssignment(int32 busIndex, int16 channel, Vst::CtrlNumber midiControllerNumber, Vst::ParamID& id) override;
|
||||
|
||||
tresult PLUGIN_API getParamStringByValue(Vst::ParamID tag, Vst::ParamValue valueNormalized, Vst::String128 string) override;
|
||||
tresult PLUGIN_API getParamValueByString(Vst::ParamID tag, Vst::TChar* string, Vst::ParamValue& valueNormalized) override;
|
||||
|
||||
|
||||
// interfaces
|
||||
OBJ_METHODS(SfizzVstControllerNoUi, Vst::EditController)
|
||||
DEFINE_INTERFACES
|
||||
DEF_INTERFACE(Vst::IMidiMapping)
|
||||
END_DEFINE_INTERFACES(Vst::EditController)
|
||||
REFCOUNT_METHODS(Vst::EditController)
|
||||
};
|
||||
|
||||
class SfizzVstController : public SfizzVstControllerNoUi, public VSTGUI::VST3EditorDelegate {
|
||||
public:
|
||||
IPlugView* PLUGIN_API createView(FIDString name) override;
|
||||
|
||||
tresult PLUGIN_API setParamNormalized(Vst::ParamID tag, Vst::ParamValue value) override;
|
||||
tresult PLUGIN_API setState(IBStream* state) override;
|
||||
tresult PLUGIN_API getState(IBStream* state) override;
|
||||
tresult PLUGIN_API setComponentState(IBStream* state) override;
|
||||
|
||||
struct StateListener {
|
||||
virtual void onStateChanged() = 0;
|
||||
};
|
||||
|
||||
const SfizzVstState& getSfizzState() const { return _state; }
|
||||
|
||||
const SfizzUiState& getSfizzUiState() const { return _uiState; }
|
||||
SfizzUiState& getSfizzUiState() { return _uiState; }
|
||||
|
||||
void addSfizzStateListener(StateListener* listener);
|
||||
void removeSfizzStateListener(StateListener* listener);
|
||||
|
||||
///
|
||||
static FUnknown* createInstance(void*);
|
||||
|
||||
static FUID cid;
|
||||
|
||||
private:
|
||||
SfizzVstState _state;
|
||||
SfizzUiState _uiState;
|
||||
std::vector<StateListener*> _stateListeners;
|
||||
};
|
||||
391
vst/SfizzVstEditor.cpp
Normal file
391
vst/SfizzVstEditor.cpp
Normal file
|
|
@ -0,0 +1,391 @@
|
|||
// SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
// This code is part of the sfizz library and is licensed under a BSD 2-clause
|
||||
// license. You should have receive a LICENSE.md file along with the code.
|
||||
// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz
|
||||
|
||||
#include "SfizzVstEditor.h"
|
||||
#include "SfizzVstState.h"
|
||||
#include "GUIComponents.h"
|
||||
#if !defined(__APPLE__) && !defined(_WIN32)
|
||||
#include "x11runloop.h"
|
||||
#endif
|
||||
|
||||
using namespace VSTGUI;
|
||||
|
||||
SfizzVstEditor::SfizzVstEditor(void *controller)
|
||||
: VSTGUIEditor(controller),
|
||||
_logo("logo.png")
|
||||
{
|
||||
getController()->addSfizzStateListener(this);
|
||||
}
|
||||
|
||||
SfizzVstEditor::~SfizzVstEditor()
|
||||
{
|
||||
getController()->removeSfizzStateListener(this);
|
||||
}
|
||||
|
||||
bool PLUGIN_API SfizzVstEditor::open(void* parent, const VSTGUI::PlatformType& platformType)
|
||||
{
|
||||
fprintf(stderr, "[sfizz] about to open view with parent %p\n", parent);
|
||||
|
||||
CRect wsize(0, 0, _logo.getWidth(), _logo.getHeight());
|
||||
CFrame *frame = new CFrame(wsize, this);
|
||||
this->frame = frame;
|
||||
|
||||
IPlatformFrameConfig* config = nullptr;
|
||||
|
||||
#if !defined(__APPLE__) && !defined(_WIN32)
|
||||
X11::FrameConfig x11config;
|
||||
x11config.runLoop = VSTGUI::owned(new RunLoop(plugFrame));
|
||||
config = &x11config;
|
||||
#endif
|
||||
|
||||
createFrameContents();
|
||||
updateStateDisplay();
|
||||
|
||||
if (!frame->open(parent, platformType, config)) {
|
||||
fprintf(stderr, "[sfizz] error opening frame\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void PLUGIN_API SfizzVstEditor::close()
|
||||
{
|
||||
CFrame *frame = this->frame;
|
||||
if (frame) {
|
||||
frame->forget();
|
||||
this->frame = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
void SfizzVstEditor::valueChanged(CControl* ctl)
|
||||
{
|
||||
int32_t tag = ctl->getTag();
|
||||
float value = ctl->getValue();
|
||||
float valueNorm = ctl->getValueNormalized();
|
||||
SfizzVstController* controller = getController();
|
||||
|
||||
switch (tag) {
|
||||
case kTagLoadSfzFile:
|
||||
if (value != 1)
|
||||
break;
|
||||
|
||||
Call::later([this]() { chooseSfzFile(); });
|
||||
break;
|
||||
|
||||
case kTagSetVolume:
|
||||
controller->setParamNormalized(kPidVolume, valueNorm);
|
||||
controller->performEdit(kPidVolume, valueNorm);
|
||||
break;
|
||||
|
||||
case kTagSetNumVoices:
|
||||
controller->setParamNormalized(kPidNumVoices, valueNorm);
|
||||
controller->performEdit(kPidNumVoices, valueNorm);
|
||||
break;
|
||||
|
||||
case kTagSetOversampling:
|
||||
controller->setParamNormalized(kPidOversampling, valueNorm);
|
||||
controller->performEdit(kPidOversampling, valueNorm);
|
||||
break;
|
||||
|
||||
case kTagSetPreloadSize:
|
||||
controller->setParamNormalized(kPidPreloadSize, valueNorm);
|
||||
controller->performEdit(kPidPreloadSize, valueNorm);
|
||||
break;
|
||||
|
||||
default:
|
||||
if (tag >= kTagFirstChangePanel && tag <= kTagLastChangePanel)
|
||||
setActivePanel(tag - kTagFirstChangePanel);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void SfizzVstEditor::enterOrLeaveEdit(CControl* ctl, bool enter)
|
||||
{
|
||||
int32_t tag = ctl->getTag();
|
||||
Vst::ParamID id;
|
||||
|
||||
switch (tag) {
|
||||
case kTagSetVolume: id = kPidVolume; break;
|
||||
case kTagSetNumVoices: id = kPidNumVoices; break;
|
||||
case kTagSetOversampling: id = kPidOversampling; break;
|
||||
case kTagSetPreloadSize: id = kPidPreloadSize; break;
|
||||
default: return;
|
||||
}
|
||||
|
||||
SfizzVstController* controller = getController();
|
||||
if (enter)
|
||||
controller->beginEdit(id);
|
||||
else
|
||||
controller->endEdit(id);
|
||||
}
|
||||
|
||||
void SfizzVstEditor::controlBeginEdit(CControl* ctl)
|
||||
{
|
||||
enterOrLeaveEdit(ctl, true);
|
||||
}
|
||||
|
||||
void SfizzVstEditor::controlEndEdit(CControl* ctl)
|
||||
{
|
||||
enterOrLeaveEdit(ctl, false);
|
||||
}
|
||||
|
||||
void SfizzVstEditor::onStateChanged()
|
||||
{
|
||||
updateStateDisplay();
|
||||
}
|
||||
|
||||
///
|
||||
void SfizzVstEditor::chooseSfzFile()
|
||||
{
|
||||
SharedPointer<CNewFileSelector> fs(CNewFileSelector::create(frame));
|
||||
|
||||
fs->setTitle("Load SFZ file");
|
||||
fs->setDefaultExtension(CFileExtension("SFZ", "sfz"));
|
||||
|
||||
if (fs->runModal()) {
|
||||
UTF8StringPtr file = fs->getSelectedFile(0);
|
||||
if (file)
|
||||
loadSfzFile(file);
|
||||
}
|
||||
}
|
||||
|
||||
void SfizzVstEditor::loadSfzFile(const std::string& filePath)
|
||||
{
|
||||
SfizzVstController* ctl = getController();
|
||||
|
||||
Vst::IMessage *msg = ctl->allocateMessage();
|
||||
if (!msg) {
|
||||
fprintf(stderr, "[Sfizz] UI could not allocate message\n");
|
||||
return;
|
||||
}
|
||||
|
||||
msg->setMessageID("LoadSfz");
|
||||
Vst::IAttributeList* attr = msg->getAttributes();
|
||||
attr->setString("File", Steinberg::String(filePath.c_str()).text());
|
||||
ctl->sendMessage(msg);
|
||||
msg->release();
|
||||
|
||||
if (_fileLabel)
|
||||
_fileLabel->setText(("File: " + filePath).c_str());
|
||||
}
|
||||
|
||||
void SfizzVstEditor::createFrameContents()
|
||||
{
|
||||
SfizzVstController* controller = getController();
|
||||
const SfizzUiState& uiState = controller->getSfizzUiState();
|
||||
|
||||
CFrame* frame = this->frame;
|
||||
CRect bounds = frame->getViewSize();
|
||||
|
||||
frame->setBackgroundColor(CColor(0xff, 0xff, 0xff));
|
||||
|
||||
CRect bottomRow = bounds;
|
||||
bottomRow.top = bottomRow.bottom - 30;
|
||||
|
||||
CRect topRow = bounds;
|
||||
topRow.bottom = topRow.top + 30;
|
||||
|
||||
CViewContainer* panel;
|
||||
_activePanel = std::max(0, std::min(kNumPanels - 1, static_cast<int>(uiState.activePanel)));
|
||||
|
||||
CRect topLeftLabelBox = topRow;
|
||||
topLeftLabelBox.right -= 20 * kNumPanels;
|
||||
|
||||
// general panel
|
||||
{
|
||||
panel = new CViewContainer(bounds);
|
||||
frame->addView(panel);
|
||||
panel->setTransparency(true);
|
||||
|
||||
CKickButton* sfizzButton = new CKickButton(bounds, this, kTagLoadSfzFile, &_logo);
|
||||
panel->addView(sfizzButton);
|
||||
|
||||
CTextLabel* topLeftLabel = new CTextLabel(topLeftLabelBox, "No file loaded");
|
||||
topLeftLabel->setFontColor(CColor(0x00, 0x00, 0x00));
|
||||
topLeftLabel->setBackColor(CColor(0x00, 0x00, 0x00, 0x00));
|
||||
panel->addView(topLeftLabel);
|
||||
_fileLabel = topLeftLabel;
|
||||
|
||||
_subPanels[kPanelGeneral] = panel;
|
||||
}
|
||||
|
||||
// settings panel
|
||||
{
|
||||
panel = new CViewContainer(bounds);
|
||||
frame->addView(panel);
|
||||
panel->setTransparency(true);
|
||||
|
||||
CTextLabel* topLeftLabel = new CTextLabel(topLeftLabelBox, "Settings");
|
||||
topLeftLabel->setFontColor(CColor(0x00, 0x00, 0x00));
|
||||
topLeftLabel->setBackColor(CColor(0x00, 0x00, 0x00, 0x00));
|
||||
panel->addView(topLeftLabel);
|
||||
|
||||
CRect row = topRow;
|
||||
row.top += 200.0;
|
||||
row.bottom += 200.0;
|
||||
row.left += 100.0;
|
||||
row.right -= 100.0;
|
||||
|
||||
CCoord interRow = 35.0;
|
||||
|
||||
auto leftSide = [&row]() -> CRect {
|
||||
CRect div = row;
|
||||
div.right = 0.5 * (div.left + div.right);
|
||||
return div;
|
||||
};
|
||||
|
||||
auto rightSide = [&row]() -> CRect {
|
||||
CRect div = row;
|
||||
div.left = 0.5 * (div.left + div.right);
|
||||
return div;
|
||||
};
|
||||
|
||||
CTextLabel* label;
|
||||
SimpleSlider* slider;
|
||||
|
||||
label = new CTextLabel(leftSide(), "Volume");
|
||||
label->setFontColor(CColor(0x00, 0x00, 0x00));
|
||||
label->setFrameColor(CColor(0x00, 0x00, 0x00, 0x00));
|
||||
label->setBackColor(CColor(0x00, 0x00, 0x00, 0x00));
|
||||
label->setHoriAlign(kLeftText);
|
||||
panel->addView(label);
|
||||
slider = new SimpleSlider(rightSide(), this, kTagSetVolume);
|
||||
panel->addView(slider);
|
||||
adjustMinMaxToRangeParam(slider, kPidVolume);
|
||||
_volumeSlider = slider;
|
||||
|
||||
row.top += interRow;
|
||||
row.bottom += interRow;
|
||||
|
||||
label = new CTextLabel(leftSide(), "Polyphony");
|
||||
label->setFontColor(CColor(0x00, 0x00, 0x00));
|
||||
label->setFrameColor(CColor(0x00, 0x00, 0x00, 0x00));
|
||||
label->setBackColor(CColor(0x00, 0x00, 0x00, 0x00));
|
||||
label->setHoriAlign(kLeftText);
|
||||
panel->addView(label);
|
||||
slider = new SimpleSlider(rightSide(), this, kTagSetNumVoices);
|
||||
panel->addView(slider);
|
||||
adjustMinMaxToRangeParam(slider, kPidNumVoices);
|
||||
_numVoicesSlider = slider;
|
||||
|
||||
row.top += interRow;
|
||||
row.bottom += interRow;
|
||||
|
||||
label = new CTextLabel(leftSide(), "Oversampling");
|
||||
label->setFontColor(CColor(0x00, 0x00, 0x00));
|
||||
label->setFrameColor(CColor(0x00, 0x00, 0x00, 0x00));
|
||||
label->setBackColor(CColor(0x00, 0x00, 0x00, 0x00));
|
||||
label->setHoriAlign(kLeftText);
|
||||
panel->addView(label);
|
||||
slider = new SimpleSlider(rightSide(), this, kTagSetOversampling);
|
||||
panel->addView(slider);
|
||||
adjustMinMaxToRangeParam(slider, kPidOversampling);
|
||||
_oversamplingSlider = slider;
|
||||
|
||||
row.top += interRow;
|
||||
row.bottom += interRow;
|
||||
|
||||
label = new CTextLabel(leftSide(), "Preload size");
|
||||
label->setFontColor(CColor(0x00, 0x00, 0x00));
|
||||
label->setFrameColor(CColor(0x00, 0x00, 0x00, 0x00));
|
||||
label->setBackColor(CColor(0x00, 0x00, 0x00, 0x00));
|
||||
label->setHoriAlign(kLeftText);
|
||||
panel->addView(label);
|
||||
slider = new SimpleSlider(rightSide(), this, kTagSetPreloadSize);
|
||||
panel->addView(slider);
|
||||
adjustMinMaxToRangeParam(slider, kPidPreloadSize);
|
||||
_preloadSizeSlider = slider;
|
||||
|
||||
// row.top += interRow;
|
||||
// row.bottom += interRow;
|
||||
|
||||
// label = new CTextLabel(leftSide(), "Freewheel");
|
||||
// label->setFontColor(CColor(0x00, 0x00, 0x00));
|
||||
// label->setFrameColor(CColor(0x00, 0x00, 0x00, 0x00));
|
||||
// label->setBackColor(CColor(0x00, 0x00, 0x00, 0x00));
|
||||
// label->setHoriAlign(kLeftText);
|
||||
// panel->addView(label);
|
||||
// slider = new SimpleSlider(rightSide(), this, kTag);
|
||||
// panel->addView(slider);
|
||||
// adjustMinMaxToRangeParam(slider, kPid);
|
||||
// _aSlider = slider;
|
||||
|
||||
_subPanels[kPanelSettings] = panel;
|
||||
}
|
||||
|
||||
// all panels
|
||||
for (unsigned currentPanel = 0; currentPanel < kNumPanels; ++currentPanel) {
|
||||
panel = _subPanels[currentPanel];
|
||||
|
||||
CTextLabel* descLabel = new CTextLabel(
|
||||
bottomRow, "Paul Ferrand and the SFZ Tools work group");
|
||||
descLabel->setFontColor(CColor(0x00, 0x00, 0x00));
|
||||
descLabel->setBackColor(CColor(0x00, 0x00, 0x00, 0x00));
|
||||
panel->addView(descLabel);
|
||||
|
||||
for (unsigned i = 0; i < kNumPanels; ++i) {
|
||||
CRect btnRect = topRow;
|
||||
btnRect.left = topRow.right - (kNumPanels - i) * 20;
|
||||
btnRect.right = btnRect.left + 20;
|
||||
|
||||
const char *text;
|
||||
switch (i) {
|
||||
case kPanelGeneral: text = "G"; break;
|
||||
case kPanelSettings: text = "S"; break;
|
||||
default: text = "?"; break;
|
||||
}
|
||||
|
||||
CTextButton* changePanelButton = new CTextButton(btnRect, this, kTagFirstChangePanel + i, text);
|
||||
panel->addView(changePanelButton);
|
||||
|
||||
changePanelButton->setRoundRadius(0.0);
|
||||
}
|
||||
|
||||
panel->setVisible(currentPanel == _activePanel);
|
||||
}
|
||||
}
|
||||
|
||||
void SfizzVstEditor::updateStateDisplay()
|
||||
{
|
||||
if (!frame)
|
||||
return;
|
||||
|
||||
SfizzVstController* controller = getController();
|
||||
const SfizzVstState& state = controller->getSfizzState();
|
||||
const SfizzUiState& uiState = controller->getSfizzUiState();
|
||||
|
||||
if (_fileLabel)
|
||||
_fileLabel->setText(("File: " + state.sfzFile).c_str());
|
||||
if (_volumeSlider)
|
||||
_volumeSlider->setValue(state.volume);
|
||||
if (_numVoicesSlider)
|
||||
_numVoicesSlider->setValue(state.numVoices);
|
||||
if (_oversamplingSlider)
|
||||
_oversamplingSlider->setValue(state.oversamplingLog2);
|
||||
if (_preloadSizeSlider)
|
||||
_preloadSizeSlider->setValue(state.preloadSize);
|
||||
|
||||
setActivePanel(uiState.activePanel);
|
||||
}
|
||||
|
||||
void SfizzVstEditor::setActivePanel(unsigned panelId)
|
||||
{
|
||||
panelId = std::max(0, std::min(kNumPanels - 1, static_cast<int>(panelId)));
|
||||
|
||||
getController()->getSfizzUiState().activePanel = panelId;
|
||||
|
||||
if (_activePanel != panelId) {
|
||||
if (frame)
|
||||
_subPanels[_activePanel]->setVisible(false);
|
||||
|
||||
_activePanel = panelId;
|
||||
|
||||
if (frame)
|
||||
_subPanels[panelId]->setVisible(true);
|
||||
}
|
||||
}
|
||||
78
vst/SfizzVstEditor.h
Normal file
78
vst/SfizzVstEditor.h
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
// SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
// This code is part of the sfizz library and is licensed under a BSD 2-clause
|
||||
// license. You should have receive a LICENSE.md file along with the code.
|
||||
// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz
|
||||
|
||||
#pragma once
|
||||
#include "SfizzVstController.h"
|
||||
#include "public.sdk/source/vst/vstguieditor.h"
|
||||
|
||||
using namespace Steinberg;
|
||||
using namespace VSTGUI;
|
||||
|
||||
class SfizzVstEditor : public Vst::VSTGUIEditor, public IControlListener, public SfizzVstController::StateListener {
|
||||
public:
|
||||
explicit SfizzVstEditor(void *controller);
|
||||
~SfizzVstEditor();
|
||||
|
||||
bool PLUGIN_API open(void* parent, const VSTGUI::PlatformType& platformType = VSTGUI::kDefaultNative) override;
|
||||
void PLUGIN_API close() override;
|
||||
|
||||
SfizzVstController* getController() const
|
||||
{
|
||||
return static_cast<SfizzVstController*>(Vst::VSTGUIEditor::getController());
|
||||
}
|
||||
|
||||
// IControlListener
|
||||
void valueChanged(CControl* ctl) override;
|
||||
void enterOrLeaveEdit(CControl* ctl, bool enter);
|
||||
void controlBeginEdit(CControl* ctl) override;
|
||||
void controlEndEdit(CControl* ctl) override;
|
||||
|
||||
// SfizzVstController::StateListener
|
||||
void onStateChanged() override;
|
||||
|
||||
private:
|
||||
void chooseSfzFile();
|
||||
void loadSfzFile(const std::string& filePath);
|
||||
|
||||
void createFrameContents();
|
||||
void updateStateDisplay();
|
||||
void setActivePanel(unsigned panelId);
|
||||
|
||||
template <class Control>
|
||||
void adjustMinMaxToRangeParam(Control* c, Vst::ParamID id)
|
||||
{
|
||||
auto* p = static_cast<Vst::RangeParameter*>(getController()->getParameterObject(id));
|
||||
c->setMin(p->getMin());
|
||||
c->setMax(p->getMax());
|
||||
}
|
||||
|
||||
enum {
|
||||
kPanelGeneral,
|
||||
// kPanelControls,
|
||||
kPanelSettings,
|
||||
kNumPanels,
|
||||
};
|
||||
|
||||
unsigned _activePanel = 0;
|
||||
CViewContainer* _subPanels[kNumPanels] = {};
|
||||
|
||||
enum {
|
||||
kTagLoadSfzFile,
|
||||
kTagSetVolume,
|
||||
kTagSetNumVoices,
|
||||
kTagSetOversampling,
|
||||
kTagSetPreloadSize,
|
||||
kTagFirstChangePanel,
|
||||
kTagLastChangePanel = kTagFirstChangePanel + kNumPanels - 1,
|
||||
};
|
||||
|
||||
CBitmap _logo;
|
||||
CTextLabel* _fileLabel = nullptr;
|
||||
CSliderBase *_volumeSlider = nullptr;
|
||||
CSliderBase *_numVoicesSlider = nullptr;
|
||||
CSliderBase *_oversamplingSlider = nullptr;
|
||||
CSliderBase *_preloadSizeSlider = nullptr;
|
||||
};
|
||||
399
vst/SfizzVstProcessor.cpp
Normal file
399
vst/SfizzVstProcessor.cpp
Normal file
|
|
@ -0,0 +1,399 @@
|
|||
// SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
// This code is part of the sfizz library and is licensed under a BSD 2-clause
|
||||
// license. You should have receive a LICENSE.md file along with the code.
|
||||
// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz
|
||||
|
||||
#include "SfizzVstProcessor.h"
|
||||
#include "SfizzVstController.h"
|
||||
#include "SfizzVstState.h"
|
||||
#include "base/source/fstreamer.h"
|
||||
#include "pluginterfaces/vst/ivstevents.h"
|
||||
#include "pluginterfaces/vst/ivstparameterchanges.h"
|
||||
#include <cstring>
|
||||
|
||||
#pragma message("TODO: send tempo")
|
||||
|
||||
SfizzVstProcessor::SfizzVstProcessor()
|
||||
: _fifoToWorker(1024)
|
||||
{
|
||||
setControllerClass(SfizzVstController::cid);
|
||||
}
|
||||
|
||||
SfizzVstProcessor::~SfizzVstProcessor()
|
||||
{
|
||||
setActive(false); // to be sure
|
||||
}
|
||||
|
||||
tresult PLUGIN_API SfizzVstProcessor::initialize(FUnknown* context)
|
||||
{
|
||||
tresult result = AudioEffect::initialize(context);
|
||||
if (result != kResultTrue)
|
||||
return result;
|
||||
|
||||
addAudioOutput(STR16("Audio Output"), Vst::SpeakerArr::kStereo);
|
||||
addEventInput(STR16("Event Input"), 1);
|
||||
|
||||
_state = SfizzVstState();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
tresult PLUGIN_API SfizzVstProcessor::setBusArrangements(Vst::SpeakerArrangement* inputs, int32 numIns, Vst::SpeakerArrangement* outputs, int32 numOuts)
|
||||
{
|
||||
bool isStereo = numIns == 0 && numOuts == 1 && outputs[0] == Vst::SpeakerArr::kStereo;
|
||||
|
||||
if (!isStereo)
|
||||
return kResultFalse;
|
||||
|
||||
return AudioEffect::setBusArrangements(inputs, numIns, outputs, numOuts);
|
||||
}
|
||||
|
||||
tresult PLUGIN_API SfizzVstProcessor::setState(IBStream* stream)
|
||||
{
|
||||
SfizzVstState s;
|
||||
|
||||
tresult r = s.load(stream);
|
||||
if (r != kResultTrue)
|
||||
return r;
|
||||
|
||||
std::lock_guard<std::mutex> lock(_processMutex);
|
||||
_state = s;
|
||||
|
||||
syncStateToSynth();
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
tresult PLUGIN_API SfizzVstProcessor::getState(IBStream* stream)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(_processMutex);
|
||||
return _state.store(stream);
|
||||
}
|
||||
|
||||
void SfizzVstProcessor::syncStateToSynth()
|
||||
{
|
||||
sfz::Sfizz* synth = _synth.get();
|
||||
|
||||
if (!synth)
|
||||
return;
|
||||
|
||||
synth->loadSfzFile(_state.sfzFile);
|
||||
synth->setVolume(_state.volume);
|
||||
synth->setNumVoices(_state.numVoices);
|
||||
synth->setOversamplingFactor(1 << _state.oversamplingLog2);
|
||||
synth->setPreloadSize(_state.preloadSize);
|
||||
}
|
||||
|
||||
tresult PLUGIN_API SfizzVstProcessor::canProcessSampleSize(int32 symbolicSampleSize)
|
||||
{
|
||||
if (symbolicSampleSize != Vst::kSample32)
|
||||
return kResultFalse;
|
||||
|
||||
return kResultTrue;
|
||||
}
|
||||
|
||||
tresult PLUGIN_API SfizzVstProcessor::setActive(TBool state)
|
||||
{
|
||||
stopBackgroundWork();
|
||||
_synth.reset();
|
||||
|
||||
if (state) {
|
||||
fprintf(stderr, "[Sfizz] new synth\n");
|
||||
sfz::Sfizz* synth = new sfz::Sfizz;
|
||||
_synth.reset(synth);
|
||||
|
||||
synth->setSampleRate(processSetup.sampleRate);
|
||||
synth->setSamplesPerBlock(processSetup.maxSamplesPerBlock);
|
||||
|
||||
syncStateToSynth();
|
||||
|
||||
_workRunning = true;
|
||||
_worker = std::thread([this]() { doBackgroundWork(); });
|
||||
}
|
||||
|
||||
return kResultTrue;
|
||||
}
|
||||
|
||||
tresult PLUGIN_API SfizzVstProcessor::process(Vst::ProcessData& data)
|
||||
{
|
||||
sfz::Sfizz& synth = *_synth;
|
||||
|
||||
if (Vst::IParameterChanges* pc = data.inputParameterChanges)
|
||||
processParameterChanges(*pc);
|
||||
|
||||
if (data.numOutputs < 1) // flush mode
|
||||
return kResultTrue;
|
||||
|
||||
uint32 numFrames = data.numSamples;
|
||||
constexpr uint32 numChannels = 2;
|
||||
float* outputs[numChannels];
|
||||
|
||||
assert(numChannels == data.outputs[0].numChannels);
|
||||
|
||||
for (unsigned c = 0; c < numChannels; ++c)
|
||||
outputs[c] = data.outputs[0].channelBuffers32[c];
|
||||
|
||||
std::unique_lock<std::mutex> lock(_processMutex, std::try_to_lock);
|
||||
|
||||
if (!lock.owns_lock()) {
|
||||
for (unsigned c = 0; c < numChannels; ++c)
|
||||
std::memset(outputs[c], 0, numFrames * sizeof(float));
|
||||
data.outputs[0].silenceFlags = 3;
|
||||
return kResultTrue;
|
||||
}
|
||||
|
||||
if (data.processMode == Vst::kOffline)
|
||||
synth.enableFreeWheeling();
|
||||
else
|
||||
synth.disableFreeWheeling();
|
||||
|
||||
if (Vst::IParameterChanges* pc = data.inputParameterChanges)
|
||||
processControllerChanges(*pc);
|
||||
|
||||
if (Vst::IEventList* events = data.inputEvents)
|
||||
processEvents(*events);
|
||||
|
||||
synth.setVolume(_state.volume);
|
||||
|
||||
synth.renderBlock(outputs, numFrames, numChannels);
|
||||
return kResultTrue;
|
||||
}
|
||||
|
||||
void SfizzVstProcessor::processParameterChanges(Vst::IParameterChanges& pc)
|
||||
{
|
||||
uint32 paramCount = pc.getParameterCount();
|
||||
|
||||
for (uint32 paramIndex = 0; paramIndex < paramCount; ++paramIndex) {
|
||||
Vst::IParamValueQueue* vq = pc.getParameterData(paramIndex);
|
||||
if (!vq)
|
||||
continue;
|
||||
|
||||
Vst::ParamID id = vq->getParameterId();
|
||||
uint32 pointCount = vq->getPointCount();
|
||||
int32 sampleOffset;
|
||||
Vst::ParamValue value;
|
||||
|
||||
switch (id) {
|
||||
case kPidVolume:
|
||||
if (pointCount > 0 && vq->getPoint(pointCount - 1, sampleOffset, value) == kResultTrue)
|
||||
_state.volume = kParamVolumeRange.denormalize(value);
|
||||
break;
|
||||
case kPidNumVoices:
|
||||
if (pointCount > 0 && vq->getPoint(pointCount - 1, sampleOffset, value) == kResultTrue) {
|
||||
Vst::IMessage* msg = allocateMessage();
|
||||
if (!msg)
|
||||
break;
|
||||
msg->setMessageID("SetNumVoices");
|
||||
Vst::IAttributeList* attr = msg->getAttributes();
|
||||
attr->setInt("NumVoices", kParamNumVoicesRange.denormalize(value));
|
||||
if (!_fifoToWorker.push(msg)) {
|
||||
msg->release();
|
||||
break;
|
||||
}
|
||||
_semaToWorker.post();
|
||||
}
|
||||
break;
|
||||
case kPidOversampling:
|
||||
if (pointCount > 0 && vq->getPoint(pointCount - 1, sampleOffset, value) == kResultTrue) {
|
||||
Vst::IMessage* msg = allocateMessage();
|
||||
if (!msg)
|
||||
break;
|
||||
msg->setMessageID("SetOversampling");
|
||||
Vst::IAttributeList* attr = msg->getAttributes();
|
||||
attr->setInt("Oversampling", kParamOversamplingRange.denormalize(value));
|
||||
if (!_fifoToWorker.push(msg)) {
|
||||
msg->release();
|
||||
break;
|
||||
}
|
||||
_semaToWorker.post();
|
||||
}
|
||||
break;
|
||||
case kPidPreloadSize:
|
||||
if (pointCount > 0 && vq->getPoint(pointCount - 1, sampleOffset, value) == kResultTrue) {
|
||||
Vst::IMessage* msg = allocateMessage();
|
||||
if (!msg)
|
||||
break;
|
||||
msg->setMessageID("SetPreloadSize");
|
||||
Vst::IAttributeList* attr = msg->getAttributes();
|
||||
attr->setInt("PreloadSize", kParamPreloadSizeRange.denormalize(value));
|
||||
if (!_fifoToWorker.push(msg)) {
|
||||
msg->release();
|
||||
break;
|
||||
}
|
||||
_semaToWorker.post();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SfizzVstProcessor::processControllerChanges(Vst::IParameterChanges& pc)
|
||||
{
|
||||
sfz::Sfizz& synth = *_synth;
|
||||
uint32 paramCount = pc.getParameterCount();
|
||||
|
||||
for (uint32 paramIndex = 0; paramIndex < paramCount; ++paramIndex) {
|
||||
Vst::IParamValueQueue* vq = pc.getParameterData(paramIndex);
|
||||
if (!vq)
|
||||
continue;
|
||||
|
||||
Vst::ParamID id = vq->getParameterId();
|
||||
uint32 pointCount = vq->getPointCount();
|
||||
int32 sampleOffset;
|
||||
Vst::ParamValue value;
|
||||
|
||||
switch (id) {
|
||||
default:
|
||||
if (id >= kPidMidiCC0 && id <= kPidMidiCCLast) {
|
||||
int ccNumber = id - kPidMidiCC0;
|
||||
for (uint32 pointIndex = 0; pointIndex < pointCount; ++pointIndex) {
|
||||
if (vq->getPoint(pointIndex, sampleOffset, value) == kResultTrue)
|
||||
synth.cc(sampleOffset, ccNumber, (int)(0.5 + value * 127.0));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case kPidMidiAftertouch:
|
||||
for (uint32 pointIndex = 0; pointIndex < pointCount; ++pointIndex) {
|
||||
if (vq->getPoint(pointIndex, sampleOffset, value) == kResultTrue)
|
||||
synth.aftertouch(sampleOffset, (int)(0.5 + value * 127.0));
|
||||
}
|
||||
break;
|
||||
|
||||
case kPidMidiPitchBend:
|
||||
for (uint32 pointIndex = 0; pointIndex < pointCount; ++pointIndex) {
|
||||
if (vq->getPoint(pointIndex, sampleOffset, value) == kResultTrue)
|
||||
synth.pitchWheel(sampleOffset, (int)(0.5 + value * 16383) - 8192);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SfizzVstProcessor::processEvents(Vst::IEventList& events)
|
||||
{
|
||||
sfz::Sfizz& synth = *_synth;
|
||||
uint32 numEvents = events.getEventCount();
|
||||
|
||||
for (uint32 i = 0; i < numEvents; i++) {
|
||||
Vst::Event e;
|
||||
if (events.getEvent(i, e) != kResultTrue)
|
||||
continue;
|
||||
|
||||
switch (e.type) {
|
||||
case Vst::Event::kNoteOnEvent:
|
||||
synth.noteOn(e.sampleOffset, e.noteOn.pitch, convertVelocityFromFloat(e.noteOn.velocity));
|
||||
break;
|
||||
case Vst::Event::kNoteOffEvent:
|
||||
synth.noteOff(e.sampleOffset, e.noteOff.pitch, convertVelocityFromFloat(e.noteOff.velocity));
|
||||
break;
|
||||
// case Vst::Event::kPolyPressureEvent:
|
||||
// synth.aftertouch(e.sampleOffset, convertVelocityFromFloat(e.polyPressure.pressure));
|
||||
// break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int SfizzVstProcessor::convertVelocityFromFloat(float x)
|
||||
{
|
||||
return std::min(127, std::max(0, (int)(x * 127.0f)));
|
||||
}
|
||||
|
||||
tresult PLUGIN_API SfizzVstProcessor::notify(Vst::IMessage* message)
|
||||
{
|
||||
tresult result = AudioEffect::notify(message);
|
||||
if (result != kResultFalse)
|
||||
return result;
|
||||
|
||||
if (!_fifoToWorker.push(message))
|
||||
return kOutOfMemory;
|
||||
|
||||
message->addRef();
|
||||
_semaToWorker.post();
|
||||
|
||||
return kResultTrue;
|
||||
}
|
||||
|
||||
FUnknown* SfizzVstProcessor::createInstance(void*)
|
||||
{
|
||||
return static_cast<Vst::IAudioProcessor*>(new SfizzVstProcessor);
|
||||
}
|
||||
|
||||
void SfizzVstProcessor::doBackgroundWork()
|
||||
{
|
||||
constexpr uint32 maxPathLen = 32768;
|
||||
|
||||
for (;;) {
|
||||
_semaToWorker.wait();
|
||||
|
||||
if (!_workRunning)
|
||||
break;
|
||||
|
||||
Vst::IMessage* msg;
|
||||
if (!_fifoToWorker.pop(msg)) {
|
||||
fprintf(stderr, "[Sfizz] message synchronization error in worker\n");
|
||||
std::abort();
|
||||
}
|
||||
|
||||
const char* id = msg->getMessageID();
|
||||
Vst::IAttributeList* attr = msg->getAttributes();
|
||||
|
||||
if (!std::strcmp(id, "LoadSfz")) {
|
||||
std::vector<Vst::TChar> path(maxPathLen + 1);
|
||||
if (attr->getString("File", path.data(), maxPathLen) == kResultTrue) {
|
||||
std::lock_guard<std::mutex> lock(_processMutex);
|
||||
_state.sfzFile = Steinberg::String(path.data()).text8();
|
||||
_synth->loadSfzFile(_state.sfzFile);
|
||||
}
|
||||
}
|
||||
else if (!std::strcmp(id, "SetNumVoices")) {
|
||||
int64 value;
|
||||
if (attr->getInt("NumVoices", value) == kResultTrue) {
|
||||
_state.numVoices = value;
|
||||
_synth->setNumVoices(value);
|
||||
}
|
||||
}
|
||||
else if (!std::strcmp(id, "SetOversampling")) {
|
||||
int64 value;
|
||||
if (attr->getInt("Oversampling", value) == kResultTrue) {
|
||||
_state.oversamplingLog2 = value;
|
||||
_synth->setOversamplingFactor(1 << value);
|
||||
}
|
||||
}
|
||||
else if (!std::strcmp(id, "SetPreloadSize")) {
|
||||
int64 value;
|
||||
if (attr->getInt("PreloadSize", value) == kResultTrue) {
|
||||
_state.preloadSize = value;
|
||||
_synth->setPreloadSize(value);
|
||||
}
|
||||
}
|
||||
|
||||
msg->release();
|
||||
}
|
||||
}
|
||||
|
||||
void SfizzVstProcessor::stopBackgroundWork()
|
||||
{
|
||||
if (!_workRunning)
|
||||
return;
|
||||
|
||||
_workRunning = false;
|
||||
_semaToWorker.post();
|
||||
_worker.join();
|
||||
|
||||
while (_semaToWorker.try_wait()) {
|
||||
Vst::IMessage* msg;
|
||||
if (!_fifoToWorker.pop(msg)) {
|
||||
fprintf(stderr, "[Sfizz] message synchronization error in processor\n");
|
||||
std::abort();
|
||||
}
|
||||
msg->release();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Note(jpc) Generated at random with uuidgen.
|
||||
Can't find docs on it... maybe it's to register somewhere?
|
||||
*/
|
||||
FUID SfizzVstProcessor::cid(0xe8fab718, 0x15ed46e3, 0x8b598310, 0x1e12993f);
|
||||
61
vst/SfizzVstProcessor.h
Normal file
61
vst/SfizzVstProcessor.h
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
// SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
// This code is part of the sfizz library and is licensed under a BSD 2-clause
|
||||
// license. You should have receive a LICENSE.md file along with the code.
|
||||
// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz
|
||||
|
||||
#pragma once
|
||||
#include "SfizzVstState.h"
|
||||
#include "RTSemaphore.h"
|
||||
#include "public.sdk/source/vst/vstaudioeffect.h"
|
||||
#include "public.sdk/source/vst/utility/ringbuffer.h"
|
||||
#include <sfizz.hpp>
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
#include <memory>
|
||||
|
||||
using namespace Steinberg;
|
||||
|
||||
class SfizzVstProcessor : public Vst::AudioEffect {
|
||||
public:
|
||||
SfizzVstProcessor();
|
||||
~SfizzVstProcessor();
|
||||
|
||||
tresult PLUGIN_API initialize(FUnknown* context) override;
|
||||
tresult PLUGIN_API setBusArrangements(Vst::SpeakerArrangement* inputs, int32 numIns, Vst::SpeakerArrangement* outputs, int32 numOuts) override;
|
||||
|
||||
tresult PLUGIN_API setState(IBStream* stream) override;
|
||||
tresult PLUGIN_API getState(IBStream* stream) override;
|
||||
void syncStateToSynth();
|
||||
|
||||
tresult PLUGIN_API canProcessSampleSize(int32 symbolicSampleSize) override;
|
||||
tresult PLUGIN_API setActive(TBool state) override;
|
||||
tresult PLUGIN_API process(Vst::ProcessData& data) override;
|
||||
void processParameterChanges(Vst::IParameterChanges& pc);
|
||||
void processControllerChanges(Vst::IParameterChanges& pc);
|
||||
void processEvents(Vst::IEventList& events);
|
||||
static int convertVelocityFromFloat(float x);
|
||||
|
||||
tresult PLUGIN_API notify(Vst::IMessage* message) override;
|
||||
|
||||
static FUnknown* createInstance(void*);
|
||||
|
||||
static FUID cid;
|
||||
|
||||
// --- Sfizz stuff here below ---
|
||||
private:
|
||||
// synth state. acquire processMutex before accessing
|
||||
std::unique_ptr<sfz::Sfizz> _synth;
|
||||
SfizzVstState _state;
|
||||
|
||||
// worker and thread sync
|
||||
std::thread _worker;
|
||||
volatile bool _workRunning = false;
|
||||
Steinberg::OneReaderOneWriter::RingBuffer<Vst::IMessage*> _fifoToWorker;
|
||||
RTSemaphore _semaToWorker;
|
||||
std::mutex _processMutex;
|
||||
|
||||
// worker
|
||||
void doBackgroundWork();
|
||||
void stopBackgroundWork();
|
||||
};
|
||||
90
vst/SfizzVstState.cpp
Normal file
90
vst/SfizzVstState.cpp
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
// SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
// This code is part of the sfizz library and is licensed under a BSD 2-clause
|
||||
// license. You should have receive a LICENSE.md file along with the code.
|
||||
// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz
|
||||
|
||||
#include "SfizzVstState.h"
|
||||
#include <sfizz.h>
|
||||
#include <mutex>
|
||||
#include <cstring>
|
||||
|
||||
tresult SfizzVstState::load(IBStream* state)
|
||||
{
|
||||
IBStreamer s(state, kLittleEndian);
|
||||
|
||||
uint64 version = 0;
|
||||
if (!s.readInt64u(version))
|
||||
return kResultFalse;
|
||||
|
||||
if (const char* str = s.readStr8())
|
||||
sfzFile = str;
|
||||
else
|
||||
return kResultFalse;
|
||||
|
||||
if (!s.readFloat(volume))
|
||||
return kResultFalse;
|
||||
|
||||
if (!s.readInt32(numVoices))
|
||||
return kResultFalse;
|
||||
|
||||
if (!s.readInt32(oversamplingLog2))
|
||||
return kResultFalse;
|
||||
|
||||
if (!s.readInt32(preloadSize))
|
||||
return kResultFalse;
|
||||
|
||||
return kResultTrue;
|
||||
}
|
||||
|
||||
tresult SfizzVstState::store(IBStream* state) const
|
||||
{
|
||||
IBStreamer s(state, kLittleEndian);
|
||||
|
||||
if (!s.writeInt64u(currentStateVersion))
|
||||
return kResultFalse;
|
||||
|
||||
if (!s.writeStr8(sfzFile.c_str()))
|
||||
return kResultFalse;
|
||||
|
||||
if (!s.writeFloat(volume))
|
||||
return kResultFalse;
|
||||
|
||||
if (!s.writeInt32(numVoices))
|
||||
return kResultFalse;
|
||||
|
||||
if (!s.writeInt32(oversamplingLog2))
|
||||
return kResultFalse;
|
||||
|
||||
if (!s.writeInt32(preloadSize))
|
||||
return kResultFalse;
|
||||
|
||||
return kResultTrue;
|
||||
}
|
||||
|
||||
tresult SfizzUiState::load(IBStream* state)
|
||||
{
|
||||
IBStreamer s(state, kLittleEndian);
|
||||
|
||||
uint64 version = 0;
|
||||
if (!s.readInt64u(version))
|
||||
return kResultFalse;
|
||||
|
||||
if (!s.readInt32u(activePanel))
|
||||
return kResultFalse;
|
||||
|
||||
return kResultTrue;
|
||||
}
|
||||
|
||||
tresult SfizzUiState::store(IBStream* state) const
|
||||
{
|
||||
IBStreamer s(state, kLittleEndian);
|
||||
|
||||
if (!s.writeInt64u(currentStateVersion))
|
||||
return kResultFalse;
|
||||
|
||||
if (!s.writeInt32u(activePanel))
|
||||
return kResultFalse;
|
||||
|
||||
return kResultTrue;
|
||||
}
|
||||
83
vst/SfizzVstState.h
Normal file
83
vst/SfizzVstState.h
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
// SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
// This code is part of the sfizz library and is licensed under a BSD 2-clause
|
||||
// license. You should have receive a LICENSE.md file along with the code.
|
||||
// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz
|
||||
|
||||
#pragma once
|
||||
#include "base/source/fstreamer.h"
|
||||
#include "public.sdk/source/vst/vstparameters.h"
|
||||
#include <string>
|
||||
|
||||
using namespace Steinberg;
|
||||
|
||||
// number of MIDI CC
|
||||
enum {
|
||||
kNumControllerParams = 128,
|
||||
};
|
||||
|
||||
// parameters
|
||||
enum {
|
||||
kPidVolume,
|
||||
kPidNumVoices,
|
||||
kPidOversampling,
|
||||
kPidPreloadSize,
|
||||
kPidMidiAftertouch,
|
||||
kPidMidiPitchBend,
|
||||
kPidMidiCC0,
|
||||
kPidMidiCCLast = kPidMidiCC0 + kNumControllerParams - 1,
|
||||
/* Reserved */
|
||||
};
|
||||
|
||||
class SfizzVstState {
|
||||
public:
|
||||
std::string sfzFile;
|
||||
float volume = 0;
|
||||
int32 numVoices = 64;
|
||||
int32 oversamplingLog2 = 0;
|
||||
int32 preloadSize = 8192;
|
||||
|
||||
static constexpr uint64 currentStateVersion = 0;
|
||||
|
||||
tresult load(IBStream* state);
|
||||
tresult store(IBStream* state) const;
|
||||
};
|
||||
|
||||
class SfizzUiState {
|
||||
public:
|
||||
uint32 activePanel = 0;
|
||||
|
||||
static constexpr uint64 currentStateVersion = 0;
|
||||
|
||||
tresult load(IBStream* state);
|
||||
tresult store(IBStream* state) const;
|
||||
};
|
||||
|
||||
struct SfizzParameterRange {
|
||||
float def = 0.0;
|
||||
float min = 0.0;
|
||||
float max = 1.0;
|
||||
|
||||
constexpr SfizzParameterRange() {}
|
||||
constexpr SfizzParameterRange(float def, float min, float max) : def(def), min(min), max(max) {}
|
||||
|
||||
constexpr float normalize(float x) const noexcept
|
||||
{
|
||||
return (x - min) / (max - min);
|
||||
}
|
||||
|
||||
constexpr float denormalize(float x) const noexcept
|
||||
{
|
||||
return min + x * (max - min);
|
||||
}
|
||||
|
||||
Vst::RangeParameter* createParameter(const Vst::TChar *title, Vst::ParamID tag, const Vst::TChar *units = nullptr, int32 stepCount = 0, int32 flags = Vst::ParameterInfo::kCanAutomate, Vst::UnitID unitID = Vst::kRootUnitId, const Vst::TChar *shortTitle = nullptr) const
|
||||
{
|
||||
return new Vst::RangeParameter(title, tag, units, min, max, def, stepCount, flags, unitID, shortTitle);
|
||||
}
|
||||
};
|
||||
|
||||
static constexpr SfizzParameterRange kParamVolumeRange(0.0, -60.0, +6.0);
|
||||
static constexpr SfizzParameterRange kParamNumVoicesRange(64.0, 1.0, 256.0);
|
||||
static constexpr SfizzParameterRange kParamOversamplingRange(0.0, 0.0, 3.0);
|
||||
static constexpr SfizzParameterRange kParamPreloadSizeRange(8192.0, 1024.0, 65536.0);
|
||||
11
vst/VstPluginDefs.h.in
Normal file
11
vst/VstPluginDefs.h.in
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
// SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
// This code is part of the sfizz library and is licensed under a BSD 2-clause
|
||||
// license. You should have receive a LICENSE.md file along with the code.
|
||||
// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz
|
||||
|
||||
#define VSTPLUGIN_NAME "@VSTPLUGIN_NAME@"
|
||||
#define VSTPLUGIN_VENDOR "@VSTPLUGIN_VENDOR@"
|
||||
#define VSTPLUGIN_URL "@VSTPLUGIN_URL@"
|
||||
#define VSTPLUGIN_EMAIL "@VSTPLUGIN_EMAIL@"
|
||||
#define VSTPLUGIN_VERSION "@PROJECT_VERSION@"
|
||||
49
vst/VstPluginFactory.cpp
Normal file
49
vst/VstPluginFactory.cpp
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
// SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
// This code is part of the sfizz library and is licensed under a BSD 2-clause
|
||||
// license. You should have receive a LICENSE.md file along with the code.
|
||||
// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz
|
||||
|
||||
#include "SfizzVstProcessor.h"
|
||||
#include "SfizzVstController.h"
|
||||
#include "VstPluginDefs.h"
|
||||
#include "public.sdk/source/main/pluginfactory.h"
|
||||
#include "pluginterfaces/vst/ivstcomponent.h"
|
||||
#include "pluginterfaces/vst/ivstaudioprocessor.h"
|
||||
#include "pluginterfaces/vst/ivsteditcontroller.h"
|
||||
|
||||
BEGIN_FACTORY_DEF(VSTPLUGIN_VENDOR,
|
||||
VSTPLUGIN_URL,
|
||||
"mailto:" VSTPLUGIN_EMAIL)
|
||||
|
||||
DEF_CLASS2 (INLINE_UID_FROM_FUID(SfizzVstProcessor::cid),
|
||||
PClassInfo::kManyInstances,
|
||||
kVstAudioEffectClass,
|
||||
VSTPLUGIN_NAME,
|
||||
Vst::kDistributable,
|
||||
Vst::PlugType::kInstrumentSynth,
|
||||
VSTPLUGIN_VERSION,
|
||||
kVstVersionString,
|
||||
SfizzVstProcessor::createInstance)
|
||||
|
||||
DEF_CLASS2 (INLINE_UID_FROM_FUID(SfizzVstController::cid),
|
||||
PClassInfo::kManyInstances,
|
||||
kVstComponentControllerClass,
|
||||
VSTPLUGIN_NAME,
|
||||
0, // not used here
|
||||
"", // not used here
|
||||
VSTPLUGIN_VERSION,
|
||||
kVstVersionString,
|
||||
SfizzVstController::createInstance)
|
||||
|
||||
END_FACTORY
|
||||
|
||||
bool InitModule()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DeinitModule()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
275
vst/cmake/Vst3.cmake
Normal file
275
vst/cmake/Vst3.cmake
Normal file
|
|
@ -0,0 +1,275 @@
|
|||
find_package(Threads REQUIRED)
|
||||
|
||||
# --- VST3SDK ---
|
||||
function(plugin_add_vst3sdk NAME)
|
||||
target_sources("${NAME}" PRIVATE
|
||||
"${VST3SDK_BASEDIR}/base/source/baseiids.cpp"
|
||||
"${VST3SDK_BASEDIR}/base/source/fbuffer.cpp"
|
||||
"${VST3SDK_BASEDIR}/base/source/fdebug.cpp"
|
||||
"${VST3SDK_BASEDIR}/base/source/fdynlib.cpp"
|
||||
"${VST3SDK_BASEDIR}/base/source/fobject.cpp"
|
||||
"${VST3SDK_BASEDIR}/base/source/fstreamer.cpp"
|
||||
"${VST3SDK_BASEDIR}/base/source/fstring.cpp"
|
||||
# "${VST3SDK_BASEDIR}/base/source/timer.cpp"
|
||||
"${VST3SDK_BASEDIR}/base/source/updatehandler.cpp"
|
||||
"${VST3SDK_BASEDIR}/base/thread/source/fcondition.cpp"
|
||||
"${VST3SDK_BASEDIR}/base/thread/source/flock.cpp"
|
||||
"${VST3SDK_BASEDIR}/pluginterfaces/base/conststringtable.cpp"
|
||||
"${VST3SDK_BASEDIR}/pluginterfaces/base/coreiids.cpp"
|
||||
"${VST3SDK_BASEDIR}/pluginterfaces/base/funknown.cpp"
|
||||
"${VST3SDK_BASEDIR}/pluginterfaces/base/ustring.cpp"
|
||||
"${VST3SDK_BASEDIR}/public.sdk/source/common/commoniids.cpp"
|
||||
"${VST3SDK_BASEDIR}/public.sdk/source/common/pluginview.cpp"
|
||||
"${VST3SDK_BASEDIR}/public.sdk/source/main/pluginfactory.cpp"
|
||||
"${VST3SDK_BASEDIR}/public.sdk/source/vst/vstaudioeffect.cpp"
|
||||
"${VST3SDK_BASEDIR}/public.sdk/source/vst/vstbus.cpp"
|
||||
"${VST3SDK_BASEDIR}/public.sdk/source/vst/vstcomponent.cpp"
|
||||
"${VST3SDK_BASEDIR}/public.sdk/source/vst/vstcomponentbase.cpp"
|
||||
"${VST3SDK_BASEDIR}/public.sdk/source/vst/vsteditcontroller.cpp"
|
||||
"${VST3SDK_BASEDIR}/public.sdk/source/vst/vstinitiids.cpp"
|
||||
"${VST3SDK_BASEDIR}/public.sdk/source/vst/vstnoteexpressiontypes.cpp"
|
||||
"${VST3SDK_BASEDIR}/public.sdk/source/vst/vstparameters.cpp"
|
||||
"${VST3SDK_BASEDIR}/public.sdk/source/vst/vstpresetfile.cpp"
|
||||
"${VST3SDK_BASEDIR}/public.sdk/source/vst/vstrepresentation.cpp")
|
||||
if(WIN32)
|
||||
target_sources("${NAME}" PRIVATE
|
||||
"${VST3SDK_BASEDIR}/public.sdk/source/common/threadchecker_win32.cpp"
|
||||
"${VST3SDK_BASEDIR}/public.sdk/source/vst/vstgui_win32_bundle_support.cpp"
|
||||
"${VST3SDK_BASEDIR}/public.sdk/source/main/dllmain.cpp")
|
||||
elseif(APPLE)
|
||||
target_sources("${NAME}" PRIVATE
|
||||
"${VST3SDK_BASEDIR}/public.sdk/source/main/macmain.cpp")
|
||||
else()
|
||||
target_sources("${NAME}" PRIVATE
|
||||
"${VST3SDK_BASEDIR}/public.sdk/source/common/threadchecker_linux.cpp"
|
||||
"${VST3SDK_BASEDIR}/public.sdk/source/main/linuxmain.cpp")
|
||||
endif()
|
||||
target_include_directories("${NAME}" PRIVATE "${VST3SDK_BASEDIR}")
|
||||
target_link_libraries("${NAME}" PRIVATE Threads::Threads)
|
||||
if(MINGW)
|
||||
target_compile_definitions("${NAME}" PRIVATE
|
||||
"_NATIVE_WCHAR_T_DEFINED=1" "__wchar_t=wchar_t")
|
||||
endif()
|
||||
|
||||
if(${CMAKE_BUILD_TYPE} MATCHES "Debug")
|
||||
target_compile_definitions("${NAME}" PRIVATE "DEVELOPMENT")
|
||||
endif()
|
||||
|
||||
if(${CMAKE_BUILD_TYPE} MATCHES "Release")
|
||||
target_compile_definitions("${NAME}" PRIVATE "RELEASE")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# --- VSTGUI ---
|
||||
function(plugin_add_vstgui NAME)
|
||||
target_sources("${NAME}" PRIVATE
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/animation/animations.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/animation/animator.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/animation/timingfunctions.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/cbitmap.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/cbitmapfilter.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/ccolor.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/cdatabrowser.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/cdrawcontext.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/cdrawmethods.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/cdropsource.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/cfileselector.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/cfont.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/cframe.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/cgradientview.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/cgraphicspath.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/clayeredviewcontainer.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/clinestyle.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/coffscreencontext.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/controls/cautoanimation.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/controls/cbuttons.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/controls/ccolorchooser.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/controls/ccontrol.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/controls/cfontchooser.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/controls/cknob.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/controls/clistcontrol.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/controls/cmoviebitmap.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/controls/cmoviebutton.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/controls/coptionmenu.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/controls/cparamdisplay.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/controls/cscrollbar.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/controls/csearchtextedit.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/controls/csegmentbutton.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/controls/cslider.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/controls/cspecialdigit.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/controls/csplashscreen.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/controls/cstringlist.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/controls/cswitch.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/controls/ctextedit.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/controls/ctextlabel.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/controls/cvumeter.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/controls/cxypad.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/copenglview.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/cpoint.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/crect.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/crowcolumnview.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/cscrollview.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/cshadowviewcontainer.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/csplitview.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/cstring.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/ctabview.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/ctooltipsupport.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/cview.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/cviewcontainer.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/cvstguitimer.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/genericstringlistdatabrowsersource.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/common/genericoptionmenu.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/vstguidebug.cpp")
|
||||
|
||||
if(WIN32)
|
||||
target_sources("${NAME}" PRIVATE
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/common/fileresourceinputstream.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/win32/direct2d/d2dbitmap.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/win32/direct2d/d2ddrawcontext.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/win32/direct2d/d2dfont.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/win32/direct2d/d2dgraphicspath.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/win32/win32datapackage.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/win32/win32dragging.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/win32/win32frame.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/win32/win32openglview.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/win32/win32optionmenu.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/win32/win32support.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/win32/win32textedit.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/win32/winfileselector.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/win32/winstring.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/win32/wintimer.cpp")
|
||||
elseif(APPLE)
|
||||
target_sources("${NAME}" PRIVATE
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/common/fileresourceinputstream.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/common/genericoptionmenu.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/common/generictextedit.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/mac/carbon/hiviewframe.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/mac/carbon/hiviewoptionmenu.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/mac/carbon/hiviewtextedit.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/mac/caviewlayer.mm"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/mac/cfontmac.mm"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/mac/cgbitmap.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/mac/cgdrawcontext.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/mac/cocoa/autoreleasepool.mm"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/mac/cocoa/cocoahelpers.mm"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/mac/cocoa/cocoaopenglview.mm"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/mac/cocoa/cocoatextedit.mm"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/mac/cocoa/nsviewdraggingsession.mm"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/mac/cocoa/nsviewframe.mm"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/mac/cocoa/nsviewoptionmenu.mm"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/mac/macclipboard.mm"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/mac/macfileselector.mm"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/mac/macglobals.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/mac/macstring.mm"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/mac/mactimer.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/mac/quartzgraphicspath.cpp")
|
||||
else()
|
||||
target_sources("${NAME}" PRIVATE
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/common/fileresourceinputstream.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/common/generictextedit.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/linux/cairobitmap.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/linux/cairocontext.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/linux/cairofont.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/linux/cairogradient.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/linux/cairopath.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/linux/linuxstring.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/linux/x11fileselector.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/linux/x11frame.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/linux/x11platform.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/linux/x11timer.cpp"
|
||||
"${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/linux/x11utils.cpp")
|
||||
endif()
|
||||
|
||||
target_include_directories("${NAME}" PRIVATE "${VST3SDK_BASEDIR}/vstgui4")
|
||||
|
||||
if(WIN32)
|
||||
target_compile_definitions("${NAME}" PRIVATE "NOMINMAX=1")
|
||||
if (NOT MSVC)
|
||||
# autolinked on MSVC with pragmas
|
||||
find_library(OPENGL32_LIBRARY "opengl32")
|
||||
find_library(D2D1_LIBRARY "d2d1")
|
||||
find_library(DWRITE_LIBRARY "dwrite")
|
||||
find_library(DWMAPI_LIBRARY "dwmapi")
|
||||
find_library(WINDOWSCODECS_LIBRARY "windowscodecs")
|
||||
find_library(SHLWAPI_LIBRARY "shlwapi")
|
||||
target_link_libraries("${NAME}" PRIVATE
|
||||
"${OPENGL32_LIBRARY}"
|
||||
"${D2D1_LIBRARY}"
|
||||
"${DWRITE_LIBRARY}"
|
||||
"${DWMAPI_LIBRARY}"
|
||||
"${WINDOWSCODECS_LIBRARY}"
|
||||
"${SHLWAPI_LIBRARY}")
|
||||
endif()
|
||||
elseif(APPLE)
|
||||
find_library(APPLE_COREFOUNDATION_LIBRARY "CoreFoundation")
|
||||
find_library(APPLE_COCOA_LIBRARY "Cocoa")
|
||||
find_library(APPLE_OPENGL_LIBRARY "OpenGL")
|
||||
find_library(APPLE_ACCELERATE_LIBRARY "Accelerate")
|
||||
find_library(APPLE_QUARTZCORE_LIBRARY "QuartzCore")
|
||||
find_library(APPLE_CARBON_LIBRARY "Carbon")
|
||||
target_link_libraries("${NAME}" PRIVATE
|
||||
"${APPLE_COREFOUNDATION_LIBRARY}"
|
||||
"${APPLE_COCOA_LIBRARY}"
|
||||
"${APPLE_OPENGL_LIBRARY}"
|
||||
"${APPLE_ACCELERATE_LIBRARY}"
|
||||
"${APPLE_QUARTZCORE_LIBRARY}"
|
||||
"${APPLE_CARBON_LIBRARY}")
|
||||
else()
|
||||
find_package(X11 REQUIRED)
|
||||
find_package(Freetype REQUIRED)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(LIBXCB REQUIRED xcb)
|
||||
pkg_check_modules(LIBXCB_UTIL REQUIRED xcb-util)
|
||||
pkg_check_modules(LIBXCB_CURSOR REQUIRED xcb-cursor)
|
||||
pkg_check_modules(LIBXCB_KEYSYMS REQUIRED xcb-keysyms)
|
||||
pkg_check_modules(LIBXCB_XKB REQUIRED xcb-xkb)
|
||||
pkg_check_modules(LIBXKB_COMMON REQUIRED xkbcommon)
|
||||
pkg_check_modules(LIBXKB_COMMON_X11 REQUIRED xkbcommon-x11)
|
||||
pkg_check_modules(CAIRO REQUIRED cairo)
|
||||
pkg_check_modules(FONTCONFIG REQUIRED fontconfig)
|
||||
target_include_directories("${NAME}" PRIVATE
|
||||
${X11_INCLUDE_DIRS}
|
||||
${FREETYPE_INCLUDE_DIRS}
|
||||
${LIBXCB_INCLUDE_DIRS}
|
||||
${LIBXCB_UTIL_INCLUDE_DIRS}
|
||||
${LIBXCB_CURSOR_INCLUDE_DIRS}
|
||||
${LIBXCB_KEYSYMS_INCLUDE_DIRS}
|
||||
${LIBXCB_XKB_INCLUDE_DIRS}
|
||||
${LIBXKB_COMMON_INCLUDE_DIRS}
|
||||
${LIBXKB_COMMON_X11_INCLUDE_DIRS}
|
||||
${CAIRO_INCLUDE_DIRS}
|
||||
${FONTCONFIG_INCLUDE_DIRS})
|
||||
target_link_libraries("${NAME}" PRIVATE
|
||||
${X11_LIBRARIES}
|
||||
${FREETYPE_LIBRARIES}
|
||||
${LIBXCB_LIBRARIES}
|
||||
${LIBXCB_UTIL_LIBRARIES}
|
||||
${LIBXCB_CURSOR_LIBRARIES}
|
||||
${LIBXCB_KEYSYMS_LIBRARIES}
|
||||
${LIBXCB_XKB_LIBRARIES}
|
||||
${LIBXKB_COMMON_LIBRARIES}
|
||||
${LIBXKB_COMMON_X11_LIBRARIES}
|
||||
${CAIRO_LIBRARIES}
|
||||
${FONTCONFIG_LIBRARIES})
|
||||
find_library(DL_LIBRARY "dl")
|
||||
if(DL_LIBRARY)
|
||||
target_link_libraries("${NAME}" PRIVATE "${DL_LIBRARY}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
target_sources("${NAME}" PRIVATE
|
||||
"${VST3SDK_BASEDIR}/public.sdk/source/vst/vstguieditor.cpp")
|
||||
|
||||
target_include_directories("${NAME}" PRIVATE
|
||||
external/steinberg/src)
|
||||
|
||||
target_compile_definitions("${NAME}" PRIVATE "SMTG_MODULE_IS_BUNDLE=1")
|
||||
|
||||
if(${CMAKE_BUILD_TYPE} MATCHES "Debug")
|
||||
target_compile_definitions("${NAME}" PRIVATE "DEVELOPMENT")
|
||||
endif()
|
||||
|
||||
if(${CMAKE_BUILD_TYPE} MATCHES "Release")
|
||||
target_compile_definitions("${NAME}" PRIVATE "RELEASE")
|
||||
endif()
|
||||
endfunction()
|
||||
27
vst/external/steinberg/LICENSE
vendored
Normal file
27
vst/external/steinberg/LICENSE
vendored
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// VSTGUI LICENSE
|
||||
// (c) 2018, Steinberg Media Technologies, All Rights Reserved
|
||||
//-----------------------------------------------------------------------------
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
// * 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.
|
||||
// * Neither the name of the Steinberg Media Technologies nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// software without specific prior written permission.
|
||||
//
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
110
vst/external/steinberg/src/x11runloop.h
vendored
Normal file
110
vst/external/steinberg/src/x11runloop.h
vendored
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
#include "vstgui/lib/platform/linux/x11frame.h"
|
||||
#include "pluginterfaces/gui/iplugview.h"
|
||||
#include "base/source/fstring.h"
|
||||
|
||||
namespace VSTGUI {
|
||||
|
||||
// Map Steinberg Vst Interface to VSTGUI Interface
|
||||
class RunLoop : public X11::IRunLoop, public AtomicReferenceCounted
|
||||
{
|
||||
public:
|
||||
struct EventHandler : Steinberg::Linux::IEventHandler, public Steinberg::FObject
|
||||
{
|
||||
X11::IEventHandler* handler {nullptr};
|
||||
|
||||
void PLUGIN_API onFDIsSet (Steinberg::Linux::FileDescriptor) override
|
||||
{
|
||||
if (handler)
|
||||
handler->onEvent ();
|
||||
}
|
||||
DELEGATE_REFCOUNT (Steinberg::FObject)
|
||||
DEFINE_INTERFACES
|
||||
DEF_INTERFACE (Steinberg::Linux::IEventHandler)
|
||||
END_DEFINE_INTERFACES (Steinberg::FObject)
|
||||
};
|
||||
struct TimerHandler : Steinberg::Linux::ITimerHandler, public Steinberg::FObject
|
||||
{
|
||||
X11::ITimerHandler* handler {nullptr};
|
||||
|
||||
void PLUGIN_API onTimer () final
|
||||
{
|
||||
if (handler)
|
||||
handler->onTimer ();
|
||||
}
|
||||
DELEGATE_REFCOUNT (Steinberg::FObject)
|
||||
DEFINE_INTERFACES
|
||||
DEF_INTERFACE (Steinberg::Linux::ITimerHandler)
|
||||
END_DEFINE_INTERFACES (Steinberg::FObject)
|
||||
};
|
||||
|
||||
bool registerEventHandler (int fd, X11::IEventHandler* handler) final
|
||||
{
|
||||
if(!runLoop)
|
||||
return false;
|
||||
|
||||
auto smtgHandler = Steinberg::owned (new EventHandler ());
|
||||
smtgHandler->handler = handler;
|
||||
if (runLoop->registerEventHandler (smtgHandler, fd) == Steinberg::kResultTrue)
|
||||
{
|
||||
eventHandlers.push_back (smtgHandler);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool unregisterEventHandler (X11::IEventHandler* handler) final
|
||||
{
|
||||
if(!runLoop)
|
||||
return false;
|
||||
|
||||
for (auto it = eventHandlers.begin (), end = eventHandlers.end (); it != end; ++it)
|
||||
{
|
||||
if ((*it)->handler == handler)
|
||||
{
|
||||
runLoop->unregisterEventHandler ((*it));
|
||||
eventHandlers.erase (it);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool registerTimer (uint64_t interval, X11::ITimerHandler* handler) final
|
||||
{
|
||||
if(!runLoop)
|
||||
return false;
|
||||
|
||||
auto smtgHandler = Steinberg::owned (new TimerHandler ());
|
||||
smtgHandler->handler = handler;
|
||||
if (runLoop->registerTimer (smtgHandler, interval) == Steinberg::kResultTrue)
|
||||
{
|
||||
timerHandlers.push_back (smtgHandler);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool unregisterTimer (X11::ITimerHandler* handler) final
|
||||
{
|
||||
if(!runLoop)
|
||||
return false;
|
||||
|
||||
for (auto it = timerHandlers.begin (), end = timerHandlers.end (); it != end; ++it)
|
||||
{
|
||||
if ((*it)->handler == handler)
|
||||
{
|
||||
runLoop->unregisterTimer ((*it));
|
||||
timerHandlers.erase (it);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
RunLoop (Steinberg::FUnknown* runLoop) : runLoop (runLoop) {}
|
||||
private:
|
||||
using EventHandlers = std::vector<Steinberg::IPtr<EventHandler>>;
|
||||
using TimerHandlers = std::vector<Steinberg::IPtr<TimerHandler>>;
|
||||
EventHandlers eventHandlers;
|
||||
TimerHandlers timerHandlers;
|
||||
Steinberg::FUnknownPtr<Steinberg::Linux::IRunLoop> runLoop;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
674
vst/gpl-3.0.txt
Normal file
674
vst/gpl-3.0.txt
Normal file
|
|
@ -0,0 +1,674 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
24
vst/mac/Info.plist
Normal file
24
vst/mac/Info.plist
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>@SFIZZ_VST3_BUNDLE_EXECUTABLE@</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>Plugin.icns</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>tools.sfz.sfizz</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>BNDL</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>@SFIZZ_VST3_BUNDLE_VERSION@</string>
|
||||
<key>CSResourcesFileMapped</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
1
vst/mac/PkgInfo
Normal file
1
vst/mac/PkgInfo
Normal file
|
|
@ -0,0 +1 @@
|
|||
BNDL????
|
||||
BIN
vst/mac/Plugin.icns
Normal file
BIN
vst/mac/Plugin.icns
Normal file
Binary file not shown.
BIN
vst/resources/logo.png
Normal file
BIN
vst/resources/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 20 KiB |
78
vst/resources/logo.svg
Normal file
78
vst/resources/logo.svg
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
<?xml version="1.0" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
|
||||
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
|
||||
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
|
||||
width="512.000000pt" height="512.000000pt" viewBox="0 0 512.000000 512.000000"
|
||||
preserveAspectRatio="xMidYMid meet">
|
||||
<metadata>
|
||||
Created by potrace 1.11, written by Peter Selinger 2001-2013
|
||||
</metadata>
|
||||
<g transform="translate(0.000000,512.000000) scale(0.100000,-0.100000)"
|
||||
fill="#000000" stroke="none">
|
||||
<path d="M2750 4174 c-63 -140 -118 -254 -122 -254 -4 0 -8 -7 -8 -16 0 -20
|
||||
-133 -324 -141 -324 -4 0 -69 117 -145 260 -95 181 -146 267 -165 281 -22 16
|
||||
-30 17 -34 7 -2 -7 -54 -159 -114 -337 -61 -178 -112 -326 -115 -328 -2 -3
|
||||
-67 19 -143 47 -340 128 -916 340 -919 338 -1 -2 62 -243 140 -536 l142 -532
|
||||
-235 -121 c-339 -174 -711 -372 -707 -377 6 -5 114 -28 571 -123 214 -44 391
|
||||
-81 392 -83 1 -1 -80 -94 -180 -207 -100 -113 -229 -263 -286 -334 -93 -114
|
||||
-101 -127 -75 -121 16 4 225 61 465 127 240 65 438 119 440 119 3 0 -18 -188
|
||||
-47 -418 -28 -229 -51 -418 -50 -419 4 -5 293 338 490 580 115 141 212 257
|
||||
215 257 3 0 34 -93 69 -207 94 -311 215 -683 222 -683 6 0 149 469 182 593 7
|
||||
26 16 47 20 47 4 0 8 12 8 28 1 37 105 395 116 399 5 2 59 -104 119 -234 116
|
||||
-254 265 -562 265 -550 0 4 18 92 41 195 22 103 65 306 95 451 30 146 57 267
|
||||
60 270 3 4 43 -14 87 -38 330 -177 830 -441 832 -439 1 2 -65 165 -146 363
|
||||
-82 198 -148 363 -149 368 0 4 7 7 16 7 21 0 814 169 838 178 14 6 -36 35
|
||||
-205 123 -123 64 -288 147 -366 184 -79 38 -143 71 -143 74 0 4 155 159 345
|
||||
345 190 186 344 341 341 343 -4 5 -110 -3 -726 -51 -91 -8 -166 -13 -167 -12
|
||||
-1 0 -7 179 -13 396 -7 217 -14 397 -16 399 -3 4 -243 -161 -532 -367 -141
|
||||
-101 -206 -142 -211 -133 -4 7 -40 130 -80 274 -91 331 -106 377 -134 414
|
||||
l-23 31 -114 -254z m227 -185 c51 -184 95 -340 98 -347 3 -10 28 3 82 42 224
|
||||
159 622 436 635 441 17 7 21 -59 34 -529 l7 -228 61 6 c64 6 537 42 691 52
|
||||
l90 6 -335 -330 -335 -330 30 -12 c58 -22 655 -323 655 -329 0 -6 -506 -117
|
||||
-721 -158 l-85 -16 10 -41 c6 -23 14 -43 18 -46 9 -7 246 -584 242 -589 -2 -2
|
||||
-45 19 -96 47 -51 27 -142 76 -203 108 -60 32 -213 113 -339 181 -126 67 -230
|
||||
122 -231 120 -1 -1 -27 -127 -58 -279 -88 -427 -119 -568 -127 -568 -8 0 -99
|
||||
189 -255 530 -60 129 -110 237 -112 240 -8 9 -20 -24 -58 -158 -21 -75 -42
|
||||
-138 -47 -140 -4 -2 -8 -15 -8 -29 0 -20 -49 -195 -197 -705 -3 -10 -9 -18
|
||||
-13 -18 -10 0 -53 129 -174 524 -53 170 -97 310 -98 312 -2 1 -96 -110 -208
|
||||
-248 -266 -327 -439 -532 -452 -537 -7 -2 -9 9 -5 30 16 92 88 712 83 717 -4
|
||||
3 -198 -47 -432 -112 -235 -64 -428 -115 -430 -114 -5 5 153 192 344 408 100
|
||||
112 182 207 182 210 0 3 -96 24 -213 48 -434 88 -707 147 -707 152 0 6 268
|
||||
149 603 320 142 73 260 138 263 144 2 6 -57 236 -130 511 -74 275 -131 501
|
||||
-126 503 8 3 153 -49 661 -239 191 -71 350 -129 355 -129 5 0 58 146 119 325
|
||||
60 179 114 325 120 325 5 0 73 -121 150 -268 174 -333 167 -328 240 -152 28
|
||||
66 53 120 58 120 4 0 7 7 7 15 0 26 244 555 254 552 6 -2 52 -154 103 -338z"/>
|
||||
<path d="M2479 3291 c-130 -42 -240 -157 -316 -331 l-32 -75 -93 -5 -93 -5 0
|
||||
-35 0 -35 78 -3 c42 -2 77 -5 77 -7 0 -17 -177 -574 -201 -630 -54 -131 -110
|
||||
-197 -186 -220 -26 -7 -29 2 -8 29 8 11 15 39 15 62 0 53 -33 84 -90 84 -72 0
|
||||
-118 -67 -100 -145 17 -77 73 -109 175 -103 136 9 252 86 353 235 80 119 197
|
||||
376 282 626 l24 67 88 0 c87 0 89 1 99 27 17 46 7 53 -81 53 -44 0 -80 4 -80
|
||||
9 0 5 20 68 46 141 61 179 89 220 152 220 l33 0 -35 -44 c-29 -34 -36 -52 -36
|
||||
-85 0 -36 4 -44 33 -61 43 -26 107 -26 140 1 60 46 56 156 -6 203 -63 47 -145
|
||||
57 -238 27z"/>
|
||||
<path d="M1600 2879 c-79 -36 -120 -88 -120 -153 0 -54 14 -79 76 -137 139
|
||||
-130 154 -146 154 -171 0 -65 -81 -106 -146 -74 -36 17 -37 18 -34 83 4 112
|
||||
-142 129 -156 18 -8 -59 21 -104 88 -139 48 -24 68 -28 139 -29 171 -1 269 67
|
||||
269 186 0 26 -6 60 -14 76 -8 15 -57 62 -109 104 -52 43 -98 84 -101 93 -11
|
||||
30 -6 61 15 88 18 23 28 27 63 24 l41 -3 21 -65 c23 -71 49 -94 94 -83 42 10
|
||||
60 33 60 76 0 49 -46 99 -105 116 -67 18 -184 13 -235 -10z"/>
|
||||
<path d="M3332 2866 c-35 -40 -82 -126 -82 -151 0 -32 30 -27 77 14 l47 42 95
|
||||
-7 c53 -4 97 -7 98 -8 1 -1 -86 -73 -193 -160 -207 -170 -264 -225 -264 -255
|
||||
0 -29 41 -34 92 -11 58 26 79 25 178 -10 89 -31 126 -32 181 -4 67 34 120 135
|
||||
101 192 -7 22 -15 27 -43 27 -33 0 -34 -1 -37 -42 -4 -61 -16 -66 -97 -42 -44
|
||||
14 -83 19 -108 16 -22 -3 -36 -2 -31 2 5 5 72 62 149 129 77 66 171 149 208
|
||||
184 63 57 68 66 62 91 -7 25 -11 28 -39 24 -17 -2 -52 -10 -78 -18 -40 -11
|
||||
-58 -11 -105 0 -32 7 -85 15 -119 18 -59 5 -61 4 -92 -31z"/>
|
||||
<path d="M2430 2465 l0 -253 -22 -6 c-13 -3 -42 -6 -64 -6 -75 0 -116 -59 -84
|
||||
-120 15 -29 85 -45 132 -31 64 19 68 38 68 291 0 206 1 221 18 216 9 -3 35 -8
|
||||
57 -11 22 -4 48 -9 58 -12 15 -4 17 4 17 71 l0 75 -57 11 c-32 6 -73 15 -90
|
||||
20 l-33 8 0 -253z"/>
|
||||
<path d="M2762 2676 c-35 -40 -82 -126 -82 -151 0 -32 30 -27 77 14 l47 42 95
|
||||
-7 c53 -4 97 -7 98 -8 1 -1 -86 -73 -193 -160 -207 -170 -264 -225 -264 -255
|
||||
0 -29 41 -34 92 -11 58 26 79 25 178 -10 89 -31 126 -32 181 -4 67 34 120 135
|
||||
101 192 -7 22 -15 27 -43 27 -33 0 -34 -1 -37 -42 -4 -61 -16 -66 -97 -42 -44
|
||||
14 -83 19 -108 16 -22 -3 -36 -2 -31 2 5 5 72 62 149 129 77 66 171 149 208
|
||||
184 63 57 68 66 62 91 -7 25 -11 28 -39 24 -17 -2 -52 -10 -78 -18 -40 -11
|
||||
-58 -11 -105 0 -32 7 -85 15 -119 18 -59 5 -61 4 -92 -31z"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 5.1 KiB |
4
vst/vst3.def
Normal file
4
vst/vst3.def
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
EXPORTS
|
||||
GetPluginFactory
|
||||
InitDll
|
||||
ExitDll
|
||||
7
vst/vst3.version
Normal file
7
vst/vst3.version
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
VST3ABI_1.0 {
|
||||
global:
|
||||
*GetPluginFactory*;
|
||||
*ModuleEntry*;
|
||||
*ModuleExit*;
|
||||
local: *;
|
||||
};
|
||||
BIN
vst/win/Plugin.ico
Normal file
BIN
vst/win/Plugin.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 344 KiB |
2
vst/win/desktop.ini
Normal file
2
vst/win/desktop.ini
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
[.ShellClassInfo]
|
||||
IconResource=Plugin.ico,0
|
||||
Loading…
Add table
Reference in a new issue