Merge pull request #111 from paulfd/gcc-4.9

GCC 4.9 compatibility
This commit is contained in:
Paul Ferrand 2020-03-14 18:02:19 +01:00 committed by GitHub
commit 4695656ea5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
74 changed files with 391 additions and 332 deletions

View file

@ -129,7 +129,6 @@ jobs:
- name: "macOS" - name: "macOS"
os: osx os: osx
osx_image: xcode10.1
env: env:
- INSTALL_DIR="sfizz-${TRAVIS_BRANCH}-${TRAVIS_OS_NAME}-${TRAVIS_CPU_ARCH}" - INSTALL_DIR="sfizz-${TRAVIS_BRANCH}-${TRAVIS_OS_NAME}-${TRAVIS_CPU_ARCH}"
install: .travis/install_osx.sh install: .travis/install_osx.sh

View file

@ -30,7 +30,7 @@ public:
output.resize(state.range(0)); output.resize(state.range(0));
} }
void TearDown(const ::benchmark::State &state[[maybe_unused]]) void TearDown(const ::benchmark::State& /* state */)
{ {
} }

View file

@ -5,6 +5,7 @@
// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz // If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz
#include "SIMDHelpers.h" #include "SIMDHelpers.h"
#include "Macros.h"
#include <benchmark/benchmark.h> #include <benchmark/benchmark.h>
#include <random> #include <random>
#include <numeric> #include <numeric>
@ -24,8 +25,8 @@ public:
std::generate(input.begin(), input.end(), [&]() { return dist(gen); }); std::generate(input.begin(), input.end(), [&]() { return dist(gen); });
} }
void TearDown(const ::benchmark::State& state [[maybe_unused]]) { void TearDown(const ::benchmark::State& state) {
UNUSED(state);
} }
std::vector<float> input; std::vector<float> input;

View file

@ -9,11 +9,11 @@
class Clock : public benchmark::Fixture { class Clock : public benchmark::Fixture {
public: public:
void SetUp(const ::benchmark::State& state) { void SetUp(const ::benchmark::State& /* state */) {
} }
void TearDown(const ::benchmark::State& state [[maybe_unused]]) { void TearDown(const ::benchmark::State& /* state */) {
} }

View file

@ -24,7 +24,7 @@ public:
std::generate(input.begin(), input.end(), [&]() { return dist(gen); }); std::generate(input.begin(), input.end(), [&]() { return dist(gen); });
} }
void TearDown(const ::benchmark::State& state [[maybe_unused]]) { void TearDown(const ::benchmark::State& /* state */) {
} }

View file

@ -23,7 +23,7 @@ public:
std::generate(input.begin(), input.end(), [&]() { return dist(gen); }); std::generate(input.begin(), input.end(), [&]() { return dist(gen); });
} }
void TearDown(const ::benchmark::State& state [[maybe_unused]]) { void TearDown(const ::benchmark::State& /* state */) {
} }

View file

@ -25,7 +25,7 @@ public:
sfz::cumsum<float, false>(input, absl::MakeSpan(input)); sfz::cumsum<float, false>(input, absl::MakeSpan(input));
} }
void TearDown(const ::benchmark::State& state [[maybe_unused]]) { void TearDown(const ::benchmark::State& /* state */) {
} }

View file

@ -26,7 +26,7 @@ public:
std::generate(input.begin(), input.end(), [&]() { return dist(gen); }); std::generate(input.begin(), input.end(), [&]() { return dist(gen); });
} }
void TearDown(const ::benchmark::State& state [[maybe_unused]]) { void TearDown(const ::benchmark::State& /* state */) {
} }

View file

@ -23,7 +23,7 @@ public:
sfz::cumsum<float, false>(input, absl::MakeSpan(input)); sfz::cumsum<float, false>(input, absl::MakeSpan(input));
} }
void TearDown(const ::benchmark::State& state [[maybe_unused]]) void TearDown(const ::benchmark::State& /* state */)
{ {
} }

View file

@ -32,7 +32,7 @@ public:
std::generate(input.begin(), input.end(), [&]() { return dist(gen); }); std::generate(input.begin(), input.end(), [&]() { return dist(gen); });
} }
void TearDown(const ::benchmark::State& state [[maybe_unused]]) { void TearDown(const ::benchmark::State& /* state */) {
} }
std::random_device rd { }; std::random_device rd { };

View file

@ -35,7 +35,7 @@ public:
std::generate(inputRight.begin(), inputRight.end(), [&]() { return dist(gen); }); std::generate(inputRight.begin(), inputRight.end(), [&]() { return dist(gen); });
} }
void TearDown(const ::benchmark::State& state [[maybe_unused]]) { void TearDown(const ::benchmark::State& /* state */) {
} }
std::random_device rd { }; std::random_device rd { };

View file

@ -10,6 +10,7 @@
#define DR_FLAC_IMPLEMENTATION #define DR_FLAC_IMPLEMENTATION
#include "dr_flac.h" #include "dr_flac.h"
#include "ghc/filesystem.hpp" #include "ghc/filesystem.hpp"
#include "absl/memory/memory.h"
#include <memory> #include <memory>
#ifndef NDEBUG #ifndef NDEBUG
#include <iostream> #include <iostream>
@ -18,7 +19,7 @@
class FileFixture : public benchmark::Fixture { class FileFixture : public benchmark::Fixture {
public: public:
void SetUp(const ::benchmark::State& state [[maybe_unused]]) { void SetUp(const ::benchmark::State& state) {
filePath1 = getPath() / "sample1.flac"; filePath1 = getPath() / "sample1.flac";
filePath2 = getPath() / "sample2.flac"; filePath2 = getPath() / "sample2.flac";
filePath3 = getPath() / "sample3.flac"; filePath3 = getPath() / "sample3.flac";
@ -32,7 +33,7 @@ public:
} }
} }
void TearDown(const ::benchmark::State& state [[maybe_unused]]) { void TearDown(const ::benchmark::State& /* state */) {
} }
ghc::filesystem::path getPath() ghc::filesystem::path getPath()
@ -60,7 +61,7 @@ BENCHMARK_DEFINE_F(FileFixture, SndFile)(benchmark::State& state) {
for (auto _ : state) for (auto _ : state)
{ {
SndfileHandle sndfile(filePath1.c_str()); SndfileHandle sndfile(filePath1.c_str());
buffer = std::make_unique<sfz::Buffer<float>>(sndfile.channels() * sndfile.frames()); buffer = absl::make_unique<sfz::Buffer<float>>(sndfile.channels() * sndfile.frames());
sndfile.readf(buffer->data(), sndfile.frames()); sndfile.readf(buffer->data(), sndfile.frames());
} }
} }
@ -69,7 +70,7 @@ BENCHMARK_DEFINE_F(FileFixture, DrFlac)(benchmark::State& state) {
for (auto _ : state) for (auto _ : state)
{ {
auto* flac = drflac_open_file(filePath2.c_str(), nullptr); auto* flac = drflac_open_file(filePath2.c_str(), nullptr);
buffer = std::make_unique<sfz::Buffer<float>>(flac->channels * flac->totalPCMFrameCount); buffer = absl::make_unique<sfz::Buffer<float>>(flac->channels * flac->totalPCMFrameCount);
drflac_read_pcm_frames_f32(flac, flac->totalPCMFrameCount, buffer->data()); drflac_read_pcm_frames_f32(flac, flac->totalPCMFrameCount, buffer->data());
} }
} }

View file

@ -24,7 +24,7 @@ public:
std::generate(input.begin(), input.end(), [&]() { return dist(gen); }); std::generate(input.begin(), input.end(), [&]() { return dist(gen); });
} }
void TearDown(const ::benchmark::State& state [[maybe_unused]]) { void TearDown(const ::benchmark::State& /* state */) {
} }
@ -46,7 +46,7 @@ public:
std::generate(input.begin(), input.end(), [&]() { return dist(gen); }); std::generate(input.begin(), input.end(), [&]() { return dist(gen); });
} }
void TearDown(const ::benchmark::State& state [[maybe_unused]]) { void TearDown(const ::benchmark::State& /* state */) {
} }

View file

@ -28,7 +28,7 @@ public:
absl::c_generate(floatJumps, [&]() { return dist(gen); }); absl::c_generate(floatJumps, [&]() { return dist(gen); });
} }
void TearDown(const ::benchmark::State& state [[maybe_unused]]) { void TearDown(const ::benchmark::State& /* state */) {
} }

View file

@ -10,11 +10,11 @@
class Logger : public benchmark::Fixture { class Logger : public benchmark::Fixture {
public: public:
void SetUp(const ::benchmark::State& state) { void SetUp(const ::benchmark::State& /* state */) {
} }
void TearDown(const ::benchmark::State& state [[maybe_unused]]) { void TearDown(const ::benchmark::State& /* state */) {
} }

View file

@ -30,7 +30,7 @@ public:
absl::c_generate(jumps, [&]() { return dist(gen); }); absl::c_generate(jumps, [&]() { return dist(gen); });
} }
void TearDown(const ::benchmark::State& state [[maybe_unused]]) { void TearDown(const ::benchmark::State& /* state */) {
} }

View file

@ -36,7 +36,7 @@ public:
}); });
} }
void TearDown(const ::benchmark::State& state [[maybe_unused]]) void TearDown(const ::benchmark::State& /* state */)
{ {
} }

View file

@ -26,7 +26,7 @@ public:
std::generate(source.begin(), source.end(), [&]() { return dist(gen); }); std::generate(source.begin(), source.end(), [&]() { return dist(gen); });
} }
void TearDown(const ::benchmark::State& state [[maybe_unused]]) void TearDown(const ::benchmark::State& /* state */)
{ {
} }

View file

@ -23,7 +23,7 @@ public:
std::generate(input.begin(), input.end(), [&]() { return dist(gen); }); std::generate(input.begin(), input.end(), [&]() { return dist(gen); });
} }
void TearDown(const ::benchmark::State& state [[maybe_unused]]) void TearDown(const ::benchmark::State& /* state */)
{ {
} }

View file

@ -23,7 +23,7 @@ public:
std::generate(input.begin(), input.end(), [&]() { return dist(gen); }); std::generate(input.begin(), input.end(), [&]() { return dist(gen); });
} }
void TearDown(const ::benchmark::State& state [[maybe_unused]]) void TearDown(const ::benchmark::State& /* state */)
{ {
} }

View file

@ -26,7 +26,7 @@ public:
std::generate(input.begin(), input.end(), [&]() { return dist(gen); }); std::generate(input.begin(), input.end(), [&]() { return dist(gen); });
} }
void TearDown(const ::benchmark::State& state [[maybe_unused]]) { void TearDown(const ::benchmark::State& /* state */) {
} }

View file

@ -26,7 +26,7 @@ public:
std::generate(input.begin(), input.end(), [&]() { return dist(gen); }); std::generate(input.begin(), input.end(), [&]() { return dist(gen); });
} }
void TearDown(const ::benchmark::State& state [[maybe_unused]]) void TearDown(const ::benchmark::State& /* state */)
{ {
} }

View file

@ -33,7 +33,7 @@ public:
span2 = absl::MakeSpan(temp2); span2 = absl::MakeSpan(temp2);
} }
void TearDown(const ::benchmark::State& state [[maybe_unused]]) { void TearDown(const ::benchmark::State& /* state */) {
} }
@ -69,7 +69,7 @@ BENCHMARK_DEFINE_F(PanArray, BlockOps)(benchmark::State& state) {
{ {
sfz::fill<float>(span2, 1.0f); sfz::fill<float>(span2, 1.0f);
sfz::add<float>(span1, span2); sfz::add<float>(span1, span2);
sfz::applyGain<float>(piFour<float>, span2); sfz::applyGain<float>(piFour<float>(), span2);
sfz::cos<float>(span2, span1); sfz::cos<float>(span2, span1);
sfz::sin<float>(span2, span2); sfz::sin<float>(span2, span2);
sfz::applyGain<float>(span1, absl::MakeSpan(left)); sfz::applyGain<float>(span1, absl::MakeSpan(left));

View file

@ -14,7 +14,7 @@ constexpr int bigNumber { 2399132 };
class IterOffset : public benchmark::Fixture { class IterOffset : public benchmark::Fixture {
public: public:
void SetUp(const ::benchmark::State& state [[maybe_unused]]) { void SetUp(const ::benchmark::State& state) {
std::random_device rd { }; std::random_device rd { };
std::mt19937 gen { rd() }; std::mt19937 gen { rd() };
std::uniform_real_distribution<float> dist { 0.001f, 1.0f }; std::uniform_real_distribution<float> dist { 0.001f, 1.0f };
@ -28,7 +28,7 @@ public:
sfz::cumsum<int>(jumps, absl::MakeSpan(offsets)); sfz::cumsum<int>(jumps, absl::MakeSpan(offsets));
} }
void TearDown(const ::benchmark::State& state [[maybe_unused]]) { void TearDown(const ::benchmark::State& /* state */) {
} }

0
benchmarks/BM_random.cpp Normal file
View file

View file

@ -12,7 +12,7 @@
#define DR_WAV_IMPLEMENTATION #define DR_WAV_IMPLEMENTATION
#include "dr_wav.h" #include "dr_wav.h"
#include "AudioBuffer.h" #include "AudioBuffer.h"
#include <memory> #include "absl/memory/memory.h"
#ifndef NDEBUG #ifndef NDEBUG
#include <iostream> #include <iostream>
#endif #endif
@ -30,10 +30,10 @@ public:
sndfile = SndfileHandle(rootPath.c_str()); sndfile = SndfileHandle(rootPath.c_str());
numFrames = static_cast<size_t>(sndfile.frames()); numFrames = static_cast<size_t>(sndfile.frames());
output = std::make_unique<sfz::AudioBuffer<float>>(sndfile.channels(), sndfile.frames()); output = absl::make_unique<sfz::AudioBuffer<float>>(sndfile.channels(), sndfile.frames());
} }
void TearDown(const ::benchmark::State& state [[maybe_unused]]) { void TearDown(const ::benchmark::State& /* state */) {
} }
ghc::filesystem::path getPath() ghc::filesystem::path getPath()

View file

@ -8,7 +8,7 @@
#include "AudioBuffer.h" #include "AudioBuffer.h"
#include "SIMDHelpers.h" #include "SIMDHelpers.h"
#include <benchmark/benchmark.h> #include <benchmark/benchmark.h>
#include <memory> #include "absl/memory/memory.h"
#include <samplerate.h> #include <samplerate.h>
#include <sndfile.hh> #include <sndfile.hh>
#include "ghc/filesystem.hpp" #include "ghc/filesystem.hpp"
@ -151,8 +151,8 @@ void upsample8xStage<true>(absl::Span<const float> input, absl::Span<float> outp
template <class T, bool SIMD=false> template <class T, bool SIMD=false>
std::unique_ptr<sfz::AudioBuffer<T>> upsample2x(const sfz::AudioBuffer<T>& buffer) std::unique_ptr<sfz::AudioBuffer<T>> upsample2x(const sfz::AudioBuffer<T>& buffer)
{ {
// auto tempBuffer = std::make_unique<sfz::Buffer<T>>(buffer.getNumFrames() * 2); // auto tempBuffer = absl::make_unique<sfz::Buffer<T>>(buffer.getNumFrames() * 2);
auto outputBuffer = std::make_unique<sfz::AudioBuffer<T>>(buffer.getNumChannels(), buffer.getNumFrames() * 2); auto outputBuffer = absl::make_unique<sfz::AudioBuffer<T>>(buffer.getNumChannels(), buffer.getNumFrames() * 2);
for (size_t channelIdx = 0; channelIdx < buffer.getNumChannels(); channelIdx++) { for (size_t channelIdx = 0; channelIdx < buffer.getNumChannels(); channelIdx++) {
upsample2xStage<SIMD>(buffer.getConstSpan(channelIdx), outputBuffer->getSpan(channelIdx)); upsample2xStage<SIMD>(buffer.getConstSpan(channelIdx), outputBuffer->getSpan(channelIdx));
} }
@ -162,8 +162,8 @@ std::unique_ptr<sfz::AudioBuffer<T>> upsample2x(const sfz::AudioBuffer<T>& buffe
template <class T, bool SIMD=false> template <class T, bool SIMD=false>
std::unique_ptr<sfz::AudioBuffer<T>> upsample4x(const sfz::AudioBuffer<T>& buffer) std::unique_ptr<sfz::AudioBuffer<T>> upsample4x(const sfz::AudioBuffer<T>& buffer)
{ {
auto tempBuffer = std::make_unique<sfz::Buffer<T>>(buffer.getNumFrames() * 2); auto tempBuffer = absl::make_unique<sfz::Buffer<T>>(buffer.getNumFrames() * 2);
auto outputBuffer = std::make_unique<sfz::AudioBuffer<T>>(buffer.getNumChannels(), buffer.getNumFrames() * 4); auto outputBuffer = absl::make_unique<sfz::AudioBuffer<T>>(buffer.getNumChannels(), buffer.getNumFrames() * 4);
for (size_t channelIdx = 0; channelIdx < buffer.getNumChannels(); channelIdx++) { for (size_t channelIdx = 0; channelIdx < buffer.getNumChannels(); channelIdx++) {
upsample2xStage<SIMD>(buffer.getConstSpan(channelIdx), absl::MakeSpan(*tempBuffer)); upsample2xStage<SIMD>(buffer.getConstSpan(channelIdx), absl::MakeSpan(*tempBuffer));
upsample4xStage<SIMD>(absl::MakeConstSpan(*tempBuffer), outputBuffer->getSpan(channelIdx)); upsample4xStage<SIMD>(absl::MakeConstSpan(*tempBuffer), outputBuffer->getSpan(channelIdx));
@ -174,9 +174,9 @@ std::unique_ptr<sfz::AudioBuffer<T>> upsample4x(const sfz::AudioBuffer<T>& buffe
template <class T, bool SIMD=false> template <class T, bool SIMD=false>
std::unique_ptr<sfz::AudioBuffer<T>> upsample8x(const sfz::AudioBuffer<T>& buffer) std::unique_ptr<sfz::AudioBuffer<T>> upsample8x(const sfz::AudioBuffer<T>& buffer)
{ {
auto tempBuffer2x = std::make_unique<sfz::Buffer<T>>(buffer.getNumFrames() * 2); auto tempBuffer2x = absl::make_unique<sfz::Buffer<T>>(buffer.getNumFrames() * 2);
auto tempBuffer4x = std::make_unique<sfz::Buffer<T>>(buffer.getNumFrames() * 4); auto tempBuffer4x = absl::make_unique<sfz::Buffer<T>>(buffer.getNumFrames() * 4);
auto outputBuffer = std::make_unique<sfz::AudioBuffer<T>>(buffer.getNumChannels(), buffer.getNumFrames() * 8); auto outputBuffer = absl::make_unique<sfz::AudioBuffer<T>>(buffer.getNumChannels(), buffer.getNumFrames() * 8);
for (size_t channelIdx = 0; channelIdx < buffer.getNumChannels(); channelIdx++) { for (size_t channelIdx = 0; channelIdx < buffer.getNumChannels(); channelIdx++) {
upsample2xStage<SIMD>(buffer.getConstSpan(channelIdx), absl::MakeSpan(*tempBuffer2x)); upsample2xStage<SIMD>(buffer.getConstSpan(channelIdx), absl::MakeSpan(*tempBuffer2x));
upsample4xStage<SIMD>(absl::MakeConstSpan(*tempBuffer2x), absl::MakeSpan(*tempBuffer4x)); upsample4xStage<SIMD>(absl::MakeConstSpan(*tempBuffer2x), absl::MakeSpan(*tempBuffer4x));
@ -202,11 +202,11 @@ public:
SndfileHandle sndfile(rootPath.c_str()); SndfileHandle sndfile(rootPath.c_str());
numFrames = sndfile.frames(); numFrames = sndfile.frames();
numChannels = sndfile.channels(); numChannels = sndfile.channels();
interleavedBuffer = std::make_unique<sfz::Buffer<float>>(numChannels * numFrames); interleavedBuffer = absl::make_unique<sfz::Buffer<float>>(numChannels * numFrames);
sndfile.readf(interleavedBuffer->data(), sndfile.frames()); sndfile.readf(interleavedBuffer->data(), sndfile.frames());
} }
void TearDown(const ::benchmark::State& state [[maybe_unused]]) void TearDown(const ::benchmark::State& /* state */)
{ {
} }
@ -231,7 +231,7 @@ public:
BENCHMARK_DEFINE_F(SndFile, HIIR2X_scalar)(benchmark::State& state) BENCHMARK_DEFINE_F(SndFile, HIIR2X_scalar)(benchmark::State& state)
{ {
for (auto _ : state) { for (auto _ : state) {
auto baseBuffer = std::make_unique<sfz::AudioBuffer<float>>(numChannels, numFrames); auto baseBuffer = absl::make_unique<sfz::AudioBuffer<float>>(numChannels, numFrames);
sfz::readInterleaved<float>(*interleavedBuffer, baseBuffer->getSpan(0), baseBuffer->getSpan(1)); sfz::readInterleaved<float>(*interleavedBuffer, baseBuffer->getSpan(0), baseBuffer->getSpan(1));
auto outBuffer = upsample2x<float, false>(*baseBuffer); auto outBuffer = upsample2x<float, false>(*baseBuffer);
benchmark::DoNotOptimize(outBuffer); benchmark::DoNotOptimize(outBuffer);
@ -241,7 +241,7 @@ BENCHMARK_DEFINE_F(SndFile, HIIR2X_scalar)(benchmark::State& state)
BENCHMARK_DEFINE_F(SndFile, HIIR4X_scalar)(benchmark::State& state) BENCHMARK_DEFINE_F(SndFile, HIIR4X_scalar)(benchmark::State& state)
{ {
for (auto _ : state) { for (auto _ : state) {
auto baseBuffer = std::make_unique<sfz::AudioBuffer<float>>(numChannels, numFrames); auto baseBuffer = absl::make_unique<sfz::AudioBuffer<float>>(numChannels, numFrames);
sfz::readInterleaved<float>(*interleavedBuffer, baseBuffer->getSpan(0), baseBuffer->getSpan(1)); sfz::readInterleaved<float>(*interleavedBuffer, baseBuffer->getSpan(0), baseBuffer->getSpan(1));
auto outBuffer = upsample4x<float, false>(*baseBuffer); auto outBuffer = upsample4x<float, false>(*baseBuffer);
benchmark::DoNotOptimize(outBuffer); benchmark::DoNotOptimize(outBuffer);
@ -251,7 +251,7 @@ BENCHMARK_DEFINE_F(SndFile, HIIR4X_scalar)(benchmark::State& state)
BENCHMARK_DEFINE_F(SndFile, HIIR8X_scalar)(benchmark::State& state) BENCHMARK_DEFINE_F(SndFile, HIIR8X_scalar)(benchmark::State& state)
{ {
for (auto _ : state) { for (auto _ : state) {
auto baseBuffer = std::make_unique<sfz::AudioBuffer<float>>(numChannels, numFrames); auto baseBuffer = absl::make_unique<sfz::AudioBuffer<float>>(numChannels, numFrames);
sfz::readInterleaved<float>(*interleavedBuffer, baseBuffer->getSpan(0), baseBuffer->getSpan(1)); sfz::readInterleaved<float>(*interleavedBuffer, baseBuffer->getSpan(0), baseBuffer->getSpan(1));
auto outBuffer = upsample8x<float, false>(*baseBuffer); auto outBuffer = upsample8x<float, false>(*baseBuffer);
benchmark::DoNotOptimize(outBuffer); benchmark::DoNotOptimize(outBuffer);
@ -261,7 +261,7 @@ BENCHMARK_DEFINE_F(SndFile, HIIR8X_scalar)(benchmark::State& state)
BENCHMARK_DEFINE_F(SndFile, HIIR2X_vector)(benchmark::State& state) BENCHMARK_DEFINE_F(SndFile, HIIR2X_vector)(benchmark::State& state)
{ {
for (auto _ : state) { for (auto _ : state) {
auto baseBuffer = std::make_unique<sfz::AudioBuffer<float>>(numChannels, numFrames); auto baseBuffer = absl::make_unique<sfz::AudioBuffer<float>>(numChannels, numFrames);
sfz::readInterleaved<float>(*interleavedBuffer, baseBuffer->getSpan(0), baseBuffer->getSpan(1)); sfz::readInterleaved<float>(*interleavedBuffer, baseBuffer->getSpan(0), baseBuffer->getSpan(1));
auto outBuffer = upsample2x<float, true>(*baseBuffer); auto outBuffer = upsample2x<float, true>(*baseBuffer);
benchmark::DoNotOptimize(outBuffer); benchmark::DoNotOptimize(outBuffer);
@ -271,7 +271,7 @@ BENCHMARK_DEFINE_F(SndFile, HIIR2X_vector)(benchmark::State& state)
BENCHMARK_DEFINE_F(SndFile, HIIR4X_vector)(benchmark::State& state) BENCHMARK_DEFINE_F(SndFile, HIIR4X_vector)(benchmark::State& state)
{ {
for (auto _ : state) { for (auto _ : state) {
auto baseBuffer = std::make_unique<sfz::AudioBuffer<float>>(numChannels, numFrames); auto baseBuffer = absl::make_unique<sfz::AudioBuffer<float>>(numChannels, numFrames);
sfz::readInterleaved<float>(*interleavedBuffer, baseBuffer->getSpan(0), baseBuffer->getSpan(1)); sfz::readInterleaved<float>(*interleavedBuffer, baseBuffer->getSpan(0), baseBuffer->getSpan(1));
auto outBuffer = upsample4x<float, true>(*baseBuffer); auto outBuffer = upsample4x<float, true>(*baseBuffer);
benchmark::DoNotOptimize(outBuffer); benchmark::DoNotOptimize(outBuffer);
@ -281,7 +281,7 @@ BENCHMARK_DEFINE_F(SndFile, HIIR4X_vector)(benchmark::State& state)
BENCHMARK_DEFINE_F(SndFile, HIIR8X_vector)(benchmark::State& state) BENCHMARK_DEFINE_F(SndFile, HIIR8X_vector)(benchmark::State& state)
{ {
for (auto _ : state) { for (auto _ : state) {
auto baseBuffer = std::make_unique<sfz::AudioBuffer<float>>(numChannels, numFrames); auto baseBuffer = absl::make_unique<sfz::AudioBuffer<float>>(numChannels, numFrames);
sfz::readInterleaved<float>(*interleavedBuffer, baseBuffer->getSpan(0), baseBuffer->getSpan(1)); sfz::readInterleaved<float>(*interleavedBuffer, baseBuffer->getSpan(0), baseBuffer->getSpan(1));
auto outBuffer = upsample8x<float, true>(*baseBuffer); auto outBuffer = upsample8x<float, true>(*baseBuffer);
benchmark::DoNotOptimize(outBuffer); benchmark::DoNotOptimize(outBuffer);
@ -291,7 +291,7 @@ BENCHMARK_DEFINE_F(SndFile, HIIR8X_vector)(benchmark::State& state)
BENCHMARK_DEFINE_F(SndFile, SRC2x_BEST)(benchmark::State& state) BENCHMARK_DEFINE_F(SndFile, SRC2x_BEST)(benchmark::State& state)
{ {
for (auto _ : state) { for (auto _ : state) {
auto intermediateBuffer = std::make_unique<sfz::Buffer<float>>(2 * numChannels * numFrames); auto intermediateBuffer = absl::make_unique<sfz::Buffer<float>>(2 * numChannels * numFrames);
SRC_DATA srcData; SRC_DATA srcData;
srcData.data_in = interleavedBuffer->data(); srcData.data_in = interleavedBuffer->data();
srcData.data_out = intermediateBuffer->data(); srcData.data_out = intermediateBuffer->data();
@ -299,7 +299,7 @@ BENCHMARK_DEFINE_F(SndFile, SRC2x_BEST)(benchmark::State& state)
srcData.input_frames = static_cast<long>(numFrames); srcData.input_frames = static_cast<long>(numFrames);
srcData.output_frames = static_cast<long>(2 * numFrames); srcData.output_frames = static_cast<long>(2 * numFrames);
src_simple(&srcData, SRC_SINC_BEST_QUALITY, static_cast<int>(numChannels)); src_simple(&srcData, SRC_SINC_BEST_QUALITY, static_cast<int>(numChannels));
auto outBuffer = std::make_unique<sfz::AudioBuffer<float>>(numChannels, 2 * numFrames); auto outBuffer = absl::make_unique<sfz::AudioBuffer<float>>(numChannels, 2 * numFrames);
sfz::readInterleaved<float>(*intermediateBuffer, outBuffer->getSpan(0), outBuffer->getSpan(1)); sfz::readInterleaved<float>(*intermediateBuffer, outBuffer->getSpan(0), outBuffer->getSpan(1));
benchmark::DoNotOptimize(outBuffer); benchmark::DoNotOptimize(outBuffer);
} }
@ -308,7 +308,7 @@ BENCHMARK_DEFINE_F(SndFile, SRC2x_BEST)(benchmark::State& state)
BENCHMARK_DEFINE_F(SndFile, SRC2x_MEDIUM)(benchmark::State& state) BENCHMARK_DEFINE_F(SndFile, SRC2x_MEDIUM)(benchmark::State& state)
{ {
for (auto _ : state) { for (auto _ : state) {
auto intermediateBuffer = std::make_unique<sfz::Buffer<float>>(2 * numChannels * numFrames); auto intermediateBuffer = absl::make_unique<sfz::Buffer<float>>(2 * numChannels * numFrames);
SRC_DATA srcData; SRC_DATA srcData;
srcData.data_in = interleavedBuffer->data(); srcData.data_in = interleavedBuffer->data();
srcData.data_out = intermediateBuffer->data(); srcData.data_out = intermediateBuffer->data();
@ -316,7 +316,7 @@ BENCHMARK_DEFINE_F(SndFile, SRC2x_MEDIUM)(benchmark::State& state)
srcData.input_frames = static_cast<long>(numFrames); srcData.input_frames = static_cast<long>(numFrames);
srcData.output_frames = static_cast<long>(2 * numFrames); srcData.output_frames = static_cast<long>(2 * numFrames);
src_simple(&srcData, SRC_SINC_MEDIUM_QUALITY, static_cast<int>(numChannels)); src_simple(&srcData, SRC_SINC_MEDIUM_QUALITY, static_cast<int>(numChannels));
auto outBuffer = std::make_unique<sfz::AudioBuffer<float>>(numChannels, 2 * numFrames); auto outBuffer = absl::make_unique<sfz::AudioBuffer<float>>(numChannels, 2 * numFrames);
sfz::readInterleaved<float>(*intermediateBuffer, outBuffer->getSpan(0), outBuffer->getSpan(1)); sfz::readInterleaved<float>(*intermediateBuffer, outBuffer->getSpan(0), outBuffer->getSpan(1));
benchmark::DoNotOptimize(outBuffer); benchmark::DoNotOptimize(outBuffer);
} }
@ -325,7 +325,7 @@ BENCHMARK_DEFINE_F(SndFile, SRC2x_MEDIUM)(benchmark::State& state)
BENCHMARK_DEFINE_F(SndFile, SRC2x_FASTEST)(benchmark::State& state) BENCHMARK_DEFINE_F(SndFile, SRC2x_FASTEST)(benchmark::State& state)
{ {
for (auto _ : state) { for (auto _ : state) {
auto intermediateBuffer = std::make_unique<sfz::Buffer<float>>(2 * numChannels * numFrames); auto intermediateBuffer = absl::make_unique<sfz::Buffer<float>>(2 * numChannels * numFrames);
SRC_DATA srcData; SRC_DATA srcData;
srcData.data_in = interleavedBuffer->data(); srcData.data_in = interleavedBuffer->data();
srcData.data_out = intermediateBuffer->data(); srcData.data_out = intermediateBuffer->data();
@ -333,7 +333,7 @@ BENCHMARK_DEFINE_F(SndFile, SRC2x_FASTEST)(benchmark::State& state)
srcData.input_frames = static_cast<long>(numFrames); srcData.input_frames = static_cast<long>(numFrames);
srcData.output_frames = static_cast<long>(2 * numFrames); srcData.output_frames = static_cast<long>(2 * numFrames);
src_simple(&srcData, SRC_SINC_FASTEST, static_cast<int>(numChannels)); src_simple(&srcData, SRC_SINC_FASTEST, static_cast<int>(numChannels));
auto outBuffer = std::make_unique<sfz::AudioBuffer<float>>(numChannels, 2 * numFrames); auto outBuffer = absl::make_unique<sfz::AudioBuffer<float>>(numChannels, 2 * numFrames);
sfz::readInterleaved<float>(*intermediateBuffer, outBuffer->getSpan(0), outBuffer->getSpan(1)); sfz::readInterleaved<float>(*intermediateBuffer, outBuffer->getSpan(0), outBuffer->getSpan(1));
benchmark::DoNotOptimize(outBuffer); benchmark::DoNotOptimize(outBuffer);
} }
@ -343,7 +343,7 @@ BENCHMARK_DEFINE_F(SndFile, SRC2x_FASTEST)(benchmark::State& state)
BENCHMARK_DEFINE_F(SndFile, SRC4x_BEST)(benchmark::State& state) BENCHMARK_DEFINE_F(SndFile, SRC4x_BEST)(benchmark::State& state)
{ {
for (auto _ : state) { for (auto _ : state) {
auto intermediateBuffer = std::make_unique<sfz::Buffer<float>>(2 * numChannels * numFrames); auto intermediateBuffer = absl::make_unique<sfz::Buffer<float>>(2 * numChannels * numFrames);
SRC_DATA srcData; SRC_DATA srcData;
srcData.data_in = interleavedBuffer->data(); srcData.data_in = interleavedBuffer->data();
srcData.data_out = intermediateBuffer->data(); srcData.data_out = intermediateBuffer->data();
@ -351,7 +351,7 @@ BENCHMARK_DEFINE_F(SndFile, SRC4x_BEST)(benchmark::State& state)
srcData.input_frames = static_cast<long>(numFrames); srcData.input_frames = static_cast<long>(numFrames);
srcData.output_frames = static_cast<long>(2 * numFrames); srcData.output_frames = static_cast<long>(2 * numFrames);
src_simple(&srcData, SRC_SINC_BEST_QUALITY, static_cast<int>(numChannels)); src_simple(&srcData, SRC_SINC_BEST_QUALITY, static_cast<int>(numChannels));
auto outBuffer = std::make_unique<sfz::AudioBuffer<float>>(numChannels, 2 * numFrames); auto outBuffer = absl::make_unique<sfz::AudioBuffer<float>>(numChannels, 2 * numFrames);
sfz::readInterleaved<float>(*intermediateBuffer, outBuffer->getSpan(0), outBuffer->getSpan(1)); sfz::readInterleaved<float>(*intermediateBuffer, outBuffer->getSpan(0), outBuffer->getSpan(1));
benchmark::DoNotOptimize(outBuffer); benchmark::DoNotOptimize(outBuffer);
} }
@ -360,7 +360,7 @@ BENCHMARK_DEFINE_F(SndFile, SRC4x_BEST)(benchmark::State& state)
BENCHMARK_DEFINE_F(SndFile, SRC4x_MEDIUM)(benchmark::State& state) BENCHMARK_DEFINE_F(SndFile, SRC4x_MEDIUM)(benchmark::State& state)
{ {
for (auto _ : state) { for (auto _ : state) {
auto intermediateBuffer = std::make_unique<sfz::Buffer<float>>(2 * numChannels * numFrames); auto intermediateBuffer = absl::make_unique<sfz::Buffer<float>>(2 * numChannels * numFrames);
SRC_DATA srcData; SRC_DATA srcData;
srcData.data_in = interleavedBuffer->data(); srcData.data_in = interleavedBuffer->data();
srcData.data_out = intermediateBuffer->data(); srcData.data_out = intermediateBuffer->data();
@ -368,7 +368,7 @@ BENCHMARK_DEFINE_F(SndFile, SRC4x_MEDIUM)(benchmark::State& state)
srcData.input_frames = static_cast<long>(numFrames); srcData.input_frames = static_cast<long>(numFrames);
srcData.output_frames = static_cast<long>(2 * numFrames); srcData.output_frames = static_cast<long>(2 * numFrames);
src_simple(&srcData, SRC_SINC_MEDIUM_QUALITY, static_cast<int>(numChannels)); src_simple(&srcData, SRC_SINC_MEDIUM_QUALITY, static_cast<int>(numChannels));
auto outBuffer = std::make_unique<sfz::AudioBuffer<float>>(numChannels, 2 * numFrames); auto outBuffer = absl::make_unique<sfz::AudioBuffer<float>>(numChannels, 2 * numFrames);
sfz::readInterleaved<float>(*intermediateBuffer, outBuffer->getSpan(0), outBuffer->getSpan(1)); sfz::readInterleaved<float>(*intermediateBuffer, outBuffer->getSpan(0), outBuffer->getSpan(1));
benchmark::DoNotOptimize(outBuffer); benchmark::DoNotOptimize(outBuffer);
} }
@ -377,7 +377,7 @@ BENCHMARK_DEFINE_F(SndFile, SRC4x_MEDIUM)(benchmark::State& state)
BENCHMARK_DEFINE_F(SndFile, SRC4x_FASTEST)(benchmark::State& state) BENCHMARK_DEFINE_F(SndFile, SRC4x_FASTEST)(benchmark::State& state)
{ {
for (auto _ : state) { for (auto _ : state) {
auto intermediateBuffer = std::make_unique<sfz::Buffer<float>>(2 * numChannels * numFrames); auto intermediateBuffer = absl::make_unique<sfz::Buffer<float>>(2 * numChannels * numFrames);
SRC_DATA srcData; SRC_DATA srcData;
srcData.data_in = interleavedBuffer->data(); srcData.data_in = interleavedBuffer->data();
srcData.data_out = intermediateBuffer->data(); srcData.data_out = intermediateBuffer->data();
@ -385,7 +385,7 @@ BENCHMARK_DEFINE_F(SndFile, SRC4x_FASTEST)(benchmark::State& state)
srcData.input_frames = static_cast<long>(numFrames); srcData.input_frames = static_cast<long>(numFrames);
srcData.output_frames = static_cast<long>(2 * numFrames); srcData.output_frames = static_cast<long>(2 * numFrames);
src_simple(&srcData, SRC_SINC_FASTEST, static_cast<int>(numChannels)); src_simple(&srcData, SRC_SINC_FASTEST, static_cast<int>(numChannels));
auto outBuffer = std::make_unique<sfz::AudioBuffer<float>>(numChannels, 2 * numFrames); auto outBuffer = absl::make_unique<sfz::AudioBuffer<float>>(numChannels, 2 * numFrames);
sfz::readInterleaved<float>(*intermediateBuffer, outBuffer->getSpan(0), outBuffer->getSpan(1)); sfz::readInterleaved<float>(*intermediateBuffer, outBuffer->getSpan(0), outBuffer->getSpan(1));
benchmark::DoNotOptimize(outBuffer); benchmark::DoNotOptimize(outBuffer);
} }
@ -394,7 +394,7 @@ BENCHMARK_DEFINE_F(SndFile, SRC4x_FASTEST)(benchmark::State& state)
BENCHMARK_DEFINE_F(SndFile, SRC8x_BEST)(benchmark::State& state) BENCHMARK_DEFINE_F(SndFile, SRC8x_BEST)(benchmark::State& state)
{ {
for (auto _ : state) { for (auto _ : state) {
auto intermediateBuffer = std::make_unique<sfz::Buffer<float>>(2 * numChannels * numFrames); auto intermediateBuffer = absl::make_unique<sfz::Buffer<float>>(2 * numChannels * numFrames);
SRC_DATA srcData; SRC_DATA srcData;
srcData.data_in = interleavedBuffer->data(); srcData.data_in = interleavedBuffer->data();
srcData.data_out = intermediateBuffer->data(); srcData.data_out = intermediateBuffer->data();
@ -402,7 +402,7 @@ BENCHMARK_DEFINE_F(SndFile, SRC8x_BEST)(benchmark::State& state)
srcData.input_frames = static_cast<long>(numFrames); srcData.input_frames = static_cast<long>(numFrames);
srcData.output_frames = static_cast<long>(2 * numFrames); srcData.output_frames = static_cast<long>(2 * numFrames);
src_simple(&srcData, SRC_SINC_BEST_QUALITY, static_cast<int>(numChannels)); src_simple(&srcData, SRC_SINC_BEST_QUALITY, static_cast<int>(numChannels));
auto outBuffer = std::make_unique<sfz::AudioBuffer<float>>(numChannels, 2 * numFrames); auto outBuffer = absl::make_unique<sfz::AudioBuffer<float>>(numChannels, 2 * numFrames);
sfz::readInterleaved<float>(*intermediateBuffer, outBuffer->getSpan(0), outBuffer->getSpan(1)); sfz::readInterleaved<float>(*intermediateBuffer, outBuffer->getSpan(0), outBuffer->getSpan(1));
benchmark::DoNotOptimize(outBuffer); benchmark::DoNotOptimize(outBuffer);
} }
@ -411,7 +411,7 @@ BENCHMARK_DEFINE_F(SndFile, SRC8x_BEST)(benchmark::State& state)
BENCHMARK_DEFINE_F(SndFile, SRC8x_MEDIUM)(benchmark::State& state) BENCHMARK_DEFINE_F(SndFile, SRC8x_MEDIUM)(benchmark::State& state)
{ {
for (auto _ : state) { for (auto _ : state) {
auto intermediateBuffer = std::make_unique<sfz::Buffer<float>>(2 * numChannels * numFrames); auto intermediateBuffer = absl::make_unique<sfz::Buffer<float>>(2 * numChannels * numFrames);
SRC_DATA srcData; SRC_DATA srcData;
srcData.data_in = interleavedBuffer->data(); srcData.data_in = interleavedBuffer->data();
srcData.data_out = intermediateBuffer->data(); srcData.data_out = intermediateBuffer->data();
@ -419,7 +419,7 @@ BENCHMARK_DEFINE_F(SndFile, SRC8x_MEDIUM)(benchmark::State& state)
srcData.input_frames = static_cast<long>(numFrames); srcData.input_frames = static_cast<long>(numFrames);
srcData.output_frames = static_cast<long>(2 * numFrames); srcData.output_frames = static_cast<long>(2 * numFrames);
src_simple(&srcData, SRC_SINC_MEDIUM_QUALITY, static_cast<int>(numChannels)); src_simple(&srcData, SRC_SINC_MEDIUM_QUALITY, static_cast<int>(numChannels));
auto outBuffer = std::make_unique<sfz::AudioBuffer<float>>(numChannels, 2 * numFrames); auto outBuffer = absl::make_unique<sfz::AudioBuffer<float>>(numChannels, 2 * numFrames);
sfz::readInterleaved<float>(*intermediateBuffer, outBuffer->getSpan(0), outBuffer->getSpan(1)); sfz::readInterleaved<float>(*intermediateBuffer, outBuffer->getSpan(0), outBuffer->getSpan(1));
benchmark::DoNotOptimize(outBuffer); benchmark::DoNotOptimize(outBuffer);
} }
@ -428,7 +428,7 @@ BENCHMARK_DEFINE_F(SndFile, SRC8x_MEDIUM)(benchmark::State& state)
BENCHMARK_DEFINE_F(SndFile, SRC8x_FASTEST)(benchmark::State& state) BENCHMARK_DEFINE_F(SndFile, SRC8x_FASTEST)(benchmark::State& state)
{ {
for (auto _ : state) { for (auto _ : state) {
auto intermediateBuffer = std::make_unique<sfz::Buffer<float>>(2 * numChannels * numFrames); auto intermediateBuffer = absl::make_unique<sfz::Buffer<float>>(2 * numChannels * numFrames);
SRC_DATA srcData; SRC_DATA srcData;
srcData.data_in = interleavedBuffer->data(); srcData.data_in = interleavedBuffer->data();
srcData.data_out = intermediateBuffer->data(); srcData.data_out = intermediateBuffer->data();
@ -436,7 +436,7 @@ BENCHMARK_DEFINE_F(SndFile, SRC8x_FASTEST)(benchmark::State& state)
srcData.input_frames = static_cast<long>(numFrames); srcData.input_frames = static_cast<long>(numFrames);
srcData.output_frames = static_cast<long>(2 * numFrames); srcData.output_frames = static_cast<long>(2 * numFrames);
src_simple(&srcData, SRC_SINC_FASTEST, static_cast<int>(numChannels)); src_simple(&srcData, SRC_SINC_FASTEST, static_cast<int>(numChannels));
auto outBuffer = std::make_unique<sfz::AudioBuffer<float>>(numChannels, 2 * numFrames); auto outBuffer = absl::make_unique<sfz::AudioBuffer<float>>(numChannels, 2 * numFrames);
sfz::readInterleaved<float>(*intermediateBuffer, outBuffer->getSpan(0), outBuffer->getSpan(1)); sfz::readInterleaved<float>(*intermediateBuffer, outBuffer->getSpan(0), outBuffer->getSpan(1));
benchmark::DoNotOptimize(outBuffer); benchmark::DoNotOptimize(outBuffer);
} }
@ -445,7 +445,7 @@ BENCHMARK_DEFINE_F(SndFile, SRC8x_FASTEST)(benchmark::State& state)
BENCHMARK_DEFINE_F(SndFile, HIIR8X_default)(benchmark::State& state) BENCHMARK_DEFINE_F(SndFile, HIIR8X_default)(benchmark::State& state)
{ {
for (auto _ : state) { for (auto _ : state) {
auto baseBuffer = std::make_unique<sfz::AudioBuffer<float>>(numChannels, numFrames); auto baseBuffer = absl::make_unique<sfz::AudioBuffer<float>>(numChannels, numFrames);
sfz::readInterleaved<float>(*interleavedBuffer, baseBuffer->getSpan(0), baseBuffer->getSpan(1)); sfz::readInterleaved<float>(*interleavedBuffer, baseBuffer->getSpan(0), baseBuffer->getSpan(1));
auto outBuffer = upsample8x<float>(*baseBuffer); auto outBuffer = upsample8x<float>(*baseBuffer);
benchmark::DoNotOptimize(outBuffer); benchmark::DoNotOptimize(outBuffer);

View file

@ -11,7 +11,7 @@
#include "ghc/filesystem.hpp" #include "ghc/filesystem.hpp"
#include "Oversampler.h" #include "Oversampler.h"
#include "AudioBuffer.h" #include "AudioBuffer.h"
#include <memory> #include "absl/memory/memory.h"
#include <iostream> #include <iostream>
@ -75,10 +75,10 @@ public:
sndfile = SndfileHandle(rootPath.c_str()); sndfile = SndfileHandle(rootPath.c_str());
numFrames = static_cast<size_t>(sndfile.frames()); numFrames = static_cast<size_t>(sndfile.frames());
output = std::make_unique<sfz::AudioBuffer<float>>(sndfile.channels(), numFrames * 4); output = absl::make_unique<sfz::AudioBuffer<float>>(sndfile.channels(), numFrames * 4);
} }
void TearDown(const ::benchmark::State& state [[maybe_unused]]) { void TearDown(const ::benchmark::State& /* state */) {
} }
ghc::filesystem::path getPath() ghc::filesystem::path getPath()

View file

@ -29,7 +29,7 @@ public:
absl::c_generate(jumps, [&]() { return dist(gen); }); absl::c_generate(jumps, [&]() { return dist(gen); });
} }
void TearDown(const ::benchmark::State& state [[maybe_unused]]) { void TearDown(const ::benchmark::State& /* state */) {
} }

View file

@ -24,7 +24,7 @@ public:
std::generate(input.begin(), input.end(), [&]() { return dist(gen); }); std::generate(input.begin(), input.end(), [&]() { return dist(gen); });
} }
void TearDown(const ::benchmark::State& state [[maybe_unused]]) { void TearDown(const ::benchmark::State& /* state */) {
} }

View file

@ -9,7 +9,7 @@
#define DR_WAV_IMPLEMENTATION #define DR_WAV_IMPLEMENTATION
#include "dr_wav.h" #include "dr_wav.h"
#include "ghc/filesystem.hpp" #include "ghc/filesystem.hpp"
#include <memory> #include "absl/memory/memory.h"
#ifndef NDEBUG #ifndef NDEBUG
#include <iostream> #include <iostream>
#endif #endif
@ -17,7 +17,7 @@
class FileFixture : public benchmark::Fixture { class FileFixture : public benchmark::Fixture {
public: public:
void SetUp(const ::benchmark::State& state [[maybe_unused]]) { void SetUp(const ::benchmark::State& /* state */) {
filePath1 = getPath() / "sample1.wav"; filePath1 = getPath() / "sample1.wav";
filePath2 = getPath() / "sample2.wav"; filePath2 = getPath() / "sample2.wav";
filePath3 = getPath() / "sample3.wav"; filePath3 = getPath() / "sample3.wav";
@ -31,7 +31,7 @@ public:
} }
} }
void TearDown(const ::benchmark::State& state [[maybe_unused]]) { void TearDown(const ::benchmark::State& /* state */) {
} }
ghc::filesystem::path getPath() ghc::filesystem::path getPath()
@ -59,7 +59,7 @@ BENCHMARK_DEFINE_F(FileFixture, SndFile)(benchmark::State& state) {
for (auto _ : state) for (auto _ : state)
{ {
SndfileHandle sndfile(filePath1.c_str()); SndfileHandle sndfile(filePath1.c_str());
buffer = std::make_unique<sfz::Buffer<float>>(sndfile.channels() * sndfile.frames()); buffer = absl::make_unique<sfz::Buffer<float>>(sndfile.channels() * sndfile.frames());
sndfile.readf(buffer->data(), sndfile.frames()); sndfile.readf(buffer->data(), sndfile.frames());
} }
} }
@ -74,7 +74,7 @@ BENCHMARK_DEFINE_F(FileFixture, DrWav)(benchmark::State& state) {
#endif #endif
std::terminate(); std::terminate();
} }
buffer = std::make_unique<sfz::Buffer<float>>(wav.channels * wav.totalPCMFrameCount); buffer = absl::make_unique<sfz::Buffer<float>>(wav.channels * wav.totalPCMFrameCount);
drwav_read_pcm_frames_f32(&wav, wav.totalPCMFrameCount, buffer->data()); drwav_read_pcm_frames_f32(&wav, wav.totalPCMFrameCount, buffer->data());
} }
} }

View file

@ -37,7 +37,7 @@ public:
span3 = absl::MakeSpan(temp3); span3 = absl::MakeSpan(temp3);
} }
void TearDown(const ::benchmark::State& state [[maybe_unused]]) { void TearDown(const ::benchmark::State& /* state */) {
} }

View file

@ -22,6 +22,7 @@
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "sfizz/Synth.h" #include "sfizz/Synth.h"
#include "sfizz/Macros.h"
#include <absl/flags/parse.h> #include <absl/flags/parse.h>
#include <absl/flags/flag.h> #include <absl/flags/flag.h>
#include <absl/types/span.h> #include <absl/types/span.h>
@ -37,7 +38,6 @@
#include <string_view> #include <string_view>
#include <chrono> #include <chrono>
#include <thread> #include <thread>
using namespace std::literals;
static jack_port_t* midiInputPort; static jack_port_t* midiInputPort;
static jack_port_t* outputPort1; static jack_port_t* outputPort1;
@ -71,9 +71,7 @@ constexpr int buildAndCenterPitch(uint8_t firstByte, uint8_t secondByte)
} }
} }
static std::atomic<bool> keepRunning [[maybe_unused]] { true }; int process(jack_nframes_t numFrames, void* arg)
int process(jack_nframes_t numFrames, void* arg [[maybe_unused]])
{ {
auto synth = reinterpret_cast<sfz::Synth*>(arg); auto synth = reinterpret_cast<sfz::Synth*>(arg);
@ -130,7 +128,7 @@ int process(jack_nframes_t numFrames, void* arg [[maybe_unused]])
return 0; return 0;
} }
int sampleBlockChanged(jack_nframes_t nframes, void* arg [[maybe_unused]]) int sampleBlockChanged(jack_nframes_t nframes, void* arg)
{ {
if (arg == nullptr) if (arg == nullptr)
return 0; return 0;
@ -141,7 +139,7 @@ int sampleBlockChanged(jack_nframes_t nframes, void* arg [[maybe_unused]])
return 0; return 0;
} }
int sampleRateChanged(jack_nframes_t nframes, void* arg [[maybe_unused]]) int sampleRateChanged(jack_nframes_t nframes, void* arg)
{ {
if (arg == nullptr) if (arg == nullptr)
return 0; return 0;
@ -154,10 +152,11 @@ int sampleRateChanged(jack_nframes_t nframes, void* arg [[maybe_unused]])
static bool shouldClose { false }; static bool shouldClose { false };
static void done(int sig [[maybe_unused]]) static void done(int sig)
{ {
std::cout << "Signal received" << '\n'; std::cout << "Signal received" << '\n';
shouldClose = true; shouldClose = true;
UNUSED(sig);
// if (client != nullptr) // if (client != nullptr)
// exit(0); // exit(0);
@ -290,7 +289,7 @@ int main(int argc, char** argv)
std::cout << "Allocated buffers: " << synth.getAllocatedBuffers() << '\n'; std::cout << "Allocated buffers: " << synth.getAllocatedBuffers() << '\n';
std::cout << "Total size: " << synth.getAllocatedBytes() << '\n'; std::cout << "Total size: " << synth.getAllocatedBytes() << '\n';
#endif #endif
std::this_thread::sleep_for(2s); std::this_thread::sleep_for(std::chrono::seconds(2));
} }
std::cout << "Closing..." << '\n'; std::cout << "Closing..." << '\n';

View file

@ -1,7 +1,5 @@
# Do not override the C++ standard if set to more than 14 set(CMAKE_CXX_STANDARD 11)
if (NOT CMAKE_CXX_STANDARD OR CMAKE_CXX_STANDARD LESS 14) set(CMAKE_C_STANDARD 99)
set(CMAKE_CXX_STANDARD 14)
endif()
# Export the compile_commands.json file # Export the compile_commands.json file
set (CMAKE_EXPORT_COMPILE_COMMANDS ON) set (CMAKE_EXPORT_COMPILE_COMMANDS ON)

View file

@ -95,27 +95,44 @@ constexpr T& map(T* elements, unsigned index) noexcept {
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Implement a "bit-twiddling hack" for finding the next power of 2
// in either 32 bits or 64 bits in C++11 compatible constexpr functions
// "Runtime" version for 32 bits
// --a;
// a |= a >> 1;
// a |= a >> 2;
// a |= a >> 4;
// a |= a >> 8;
// a |= a >> 16;
// ++a;
template<class T>
constexpr T decrement(T x) {
return x - 1;
}
template<class T>
constexpr T increment(T x) {
return x + 1;
}
template<class T>
constexpr T or_equal(T x, unsigned u) {
return (x | x >> u);
}
template<class T, class... Args>
constexpr T or_equal(T x, unsigned u, Args... rest) {
return or_equal(or_equal(x, u), rest...);
}
constexpr uint32_t round_up_to_power_of_2(uint32_t a) noexcept { constexpr uint32_t round_up_to_power_of_2(uint32_t a) noexcept {
--a; return increment(or_equal(decrement(a), 1, 2, 4, 8, 16));
a |= a >> 1;
a |= a >> 2;
a |= a >> 4;
a |= a >> 8;
a |= a >> 16;
++a;
return a;
} }
constexpr uint64_t round_up_to_power_of_2(uint64_t a) noexcept { constexpr uint64_t round_up_to_power_of_2(uint64_t a) noexcept {
--a; return increment(or_equal(decrement(a), 1, 2, 4, 8, 16, 32));
a |= a >> 1;
a |= a >> 2;
a |= a >> 4;
a |= a >> 8;
a |= a >> 16;
a |= a >> 32;
++a;
return a;
} }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -304,7 +321,7 @@ public:
static_cast<Derived&>(*this).do_push(std::forward<T>(element), head); static_cast<Derived&>(*this).do_push(std::forward<T>(element), head);
} }
auto pop() noexcept { Derived& pop() noexcept {
unsigned tail; unsigned tail;
if(Derived::spsc_) { if(Derived::spsc_) {
tail = tail_.load(X); tail = tail_.load(X);

View file

@ -12,20 +12,11 @@
#pragma once #pragma once
#include <stddef.h> #include <stddef.h>
#include <stdbool.h> #include <stdbool.h>
#include "sfizz/Macros.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#if defined SFIZZ_EXPORT_SYMBOLS
#if defined _WIN32
#define SFIZZ_EXPORTED_API __declspec(dllexport)
#else
#define SFIZZ_EXPORTED_API __attribute__ ((visibility ("default")))
#endif
#else
#define SFIZZ_EXPORTED_API
#endif
typedef struct sfizz_synth_t sfizz_synth_t; typedef struct sfizz_synth_t sfizz_synth_t;
typedef enum { typedef enum {
SFIZZ_OVERSAMPLING_X1 = 1, SFIZZ_OVERSAMPLING_X1 = 1,

View file

@ -7,16 +7,7 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include <memory> #include <memory>
#include "sfizz/Macros.h"
#if defined SFIZZ_EXPORT_SYMBOLS
#if defined _WIN32
#define SFIZZ_EXPORTED_API __declspec(dllexport)
#else
#define SFIZZ_EXPORTED_API __attribute__ ((visibility ("default")))
#endif
#else
#define SFIZZ_EXPORTED_API
#endif
namespace sfz namespace sfz
{ {

View file

@ -14,7 +14,7 @@ namespace sfz {
template <class Type> template <class Type>
void ADSREnvelope<Type>::reset(const Region& region, const MidiState& state, int delay, uint8_t velocity, float sampleRate) noexcept void ADSREnvelope<Type>::reset(const Region& region, const MidiState& state, int delay, uint8_t velocity, float sampleRate) noexcept
{ {
auto secondsToSamples = [sampleRate](auto timeInSeconds) { auto secondsToSamples = [sampleRate](Type timeInSeconds) {
return static_cast<int>(timeInSeconds * sampleRate); return static_cast<int>(timeInSeconds * sampleRate);
}; };
@ -54,7 +54,7 @@ Type ADSREnvelope<Type>::getNextValue() noexcept
currentState = State::Attack; currentState = State::Attack;
step = (peak - currentValue) / (attack > 0 ? attack : 1); step = (peak - currentValue) / (attack > 0 ? attack : 1);
[[fallthrough]]; // fallthrough
case State::Attack: case State::Attack:
if (attack-- > 0) { if (attack-- > 0) {
currentValue += step; currentValue += step;
@ -63,14 +63,14 @@ Type ADSREnvelope<Type>::getNextValue() noexcept
currentState = State::Hold; currentState = State::Hold;
currentValue = peak; currentValue = peak;
[[fallthrough]]; // fallthrough
case State::Hold: case State::Hold:
if (hold-- > 0) if (hold-- > 0)
return currentValue; return currentValue;
step = std::exp(std::log(sustain + config::virtuallyZero) / (decay > 0 ? decay : 1)); step = std::exp(std::log(sustain + config::virtuallyZero) / (decay > 0 ? decay : 1));
currentState = State::Decay; currentState = State::Decay;
[[fallthrough]]; // fallthrough
case State::Decay: case State::Decay:
if (decay-- > 0) { if (decay-- > 0) {
currentValue *= step; currentValue *= step;
@ -79,7 +79,7 @@ Type ADSREnvelope<Type>::getNextValue() noexcept
currentState = State::Sustain; currentState = State::Sustain;
currentValue = sustain; currentValue = sustain;
[[fallthrough]]; // fallthrough
case State::Sustain: case State::Sustain:
if (freeRunning) if (freeRunning)
shouldRelease = true; shouldRelease = true;
@ -92,7 +92,7 @@ Type ADSREnvelope<Type>::getNextValue() noexcept
currentState = State::Done; currentState = State::Done;
currentValue = 0.0; currentValue = 0.0;
[[fallthrough]]; // fallthrough
default: default:
return 0.0; return 0.0;
} }
@ -116,7 +116,7 @@ void ADSREnvelope<Type>::getBlock(absl::Span<Type> output) noexcept
currentState = State::Attack; currentState = State::Attack;
step = (peak - start) / (attack > 0 ? attack : 1); step = (peak - start) / (attack > 0 ? attack : 1);
[[fallthrough]]; // fallthrough
case State::Attack: case State::Attack:
length = min(remainingSamples, attack); length = min(remainingSamples, attack);
currentValue = linearRamp<Type>(output, currentValue, step); currentValue = linearRamp<Type>(output, currentValue, step);
@ -128,7 +128,7 @@ void ADSREnvelope<Type>::getBlock(absl::Span<Type> output) noexcept
currentValue = peak; currentValue = peak;
currentState = State::Hold; currentState = State::Hold;
[[fallthrough]]; // fallthrough
case State::Hold: case State::Hold:
length = min(remainingSamples, hold); length = min(remainingSamples, hold);
fill<Type>(output, currentValue); fill<Type>(output, currentValue);
@ -140,7 +140,7 @@ void ADSREnvelope<Type>::getBlock(absl::Span<Type> output) noexcept
step = std::exp(std::log(sustain + config::virtuallyZero) / (decay > 0 ? decay : 1)); step = std::exp(std::log(sustain + config::virtuallyZero) / (decay > 0 ? decay : 1));
currentState = State::Decay; currentState = State::Decay;
[[fallthrough]]; // fallthrough
case State::Decay: case State::Decay:
length = min(remainingSamples, decay); length = min(remainingSamples, decay);
currentValue = multiplicativeRamp<Type>(output, currentValue, step); currentValue = multiplicativeRamp<Type>(output, currentValue, step);
@ -152,7 +152,7 @@ void ADSREnvelope<Type>::getBlock(absl::Span<Type> output) noexcept
currentValue = sustain; currentValue = sustain;
currentState = State::Sustain; currentState = State::Sustain;
[[fallthrough]]; // fallthrough
case State::Sustain: case State::Sustain:
if (freeRunning) if (freeRunning)
shouldRelease = true; shouldRelease = true;
@ -168,9 +168,9 @@ void ADSREnvelope<Type>::getBlock(absl::Span<Type> output) noexcept
currentValue = 0.0; currentValue = 0.0;
currentState = State::Done; currentState = State::Done;
[[fallthrough]]; // fallthrough
case State::Done: case State::Done:
[[fallthrough]]; // fallthrough
default: default:
break; break;
} }

View file

@ -10,7 +10,7 @@
#include "Debug.h" #include "Debug.h"
#include "LeakDetector.h" #include "LeakDetector.h"
#include "absl/types/span.h" #include "absl/types/span.h"
#include <memory> #include "absl/memory/memory.h"
#include <array> #include <array>
namespace sfz namespace sfz
@ -28,7 +28,7 @@ namespace sfz
template <class Type, size_t MaxChannels = sfz::config::numChannels, unsigned int Alignment = SIMDConfig::defaultAlignment> template <class Type, size_t MaxChannels = sfz::config::numChannels, unsigned int Alignment = SIMDConfig::defaultAlignment>
class AudioBuffer { class AudioBuffer {
public: public:
using value_type = std::remove_cv_t<Type>; using value_type = typename std::remove_cv<Type>::type;
using pointer = value_type*; using pointer = value_type*;
using const_pointer = const value_type*; using const_pointer = const value_type*;
using iterator = pointer; using iterator = pointer;
@ -54,7 +54,7 @@ public:
, numFrames(numFrames) , numFrames(numFrames)
{ {
for (size_t i = 0; i < numChannels; ++i) for (size_t i = 0; i < numChannels; ++i)
buffers[i] = std::make_unique<buffer_type>(numFrames); buffers[i] = absl::make_unique<buffer_type>(numFrames);
} }
/** /**
@ -170,7 +170,7 @@ public:
void addChannel() void addChannel()
{ {
if (numChannels < MaxChannels) if (numChannels < MaxChannels)
buffers[numChannels++] = std::make_unique<buffer_type>(numFrames); buffers[numChannels++] = absl::make_unique<buffer_type>(numFrames);
} }
/** /**

View file

@ -148,7 +148,7 @@ public:
* @tparam Alignment the alignment block size for the platform * @tparam Alignment the alignment block size for the platform
* @param audioBuffer the source AudioBuffer. * @param audioBuffer the source AudioBuffer.
*/ */
template <class U, size_t N, unsigned int Alignment, typename = std::enable_if<N <= MaxChannels>, typename = std::enable_if_t<std::is_const<U>::value, int>> template <class U, size_t N, unsigned int Alignment, typename = typename std::enable_if<N <= MaxChannels>::type, typename = typename std::enable_if<std::is_const<U>::value, int>::type>
AudioSpan(AudioBuffer<U, N, Alignment>& audioBuffer) AudioSpan(AudioBuffer<U, N, Alignment>& audioBuffer)
: numFrames(audioBuffer.getNumFrames()) : numFrames(audioBuffer.getNumFrames())
, numChannels(audioBuffer.getNumChannels()) , numChannels(audioBuffer.getNumChannels())

View file

@ -31,6 +31,8 @@
#include <memory> #include <memory>
#include <type_traits> #include <type_traits>
#include <utility> #include <utility>
#include <atomic>
#ifdef DEBUG #ifdef DEBUG
#include <iostream> #include <iostream>
#endif #endif
@ -92,6 +94,8 @@ private:
std::atomic<int> bytes { 0 }; std::atomic<int> bytes { 0 };
}; };
/** /**
* @brief A heap buffer structure that tries to align its beginning and * @brief A heap buffer structure that tries to align its beginning and
* adds a small offset at the end for alignment too. * adds a small offset at the end for alignment too.
@ -109,7 +113,7 @@ private:
template <class Type, unsigned int Alignment = SIMDConfig::defaultAlignment> template <class Type, unsigned int Alignment = SIMDConfig::defaultAlignment>
class Buffer { class Buffer {
public: public:
using value_type = std::remove_cv_t<Type>; using value_type = typename std::remove_cv<Type>::type;
using pointer = value_type*; using pointer = value_type*;
using const_pointer = const value_type*; using const_pointer = const value_type*;
using reference = value_type&; using reference = value_type&;
@ -165,7 +169,7 @@ public:
largerSize = tempSize; largerSize = tempSize;
alignedSize = newSize; alignedSize = newSize;
paddedData = static_cast<pointer>(newData); paddedData = static_cast<pointer>(newData);
normalData = static_cast<pointer>(std::align(Alignment, alignedSize, newData, tempSize)); normalData = static_cast<pointer>(align(Alignment, alignedSize, newData, tempSize));
normalEnd = normalData + alignedSize; normalEnd = normalData + alignedSize;
auto endMisalignment = (alignedSize & TypeAlignmentMask); auto endMisalignment = (alignedSize & TypeAlignmentMask);
if (endMisalignment != 0) if (endMisalignment != 0)
@ -256,9 +260,9 @@ public:
constexpr pointer data() const noexcept { return normalData; } constexpr pointer data() const noexcept { return normalData; }
constexpr size_type size() const noexcept { return alignedSize; } constexpr size_type size() const noexcept { return alignedSize; }
constexpr bool empty() const noexcept { return alignedSize == 0; } constexpr bool empty() const noexcept { return alignedSize == 0; }
constexpr iterator begin() noexcept { return data(); } constexpr iterator begin() const noexcept { return data(); }
constexpr iterator end() noexcept { return normalEnd; } constexpr iterator end() const noexcept { return normalEnd; }
constexpr pointer alignedEnd() noexcept { return _alignedEnd; } constexpr pointer alignedEnd() const noexcept { return _alignedEnd; }
/** /**
@ -274,12 +278,22 @@ public:
return counter; return counter;
} }
private: private:
static constexpr auto AlignmentMask { Alignment - 1 }; static constexpr int AlignmentMask { Alignment - 1 };
static constexpr auto TypeAlignment { Alignment / sizeof(value_type) }; static constexpr int TypeAlignment { Alignment / sizeof(value_type) };
static constexpr auto TypeAlignmentMask { TypeAlignment - 1 }; static constexpr int TypeAlignmentMask { TypeAlignment - 1 };
static_assert(std::is_arithmetic<value_type>::value, "Type should be arithmetic"); static_assert(std::is_arithmetic<value_type>::value, "Type should be arithmetic");
static_assert(Alignment == 0 || Alignment == 4 || Alignment == 8 || Alignment == 16, "Bad alignment value"); static_assert(Alignment == 0 || Alignment == 4 || Alignment == 8 || Alignment == 16, "Bad alignment value");
static_assert(TypeAlignment * sizeof(value_type) == Alignment, "The alignment does not appear to be divided by the size of the Type"); static_assert(TypeAlignment * sizeof(value_type) == Alignment, "The alignment does not appear to be divided by the size of the Type");
void* align(std::size_t alignment, std::size_t size, void *&ptr, std::size_t &space )
{
std::uintptr_t pn = reinterpret_cast< std::uintptr_t>( ptr );
std::uintptr_t aligned = ( pn + alignment - 1 ) & - alignment;
std::size_t padding = aligned - pn;
if ( space < size + padding ) return nullptr;
space -= padding;
return ptr = reinterpret_cast< void * >( aligned );
}
size_type largerSize { 0 }; size_type largerSize { 0 };
size_type alignedSize { 0 }; size_type alignedSize { 0 };
pointer normalData { nullptr }; pointer normalData { nullptr };

View file

@ -26,6 +26,7 @@
#pragma once #pragma once
#include "Config.h" #include "Config.h"
#include "Defaults.h" #include "Defaults.h"
#include "Macros.h"
#include "LeakDetector.h" #include "LeakDetector.h"
#include "SfzHelpers.h" #include "SfzHelpers.h"
#include <absl/types/optional.h> #include <absl/types/optional.h>
@ -134,8 +135,9 @@ struct EGDescription
* @param velocity * @param velocity
* @return float * @return float
*/ */
float getStart(const SfzCCArray &ccValues, uint8_t velocity [[maybe_unused]]) const noexcept float getStart(const SfzCCArray &ccValues, uint8_t velocity) const noexcept
{ {
UNUSED(velocity);
return Default::egPercentRange.clamp(ccSwitchedValue(ccValues, ccStart, start)); return Default::egPercentRange.clamp(ccSwitchedValue(ccValues, ccStart, start));
} }
/** /**

View file

@ -3,7 +3,6 @@
#include <thread> #include <thread>
#include "absl/algorithm/container.h" #include "absl/algorithm/container.h"
#include "SIMDHelpers.h" #include "SIMDHelpers.h"
using namespace std::chrono_literals;
sfz::EQHolder::EQHolder(const MidiState& state) sfz::EQHolder::EQHolder(const MidiState& state)
:midiState(state) :midiState(state)
@ -114,7 +113,7 @@ size_t sfz::EQPool::setnumEQs(size_t numEQs)
AtomicDisabler disabler { canGiveOutEQs }; AtomicDisabler disabler { canGiveOutEQs };
while(givingOutEQs) while(givingOutEQs)
std::this_thread::sleep_for(1ms); std::this_thread::sleep_for(std::chrono::milliseconds(1));
auto eqIterator = eqs.begin(); auto eqIterator = eqs.begin();
auto eqSentinel = eqs.rbegin(); auto eqSentinel = eqs.rbegin();

View file

@ -44,21 +44,21 @@ std::unique_ptr<Effect> EffectFactory::makeEffect(absl::Span<const Opcode> membe
if (!opcode) { if (!opcode) {
DBG("The effect does not specify a type"); DBG("The effect does not specify a type");
return std::make_unique<sfz::fx::Nothing>(); return absl::make_unique<sfz::fx::Nothing>();
} }
const absl::string_view type = opcode->value; const absl::string_view type = opcode->value;
const auto it = absl::c_find_if(_entries, [&](auto&& entry) { return entry.name == type; }); const auto it = absl::c_find_if(_entries, [&](const FactoryEntry& entry) { return entry.name == type; });
if (it == _entries.end()) { if (it == _entries.end()) {
DBG("Unsupported effect type: " << type); DBG("Unsupported effect type: " << type);
return std::make_unique<sfz::fx::Nothing>(); return absl::make_unique<sfz::fx::Nothing>();
} }
auto fx = it->make(members); auto fx = it->make(members);
if (!fx) { if (!fx) {
DBG("Could not instantiate effect of type: " << type); DBG("Could not instantiate effect of type: " << type);
return std::make_unique<sfz::fx::Nothing>(); return absl::make_unique<sfz::fx::Nothing>();
} }
return fx; return fx;

View file

@ -53,7 +53,7 @@ void EventEnvelope<Type>::prepareEvents(int blockLength)
if (resetEvents) if (resetEvents)
clear(); clear();
absl::c_stable_sort(events, [](const auto& lhs, const auto& rhs) { absl::c_stable_sort(events, [](const std::pair<int, Type>& lhs, const std::pair<int, Type>& rhs) {
return lhs.first < rhs.first; return lhs.first < rhs.first;
}); });

View file

@ -94,7 +94,7 @@ protected:
Type currentValue { 0.0 }; Type currentValue { 0.0 };
private: private:
static_assert(std::is_arithmetic<Type>::value, "Type should be arithmetic"); static_assert(std::is_arithmetic<Type>::value, "Type should be arithmetic");
std::function<Type(Type)> function { [](Type input) { return input; } }; std::function<Type(Type)> function { [](Type input) -> Type { return input; } };
int maxCapacity { config::defaultSamplesPerBlock }; int maxCapacity { config::defaultSamplesPerBlock };
void prepareEvents(int blockLength); void prepareEvents(int blockLength);
bool resetEvents { false }; bool resetEvents { false };

View file

@ -32,10 +32,10 @@
#include "AtomicGuard.h" #include "AtomicGuard.h"
#include "absl/types/span.h" #include "absl/types/span.h"
#include "absl/strings/match.h" #include "absl/strings/match.h"
#include "absl/memory/memory.h"
#include <memory> #include <memory>
#include <sndfile.hh> #include <sndfile.hh>
#include <thread> #include <thread>
using namespace std::chrono_literals;
template <class T> template <class T>
void readBaseFile(SndfileHandle& sndFile, sfz::AudioBuffer<T>& output, uint32_t numFrames) void readBaseFile(SndfileHandle& sndFile, sfz::AudioBuffer<T>& output, uint32_t numFrames)
@ -57,13 +57,13 @@ void readBaseFile(SndfileHandle& sndFile, sfz::AudioBuffer<T>& output, uint32_t
template <class T> template <class T>
std::unique_ptr<sfz::AudioBuffer<T>> readFromFile(SndfileHandle& sndFile, uint32_t numFrames, sfz::Oversampling factor) std::unique_ptr<sfz::AudioBuffer<T>> readFromFile(SndfileHandle& sndFile, uint32_t numFrames, sfz::Oversampling factor)
{ {
auto baseBuffer = std::make_unique<sfz::AudioBuffer<T>>(); auto baseBuffer = absl::make_unique<sfz::AudioBuffer<T>>();
readBaseFile(sndFile, *baseBuffer, numFrames); readBaseFile(sndFile, *baseBuffer, numFrames);
if (factor == sfz::Oversampling::x1) if (factor == sfz::Oversampling::x1)
return baseBuffer; return baseBuffer;
auto outputBuffer = std::make_unique<sfz::AudioBuffer<T>>(sndFile.channels(), numFrames * static_cast<int>(factor)); auto outputBuffer = absl::make_unique<sfz::AudioBuffer<T>>(sndFile.channels(), numFrames * static_cast<int>(factor));
sfz::Oversampler oversampler { factor }; sfz::Oversampler oversampler { factor };
oversampler.stream(*baseBuffer, *outputBuffer); oversampler.stream(*baseBuffer, *outputBuffer);
return outputBuffer; return outputBuffer;
@ -216,10 +216,9 @@ bool sfz::FilePool::preloadFile(const std::string& filename, uint32_t maxOffset)
preloadedFiles[filename].preloadedData = readFromFile<float>(sndFile, framesToLoad, oversamplingFactor); preloadedFiles[filename].preloadedData = readFromFile<float>(sndFile, framesToLoad, oversamplingFactor);
} }
} else { } else {
preloadedFiles.insert_or_assign(filename, { const float sourceSampleRate { static_cast<float>(oversamplingFactor) * static_cast<float>(sndFile.samplerate()) };
readFromFile<float>(sndFile, framesToLoad, oversamplingFactor), PreloadedFileHandle handle { readFromFile<float>(sndFile, framesToLoad, oversamplingFactor), sourceSampleRate };
static_cast<float>(oversamplingFactor) * static_cast<float>(sndFile.samplerate()) preloadedFiles.insert_or_assign(filename, handle);
});
} }
return true; return true;
@ -272,7 +271,7 @@ void sfz::FilePool::tryToClearPromises()
AtomicDisabler disabler { canAddPromisesToClear }; AtomicDisabler disabler { canAddPromisesToClear };
while (addingPromisesToClear) while (addingPromisesToClear)
std::this_thread::sleep_for(1ms); std::this_thread::sleep_for(std::chrono::milliseconds(1));
for (auto& promise: promisesToClear) { for (auto& promise: promisesToClear) {
if (promise->dataReady) if (promise->dataReady)
@ -284,7 +283,7 @@ void sfz::FilePool::clearingThread()
{ {
while (!quitThread) { while (!quitThread) {
tryToClearPromises(); tryToClearPromises();
std::this_thread::sleep_for(50ms); std::this_thread::sleep_for(std::chrono::milliseconds(50));
} }
} }
@ -302,7 +301,7 @@ void sfz::FilePool::loadingThread() noexcept
} }
if (!promiseQueue.try_pop(promise)) { if (!promiseQueue.try_pop(promise)) {
std::this_thread::sleep_for(1ms); std::this_thread::sleep_for(std::chrono::milliseconds(1));
continue; continue;
} }
@ -326,7 +325,7 @@ void sfz::FilePool::loadingThread() noexcept
while (!filledPromiseQueue.try_push(promise)) { while (!filledPromiseQueue.try_push(promise)) {
DBG("[sfizz] Error enqueuing the promise for " << promise->filename << " in the filledPromiseQueue"); DBG("[sfizz] Error enqueuing the promise for " << promise->filename << " in the filledPromiseQueue");
std::this_thread::sleep_for(1ms); std::this_thread::sleep_for(std::chrono::milliseconds(1));
} }
promise.reset(); promise.reset();
@ -412,7 +411,7 @@ void sfz::FilePool::emptyFileLoadingQueues() noexcept
{ {
emptyQueue = true; emptyQueue = true;
while (emptyQueue) while (emptyQueue)
std::this_thread::sleep_for(1ms); std::this_thread::sleep_for(std::chrono::milliseconds(1));
} }
void sfz::FilePool::waitForBackgroundLoading() noexcept void sfz::FilePool::waitForBackgroundLoading() noexcept
@ -421,11 +420,11 @@ void sfz::FilePool::waitForBackgroundLoading() noexcept
// of the files we need to load still. // of the files we need to load still.
// Spinlocking on the size of the background queue // Spinlocking on the size of the background queue
while (!promiseQueue.was_empty()){ while (!promiseQueue.was_empty()){
std::this_thread::sleep_for(0.1ms); std::this_thread::sleep_for(std::chrono::microseconds(100));
} }
// Spinlocking on the threads possibly logging in the background // Spinlocking on the threads possibly logging in the background
while (threadsLoading > 0) { while (threadsLoading > 0) {
std::this_thread::sleep_for(0.1ms); std::this_thread::sleep_for(std::chrono::microseconds(100));
} }
} }

View file

@ -44,15 +44,16 @@ namespace sfz {
using AudioBufferPtr = std::shared_ptr<AudioBuffer<float>>; using AudioBufferPtr = std::shared_ptr<AudioBuffer<float>>;
// Strict C++11 disallows member initialization if aggregate initialization is to be used...
struct PreloadedFileHandle struct PreloadedFileHandle
{ {
std::shared_ptr<AudioBuffer<float>> preloadedData {}; std::shared_ptr<AudioBuffer<float>> preloadedData;
float sampleRate { config::defaultSampleRate }; float sampleRate;
}; };
struct FilePromise struct FilePromise
{ {
auto getData() AudioSpan<const float> getData()
{ {
if (dataReady) if (dataReady)
return AudioSpan<const float>(fileData); return AudioSpan<const float>(fileData);
@ -78,7 +79,7 @@ struct FilePromise
AudioBuffer<float> fileData {}; AudioBuffer<float> fileData {};
float sampleRate { config::defaultSampleRate }; float sampleRate { config::defaultSampleRate };
Oversampling oversamplingFactor { config::defaultOversamplingFactor }; Oversampling oversamplingFactor { config::defaultOversamplingFactor };
std::atomic_size_t availableFrames { 0 }; std::atomic<size_t> availableFrames { 0 };
std::atomic<bool> dataReady { false }; std::atomic<bool> dataReady { false };
std::chrono::time_point<std::chrono::high_resolution_clock> creationTime; std::chrono::time_point<std::chrono::high_resolution_clock> creationTime;

View file

@ -4,7 +4,6 @@
#include "AtomicGuard.h" #include "AtomicGuard.h"
#include <thread> #include <thread>
#include <chrono> #include <chrono>
using namespace std::chrono_literals;
sfz::FilterHolder::FilterHolder(const MidiState& midiState) sfz::FilterHolder::FilterHolder(const MidiState& midiState)
: midiState(midiState) : midiState(midiState)
@ -113,7 +112,7 @@ size_t sfz::FilterPool::setNumFilters(size_t numFilters)
AtomicDisabler disabler { canGiveOutFilters }; AtomicDisabler disabler { canGiveOutFilters };
while(givingOutFilters) while(givingOutFilters)
std::this_thread::sleep_for(1ms); std::this_thread::sleep_for(std::chrono::milliseconds(1));
auto filterIterator = filters.begin(); auto filterIterator = filters.begin();
auto filterSentinel = filters.rbegin(); auto filterSentinel = filters.rbegin();

View file

@ -13,8 +13,6 @@
#include <sstream> #include <sstream>
#include <cmath> #include <cmath>
using namespace std::chrono_literals;
template<class T> template<class T>
void printStatistics(std::vector<T>& data) void printStatistics(std::vector<T>& data)
{ {
@ -141,7 +139,7 @@ void sfz::Logger::moveEvents() noexcept
callbackTimes.clear(); callbackTimes.clear();
} }
std::this_thread::sleep_for(10ms); std::this_thread::sleep_for(std::chrono::milliseconds(10));
} }
} }

View file

@ -6,6 +6,7 @@
#pragma once #pragma once
#include "Config.h" #include "Config.h"
#include "LeakDetector.h"
#include "atomic_queue/atomic_queue.h" #include "atomic_queue/atomic_queue.h"
#include <vector> #include <vector>
#include <string> #include <string>
@ -47,10 +48,18 @@ struct ScopedTiming
struct FileTime struct FileTime
{ {
Duration waitDuration; FileTime() = default;
Duration loadDuration; FileTime(Duration waitDuration, Duration loadDuration, uint32_t fileSize, absl::string_view filename)
uint32_t fileSize; : waitDuration(waitDuration), loadDuration(loadDuration), fileSize(fileSize), filename(filename) { }
absl::string_view filename; FileTime(const FileTime&) = default;
FileTime& operator=(const FileTime&) = default;
FileTime(FileTime&&) = default;
FileTime& operator=(FileTime&&) = default;
Duration waitDuration { 0 };
Duration loadDuration { 0 };
uint32_t fileSize { 0 };
absl::string_view filename {};
LEAK_DETECTOR(FileTime);
}; };
struct CallbackBreakdown struct CallbackBreakdown
@ -62,13 +71,22 @@ struct CallbackBreakdown
Duration filters { 0 }; Duration filters { 0 };
Duration panning { 0 }; Duration panning { 0 };
Duration effects { 0 }; Duration effects { 0 };
LEAK_DETECTOR(CallbackBreakdown);
}; };
struct CallbackTime struct CallbackTime
{ {
CallbackBreakdown breakdown; CallbackTime() = default;
int numVoices; CallbackTime(const CallbackBreakdown& breakdown, int numVoices, size_t numSamples)
size_t numSamples; : breakdown(breakdown), numVoices(numVoices), numSamples(numSamples) { }
CallbackTime(const CallbackTime&) = default;
CallbackTime& operator=(const CallbackTime&) = default;
CallbackTime(CallbackTime&&) = default;
CallbackTime& operator=(CallbackTime&&) = default;
CallbackBreakdown breakdown {};
int numVoices { 0 };
size_t numSamples { 0 };
LEAK_DETECTOR(CallbackTime);
}; };
class Logger class Logger
@ -135,6 +153,7 @@ private:
std::atomic_flag keepRunning; std::atomic_flag keepRunning;
std::atomic_flag clearFlag; std::atomic_flag clearFlag;
std::thread loggingThread; std::thread loggingThread;
LEAK_DETECTOR(Logger);
}; };
} }

25
src/sfizz/Macros.h Normal file
View file

@ -0,0 +1,25 @@
// 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
#define UNUSED(x) (void)(x)
#if defined SFIZZ_EXPORT_SYMBOLS
#if defined _WIN32
#define SFIZZ_EXPORTED_API __declspec(dllexport)
#else
#define SFIZZ_EXPORTED_API __attribute__ ((visibility ("default")))
#endif
#else
#define SFIZZ_EXPORTED_API
#endif
#if __cplusplus > 201103L
#define CXX14_CONSTEXPR constexpr
#else
#define CXX14_CONSTEXPR
#endif

View file

@ -10,6 +10,7 @@
*/ */
#pragma once #pragma once
#include "Config.h" #include "Config.h"
#include "Macros.h"
#include <algorithm> #include <algorithm>
#include <cmath> #include <cmath>
#include <random> #include <random>
@ -17,25 +18,25 @@
template<class T> template<class T>
constexpr T max(T op1, T op2) constexpr T max(T op1, T op2)
{ {
return std::max(op1, op2); return op1 > op2 ? op1 : op2;
} }
template<class T, class... Args> template<class T, class... Args>
constexpr T max(T op1, Args... rest) constexpr T max(T op1, Args... rest)
{ {
return std::max(op1, max(rest...)); return max(op1, max(rest...));
} }
template<class T> template<class T>
constexpr T min(T op1, T op2) constexpr T min(T op1, T op2)
{ {
return std::min(op1, op2); return op1 > op2 ? op2 : op1;
} }
template<class T, class... Args> template<class T, class... Args>
constexpr T min(T op1, Args... rest) constexpr T min(T op1, Args... rest)
{ {
return std::min(op1, min(rest...)); return min(op1, min(rest...));
} }
/** /**
@ -124,19 +125,17 @@ inline float midiNoteFrequency(const int noteNumber)
template<class T> template<class T>
constexpr T clamp( T v, T lo, T hi ) constexpr T clamp( T v, T lo, T hi )
{ {
v = std::min(v, hi); return max(min(v, hi), lo);
v = std::max(v, lo);
return v;
} }
template<int Increment = 1, class T> template<int Increment = 1, class T>
constexpr void incrementAll(T& only) inline CXX14_CONSTEXPR void incrementAll(T& only)
{ {
only += Increment; only += Increment;
} }
template<int Increment = 1, class T, class... Args> template<int Increment = 1, class T, class... Args>
constexpr void incrementAll(T& first, Args&... rest) inline CXX14_CONSTEXPR void incrementAll(T& first, Args&... rest)
{ {
first += Increment; first += Increment;
incrementAll<Increment>(rest...); incrementAll<Increment>(rest...);
@ -148,18 +147,18 @@ constexpr ValueType linearInterpolation(ValueType left, ValueType right, ValueTy
return left * leftCoeff + right * rightCoeff; return left * leftCoeff + right * rightCoeff;
} }
template <class Type> template<class Type>
constexpr Type pi { static_cast<Type>(3.141592653589793238462643383279502884) }; constexpr Type pi() { return static_cast<Type>(3.141592653589793238462643383279502884); };
template <class Type> template<class Type>
constexpr Type twoPi { static_cast<Type>(2) * pi<Type> }; constexpr Type twoPi() { return pi<Type>() * 2; };
template <class Type> template<class Type>
constexpr Type piTwo { pi<Type> / static_cast<Type>(2) }; constexpr Type piTwo() { return pi<Type>() / 2; };
template <class Type> template<class Type>
constexpr Type piFour { pi<Type> / static_cast<Type>(4) }; constexpr Type piFour() { return pi<Type>() / 4; };
template <class Type> template<class Type>
constexpr Type sqrtTwo { static_cast<Type>(1.414213562373095048801688724209698078569671875376948073176) }; constexpr Type sqrtTwo() { return static_cast<Type>(1.414213562373095048801688724209698078569671875376948073176); };
template <class Type> template<class Type>
constexpr Type sqrtTwoInv { static_cast<Type>(0.707106781186547524400844362104849039284835937688474036588) }; constexpr Type sqrtTwoInv() { return static_cast<Type>(0.707106781186547524400844362104849039284835937688474036588); };
/** /**
@brief A fraction which is parameterized by integer type @brief A fraction which is parameterized by integer type

View file

@ -5,6 +5,7 @@
// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz // If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz
#include "MidiState.h" #include "MidiState.h"
#include "Macros.h"
#include "Debug.h" #include "Debug.h"
sfz::MidiState::MidiState() sfz::MidiState::MidiState()
@ -25,11 +26,11 @@ void sfz::MidiState::noteOnEvent(int delay, int noteNumber, uint8_t velocity) no
} }
void sfz::MidiState::noteOffEvent(int delay, int noteNumber, uint8_t velocity [[maybe_unused]]) noexcept void sfz::MidiState::noteOffEvent(int delay, int noteNumber, uint8_t velocity) noexcept
{ {
ASSERT(noteNumber >= 0 && noteNumber <= 127); ASSERT(noteNumber >= 0 && noteNumber <= 127);
ASSERT(velocity >= 0 && velocity <= 127); ASSERT(velocity >= 0 && velocity <= 127);
UNUSED(velocity);
if (noteNumber >= 0 && noteNumber < 128) { if (noteNumber >= 0 && noteNumber < 128) {
if (activeNotes > 0) if (activeNotes > 0)
activeNotes--; activeNotes--;

View file

@ -134,13 +134,13 @@ private:
* @brief Stores the note on times. * @brief Stores the note on times.
* *
*/ */
MidiNoteArray<NoteOnTime> noteOnTimes { }; MidiNoteArray<NoteOnTime> noteOnTimes;
/** /**
* @brief Stores the velocity of the note ons for currently * @brief Stores the velocity of the note ons for currently
* depressed notes. * depressed notes.
* *
*/ */
MidiNoteArray<uint8_t> lastNoteVelocities { }; MidiNoteArray<uint8_t> lastNoteVelocities;
/** /**
* @brief Current known values for the CCs. * @brief Current known values for the CCs.
* *

View file

@ -26,7 +26,7 @@ public:
template <class C> template <class C>
static Type normalizedGain(Type cutoff, C sampleRate) static Type normalizedGain(Type cutoff, C sampleRate)
{ {
return std::tan(cutoff / static_cast<Type>(sampleRate) * pi<float>); return std::tan(cutoff / static_cast<Type>(sampleRate) * pi<float>());
} }
OnePoleFilter(Type gain) OnePoleFilter(Type gain)

View file

@ -11,6 +11,7 @@
#include "SfzHelpers.h" #include "SfzHelpers.h"
#include "StringViewHelpers.h" #include "StringViewHelpers.h"
#include <absl/types/optional.h> #include <absl/types/optional.h>
#include "absl/meta/type_traits.h"
#include <string_view> #include <string_view>
#include <vector> #include <vector>
#include <type_traits> #include <type_traits>
@ -45,7 +46,7 @@ struct Opcode {
* @param validRange the range of admitted values * @param validRange the range of admitted values
* @return absl::optional<ValueType> the cast value, or null * @return absl::optional<ValueType> the cast value, or null
*/ */
template <typename ValueType, std::enable_if_t<std::is_integral<ValueType>::value, int> = 0> template <typename ValueType, absl::enable_if_t<std::is_integral<ValueType>::value, int> = 0>
inline absl::optional<ValueType> readOpcode(absl::string_view value, const Range<ValueType>& validRange) inline absl::optional<ValueType> readOpcode(absl::string_view value, const Range<ValueType>& validRange)
{ {
int64_t returnedValue; int64_t returnedValue;
@ -74,7 +75,7 @@ inline absl::optional<ValueType> readOpcode(absl::string_view value, const Range
* @param validRange the range of admitted values * @param validRange the range of admitted values
* @return absl::optional<ValueType> the cast value, or null * @return absl::optional<ValueType> the cast value, or null
*/ */
template <typename ValueType, std::enable_if_t<std::is_floating_point<ValueType>::value, int> = 0> template <typename ValueType, absl::enable_if_t<std::is_floating_point<ValueType>::value, int> = 0>
inline absl::optional<ValueType> readOpcode(absl::string_view value, const Range<ValueType>& validRange) inline absl::optional<ValueType> readOpcode(absl::string_view value, const Range<ValueType>& validRange)
{ {
float returnedValue; float returnedValue;

View file

@ -78,11 +78,11 @@ void sfz::Oversampler::stream(const sfz::AudioBuffer<float>& input, sfz::AudioBu
case Oversampling::x8: case Oversampling::x8:
for (auto& upsampler: upsampler8x) for (auto& upsampler: upsampler8x)
upsampler.set_coefs(coeffsStage8x.data()); upsampler.set_coefs(coeffsStage8x.data());
[[fallthrough]]; // fallthrough
case Oversampling::x4: case Oversampling::x4:
for (auto& upsampler: upsampler4x) for (auto& upsampler: upsampler4x)
upsampler.set_coefs(coeffsStage4x.data()); upsampler.set_coefs(coeffsStage4x.data());
[[fallthrough]]; // fallthrough
case Oversampling::x2: case Oversampling::x2:
for (auto& upsampler: upsampler2x) for (auto& upsampler: upsampler2x)
upsampler.set_coefs(coeffsStage2x.data()); upsampler.set_coefs(coeffsStage2x.data());
@ -105,7 +105,7 @@ void sfz::Oversampler::stream(const sfz::AudioBuffer<float>& input, sfz::AudioBu
{ {
// std::cout << "Input frames: " << inputFrameCounter << "/" << numFrames << '\n'; // std::cout << "Input frames: " << inputFrameCounter << "/" << numFrames << '\n';
const auto thisChunkSize = std::min(chunkSize, numFrames - inputFrameCounter); const auto thisChunkSize = std::min(chunkSize, numFrames - inputFrameCounter);
const auto outputChunkSize { thisChunkSize * static_cast<int>(factor) }; const auto outputChunkSize = thisChunkSize * static_cast<int>(factor);
for (size_t chanIdx = 0; chanIdx < numChannels; chanIdx++) { for (size_t chanIdx = 0; chanIdx < numChannels; chanIdx++) {
const auto inputChunk = input.getSpan(chanIdx).subspan(inputFrameCounter, thisChunkSize); const auto inputChunk = input.getSpan(chanIdx).subspan(inputFrameCounter, thisChunkSize);
const auto outputChunk = output.getSpan(chanIdx).subspan(outputFrameCounter, outputChunkSize); const auto outputChunk = output.getSpan(chanIdx).subspan(outputFrameCounter, outputChunkSize);

View file

@ -24,7 +24,7 @@ public:
constexpr Range() = default; constexpr Range() = default;
constexpr Range(Type start, Type end) noexcept constexpr Range(Type start, Type end) noexcept
: _start(start) : _start(start)
, _end(std::max(start, end)) , _end(max(start, end))
{ {
} }

View file

@ -7,6 +7,7 @@
#include "Region.h" #include "Region.h"
#include "Defaults.h" #include "Defaults.h"
#include "MathHelpers.h" #include "MathHelpers.h"
#include "Macros.h"
#include "Debug.h" #include "Debug.h"
#include "Opcode.h" #include "Opcode.h"
#include "StringViewHelpers.h" #include "StringViewHelpers.h"
@ -66,7 +67,7 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
case hash("count"): case hash("count"):
setValueFromOpcode(opcode, sampleCount, Default::sampleCountRange); setValueFromOpcode(opcode, sampleCount, Default::sampleCountRange);
break; break;
case hash("loopmode"): [[fallthrough]]; case hash("loopmode"): // fallthrough
case hash("loop_mode"): case hash("loop_mode"):
switch (hash(opcode.value)) { switch (hash(opcode.value)) {
case hash("no_loop"): case hash("no_loop"):
@ -85,21 +86,21 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
DBG("Unkown loop mode:" << std::string(opcode.value)); DBG("Unkown loop mode:" << std::string(opcode.value));
} }
break; break;
case hash("loopend"): [[fallthrough]]; case hash("loopend"): // fallthrough
case hash("loop_end"): case hash("loop_end"):
setRangeEndFromOpcode(opcode, loopRange, Default::loopRange); setRangeEndFromOpcode(opcode, loopRange, Default::loopRange);
break; break;
case hash("loopstart"): [[fallthrough]]; case hash("loopstart"): // fallthrough
case hash("loop_start"): case hash("loop_start"):
setRangeStartFromOpcode(opcode, loopRange, Default::loopRange); setRangeStartFromOpcode(opcode, loopRange, Default::loopRange);
break; break;
// Instrument settings: voice lifecycle // Instrument settings: voice lifecycle
case hash("group"): [[fallthrough]]; case hash("group"): // fallthrough
case hash("polyphony_group"): case hash("polyphony_group"):
setValueFromOpcode(opcode, group, Default::groupRange); setValueFromOpcode(opcode, group, Default::groupRange);
break; break;
case hash("offby"): [[fallthrough]]; case hash("offby"): // fallthrough
case hash("off_by"): case hash("off_by"):
setValueFromOpcode(opcode, offBy, Default::groupRange); setValueFromOpcode(opcode, offBy, Default::groupRange);
break; break;
@ -237,11 +238,11 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
DBG("Unknown trigger mode: " << std::string(opcode.value)); DBG("Unknown trigger mode: " << std::string(opcode.value));
} }
break; break;
case hash("on_locc&"): [[fallthrough]]; case hash("on_locc&"): // fallthrough
case hash("start_locc&"): case hash("start_locc&"):
setRangeStartFromOpcode(opcode, ccTriggers[opcode.parameters.back()], Default::ccTriggerValueRange); setRangeStartFromOpcode(opcode, ccTriggers[opcode.parameters.back()], Default::ccTriggerValueRange);
break; break;
case hash("on_hicc&"): [[fallthrough]]; case hash("on_hicc&"): // fallthrough
case hash("start_hicc&"): case hash("start_hicc&"):
setRangeEndFromOpcode(opcode, ccTriggers[opcode.parameters.back()], Default::ccTriggerValueRange); setRangeEndFromOpcode(opcode, ccTriggers[opcode.parameters.back()], Default::ccTriggerValueRange);
break; break;
@ -251,14 +252,14 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
setValueFromOpcode(opcode, volume, Default::volumeRange); setValueFromOpcode(opcode, volume, Default::volumeRange);
break; break;
case hash("gain_cc&"): case hash("gain_cc&"):
case hash("gain_oncc&"): [[fallthrough]]; case hash("gain_oncc&"): // fallthrough
case hash("volume_oncc&"): case hash("volume_oncc&"):
setCCPairFromOpcode(opcode, volumeCC, Default::volumeCCRange); setCCPairFromOpcode(opcode, volumeCC, Default::volumeCCRange);
break; break;
case hash("amplitude"): case hash("amplitude"):
setValueFromOpcode(opcode, amplitude, Default::amplitudeRange); setValueFromOpcode(opcode, amplitude, Default::amplitudeRange);
break; break;
case hash("amplitude_cc&"): [[fallthrough]]; case hash("amplitude_cc&"): // fallthrough
case hash("amplitude_oncc&"): case hash("amplitude_oncc&"):
setCCPairFromOpcode(opcode, amplitudeCC, Default::amplitudeRange); setCCPairFromOpcode(opcode, amplitudeCC, Default::amplitudeRange);
break; break;
@ -377,7 +378,7 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
break; break;
// Performance parameters: filters // Performance parameters: filters
case hash("cutoff"): [[fallthrough]]; case hash("cutoff"): // fallthrough
case hash("cutoff&"): case hash("cutoff&"):
{ {
const auto filterIndex = opcode.parameters.empty() ? 0 : (opcode.parameters.back() - 1); const auto filterIndex = opcode.parameters.empty() ? 0 : (opcode.parameters.back() - 1);
@ -386,7 +387,7 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
setValueFromOpcode(opcode, filters[filterIndex].cutoff, Default::filterCutoffRange); setValueFromOpcode(opcode, filters[filterIndex].cutoff, Default::filterCutoffRange);
} }
break; break;
case hash("resonance"): [[fallthrough]]; case hash("resonance"): // fallthrough
case hash("resonance&"): case hash("resonance&"):
{ {
const auto filterIndex = opcode.parameters.empty() ? 0 : (opcode.parameters.back() - 1); const auto filterIndex = opcode.parameters.empty() ? 0 : (opcode.parameters.back() - 1);
@ -397,7 +398,7 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
break; break;
case hash("cutoff_oncc&"): case hash("cutoff_oncc&"):
case hash("cutoff_cc&"): case hash("cutoff_cc&"):
case hash("cutoff&_oncc&"): [[fallthrough]]; case hash("cutoff&_oncc&"): // fallthrough
case hash("cutoff&_cc&"): case hash("cutoff&_cc&"):
{ {
const auto filterIndex = opcode.parameters.size() == 1 ? 0 : (opcode.parameters.front() - 1); const auto filterIndex = opcode.parameters.size() == 1 ? 0 : (opcode.parameters.front() - 1);
@ -413,7 +414,7 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
break; break;
case hash("resonance&_oncc&"): case hash("resonance&_oncc&"):
case hash("resonance&_cc&"): case hash("resonance&_cc&"):
case hash("resonance_oncc&"): [[fallthrough]]; case hash("resonance_oncc&"): // fallthrough
case hash("resonance_cc&"): case hash("resonance_cc&"):
{ {
const auto filterIndex = opcode.parameters.size() == 1 ? 0 : (opcode.parameters.front() - 1); const auto filterIndex = opcode.parameters.size() == 1 ? 0 : (opcode.parameters.front() - 1);
@ -427,7 +428,7 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
); );
} }
break; break;
case hash("fil_keytrack"): [[fallthrough]]; case hash("fil_keytrack"): // fallthrough
case hash("fil&_keytrack"): case hash("fil&_keytrack"):
{ {
const auto filterIndex = opcode.parameters.empty() ? 0 : (opcode.parameters.front() - 1); const auto filterIndex = opcode.parameters.empty() ? 0 : (opcode.parameters.front() - 1);
@ -437,7 +438,7 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
setValueFromOpcode(opcode, filters[filterIndex].keytrack, Default::filterKeytrackRange); setValueFromOpcode(opcode, filters[filterIndex].keytrack, Default::filterKeytrackRange);
} }
break; break;
case hash("fil_keycenter"): [[fallthrough]]; case hash("fil_keycenter"): // fallthrough
case hash("fil&_keycenter"): case hash("fil&_keycenter"):
{ {
const auto filterIndex = opcode.parameters.empty() ? 0 : (opcode.parameters.front() - 1); const auto filterIndex = opcode.parameters.empty() ? 0 : (opcode.parameters.front() - 1);
@ -447,7 +448,7 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
setValueFromOpcode(opcode, filters[filterIndex].keycenter, Default::keyRange); setValueFromOpcode(opcode, filters[filterIndex].keycenter, Default::keyRange);
} }
break; break;
case hash("fil_veltrack"): [[fallthrough]]; case hash("fil_veltrack"): // fallthrough
case hash("fil&_veltrack"): case hash("fil&_veltrack"):
{ {
const auto filterIndex = opcode.parameters.empty() ? 0 : (opcode.parameters.front() - 1); const auto filterIndex = opcode.parameters.empty() ? 0 : (opcode.parameters.front() - 1);
@ -457,7 +458,7 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
setValueFromOpcode(opcode, filters[filterIndex].veltrack, Default::filterVeltrackRange); setValueFromOpcode(opcode, filters[filterIndex].veltrack, Default::filterVeltrackRange);
} }
break; break;
case hash("fil_random"): [[fallthrough]]; case hash("fil_random"): // fallthrough
case hash("fil&_random"): case hash("fil&_random"):
{ {
const auto filterIndex = opcode.parameters.empty() ? 0 : (opcode.parameters.front() - 1); const auto filterIndex = opcode.parameters.empty() ? 0 : (opcode.parameters.front() - 1);
@ -467,7 +468,7 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
setValueFromOpcode(opcode, filters[filterIndex].random, Default::filterRandomRange); setValueFromOpcode(opcode, filters[filterIndex].random, Default::filterRandomRange);
} }
break; break;
case hash("fil_gain"): [[fallthrough]]; case hash("fil_gain"): // fallthrough
case hash("fil&_gain"): case hash("fil&_gain"):
{ {
const auto filterIndex = opcode.parameters.empty() ? 0 : (opcode.parameters.front() - 1); const auto filterIndex = opcode.parameters.empty() ? 0 : (opcode.parameters.front() - 1);
@ -477,7 +478,7 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
setValueFromOpcode(opcode, filters[filterIndex].gain, Default::filterGainRange); setValueFromOpcode(opcode, filters[filterIndex].gain, Default::filterGainRange);
} }
break; break;
case hash("fil_gaincc&"): [[fallthrough]]; case hash("fil_gaincc&"): // fallthrough
case hash("fil&_gaincc&"): case hash("fil&_gaincc&"):
{ {
const auto filterIndex = opcode.parameters.size() == 1 ? 0 : (opcode.parameters.front() - 1); const auto filterIndex = opcode.parameters.size() == 1 ? 0 : (opcode.parameters.front() - 1);
@ -491,7 +492,7 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
); );
} }
break; break;
case hash("fil_type"): [[fallthrough]]; case hash("fil_type"): // fallthrough
case hash("fil&_type"): case hash("fil&_type"):
{ {
const auto filterIndex = opcode.parameters.empty() ? 0 : (opcode.parameters.front() - 1); const auto filterIndex = opcode.parameters.empty() ? 0 : (opcode.parameters.front() - 1);
@ -520,7 +521,7 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
setValueFromOpcode(opcode, equalizers[eqNumber - 1].bandwidth, Default::eqBandwidthRange); setValueFromOpcode(opcode, equalizers[eqNumber - 1].bandwidth, Default::eqBandwidthRange);
} }
break; break;
case hash("eq&_bw_oncc&"): [[fallthrough]]; case hash("eq&_bw_oncc&"): // fallthrough
case hash("eq&_bwcc&"): case hash("eq&_bwcc&"):
{ {
const auto eqNumber = opcode.parameters.front(); const auto eqNumber = opcode.parameters.front();
@ -542,7 +543,7 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
setValueFromOpcode(opcode, equalizers[eqNumber - 1].frequency, Default::eqFrequencyRange); setValueFromOpcode(opcode, equalizers[eqNumber - 1].frequency, Default::eqFrequencyRange);
} }
break; break;
case hash("eq&_freq_oncc&"): [[fallthrough]]; case hash("eq&_freq_oncc&"): // fallthrough
case hash("eq&_freqcc&"): case hash("eq&_freqcc&"):
{ {
const auto eqNumber = opcode.parameters.front(); const auto eqNumber = opcode.parameters.front();
@ -577,7 +578,7 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
setValueFromOpcode(opcode, equalizers[eqNumber - 1].gain, Default::eqGainRange); setValueFromOpcode(opcode, equalizers[eqNumber - 1].gain, Default::eqGainRange);
} }
break; break;
case hash("eq&_gain_oncc&"): [[fallthrough]]; case hash("eq&_gain_oncc&"): // fallthrough
case hash("eq&_gaincc&"): case hash("eq&_gaincc&"):
{ {
const auto eqNumber = opcode.parameters.front(); const auto eqNumber = opcode.parameters.front();
@ -638,7 +639,7 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
case hash("transpose"): case hash("transpose"):
setValueFromOpcode(opcode, transpose, Default::transposeRange); setValueFromOpcode(opcode, transpose, Default::transposeRange);
break; break;
case hash("tune"): [[fallthrough]]; case hash("tune"): // fallthrough
case hash("pitch"): case hash("pitch"):
setValueFromOpcode(opcode, tune, Default::tuneRange); setValueFromOpcode(opcode, tune, Default::tuneRange);
break; break;
@ -704,31 +705,31 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
return false; // Was not vel2... return false; // Was not vel2...
setValueFromOpcode(opcode, amplitudeEG.vel2sustain, Default::egOnCCPercentRange); setValueFromOpcode(opcode, amplitudeEG.vel2sustain, Default::egOnCCPercentRange);
break; break;
case hash("ampeg_attackcc&"): [[fallthrough]]; case hash("ampeg_attackcc&"): // fallthrough
case hash("ampeg_attack_oncc&"): case hash("ampeg_attack_oncc&"):
setCCPairFromOpcode(opcode, amplitudeEG.ccAttack, Default::egOnCCTimeRange); setCCPairFromOpcode(opcode, amplitudeEG.ccAttack, Default::egOnCCTimeRange);
break; break;
case hash("ampeg_decaycc&"): [[fallthrough]]; case hash("ampeg_decaycc&"): // fallthrough
case hash("ampeg_decay_oncc&"): case hash("ampeg_decay_oncc&"):
setCCPairFromOpcode(opcode, amplitudeEG.ccDecay, Default::egOnCCTimeRange); setCCPairFromOpcode(opcode, amplitudeEG.ccDecay, Default::egOnCCTimeRange);
break; break;
case hash("ampeg_delaycc&"): [[fallthrough]]; case hash("ampeg_delaycc&"): // fallthrough
case hash("ampeg_delay_oncc&"): case hash("ampeg_delay_oncc&"):
setCCPairFromOpcode(opcode, amplitudeEG.ccDelay, Default::egOnCCTimeRange); setCCPairFromOpcode(opcode, amplitudeEG.ccDelay, Default::egOnCCTimeRange);
break; break;
case hash("ampeg_holdcc&"): [[fallthrough]]; case hash("ampeg_holdcc&"): // fallthrough
case hash("ampeg_hold_oncc&"): case hash("ampeg_hold_oncc&"):
setCCPairFromOpcode(opcode, amplitudeEG.ccHold, Default::egOnCCTimeRange); setCCPairFromOpcode(opcode, amplitudeEG.ccHold, Default::egOnCCTimeRange);
break; break;
case hash("ampeg_releasecc&"): [[fallthrough]]; case hash("ampeg_releasecc&"): // fallthrough
case hash("ampeg_release_oncc&"): case hash("ampeg_release_oncc&"):
setCCPairFromOpcode(opcode, amplitudeEG.ccRelease, Default::egOnCCTimeRange); setCCPairFromOpcode(opcode, amplitudeEG.ccRelease, Default::egOnCCTimeRange);
break; break;
case hash("ampeg_startcc&"): [[fallthrough]]; case hash("ampeg_startcc&"): // fallthrough
case hash("ampeg_start_oncc&"): case hash("ampeg_start_oncc&"):
setCCPairFromOpcode(opcode, amplitudeEG.ccStart, Default::egOnCCPercentRange); setCCPairFromOpcode(opcode, amplitudeEG.ccStart, Default::egOnCCPercentRange);
break; break;
case hash("ampeg_sustaincc&"): [[fallthrough]]; case hash("ampeg_sustaincc&"): // fallthrough
case hash("ampeg_sustain_oncc&"): case hash("ampeg_sustain_oncc&"):
setCCPairFromOpcode(opcode, amplitudeEG.ccSustain, Default::egOnCCPercentRange); setCCPairFromOpcode(opcode, amplitudeEG.ccSustain, Default::egOnCCPercentRange);
break; break;
@ -817,7 +818,7 @@ bool sfz::Region::registerNoteOn(int noteNumber, uint8_t velocity, float randVal
return keyOk && velOk && randOk && (attackTrigger || firstLegatoNote || notFirstLegatoNote); return keyOk && velOk && randOk && (attackTrigger || firstLegatoNote || notFirstLegatoNote);
} }
bool sfz::Region::registerNoteOff(int noteNumber, uint8_t velocity [[maybe_unused]], float randValue) noexcept bool sfz::Region::registerNoteOff(int noteNumber, uint8_t velocity, float randValue) noexcept
{ {
if (keyswitchRange.containsWithEnd(noteNumber)) { if (keyswitchRange.containsWithEnd(noteNumber)) {
if (keyswitchDown && *keyswitchDown == noteNumber) if (keyswitchDown && *keyswitchDown == noteNumber)
@ -1011,7 +1012,7 @@ float sfz::Region::velocityCurve(uint8_t velocity) const noexcept
float gain { 1.0f }; float gain { 1.0f };
if (velocityPoints.size() > 0) { // Custom velocity curve if (velocityPoints.size() > 0) { // Custom velocity curve
auto after = std::find_if(velocityPoints.begin(), velocityPoints.end(), [velocity](auto& val) { return val.first >= velocity; }); auto after = std::find_if(velocityPoints.begin(), velocityPoints.end(), [velocity](const std::pair<int, float>& val) { return val.first >= velocity; });
auto before = after == velocityPoints.begin() ? velocityPoints.begin() : after - 1; auto before = after == velocityPoints.begin() ? velocityPoints.begin() : after - 1;
// Linear interpolation // Linear interpolation
float relativePositionInSegment { float relativePositionInSegment {

View file

@ -748,7 +748,7 @@ namespace _internals {
int i = 0; int i = 0;
for (; i < panSize; ++i) for (; i < panSize; ++i)
pan[i] = std::cos(i * (piTwo<double> / (panSize - 1))); pan[i] = std::cos(i * (piTwo<double>() / (panSize - 1)));
for (; i < static_cast<int>(pan.size()); ++i) for (; i < static_cast<int>(pan.size()); ++i)
pan[i] = pan[panSize - 1]; pan[i] = pan[panSize - 1];

View file

@ -29,10 +29,9 @@
#include <arm_neon.h> #include <arm_neon.h>
using Type = float; using Type = float;
[[maybe_unused]] constexpr uintptr_t TypeAlignment { 4 }; constexpr uintptr_t TypeAlignment { 4 };
[[maybe_unused]] constexpr uintptr_t TypeAlignmentMask { TypeAlignment - 1 }; constexpr uintptr_t ByteAlignment { TypeAlignment * sizeof(Type) };
[[maybe_unused]] constexpr uintptr_t ByteAlignment { TypeAlignment * sizeof(Type) }; constexpr uintptr_t ByteAlignmentMask { ByteAlignment - 1 };
[[maybe_unused]] constexpr uintptr_t ByteAlignmentMask { ByteAlignment - 1 };
float* nextAligned(const float* ptr) float* nextAligned(const float* ptr)
{ {

View file

@ -16,10 +16,9 @@
#include "mathfuns/sse_mathfun.h" #include "mathfuns/sse_mathfun.h"
using Type = float; using Type = float;
[[maybe_unused]] constexpr uintptr_t TypeAlignment { 4 }; constexpr uintptr_t TypeAlignment { 4 };
[[maybe_unused]] constexpr uintptr_t TypeAlignmentMask { TypeAlignment - 1 }; constexpr uintptr_t ByteAlignment { TypeAlignment * sizeof(Type) };
[[maybe_unused]] constexpr uintptr_t ByteAlignment { TypeAlignment * sizeof(Type) }; constexpr uintptr_t ByteAlignmentMask { ByteAlignment - 1 };
[[maybe_unused]] constexpr uintptr_t ByteAlignmentMask { ByteAlignment - 1 };
struct AlignmentSentinels { struct AlignmentSentinels {
float* nextAligned; float* nextAligned;
@ -623,7 +622,7 @@ void sfz::pan<float, true>(absl::Span<const float> panEnvelope, absl::Span<float
} }
const auto mmOne = _mm_set_ps1(1.0f); const auto mmOne = _mm_set_ps1(1.0f);
const auto mmPiFour = _mm_set_ps1(piFour<float>); const auto mmPiFour = _mm_set_ps1(piFour<float>());
__m128 mmCos; __m128 mmCos;
__m128 mmSin; __m128 mmSin;
while (pan < lastAligned) { while (pan < lastAligned) {
@ -660,7 +659,7 @@ void sfz::width<float, true>(absl::Span<const float> widthEnvelope, absl::Span<f
incrementAll(width, left, right); incrementAll(width, left, right);
} }
const auto mmPiFour = _mm_set_ps1(piFour<float>); const auto mmPiFour = _mm_set_ps1(piFour<float>());
__m128 mmCos; __m128 mmCos;
__m128 mmSin; __m128 mmSin;
while (width < lastAligned) { while (width < lastAligned) {

View file

@ -10,7 +10,9 @@
//#include <string> //#include <string>
#include <array> #include <array>
#include <cmath> #include <cmath>
#include "Macros.h"
#include "Config.h" #include "Config.h"
#include "MathHelpers.h"
namespace sfz namespace sfz
{ {
@ -85,7 +87,7 @@ template<class T>
constexpr float normalizeCC(T ccValue) constexpr float normalizeCC(T ccValue)
{ {
static_assert(std::is_integral<T>::value, "Requires an integral T"); static_assert(std::is_integral<T>::value, "Requires an integral T");
return static_cast<float>(std::min(std::max(ccValue, static_cast<T>(0)), static_cast<T>(127))) / 127.0f; return static_cast<float>(min(max(ccValue, static_cast<T>(0)), static_cast<T>(127))) / 127.0f;
} }
/** /**
@ -124,7 +126,7 @@ constexpr float normalizePercents(T percentValue)
*/ */
constexpr float normalizeBend(float bendValue) constexpr float normalizeBend(float bendValue)
{ {
return std::min(std::max(bendValue, -8191.0f), 8191.0f) / 8191.0f; return min(max(bendValue, -8191.0f), 8191.0f) / 8191.0f;
} }
/** /**
@ -229,7 +231,7 @@ using modFunction = std::function<void(T&, U)>;
* @param modifier the modifier value * @param modifier the modifier value
*/ */
template<class T> template<class T>
constexpr void addToBase(T& base, T modifier) inline CXX14_CONSTEXPR void addToBase(T& base, T modifier)
{ {
base += modifier; base += modifier;
} }
@ -240,7 +242,7 @@ constexpr void addToBase(T& base, T modifier)
* @param base * @param base
* @param modifier * @param modifier
*/ */
constexpr void multiplyByCents(float& base, int modifier) inline CXX14_CONSTEXPR void multiplyByCents(float& base, int modifier)
{ {
base *= centsFactor(modifier); base *= centsFactor(modifier);
} }

View file

@ -56,10 +56,7 @@ constexpr uint64_t Fnv1aPrime = 0x01000193;
*/ */
constexpr uint64_t hash(absl::string_view s, uint64_t h = Fnv1aBasis) constexpr uint64_t hash(absl::string_view s, uint64_t h = Fnv1aBasis)
{ {
if (s.length() > 0) return (s.length() == 0) ? h : hash( { s.data() + 1, s.length() - 1 }, (h ^ s.front()) * Fnv1aPrime );
return hash( { s.data() + 1, s.length() - 1 }, (h ^ s.front()) * Fnv1aPrime );
return h;
} }
/** /**
@ -73,12 +70,9 @@ constexpr uint64_t hash(absl::string_view s, uint64_t h = Fnv1aBasis)
*/ */
constexpr uint64_t hashNoAmpersand(absl::string_view s, uint64_t h = Fnv1aBasis) constexpr uint64_t hashNoAmpersand(absl::string_view s, uint64_t h = Fnv1aBasis)
{ {
if (s.length() > 0) { return (s.length() == 0) ? h : (
if (s.front() == '&') (s.front() == '&')
return hashNoAmpersand( { s.data() + 1, s.length() - 1 }, h ); ? hashNoAmpersand( { s.data() + 1, s.length() - 1 }, h )
else : hashNoAmpersand( { s.data() + 1, s.length() - 1 }, (h ^ s.front()) * Fnv1aPrime )
return hashNoAmpersand( { s.data() + 1, s.length() - 1 }, (h ^ s.front()) * Fnv1aPrime ); );
}
return h;
} }

View file

@ -8,17 +8,18 @@
#include "AtomicGuard.h" #include "AtomicGuard.h"
#include "Config.h" #include "Config.h"
#include "Debug.h" #include "Debug.h"
#include "Macros.h"
#include "MidiState.h" #include "MidiState.h"
#include "ScopedFTZ.h" #include "ScopedFTZ.h"
#include "StringViewHelpers.h" #include "StringViewHelpers.h"
#include "pugixml.hpp" #include "pugixml.hpp"
#include "absl/algorithm/container.h" #include "absl/algorithm/container.h"
#include "absl/memory/memory.h"
#include "absl/strings/str_replace.h" #include "absl/strings/str_replace.h"
#include <algorithm> #include <algorithm>
#include <chrono> #include <chrono>
#include <iostream> #include <iostream>
#include <utility> #include <utility>
using namespace std::literals;
sfz::Synth::Synth() sfz::Synth::Synth()
: Synth(config::numVoices) : Synth(config::numVoices)
@ -38,7 +39,7 @@ sfz::Synth::~Synth()
{ {
AtomicDisabler callbackDisabler { canEnterCallback }; AtomicDisabler callbackDisabler { canEnterCallback };
while (inCallback) { while (inCallback) {
std::this_thread::sleep_for(1ms); std::this_thread::sleep_for(std::chrono::milliseconds(1));
} }
for (auto& voice: voices) for (auto& voice: voices)
@ -83,9 +84,9 @@ void sfz::Synth::callback(absl::string_view header, const std::vector<Opcode>& m
void sfz::Synth::buildRegion(const std::vector<Opcode>& regionOpcodes) void sfz::Synth::buildRegion(const std::vector<Opcode>& regionOpcodes)
{ {
auto lastRegion = std::make_unique<Region>(resources.midiState, defaultPath); auto lastRegion = absl::make_unique<Region>(resources.midiState, defaultPath);
auto parseOpcodes = [&](const auto& opcodes) { auto parseOpcodes = [&](const std::vector<Opcode>& opcodes) {
for (auto& opcode : opcodes) { for (auto& opcode : opcodes) {
const auto unknown = absl::c_find_if(unknownOpcodes, [&](absl::string_view sv) { return sv.compare(opcode.opcode) == 0; }); const auto unknown = absl::c_find_if(unknownOpcodes, [&](absl::string_view sv) { return sv.compare(opcode.opcode) == 0; });
if (unknown != unknownOpcodes.end()) { if (unknown != unknownOpcodes.end()) {
@ -112,7 +113,7 @@ void sfz::Synth::clear()
{ {
AtomicDisabler callbackDisabler { canEnterCallback }; AtomicDisabler callbackDisabler { canEnterCallback };
while (inCallback) { while (inCallback) {
std::this_thread::sleep_for(1ms); std::this_thread::sleep_for(std::chrono::milliseconds(1));
} }
for (auto &voice: voices) for (auto &voice: voices)
@ -163,20 +164,20 @@ void sfz::Synth::handleControlOpcodes(const std::vector<Opcode>& members)
{ {
for (auto& member : members) { for (auto& member : members) {
switch (member.lettersOnlyHash) { switch (member.lettersOnlyHash) {
case hash("Set_cc&"): [[fallthrough]]; case hash("Set_cc&"): // fallthrough
case hash("set_cc&"): case hash("set_cc&"):
if (Default::ccNumberRange.containsWithEnd(member.parameters.back())) { if (Default::ccNumberRange.containsWithEnd(member.parameters.back())) {
const auto ccValue = readOpcode(member.value, Default::ccValueRange).value_or(0); const auto ccValue = readOpcode(member.value, Default::ccValueRange).value_or(0);
resources.midiState.ccEvent(0, member.parameters.back(), ccValue); resources.midiState.ccEvent(0, member.parameters.back(), ccValue);
} }
break; break;
case hash("Label_cc&"): [[fallthrough]]; case hash("Label_cc&"): // fallthrough
case hash("label_cc&"): case hash("label_cc&"):
if (Default::ccNumberRange.containsWithEnd(member.parameters.back())) if (Default::ccNumberRange.containsWithEnd(member.parameters.back()))
ccNames.emplace_back(member.parameters.back(), std::string(member.value)); ccNames.emplace_back(member.parameters.back(), std::string(member.value));
break; break;
case hash("Default_path"): case hash("Default_path"):
[[fallthrough]]; // fallthrough
case hash("default_path"): case hash("default_path"):
defaultPath = absl::StrReplaceAll(trim(member.value), { { "\\", "/" } }); defaultPath = absl::StrReplaceAll(trim(member.value), { { "\\", "/" } });
DBG("Changing default sample path to " << defaultPath); DBG("Changing default sample path to " << defaultPath);
@ -260,7 +261,7 @@ void sfz::Synth::handleEffectOpcodes(const std::vector<Opcode>& members)
void addEndpointsToVelocityCurve(sfz::Region& region) void addEndpointsToVelocityCurve(sfz::Region& region)
{ {
if (region.velocityPoints.size() > 0) { if (region.velocityPoints.size() > 0) {
absl::c_sort(region.velocityPoints, [](auto& lhs, auto& rhs) { return lhs.first < rhs.first; }); absl::c_sort(region.velocityPoints, [](const std::pair<int, float>& lhs, const std::pair<int, float>& rhs) { return lhs.first < rhs.first; });
if (region.ampVeltrack > 0) { if (region.ampVeltrack > 0) {
if (region.velocityPoints.back().first != sfz::Default::velocityRange.getEnd()) if (region.velocityPoints.back().first != sfz::Default::velocityRange.getEnd())
region.velocityPoints.push_back(std::make_pair<int, float>(127, 1.0f)); region.velocityPoints.push_back(std::make_pair<int, float>(127, 1.0f));
@ -279,7 +280,7 @@ bool sfz::Synth::loadSfzFile(const fs::path& file)
{ {
AtomicDisabler callbackDisabler { canEnterCallback }; AtomicDisabler callbackDisabler { canEnterCallback };
while (inCallback) { while (inCallback) {
std::this_thread::sleep_for(1ms); std::this_thread::sleep_for(std::chrono::milliseconds(1));
} }
clear(); clear();
@ -342,7 +343,7 @@ bool sfz::Synth::loadSfzFile(const fs::path& file)
region->isStereo = true; region->isStereo = true;
// TODO: adjust with LFO targets // TODO: adjust with LFO targets
const auto maxOffset { region->offset + region->offsetRandom }; const auto maxOffset = region->offset + region->offsetRandom;
if (!resources.filePool.preloadFile(region->sample, maxOffset)) if (!resources.filePool.preloadFile(region->sample, maxOffset))
removeCurrentRegion(); removeCurrentRegion();
} }
@ -409,7 +410,7 @@ bool sfz::Synth::loadSfzFile(const fs::path& file)
sfz::Voice* sfz::Synth::findFreeVoice() noexcept sfz::Voice* sfz::Synth::findFreeVoice() noexcept
{ {
auto freeVoice = absl::c_find_if(voices, [](const auto& voice) { return voice->isFree(); }); auto freeVoice = absl::c_find_if(voices, [](const std::unique_ptr<Voice>& voice) { return voice->isFree(); });
if (freeVoice != voices.end()) if (freeVoice != voices.end())
return freeVoice->get(); return freeVoice->get();
@ -418,7 +419,7 @@ sfz::Voice* sfz::Synth::findFreeVoice() noexcept
for (auto& voice : voices) for (auto& voice : voices)
if (voice->canBeStolen()) if (voice->canBeStolen())
voiceViewArray.push_back(voice.get()); voiceViewArray.push_back(voice.get());
absl::c_sort(voiceViewArray, [](const auto& lhs, const auto& rhs) { return lhs->getSourcePosition() > rhs->getSourcePosition(); }); absl::c_sort(voiceViewArray, [](Voice* lhs, Voice* rhs) { return lhs->getSourcePosition() > rhs->getSourcePosition(); });
for (auto* voice : voiceViewArray) { for (auto* voice : voiceViewArray) {
if (voice->getMeanSquaredAverage() < config::voiceStealingThreshold) { if (voice->getMeanSquaredAverage() < config::voiceStealingThreshold) {
@ -432,7 +433,7 @@ sfz::Voice* sfz::Synth::findFreeVoice() noexcept
int sfz::Synth::getNumActiveVoices() const noexcept int sfz::Synth::getNumActiveVoices() const noexcept
{ {
auto activeVoices { 0 }; auto activeVoices = 0;
for (const auto& voice : voices) { for (const auto& voice : voices) {
if (!voice->isFree()) if (!voice->isFree())
activeVoices++; activeVoices++;
@ -452,7 +453,7 @@ void sfz::Synth::setSamplesPerBlock(int samplesPerBlock) noexcept
AtomicDisabler callbackDisabler { canEnterCallback }; AtomicDisabler callbackDisabler { canEnterCallback };
while (inCallback) { while (inCallback) {
std::this_thread::sleep_for(1ms); std::this_thread::sleep_for(std::chrono::milliseconds(1));
} }
this->samplesPerBlock = samplesPerBlock; this->samplesPerBlock = samplesPerBlock;
@ -471,7 +472,7 @@ void sfz::Synth::setSampleRate(float sampleRate) noexcept
{ {
AtomicDisabler callbackDisabler { canEnterCallback }; AtomicDisabler callbackDisabler { canEnterCallback };
while (inCallback) { while (inCallback) {
std::this_thread::sleep_for(1ms); std::this_thread::sleep_for(std::chrono::milliseconds(1));
} }
this->sampleRate = sampleRate; this->sampleRate = sampleRate;
@ -589,10 +590,11 @@ void sfz::Synth::noteOn(int delay, int noteNumber, uint8_t velocity) noexcept
noteOnDispatch(delay, noteNumber, velocity); noteOnDispatch(delay, noteNumber, velocity);
} }
void sfz::Synth::noteOff(int delay, int noteNumber, uint8_t velocity [[maybe_unused]]) noexcept void sfz::Synth::noteOff(int delay, int noteNumber, uint8_t velocity) noexcept
{ {
ASSERT(noteNumber < 128); ASSERT(noteNumber < 128);
ASSERT(noteNumber >= 0); ASSERT(noteNumber >= 0);
UNUSED(velocity);
ScopedTiming logger { dispatchDuration, ScopedTiming::Operation::addToDuration }; ScopedTiming logger { dispatchDuration, ScopedTiming::Operation::addToDuration };
resources.midiState.noteOffEvent(delay, noteNumber, velocity); resources.midiState.noteOffEvent(delay, noteNumber, velocity);
@ -851,12 +853,12 @@ void sfz::Synth::resetVoices(int numVoices)
{ {
AtomicDisabler callbackDisabler{ canEnterCallback }; AtomicDisabler callbackDisabler{ canEnterCallback };
while (inCallback) { while (inCallback) {
std::this_thread::sleep_for(1ms); std::this_thread::sleep_for(std::chrono::milliseconds(1));
} }
voices.clear(); voices.clear();
for (int i = 0; i < numVoices; ++i) for (int i = 0; i < numVoices; ++i)
voices.push_back(std::make_unique<Voice>(resources)); voices.push_back(absl::make_unique<Voice>(resources));
for (auto& voice: voices) { for (auto& voice: voices) {
voice->setSampleRate(this->sampleRate); voice->setSampleRate(this->sampleRate);
@ -871,7 +873,7 @@ void sfz::Synth::setOversamplingFactor(sfz::Oversampling factor) noexcept
{ {
AtomicDisabler callbackDisabler{ canEnterCallback }; AtomicDisabler callbackDisabler{ canEnterCallback };
while (inCallback) { while (inCallback) {
std::this_thread::sleep_for(1ms); std::this_thread::sleep_for(std::chrono::milliseconds(1));
} }
for (auto& voice: voices) for (auto& voice: voices)
@ -891,7 +893,7 @@ void sfz::Synth::setPreloadSize(uint32_t preloadSize) noexcept
{ {
AtomicDisabler callbackDisabler{ canEnterCallback }; AtomicDisabler callbackDisabler{ canEnterCallback };
while (inCallback) { while (inCallback) {
std::this_thread::sleep_for(1ms); std::this_thread::sleep_for(std::chrono::milliseconds(1));
} }
resources.filePool.setPreloadSize(preloadSize); resources.filePool.setPreloadSize(preloadSize);

View file

@ -4,6 +4,7 @@
// license. You should have receive a LICENSE.md file along with the code. // 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 // If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz
#include "Macros.h"
#include "Voice.h" #include "Voice.h"
#include "AudioSpan.h" #include "AudioSpan.h"
#include "Config.h" #include "Config.h"
@ -45,7 +46,7 @@ void sfz::Voice::startVoice(Region* region, int delay, int number, uint8_t value
pitchRatio = region->getBasePitchVariation(number, value); pitchRatio = region->getBasePitchVariation(number, value);
baseVolumedB = region->getBaseVolumedB(number); baseVolumedB = region->getBaseVolumedB(number);
auto volumedB { baseVolumedB }; auto volumedB = baseVolumedB;
if (region->volumeCC) if (region->volumeCC)
volumedB += normalizeCC(resources.midiState.getCCValue(region->volumeCC->cc)) * region->volumeCC->value; volumedB += normalizeCC(resources.midiState.getCCValue(region->volumeCC->cc)) * region->volumeCC->value;
volumeEnvelope.reset(db2mag(Default::volumeRange.clamp(volumedB))); volumeEnvelope.reset(db2mag(Default::volumeRange.clamp(volumedB)));
@ -63,19 +64,19 @@ void sfz::Voice::startVoice(Region* region, int delay, int number, uint8_t value
crossfadeEnvelope.reset(Default::normalizedRange.clamp(crossfadeGain)); crossfadeEnvelope.reset(Default::normalizedRange.clamp(crossfadeGain));
basePan = normalizePercents(region->pan); basePan = normalizePercents(region->pan);
auto pan { basePan }; auto pan = basePan;
if (region->panCC) if (region->panCC)
pan += normalizeCC(resources.midiState.getCCValue(region->panCC->cc)) * normalizePercents(region->panCC->value); pan += normalizeCC(resources.midiState.getCCValue(region->panCC->cc)) * normalizePercents(region->panCC->value);
panEnvelope.reset(Default::symmetricNormalizedRange.clamp(pan)); panEnvelope.reset(Default::symmetricNormalizedRange.clamp(pan));
basePosition = normalizePercents(region->position); basePosition = normalizePercents(region->position);
auto position { basePosition }; auto position = basePosition;
if (region->positionCC) if (region->positionCC)
position += normalizeCC(resources.midiState.getCCValue(region->positionCC->cc)) * normalizePercents(region->positionCC->value); position += normalizeCC(resources.midiState.getCCValue(region->positionCC->cc)) * normalizePercents(region->positionCC->value);
positionEnvelope.reset(Default::symmetricNormalizedRange.clamp(position)); positionEnvelope.reset(Default::symmetricNormalizedRange.clamp(position));
baseWidth = normalizePercents(region->width); baseWidth = normalizePercents(region->width);
auto width { baseWidth }; auto width = baseWidth;
if (region->widthCC) if (region->widthCC)
width += normalizeCC(resources.midiState.getCCValue(region->widthCC->cc)) * normalizePercents(region->widthCC->value); width += normalizeCC(resources.midiState.getCCValue(region->widthCC->cc)) * normalizePercents(region->widthCC->value);
widthEnvelope.reset(Default::symmetricNormalizedRange.clamp(width)); widthEnvelope.reset(Default::symmetricNormalizedRange.clamp(width));
@ -129,8 +130,9 @@ void sfz::Voice::release(int delay, bool fastRelease) noexcept
} }
} }
void sfz::Voice::registerNoteOff(int delay, int noteNumber, uint8_t velocity [[maybe_unused]]) noexcept void sfz::Voice::registerNoteOff(int delay, int noteNumber, uint8_t velocity) noexcept
{ {
UNUSED(velocity);
if (region == nullptr) if (region == nullptr)
return; return;
@ -207,14 +209,18 @@ void sfz::Voice::registerPitchWheel(int delay, int pitch) noexcept
pitchBendEnvelope.registerEvent(delay, static_cast<float>(pitch)); pitchBendEnvelope.registerEvent(delay, static_cast<float>(pitch));
} }
void sfz::Voice::registerAftertouch(int delay [[maybe_unused]], uint8_t aftertouch [[maybe_unused]]) noexcept void sfz::Voice::registerAftertouch(int delay, uint8_t aftertouch) noexcept
{ {
// TODO // TODO
UNUSED(delay);
UNUSED(aftertouch);
} }
void sfz::Voice::registerTempo(int delay [[maybe_unused]], float secondsPerQuarter [[maybe_unused]]) noexcept void sfz::Voice::registerTempo(int delay, float secondsPerQuarter) noexcept
{ {
// TODO // TODO
UNUSED(delay);
UNUSED(secondsPerQuarter);
} }
void sfz::Voice::setSampleRate(float sampleRate) noexcept void sfz::Voice::setSampleRate(float sampleRate) noexcept
@ -479,7 +485,7 @@ void sfz::Voice::fillWithGenerator(AudioSpan<float> buffer) noexcept
auto bends = tempSpan2.first(buffer.getNumFrames()); auto bends = tempSpan2.first(buffer.getNumFrames());
auto phases = tempSpan2.first(buffer.getNumFrames()); auto phases = tempSpan2.first(buffer.getNumFrames());
const float step = baseFrequency * twoPi<float> / sampleRate; const float step = baseFrequency * twoPi<float>() / sampleRate;
fill<float>(jumps, step); fill<float>(jumps, step);
if (region->bendStep > 1) if (region->bendStep > 1)
@ -496,8 +502,8 @@ void sfz::Voice::fillWithGenerator(AudioSpan<float> buffer) noexcept
copy<float>(leftSpan, rightSpan); copy<float>(leftSpan, rightSpan);
// Wrap the phase so we don't loose too much precision on longer notes // Wrap the phase so we don't loose too much precision on longer notes
const auto numTwoPiWraps = static_cast<int>(phase / twoPi<float>); const auto numTwoPiWraps = static_cast<int>(phase / twoPi<float>());
phase -= twoPi<float> * static_cast<float>(numTwoPiWraps); phase -= twoPi<float>() * static_cast<float>(numTwoPiWraps);
} }
} }

View file

@ -37,7 +37,7 @@
#include "Lofi.h" #include "Lofi.h"
#include "Opcode.h" #include "Opcode.h"
#include <memory> #include "absl/memory/memory.h"
#include <algorithm> #include <algorithm>
#include <cstring> #include <cstring>
#include <cmath> #include <cmath>
@ -79,7 +79,7 @@ namespace fx {
std::unique_ptr<Effect> Lofi::makeInstance(absl::Span<const Opcode> members) std::unique_ptr<Effect> Lofi::makeInstance(absl::Span<const Opcode> members)
{ {
auto fx = std::make_unique<Lofi>(); auto fx = absl::make_unique<Lofi>();
for (const Opcode& opcode : members) { for (const Opcode& opcode : members) {
switch (opcode.lettersOnlyHash) { switch (opcode.lettersOnlyHash) {
@ -92,7 +92,7 @@ namespace fx {
} }
} }
return fx; return std::move(fx);
} }
/// ///

View file

@ -6,10 +6,11 @@
#include "Synth.h" #include "Synth.h"
#include "sfizz.hpp" #include "sfizz.hpp"
#include "absl/memory/memory.h"
sfz::Sfizz::Sfizz() sfz::Sfizz::Sfizz()
{ {
synth = std::make_unique<sfz::Synth>(); synth = absl::make_unique<sfz::Synth>();
} }
sfz::Sfizz::~Sfizz() sfz::Sfizz::~Sfizz()

View file

@ -5,10 +5,10 @@
// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz // If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz
#include "Config.h" #include "Config.h"
#include "Macros.h"
#include "Synth.h" #include "Synth.h"
#include "sfizz.h" #include "sfizz.h"
#define UNUSED(x) (void)(x)
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif

View file

@ -64,8 +64,8 @@ TEST_CASE("[AudioBuffer] Iterators")
std::fill(buffer.channelWriter(0), buffer.channelWriterEnd(0), fillValue); std::fill(buffer.channelWriter(0), buffer.channelWriterEnd(0), fillValue);
std::fill(buffer.channelWriter(1), buffer.channelWriterEnd(1), fillValue); std::fill(buffer.channelWriter(1), buffer.channelWriterEnd(1), fillValue);
REQUIRE(std::all_of(buffer.channelReader(0), buffer.channelReaderEnd(0), [fillValue](auto value) { return value == fillValue; })); REQUIRE(std::all_of(buffer.channelReader(0), buffer.channelReaderEnd(0), [fillValue](float value) { return value == fillValue; }));
REQUIRE(std::all_of(buffer.channelReader(1), buffer.channelReaderEnd(1), [fillValue](auto value) { return value == fillValue; })); REQUIRE(std::all_of(buffer.channelReader(1), buffer.channelReaderEnd(1), [fillValue](float value) { return value == fillValue; }));
} }
TEST_CASE("[AudioSpan] Constructions") TEST_CASE("[AudioSpan] Constructions")

View file

@ -73,7 +73,7 @@ TEST_CASE("[Buffer] Resize 10 floats ")
REQUIRE(buffer.resize(smallSize)); REQUIRE(buffer.resize(smallSize));
checkBoundaries(buffer, smallSize); checkBoundaries(buffer, smallSize);
REQUIRE(std::all_of(buffer.begin(), buffer.end(), [](auto value) { return value == 1.0f; })); REQUIRE(std::all_of(buffer.begin(), buffer.end(), [](float value) { return value == 1.0f; }));
REQUIRE(buffer.resize(bigSize)); REQUIRE(buffer.resize(bigSize));
checkBoundaries(buffer, bigSize); checkBoundaries(buffer, bigSize);
@ -95,7 +95,7 @@ TEST_CASE("[Buffer] Resize 4096 floats ")
REQUIRE(buffer.resize(smallSize)); REQUIRE(buffer.resize(smallSize));
checkBoundaries(buffer, smallSize); checkBoundaries(buffer, smallSize);
REQUIRE(std::all_of(buffer.begin(), buffer.end(), [](auto value) { return value == 1.0f; })); REQUIRE(std::all_of(buffer.begin(), buffer.end(), [](float value) { return value == 1.0f; }));
REQUIRE(buffer.resize(bigSize)); REQUIRE(buffer.resize(bigSize));
checkBoundaries(buffer, bigSize); checkBoundaries(buffer, bigSize);
@ -117,7 +117,7 @@ TEST_CASE("[Buffer] Resize 65536 floats ")
REQUIRE(buffer.resize(smallSize)); REQUIRE(buffer.resize(smallSize));
checkBoundaries(buffer, smallSize); checkBoundaries(buffer, smallSize);
REQUIRE(std::all_of(buffer.begin(), buffer.end(), [](auto value) { return value == 1.0f; })); REQUIRE(std::all_of(buffer.begin(), buffer.end(), [](float value) { return value == 1.0f; }));
REQUIRE(buffer.resize(bigSize)); REQUIRE(buffer.resize(bigSize));
checkBoundaries(buffer, bigSize); checkBoundaries(buffer, bigSize);
@ -134,11 +134,11 @@ TEST_CASE("[Buffer] Copy and move")
std::fill(copied.begin(), copied.end(), 2.0f); std::fill(copied.begin(), copied.end(), 2.0f);
copied = buffer; copied = buffer;
checkBoundaries(copied, baseSize); checkBoundaries(copied, baseSize);
REQUIRE(std::all_of(copied.begin(), copied.end(), [](auto value) { return value == 1.0f; })); REQUIRE(std::all_of(copied.begin(), copied.end(), [](float value) { return value == 1.0f; }));
sfz::Buffer<float> copyConstructed { buffer }; sfz::Buffer<float> copyConstructed { buffer };
checkBoundaries(copyConstructed, baseSize); checkBoundaries(copyConstructed, baseSize);
REQUIRE(std::all_of(copyConstructed.begin(), copyConstructed.end(), [](auto value) { return value == 1.0f; })); REQUIRE(std::all_of(copyConstructed.begin(), copyConstructed.end(), [](float value) { return value == 1.0f; }));
// sfz::Buffer<float> moveConstructed { std::move(buffer) }; // sfz::Buffer<float> moveConstructed { std::move(buffer) };
// REQUIRE(buffer.empty()); // REQUIRE(buffer.empty());

View file

@ -134,7 +134,7 @@ TEST_CASE("[LinearEnvelope] 2 events, with another block call")
TEST_CASE("[LinearEnvelope] 2 events, function") TEST_CASE("[LinearEnvelope] 2 events, function")
{ {
sfz::LinearEnvelope<float> envelope; sfz::LinearEnvelope<float> envelope;
envelope.setFunction([](auto x) { return 2 * x; }); envelope.setFunction([](float x) { return 2 * x; });
envelope.registerEvent(2, 1.0f); envelope.registerEvent(2, 1.0f);
envelope.registerEvent(6, 2.0f); envelope.registerEvent(6, 2.0f);
std::array<float, 8> output; std::array<float, 8> output;

View file

@ -36,6 +36,7 @@ function(plugin_add_vst3sdk NAME)
"${VST3SDK_BASEDIR}/public.sdk/source/common/threadchecker_win32.cpp" "${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/vst/vstgui_win32_bundle_support.cpp"
"${VST3SDK_BASEDIR}/public.sdk/source/main/dllmain.cpp") "${VST3SDK_BASEDIR}/public.sdk/source/main/dllmain.cpp")
set_property(TARGET "${NAME}" PROPERTY CXX_STANDARD 14)
elseif(APPLE) elseif(APPLE)
target_sources("${NAME}" PRIVATE target_sources("${NAME}" PRIVATE
"${VST3SDK_BASEDIR}/public.sdk/source/main/macmain.cpp") "${VST3SDK_BASEDIR}/public.sdk/source/main/macmain.cpp")