Merge branch 'windows' into develop
This commit is contained in:
commit
3268bcde3a
63 changed files with 683 additions and 536 deletions
32
README.md
32
README.md
|
|
@ -39,3 +39,35 @@ git submodule update --init --recursive
|
||||||
```
|
```
|
||||||
|
|
||||||
You can build with `clang`, although in that case the CMakeFile defaults to using `libc++` instead of `libstdc++`.
|
You can build with `clang`, although in that case the CMakeFile defaults to using `libc++` instead of `libstdc++`.
|
||||||
|
|
||||||
|
### Building with MSVC on windows
|
||||||
|
|
||||||
|
The simplest is to use `vcpkg` as a package manager, which will give you access to `libsndfile`.
|
||||||
|
```powershell
|
||||||
|
git clone https://github.com/Microsoft/vcpkg.git
|
||||||
|
cd vcpkg
|
||||||
|
.\bootstrap-vcpkg.bat
|
||||||
|
.\vcpkg integrate install
|
||||||
|
.\vcpkg integrate powershell
|
||||||
|
```
|
||||||
|
|
||||||
|
Assuming you want to build for x64, install the relevant packages as follows
|
||||||
|
```powershell
|
||||||
|
.\vcpkg.exe install libsndfile:x64-windows zlib:x64-windows libsamplerate:x64-windows
|
||||||
|
```
|
||||||
|
|
||||||
|
In the sfizz source directory, you can then build with CMake as usual, although you should clone the windows branch:
|
||||||
|
```powershell
|
||||||
|
git clone --branch windows --recursive https://github.com/sfztools/sfizz.git
|
||||||
|
cd sfizz
|
||||||
|
mkdir build
|
||||||
|
cd build
|
||||||
|
cmake .. -DSFIZZ_JACK=OFF "-DCMAKE_TOOLCHAIN_FILE=C:\Users\Paul\source\vcpkg\scripts\buildsystems\vcpkg.cmake" -DVCPKG_TARGET_TRIPLET=x64-windows
|
||||||
|
cmake --build . -j 16 --config Release
|
||||||
|
```
|
||||||
|
|
||||||
|
This builds the lv2 plugin in `build\lv2\Release` and the Turtle files in `build\sfizz.lv2`, but the installation procedure is not entirely automatic yet.
|
||||||
|
In particular, having the required DLLs along with `sfizz.dll` is actually not helpful because the system cannot find dlls from another dll's root directory.
|
||||||
|
You thus need to add all of `FLAC.dll`, `libsndfile-1.dll`, `vorbis.dll`, `ogg.dll`, `vorbisenc.dll` in some directory in your `PATH` variable, and manually add `sfizz.dll` to the `sfizz.lv2` directory, and the the `sfizz.lv2` directory to `%APPDATA%\Roaming\LV2`.
|
||||||
|
Ardour should then find the plugin correctly and load it without issues.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,9 @@
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include <benchmark/benchmark.h>
|
#include "Config.h"
|
||||||
#include "ADSREnvelope.h"
|
#include "ADSREnvelope.h"
|
||||||
|
#include <benchmark/benchmark.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <random>
|
#include <random>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
|
|
@ -44,12 +45,12 @@ static void Point(benchmark::State& state) {
|
||||||
for (auto _ : state) {
|
for (auto _ : state) {
|
||||||
envelope.reset(attack, release, 1.0, fixedAmount, decay, fixedAmount);
|
envelope.reset(attack, release, 1.0, fixedAmount, decay, fixedAmount);
|
||||||
envelope.startRelease(releaseTime);
|
envelope.startRelease(releaseTime);
|
||||||
for(int offset = 0; offset < envelopeSize; offset += state.range(0))
|
for(int offset = 0; offset < envelopeSize; offset += static_cast<int>(state.range(0)))
|
||||||
for (auto& out: output)
|
for (auto& out: output)
|
||||||
out = envelope.getNextValue();
|
out = envelope.getNextValue();
|
||||||
benchmark::DoNotOptimize(output);
|
benchmark::DoNotOptimize(output);
|
||||||
}
|
}
|
||||||
state.counters["Per block"] = benchmark::Counter(envelopeSize / state.range(0), benchmark::Counter::kIsRate);
|
state.counters["Per block"] = benchmark::Counter(envelopeSize / static_cast<double>(state.range(0)), benchmark::Counter::kIsRate);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Block(benchmark::State& state) {
|
static void Block(benchmark::State& state) {
|
||||||
|
|
@ -58,12 +59,12 @@ static void Block(benchmark::State& state) {
|
||||||
for (auto _ : state) {
|
for (auto _ : state) {
|
||||||
envelope.reset(attack, release, 1.0, fixedAmount, decay, fixedAmount);
|
envelope.reset(attack, release, 1.0, fixedAmount, decay, fixedAmount);
|
||||||
envelope.startRelease(releaseTime);
|
envelope.startRelease(releaseTime);
|
||||||
for(int offset = 0; offset < envelopeSize; offset += state.range(0))
|
for(int offset = 0; offset < envelopeSize; offset += static_cast<int>(state.range(0)))
|
||||||
envelope.getBlock(absl::MakeSpan(output));
|
envelope.getBlock(absl::MakeSpan(output));
|
||||||
benchmark::DoNotOptimize(output);
|
benchmark::DoNotOptimize(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
state.counters["Per block"] = benchmark::Counter(envelopeSize / state.range(0), benchmark::Counter::kIsRate);
|
state.counters["Per block"] = benchmark::Counter(envelopeSize / static_cast<double>(state.range(0)), benchmark::Counter::kIsRate);
|
||||||
}
|
}
|
||||||
|
|
||||||
BENCHMARK(Point)->RangeMultiplier(2)->Range((2<<6), (2<<11));
|
BENCHMARK(Point)->RangeMultiplier(2)->Range((2<<6), (2<<11));
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
#include "Config.h"
|
||||||
#include <benchmark/benchmark.h>
|
#include <benchmark/benchmark.h>
|
||||||
#include <absl/types/span.h>
|
#include <absl/types/span.h>
|
||||||
#include <random>
|
#include <random>
|
||||||
|
|
|
||||||
|
|
@ -21,13 +21,13 @@
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
#include "SIMDHelpers.h"
|
||||||
#include <benchmark/benchmark.h>
|
#include <benchmark/benchmark.h>
|
||||||
#include <random>
|
#include <random>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "SIMDHelpers.h"
|
|
||||||
|
|
||||||
class AddArray : public benchmark::Fixture {
|
class AddArray : public benchmark::Fixture {
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -21,13 +21,13 @@
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
#include "SIMDHelpers.h"
|
||||||
#include <benchmark/benchmark.h>
|
#include <benchmark/benchmark.h>
|
||||||
#include <random>
|
#include <random>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "SIMDHelpers.h"
|
|
||||||
|
|
||||||
class CopyArray : public benchmark::Fixture {
|
class CopyArray : public benchmark::Fixture {
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -21,20 +21,20 @@
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
#include "SIMDHelpers.h"
|
||||||
#include <benchmark/benchmark.h>
|
#include <benchmark/benchmark.h>
|
||||||
#include <random>
|
#include <random>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "SIMDHelpers.h"
|
|
||||||
|
|
||||||
class CumArray : public benchmark::Fixture {
|
class CumArray : public benchmark::Fixture {
|
||||||
public:
|
public:
|
||||||
void SetUp(const ::benchmark::State& state) {
|
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.1, 1 };
|
std::uniform_real_distribution<float> dist { 0.1f, 1.0f };
|
||||||
input = std::vector<float>(state.range(0));
|
input = std::vector<float>(state.range(0));
|
||||||
output = std::vector<float>(state.range(0));
|
output = std::vector<float>(state.range(0));
|
||||||
std::generate(input.begin(), input.end(), [&]() { return dist(gen); });
|
std::generate(input.begin(), input.end(), [&]() { return dist(gen); });
|
||||||
|
|
|
||||||
|
|
@ -21,13 +21,13 @@
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
#include "SIMDHelpers.h"
|
||||||
#include <benchmark/benchmark.h>
|
#include <benchmark/benchmark.h>
|
||||||
#include <random>
|
#include <random>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "SIMDHelpers.h"
|
|
||||||
#include "absl/types/span.h"
|
#include "absl/types/span.h"
|
||||||
|
|
||||||
class DiffArray : public benchmark::Fixture {
|
class DiffArray : public benchmark::Fixture {
|
||||||
|
|
@ -35,7 +35,7 @@ public:
|
||||||
void SetUp(const ::benchmark::State& state) {
|
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.1, 1 };
|
std::uniform_real_distribution<float> dist { 0.1f, 1.0f };
|
||||||
input = std::vector<float>(state.range(0));
|
input = std::vector<float>(state.range(0));
|
||||||
output = std::vector<float>(state.range(0));
|
output = std::vector<float>(state.range(0));
|
||||||
std::generate(input.begin(), input.end(), [&]() { return dist(gen); });
|
std::generate(input.begin(), input.end(), [&]() { return dist(gen); });
|
||||||
|
|
|
||||||
|
|
@ -21,13 +21,13 @@
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
#include "SIMDHelpers.h"
|
||||||
#include <benchmark/benchmark.h>
|
#include <benchmark/benchmark.h>
|
||||||
#include <random>
|
#include <random>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "SIMDHelpers.h"
|
|
||||||
|
|
||||||
|
|
||||||
class Divide : public benchmark::Fixture {
|
class Divide : public benchmark::Fixture {
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
#include "SIMDHelpers.h"
|
||||||
#include <benchmark/benchmark.h>
|
#include <benchmark/benchmark.h>
|
||||||
#include <random>
|
#include <random>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
|
|
@ -28,7 +29,6 @@
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "EventEnvelopes.h"
|
#include "EventEnvelopes.h"
|
||||||
#include "SIMDHelpers.h"
|
|
||||||
#include "absl/types/span.h"
|
#include "absl/types/span.h"
|
||||||
|
|
||||||
#include "FloatEnvelopes.cpp"
|
#include "FloatEnvelopes.cpp"
|
||||||
|
|
@ -59,7 +59,7 @@ BENCHMARK_DEFINE_F(EnvelopeFixture, Linear)(benchmark::State& state) {
|
||||||
sfz::LinearEnvelope<float> envelope;
|
sfz::LinearEnvelope<float> envelope;
|
||||||
for (auto _ : state)
|
for (auto _ : state)
|
||||||
{
|
{
|
||||||
envelope.registerEvent(state.range(0) - 1, dist(gen));
|
envelope.registerEvent(static_cast<int>(state.range(0) - 1), dist(gen));
|
||||||
envelope.getBlock(absl::MakeSpan(output));
|
envelope.getBlock(absl::MakeSpan(output));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -68,7 +68,7 @@ BENCHMARK_DEFINE_F(EnvelopeFixture, LinearQuantized)(benchmark::State& state) {
|
||||||
sfz::LinearEnvelope<float> envelope;
|
sfz::LinearEnvelope<float> envelope;
|
||||||
for (auto _ : state)
|
for (auto _ : state)
|
||||||
{
|
{
|
||||||
envelope.registerEvent(state.range(0) - 1, dist(gen));
|
envelope.registerEvent(static_cast<int>(state.range(0) - 1), dist(gen));
|
||||||
envelope.getQuantizedBlock(absl::MakeSpan(output), 0.5);
|
envelope.getQuantizedBlock(absl::MakeSpan(output), 0.5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -77,7 +77,7 @@ BENCHMARK_DEFINE_F(EnvelopeFixture, Multiplicative)(benchmark::State& state) {
|
||||||
sfz::MultiplicativeEnvelope<float> envelope;
|
sfz::MultiplicativeEnvelope<float> envelope;
|
||||||
for (auto _ : state)
|
for (auto _ : state)
|
||||||
{
|
{
|
||||||
envelope.registerEvent(state.range(0) - 1, dist(gen));
|
envelope.registerEvent(static_cast<int>(state.range(0) - 1), dist(gen));
|
||||||
envelope.getBlock(absl::MakeSpan(output));
|
envelope.getBlock(absl::MakeSpan(output));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -86,7 +86,7 @@ BENCHMARK_DEFINE_F(EnvelopeFixture, MultiplicativeQuantized)(benchmark::State& s
|
||||||
sfz::MultiplicativeEnvelope<float> envelope;
|
sfz::MultiplicativeEnvelope<float> envelope;
|
||||||
for (auto _ : state)
|
for (auto _ : state)
|
||||||
{
|
{
|
||||||
envelope.registerEvent(state.range(0) - 1, dist(gen));
|
envelope.registerEvent(static_cast<int>(state.range(0) - 1), dist(gen));
|
||||||
envelope.getQuantizedBlock(absl::MakeSpan(output), 1.5);
|
envelope.getQuantizedBlock(absl::MakeSpan(output), 1.5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,8 @@
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include <benchmark/benchmark.h>
|
|
||||||
#include "SIMDHelpers.h"
|
#include "SIMDHelpers.h"
|
||||||
|
#include <benchmark/benchmark.h>
|
||||||
#include "Buffer.h"
|
#include "Buffer.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <random>
|
#include <random>
|
||||||
|
|
|
||||||
|
|
@ -20,23 +20,27 @@
|
||||||
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
#include "Buffer.h"
|
||||||
#include <benchmark/benchmark.h>
|
#include <benchmark/benchmark.h>
|
||||||
#include <sndfile.hh>
|
#include <sndfile.hh>
|
||||||
#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 "Buffer.h"
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#endif
|
#endif
|
||||||
|
#include "libnyquist/Decoders.h"
|
||||||
|
|
||||||
class FileFixture : public benchmark::Fixture {
|
class FileFixture : public benchmark::Fixture {
|
||||||
public:
|
public:
|
||||||
void SetUp(const ::benchmark::State& state) {
|
void SetUp(const ::benchmark::State& state) {
|
||||||
rootPath1 = getPath() / "sample1.flac";
|
filePath1 = getPath() / "sample1.flac";
|
||||||
rootPath2 = getPath() / "sample2.flac";
|
filePath2 = getPath() / "sample2.flac";
|
||||||
if (!ghc::filesystem::exists(rootPath1) || !ghc::filesystem::exists(rootPath2)) {
|
filePath3 = getPath() / "sample3.flac";
|
||||||
|
if ( !ghc::filesystem::exists(filePath1)
|
||||||
|
|| !ghc::filesystem::exists(filePath2)
|
||||||
|
|| !ghc::filesystem::exists(filePath3) ) {
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
std::cerr << "Can't find path" << '\n';
|
std::cerr << "Can't find path" << '\n';
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -62,15 +66,16 @@ public:
|
||||||
|
|
||||||
std::unique_ptr<sfz::Buffer<float>> buffer;
|
std::unique_ptr<sfz::Buffer<float>> buffer;
|
||||||
|
|
||||||
ghc::filesystem::path rootPath1;
|
ghc::filesystem::path filePath1;
|
||||||
ghc::filesystem::path rootPath2;
|
ghc::filesystem::path filePath2;
|
||||||
|
ghc::filesystem::path filePath3;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
BENCHMARK_DEFINE_F(FileFixture, SndFile)(benchmark::State& state) {
|
BENCHMARK_DEFINE_F(FileFixture, SndFile)(benchmark::State& state) {
|
||||||
for (auto _ : state)
|
for (auto _ : state)
|
||||||
{
|
{
|
||||||
SndfileHandle sndfile(rootPath1.c_str());
|
SndfileHandle sndfile(filePath1.c_str());
|
||||||
buffer = std::make_unique<sfz::Buffer<float>>(sndfile.channels() * sndfile.frames());
|
buffer = std::make_unique<sfz::Buffer<float>>(sndfile.channels() * sndfile.frames());
|
||||||
sndfile.readf(buffer->data(), sndfile.frames());
|
sndfile.readf(buffer->data(), sndfile.frames());
|
||||||
}
|
}
|
||||||
|
|
@ -79,12 +84,23 @@ BENCHMARK_DEFINE_F(FileFixture, SndFile)(benchmark::State& state) {
|
||||||
BENCHMARK_DEFINE_F(FileFixture, DrFlac)(benchmark::State& state) {
|
BENCHMARK_DEFINE_F(FileFixture, DrFlac)(benchmark::State& state) {
|
||||||
for (auto _ : state)
|
for (auto _ : state)
|
||||||
{
|
{
|
||||||
auto* flac = drflac_open_file(rootPath2.c_str(), nullptr);
|
auto* flac = drflac_open_file(filePath2.c_str(), nullptr);
|
||||||
buffer = std::make_unique<sfz::Buffer<float>>(flac->channels * flac->totalPCMFrameCount);
|
buffer = std::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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BENCHMARK_DEFINE_F(FileFixture, LibNyquist)(benchmark::State& state) {
|
||||||
|
for (auto _ : state)
|
||||||
|
{
|
||||||
|
nqr::AudioData data;
|
||||||
|
nqr::NyquistIO loader;
|
||||||
|
loader.Load(&data, filePath3.string());
|
||||||
|
benchmark::DoNotOptimize(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
BENCHMARK_REGISTER_F(FileFixture, SndFile);
|
BENCHMARK_REGISTER_F(FileFixture, SndFile);
|
||||||
BENCHMARK_REGISTER_F(FileFixture, DrFlac);
|
BENCHMARK_REGISTER_F(FileFixture, DrFlac);
|
||||||
|
BENCHMARK_REGISTER_F(FileFixture, LibNyquist);
|
||||||
BENCHMARK_MAIN();
|
BENCHMARK_MAIN();
|
||||||
|
|
|
||||||
|
|
@ -21,13 +21,13 @@
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
#include "SIMDHelpers.h"
|
||||||
#include <benchmark/benchmark.h>
|
#include <benchmark/benchmark.h>
|
||||||
#include <random>
|
#include <random>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "SIMDHelpers.h"
|
|
||||||
|
|
||||||
class GainSingle : public benchmark::Fixture {
|
class GainSingle : public benchmark::Fixture {
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -21,12 +21,12 @@
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
#include "SIMDHelpers.h"
|
||||||
#include <benchmark/benchmark.h>
|
#include <benchmark/benchmark.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <random>
|
#include <random>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
#include <absl/algorithm/container.h>
|
#include <absl/algorithm/container.h>
|
||||||
#include "SIMDHelpers.h"
|
|
||||||
|
|
||||||
// In this one we have an array of jumps
|
// In this one we have an array of jumps
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,11 +22,11 @@
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include <benchmark/benchmark.h>
|
#include <benchmark/benchmark.h>
|
||||||
|
#include "SIMDHelpers.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <random>
|
#include <random>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
#include <absl/algorithm/container.h>
|
#include <absl/algorithm/container.h>
|
||||||
#include "SIMDHelpers.h"
|
|
||||||
|
|
||||||
// In this one we have an array of indices
|
// In this one we have an array of indices
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ public:
|
||||||
{
|
{
|
||||||
std::random_device rd {};
|
std::random_device rd {};
|
||||||
std::mt19937 gen { rd() };
|
std::mt19937 gen { rd() };
|
||||||
std::uniform_real_distribution<float> dist { 0.1, 1 };
|
std::uniform_real_distribution<float> dist { 0.1f, 1.0f };
|
||||||
source = std::vector<float>(state.range(0));
|
source = std::vector<float>(state.range(0));
|
||||||
result = std::vector<float>(state.range(0));
|
result = std::vector<float>(state.range(0));
|
||||||
std::generate(source.begin(), source.end(), [&]() { return dist(gen); });
|
std::generate(source.begin(), source.end(), [&]() { return dist(gen); });
|
||||||
|
|
|
||||||
|
|
@ -21,13 +21,13 @@
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
#include "SIMDHelpers.h"
|
||||||
#include <benchmark/benchmark.h>
|
#include <benchmark/benchmark.h>
|
||||||
#include <random>
|
#include <random>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "SIMDHelpers.h"
|
|
||||||
|
|
||||||
class MultiplyAdd : public benchmark::Fixture {
|
class MultiplyAdd : public benchmark::Fixture {
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -21,13 +21,13 @@
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
#include "SIMDHelpers.h"
|
||||||
#include <benchmark/benchmark.h>
|
#include <benchmark/benchmark.h>
|
||||||
#include <random>
|
#include <random>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "SIMDHelpers.h"
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
#include "absl/types/span.h"
|
#include "absl/types/span.h"
|
||||||
|
|
||||||
|
|
@ -36,7 +36,7 @@ public:
|
||||||
void SetUp(const ::benchmark::State& state) {
|
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.001, 1 };
|
std::uniform_real_distribution<float> dist { 0.001f, 1.0f };
|
||||||
pan = std::vector<float>(state.range(0));
|
pan = std::vector<float>(state.range(0));
|
||||||
left = std::vector<float>(state.range(0));
|
left = std::vector<float>(state.range(0));
|
||||||
right = std::vector<float>(state.range(0));
|
right = std::vector<float>(state.range(0));
|
||||||
|
|
|
||||||
|
|
@ -21,10 +21,10 @@
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
#include "SIMDHelpers.h"
|
||||||
#include <benchmark/benchmark.h>
|
#include <benchmark/benchmark.h>
|
||||||
#include <random>
|
#include <random>
|
||||||
#include <absl/algorithm/container.h>
|
#include <absl/algorithm/container.h>
|
||||||
#include "SIMDHelpers.h"
|
|
||||||
#include "absl/types/span.h"
|
#include "absl/types/span.h"
|
||||||
|
|
||||||
constexpr int bigNumber { 2399132 };
|
constexpr int bigNumber { 2399132 };
|
||||||
|
|
@ -34,7 +34,7 @@ public:
|
||||||
void SetUp(const ::benchmark::State& state [[maybe_unused]]) {
|
void SetUp(const ::benchmark::State& state [[maybe_unused]]) {
|
||||||
std::random_device rd { };
|
std::random_device rd { };
|
||||||
std::mt19937 gen { rd() };
|
std::mt19937 gen { rd() };
|
||||||
std::uniform_real_distribution<float> dist { 0.001, 1 };
|
std::uniform_real_distribution<float> dist { 0.001f, 1.0f };
|
||||||
std::uniform_int_distribution<int> jumpDist { 0, 3 };
|
std::uniform_int_distribution<int> jumpDist { 0, 3 };
|
||||||
source = std::vector<float>(bigNumber);
|
source = std::vector<float>(bigNumber);
|
||||||
result.resize(state.range(0));
|
result.resize(state.range(0));
|
||||||
|
|
|
||||||
|
|
@ -21,9 +21,9 @@
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
#include "SIMDHelpers.h"
|
||||||
#include <benchmark/benchmark.h>
|
#include <benchmark/benchmark.h>
|
||||||
#include <random>
|
#include <random>
|
||||||
#include "SIMDHelpers.h"
|
|
||||||
#include "Buffer.h"
|
#include "Buffer.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,11 +20,11 @@
|
||||||
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
#include "SIMDHelpers.h"
|
||||||
|
#include "Buffer.h"
|
||||||
#include <benchmark/benchmark.h>
|
#include <benchmark/benchmark.h>
|
||||||
#include <sndfile.hh>
|
#include <sndfile.hh>
|
||||||
#include "ghc/filesystem.hpp"
|
#include "ghc/filesystem.hpp"
|
||||||
#include "Buffer.h"
|
|
||||||
#include "SIMDHelpers.h"
|
|
||||||
#define DR_WAV_IMPLEMENTATION
|
#define DR_WAV_IMPLEMENTATION
|
||||||
#include "dr_wav.h"
|
#include "dr_wav.h"
|
||||||
#include "AudioBuffer.h"
|
#include "AudioBuffer.h"
|
||||||
|
|
|
||||||
|
|
@ -21,9 +21,9 @@
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include <benchmark/benchmark.h>
|
|
||||||
#include "SIMDHelpers.h"
|
#include "SIMDHelpers.h"
|
||||||
#include "Buffer.h"
|
#include "Buffer.h"
|
||||||
|
#include <benchmark/benchmark.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
#include <absl/types/span.h>
|
#include <absl/types/span.h>
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ void upsample2xStage(absl::Span<const float> input, absl::Span<float> output)
|
||||||
ASSERT(output.size() >= 2 * input.size());
|
ASSERT(output.size() >= 2 * input.size());
|
||||||
hiir::Upsampler2xFpu<coeffsStage2x.size()> upsampler;
|
hiir::Upsampler2xFpu<coeffsStage2x.size()> upsampler;
|
||||||
upsampler.set_coefs(coeffsStage2x.data());
|
upsampler.set_coefs(coeffsStage2x.data());
|
||||||
upsampler.process_block(output.data(), input.data(), input.size());
|
upsampler.process_block(output.data(), input.data(), static_cast<long>(input.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -74,7 +74,7 @@ void upsample4xStage(absl::Span<const float> input, absl::Span<float> output)
|
||||||
ASSERT(output.size() >= 2 * input.size());
|
ASSERT(output.size() >= 2 * input.size());
|
||||||
hiir::Upsampler2xFpu<coeffsStage4x.size()> upsampler;
|
hiir::Upsampler2xFpu<coeffsStage4x.size()> upsampler;
|
||||||
upsampler.set_coefs(coeffsStage4x.data());
|
upsampler.set_coefs(coeffsStage4x.data());
|
||||||
upsampler.process_block(output.data(), input.data(), input.size());
|
upsampler.process_block(output.data(), input.data(), static_cast<long>(input.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<bool SIMD=false>
|
template<bool SIMD=false>
|
||||||
|
|
@ -83,7 +83,7 @@ void upsample8xStage(absl::Span<const float> input, absl::Span<float> output)
|
||||||
ASSERT(output.size() >= 2 * input.size());
|
ASSERT(output.size() >= 2 * input.size());
|
||||||
hiir::Upsampler2xFpu<coeffsStage8x.size()> upsampler;
|
hiir::Upsampler2xFpu<coeffsStage8x.size()> upsampler;
|
||||||
upsampler.set_coefs(coeffsStage8x.data());
|
upsampler.set_coefs(coeffsStage8x.data());
|
||||||
upsampler.process_block(output.data(), input.data(), input.size());
|
upsampler.process_block(output.data(), input.data(), static_cast<long>(input.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__x86_64__) || defined(__i386__)
|
#if defined(__x86_64__) || defined(__i386__)
|
||||||
|
|
@ -94,7 +94,7 @@ void upsample2xStage<true>(absl::Span<const float> input, absl::Span<float> outp
|
||||||
ASSERT(output.size() >= 2 * input.size());
|
ASSERT(output.size() >= 2 * input.size());
|
||||||
hiir::Upsampler2xSse<coeffsStage2x.size()> upsampler;
|
hiir::Upsampler2xSse<coeffsStage2x.size()> upsampler;
|
||||||
upsampler.set_coefs(coeffsStage2x.data());
|
upsampler.set_coefs(coeffsStage2x.data());
|
||||||
upsampler.process_block(output.data(), input.data(), input.size());
|
upsampler.process_block(output.data(), input.data(), static_cast<long>(input.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
|
|
@ -103,7 +103,7 @@ void upsample4xStage<true>(absl::Span<const float> input, absl::Span<float> outp
|
||||||
ASSERT(output.size() >= 2 * input.size());
|
ASSERT(output.size() >= 2 * input.size());
|
||||||
hiir::Upsampler2xSse<coeffsStage4x.size()> upsampler;
|
hiir::Upsampler2xSse<coeffsStage4x.size()> upsampler;
|
||||||
upsampler.set_coefs(coeffsStage4x.data());
|
upsampler.set_coefs(coeffsStage4x.data());
|
||||||
upsampler.process_block(output.data(), input.data(), input.size());
|
upsampler.process_block(output.data(), input.data(), static_cast<long>(input.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
|
|
@ -112,7 +112,7 @@ void upsample8xStage<true>(absl::Span<const float> input, absl::Span<float> outp
|
||||||
ASSERT(output.size() >= 2 * input.size());
|
ASSERT(output.size() >= 2 * input.size());
|
||||||
hiir::Upsampler2xSse<coeffsStage8x.size()> upsampler;
|
hiir::Upsampler2xSse<coeffsStage8x.size()> upsampler;
|
||||||
upsampler.set_coefs(coeffsStage8x.data());
|
upsampler.set_coefs(coeffsStage8x.data());
|
||||||
upsampler.process_block(output.data(), input.data(), input.size());
|
upsampler.process_block(output.data(), input.data(), static_cast<long>(input.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif defined(__arm__) || defined (__aarch64__)
|
#elif defined(__arm__) || defined (__aarch64__)
|
||||||
|
|
@ -125,7 +125,7 @@ void upsample2xStage<true>(absl::Span<const float> input, absl::Span<float> outp
|
||||||
ASSERT(output.size() >= 2 * input.size());
|
ASSERT(output.size() >= 2 * input.size());
|
||||||
hiir::Upsampler2xNeon<coeffsStage2x.size()> upsampler;
|
hiir::Upsampler2xNeon<coeffsStage2x.size()> upsampler;
|
||||||
upsampler.set_coefs(coeffsStage2x.data());
|
upsampler.set_coefs(coeffsStage2x.data());
|
||||||
upsampler.process_block(output.data(), input.data(), input.size());
|
upsampler.process_block(output.data(), input.data(), static_cast<long>(input.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
|
|
@ -134,7 +134,7 @@ void upsample4xStage<true>(absl::Span<const float> input, absl::Span<float> outp
|
||||||
ASSERT(output.size() >= 2 * input.size());
|
ASSERT(output.size() >= 2 * input.size());
|
||||||
hiir::Upsampler2xNeon<coeffsStage4x.size()> upsampler;
|
hiir::Upsampler2xNeon<coeffsStage4x.size()> upsampler;
|
||||||
upsampler.set_coefs(coeffsStage4x.data());
|
upsampler.set_coefs(coeffsStage4x.data());
|
||||||
upsampler.process_block(output.data(), input.data(), input.size());
|
upsampler.process_block(output.data(), input.data(), static_cast<long>(input.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
|
|
@ -143,7 +143,7 @@ void upsample8xStage<true>(absl::Span<const float> input, absl::Span<float> outp
|
||||||
ASSERT(output.size() >= 2 * input.size());
|
ASSERT(output.size() >= 2 * input.size());
|
||||||
hiir::Upsampler2xNeon<coeffsStage8x.size()> upsampler;
|
hiir::Upsampler2xNeon<coeffsStage8x.size()> upsampler;
|
||||||
upsampler.set_coefs(coeffsStage8x.data());
|
upsampler.set_coefs(coeffsStage8x.data());
|
||||||
upsampler.process_block(output.data(), input.data(), input.size());
|
upsampler.process_block(output.data(), input.data(), static_cast<long>(input.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
@ -170,7 +170,7 @@ std::unique_ptr<sfz::AudioBuffer<T>> upsample2x(const sfz::AudioBuffer<T>& buffe
|
||||||
{
|
{
|
||||||
// auto tempBuffer = std::make_unique<sfz::Buffer<T>>(buffer.getNumFrames() * 2);
|
// auto tempBuffer = std::make_unique<sfz::Buffer<T>>(buffer.getNumFrames() * 2);
|
||||||
auto outputBuffer = std::make_unique<sfz::AudioBuffer<T>>(buffer.getNumChannels(), buffer.getNumFrames() * 2);
|
auto outputBuffer = std::make_unique<sfz::AudioBuffer<T>>(buffer.getNumChannels(), buffer.getNumFrames() * 2);
|
||||||
for (int 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));
|
||||||
}
|
}
|
||||||
return outputBuffer;
|
return outputBuffer;
|
||||||
|
|
@ -181,7 +181,7 @@ std::unique_ptr<sfz::AudioBuffer<T>> upsample4x(const sfz::AudioBuffer<T>& buffe
|
||||||
{
|
{
|
||||||
auto tempBuffer = std::make_unique<sfz::Buffer<T>>(buffer.getNumFrames() * 2);
|
auto tempBuffer = std::make_unique<sfz::Buffer<T>>(buffer.getNumFrames() * 2);
|
||||||
auto outputBuffer = std::make_unique<sfz::AudioBuffer<T>>(buffer.getNumChannels(), buffer.getNumFrames() * 4);
|
auto outputBuffer = std::make_unique<sfz::AudioBuffer<T>>(buffer.getNumChannels(), buffer.getNumFrames() * 4);
|
||||||
for (int 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));
|
||||||
}
|
}
|
||||||
|
|
@ -194,7 +194,7 @@ std::unique_ptr<sfz::AudioBuffer<T>> upsample8x(const sfz::AudioBuffer<T>& buffe
|
||||||
auto tempBuffer2x = std::make_unique<sfz::Buffer<T>>(buffer.getNumFrames() * 2);
|
auto tempBuffer2x = std::make_unique<sfz::Buffer<T>>(buffer.getNumFrames() * 2);
|
||||||
auto tempBuffer4x = std::make_unique<sfz::Buffer<T>>(buffer.getNumFrames() * 4);
|
auto tempBuffer4x = std::make_unique<sfz::Buffer<T>>(buffer.getNumFrames() * 4);
|
||||||
auto outputBuffer = std::make_unique<sfz::AudioBuffer<T>>(buffer.getNumChannels(), buffer.getNumFrames() * 8);
|
auto outputBuffer = std::make_unique<sfz::AudioBuffer<T>>(buffer.getNumChannels(), buffer.getNumFrames() * 8);
|
||||||
for (int 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));
|
||||||
upsample8xStage<SIMD>(absl::MakeConstSpan(*tempBuffer4x), outputBuffer->getSpan(channelIdx));
|
upsample8xStage<SIMD>(absl::MakeConstSpan(*tempBuffer4x), outputBuffer->getSpan(channelIdx));
|
||||||
|
|
@ -240,8 +240,8 @@ public:
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int numChannels;
|
size_t numChannels;
|
||||||
int numFrames;
|
size_t numFrames;
|
||||||
std::unique_ptr<sfz::Buffer<float>> interleavedBuffer;
|
std::unique_ptr<sfz::Buffer<float>> interleavedBuffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -313,9 +313,9 @@ BENCHMARK_DEFINE_F(SndFile, SRC2x_BEST)(benchmark::State& state)
|
||||||
srcData.data_in = interleavedBuffer->data();
|
srcData.data_in = interleavedBuffer->data();
|
||||||
srcData.data_out = intermediateBuffer->data();
|
srcData.data_out = intermediateBuffer->data();
|
||||||
srcData.src_ratio = 2.0;
|
srcData.src_ratio = 2.0;
|
||||||
srcData.input_frames = numFrames;
|
srcData.input_frames = static_cast<long>(numFrames);
|
||||||
srcData.output_frames = 2 * numFrames;
|
srcData.output_frames = static_cast<long>(2 * numFrames);
|
||||||
src_simple(&srcData, SRC_SINC_BEST_QUALITY, 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 = std::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);
|
||||||
|
|
@ -330,9 +330,9 @@ BENCHMARK_DEFINE_F(SndFile, SRC2x_MEDIUM)(benchmark::State& state)
|
||||||
srcData.data_in = interleavedBuffer->data();
|
srcData.data_in = interleavedBuffer->data();
|
||||||
srcData.data_out = intermediateBuffer->data();
|
srcData.data_out = intermediateBuffer->data();
|
||||||
srcData.src_ratio = 2.0;
|
srcData.src_ratio = 2.0;
|
||||||
srcData.input_frames = numFrames;
|
srcData.input_frames = static_cast<long>(numFrames);
|
||||||
srcData.output_frames = 2 * numFrames;
|
srcData.output_frames = static_cast<long>(2 * numFrames);
|
||||||
src_simple(&srcData, SRC_SINC_MEDIUM_QUALITY, 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 = std::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);
|
||||||
|
|
@ -347,9 +347,9 @@ BENCHMARK_DEFINE_F(SndFile, SRC2x_FASTEST)(benchmark::State& state)
|
||||||
srcData.data_in = interleavedBuffer->data();
|
srcData.data_in = interleavedBuffer->data();
|
||||||
srcData.data_out = intermediateBuffer->data();
|
srcData.data_out = intermediateBuffer->data();
|
||||||
srcData.src_ratio = 2.0;
|
srcData.src_ratio = 2.0;
|
||||||
srcData.input_frames = numFrames;
|
srcData.input_frames = static_cast<long>(numFrames);
|
||||||
srcData.output_frames = 2 * numFrames;
|
srcData.output_frames = static_cast<long>(2 * numFrames);
|
||||||
src_simple(&srcData, SRC_SINC_FASTEST, numChannels);
|
src_simple(&srcData, SRC_SINC_FASTEST, static_cast<int>(numChannels));
|
||||||
auto outBuffer = std::make_unique<sfz::AudioBuffer<float>>(numChannels, 2 * numFrames);
|
auto outBuffer = std::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);
|
||||||
|
|
@ -365,9 +365,9 @@ BENCHMARK_DEFINE_F(SndFile, SRC4x_BEST)(benchmark::State& state)
|
||||||
srcData.data_in = interleavedBuffer->data();
|
srcData.data_in = interleavedBuffer->data();
|
||||||
srcData.data_out = intermediateBuffer->data();
|
srcData.data_out = intermediateBuffer->data();
|
||||||
srcData.src_ratio = 4.0;
|
srcData.src_ratio = 4.0;
|
||||||
srcData.input_frames = numFrames;
|
srcData.input_frames = static_cast<long>(numFrames);
|
||||||
srcData.output_frames = 2 * numFrames;
|
srcData.output_frames = static_cast<long>(2 * numFrames);
|
||||||
src_simple(&srcData, SRC_SINC_BEST_QUALITY, 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 = std::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);
|
||||||
|
|
@ -382,9 +382,9 @@ BENCHMARK_DEFINE_F(SndFile, SRC4x_MEDIUM)(benchmark::State& state)
|
||||||
srcData.data_in = interleavedBuffer->data();
|
srcData.data_in = interleavedBuffer->data();
|
||||||
srcData.data_out = intermediateBuffer->data();
|
srcData.data_out = intermediateBuffer->data();
|
||||||
srcData.src_ratio = 4.0;
|
srcData.src_ratio = 4.0;
|
||||||
srcData.input_frames = numFrames;
|
srcData.input_frames = static_cast<long>(numFrames);
|
||||||
srcData.output_frames = 2 * numFrames;
|
srcData.output_frames = static_cast<long>(2 * numFrames);
|
||||||
src_simple(&srcData, SRC_SINC_MEDIUM_QUALITY, 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 = std::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);
|
||||||
|
|
@ -399,9 +399,9 @@ BENCHMARK_DEFINE_F(SndFile, SRC4x_FASTEST)(benchmark::State& state)
|
||||||
srcData.data_in = interleavedBuffer->data();
|
srcData.data_in = interleavedBuffer->data();
|
||||||
srcData.data_out = intermediateBuffer->data();
|
srcData.data_out = intermediateBuffer->data();
|
||||||
srcData.src_ratio = 4.0;
|
srcData.src_ratio = 4.0;
|
||||||
srcData.input_frames = numFrames;
|
srcData.input_frames = static_cast<long>(numFrames);
|
||||||
srcData.output_frames = 2 * numFrames;
|
srcData.output_frames = static_cast<long>(2 * numFrames);
|
||||||
src_simple(&srcData, SRC_SINC_FASTEST, numChannels);
|
src_simple(&srcData, SRC_SINC_FASTEST, static_cast<int>(numChannels));
|
||||||
auto outBuffer = std::make_unique<sfz::AudioBuffer<float>>(numChannels, 2 * numFrames);
|
auto outBuffer = std::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);
|
||||||
|
|
@ -416,9 +416,9 @@ BENCHMARK_DEFINE_F(SndFile, SRC8x_BEST)(benchmark::State& state)
|
||||||
srcData.data_in = interleavedBuffer->data();
|
srcData.data_in = interleavedBuffer->data();
|
||||||
srcData.data_out = intermediateBuffer->data();
|
srcData.data_out = intermediateBuffer->data();
|
||||||
srcData.src_ratio = 8.0;
|
srcData.src_ratio = 8.0;
|
||||||
srcData.input_frames = numFrames;
|
srcData.input_frames = static_cast<long>(numFrames);
|
||||||
srcData.output_frames = 2 * numFrames;
|
srcData.output_frames = static_cast<long>(2 * numFrames);
|
||||||
src_simple(&srcData, SRC_SINC_BEST_QUALITY, 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 = std::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);
|
||||||
|
|
@ -433,9 +433,9 @@ BENCHMARK_DEFINE_F(SndFile, SRC8x_MEDIUM)(benchmark::State& state)
|
||||||
srcData.data_in = interleavedBuffer->data();
|
srcData.data_in = interleavedBuffer->data();
|
||||||
srcData.data_out = intermediateBuffer->data();
|
srcData.data_out = intermediateBuffer->data();
|
||||||
srcData.src_ratio = 8.0;
|
srcData.src_ratio = 8.0;
|
||||||
srcData.input_frames = numFrames;
|
srcData.input_frames = static_cast<long>(numFrames);
|
||||||
srcData.output_frames = 2 * numFrames;
|
srcData.output_frames = static_cast<long>(2 * numFrames);
|
||||||
src_simple(&srcData, SRC_SINC_MEDIUM_QUALITY, 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 = std::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);
|
||||||
|
|
@ -450,9 +450,9 @@ BENCHMARK_DEFINE_F(SndFile, SRC8x_FASTEST)(benchmark::State& state)
|
||||||
srcData.data_in = interleavedBuffer->data();
|
srcData.data_in = interleavedBuffer->data();
|
||||||
srcData.data_out = intermediateBuffer->data();
|
srcData.data_out = intermediateBuffer->data();
|
||||||
srcData.src_ratio = 8.0;
|
srcData.src_ratio = 8.0;
|
||||||
srcData.input_frames = numFrames;
|
srcData.input_frames = static_cast<long>(numFrames);
|
||||||
srcData.output_frames = 2 * numFrames;
|
srcData.output_frames = static_cast<long>(2 * numFrames);
|
||||||
src_simple(&srcData, SRC_SINC_FASTEST, numChannels);
|
src_simple(&srcData, SRC_SINC_FASTEST, static_cast<int>(numChannels));
|
||||||
auto outBuffer = std::make_unique<sfz::AudioBuffer<float>>(numChannels, 2 * numFrames);
|
auto outBuffer = std::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);
|
||||||
|
|
|
||||||
|
|
@ -20,11 +20,11 @@
|
||||||
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
#include "Buffer.h"
|
||||||
|
#include "SIMDHelpers.h"
|
||||||
#include <benchmark/benchmark.h>
|
#include <benchmark/benchmark.h>
|
||||||
#include <sndfile.hh>
|
#include <sndfile.hh>
|
||||||
#include "ghc/filesystem.hpp"
|
#include "ghc/filesystem.hpp"
|
||||||
#include "Buffer.h"
|
|
||||||
#include "SIMDHelpers.h"
|
|
||||||
#include "Oversampler.h"
|
#include "Oversampler.h"
|
||||||
#include "AudioBuffer.h"
|
#include "AudioBuffer.h"
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
@ -139,14 +139,14 @@ BENCHMARK_DEFINE_F(FileFixture, ResampleAtOnce)(benchmark::State& state) {
|
||||||
sndfile.readf(buffer.data(), numFrames);
|
sndfile.readf(buffer.data(), numFrames);
|
||||||
sfz::readInterleaved<float>(buffer, output->getSpan(0), output->getSpan(1));
|
sfz::readInterleaved<float>(buffer, output->getSpan(0), output->getSpan(1));
|
||||||
|
|
||||||
upsampler2x.process_block(temp.data(), output->channelReader(0), numFrames);
|
upsampler2x.process_block(temp.data(), output->channelReader(0), static_cast<long>(numFrames));
|
||||||
upsampler4x.process_block(output->channelWriter(0), temp.data(), numFrames * 2);
|
upsampler4x.process_block(output->channelWriter(0), temp.data(), static_cast<long>(numFrames * 2));
|
||||||
|
|
||||||
upsampler2x.clear_buffers();
|
upsampler2x.clear_buffers();
|
||||||
upsampler4x.clear_buffers();
|
upsampler4x.clear_buffers();
|
||||||
|
|
||||||
upsampler2x.process_block(temp.data(), output->channelReader(1), numFrames);
|
upsampler2x.process_block(temp.data(), output->channelReader(1), static_cast<long>(numFrames));
|
||||||
upsampler4x.process_block(output->channelWriter(1), temp.data(), numFrames * 2);
|
upsampler4x.process_block(output->channelWriter(1), temp.data(), static_cast<long>(numFrames * 2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -189,11 +189,11 @@ BENCHMARK_DEFINE_F(FileFixture, ResampleInChunks)(benchmark::State& state) {
|
||||||
|
|
||||||
sfz::readInterleaved<float>(bufferChunk, leftSpan, rightSpan);
|
sfz::readInterleaved<float>(bufferChunk, leftSpan, rightSpan);
|
||||||
|
|
||||||
upsampler2xLeft.process_block(chunkSpan.data(), leftSpan.data(), thisChunkSize);
|
upsampler2xLeft.process_block(chunkSpan.data(), leftSpan.data(), static_cast<long>(thisChunkSize));
|
||||||
upsampler4xLeft.process_block(output->channelWriter(0) + outputFrameCounter, chunkSpan.data(), thisChunkSize * 2);
|
upsampler4xLeft.process_block(output->channelWriter(0) + outputFrameCounter, chunkSpan.data(), static_cast<long>(thisChunkSize * 2));
|
||||||
|
|
||||||
upsampler2xRight.process_block(chunkSpan.data(), rightSpan.data(), thisChunkSize);
|
upsampler2xRight.process_block(chunkSpan.data(), rightSpan.data(), static_cast<long>(thisChunkSize));
|
||||||
upsampler4xRight.process_block(output->channelWriter(1) + outputFrameCounter, chunkSpan.data(), thisChunkSize * 2);
|
upsampler4xRight.process_block(output->channelWriter(1) + outputFrameCounter, chunkSpan.data(), static_cast<long>(thisChunkSize * 2));
|
||||||
|
|
||||||
inputFrameCounter += chunkSize;
|
inputFrameCounter += chunkSize;
|
||||||
outputFrameCounter += chunkSize * 4;
|
outputFrameCounter += chunkSize * 4;
|
||||||
|
|
|
||||||
|
|
@ -21,12 +21,12 @@
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
#include "SIMDHelpers.h"
|
||||||
#include <benchmark/benchmark.h>
|
#include <benchmark/benchmark.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <random>
|
#include <random>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
#include <absl/algorithm/container.h>
|
#include <absl/algorithm/container.h>
|
||||||
#include "SIMDHelpers.h"
|
|
||||||
|
|
||||||
// In this one we have an array of indices
|
// In this one we have an array of indices
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,13 +21,13 @@
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
#include "SIMDHelpers.h"
|
||||||
#include <benchmark/benchmark.h>
|
#include <benchmark/benchmark.h>
|
||||||
#include <random>
|
#include <random>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "SIMDHelpers.h"
|
|
||||||
|
|
||||||
class SubArray : public benchmark::Fixture {
|
class SubArray : public benchmark::Fixture {
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -20,23 +20,27 @@
|
||||||
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
#include "Buffer.h"
|
||||||
#include <benchmark/benchmark.h>
|
#include <benchmark/benchmark.h>
|
||||||
#include <sndfile.hh>
|
#include <sndfile.hh>
|
||||||
#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 "Buffer.h"
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#endif
|
#endif
|
||||||
|
#include "libnyquist/Decoders.h"
|
||||||
|
|
||||||
class FileFixture : public benchmark::Fixture {
|
class FileFixture : public benchmark::Fixture {
|
||||||
public:
|
public:
|
||||||
void SetUp(const ::benchmark::State& state) {
|
void SetUp(const ::benchmark::State& state) {
|
||||||
rootPath1 = getPath() / "sample1.wav";
|
filePath1 = getPath() / "sample1.wav";
|
||||||
rootPath2 = getPath() / "sample2.wav";
|
filePath2 = getPath() / "sample2.wav";
|
||||||
if (!ghc::filesystem::exists(rootPath1) || !ghc::filesystem::exists(rootPath2)) {
|
filePath3 = getPath() / "sample3.wav";
|
||||||
|
if ( !ghc::filesystem::exists(filePath1)
|
||||||
|
|| !ghc::filesystem::exists(filePath2)
|
||||||
|
|| !ghc::filesystem::exists(filePath3)) {
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
std::cerr << "Can't find path" << '\n';
|
std::cerr << "Can't find path" << '\n';
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -62,15 +66,16 @@ public:
|
||||||
|
|
||||||
std::unique_ptr<sfz::Buffer<float>> buffer;
|
std::unique_ptr<sfz::Buffer<float>> buffer;
|
||||||
|
|
||||||
ghc::filesystem::path rootPath1;
|
ghc::filesystem::path filePath1;
|
||||||
ghc::filesystem::path rootPath2;
|
ghc::filesystem::path filePath2;
|
||||||
|
ghc::filesystem::path filePath3;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
BENCHMARK_DEFINE_F(FileFixture, SndFile)(benchmark::State& state) {
|
BENCHMARK_DEFINE_F(FileFixture, SndFile)(benchmark::State& state) {
|
||||||
for (auto _ : state)
|
for (auto _ : state)
|
||||||
{
|
{
|
||||||
SndfileHandle sndfile(rootPath1.c_str());
|
SndfileHandle sndfile(filePath1.c_str());
|
||||||
buffer = std::make_unique<sfz::Buffer<float>>(sndfile.channels() * sndfile.frames());
|
buffer = std::make_unique<sfz::Buffer<float>>(sndfile.channels() * sndfile.frames());
|
||||||
sndfile.readf(buffer->data(), sndfile.frames());
|
sndfile.readf(buffer->data(), sndfile.frames());
|
||||||
}
|
}
|
||||||
|
|
@ -80,7 +85,7 @@ BENCHMARK_DEFINE_F(FileFixture, DrWav)(benchmark::State& state) {
|
||||||
for (auto _ : state)
|
for (auto _ : state)
|
||||||
{
|
{
|
||||||
drwav wav;
|
drwav wav;
|
||||||
if (!drwav_init_file(&wav, rootPath2.c_str(), nullptr)) {
|
if (!drwav_init_file(&wav, filePath2.c_str(), nullptr)) {
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
std::cerr << "Can't find path" << '\n';
|
std::cerr << "Can't find path" << '\n';
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -91,6 +96,17 @@ BENCHMARK_DEFINE_F(FileFixture, DrWav)(benchmark::State& state) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BENCHMARK_DEFINE_F(FileFixture, LibNyquist)(benchmark::State& state) {
|
||||||
|
for (auto _ : state)
|
||||||
|
{
|
||||||
|
nqr::AudioData data;
|
||||||
|
nqr::NyquistIO loader;
|
||||||
|
loader.Load(&data, filePath3.string());
|
||||||
|
benchmark::DoNotOptimize(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
BENCHMARK_REGISTER_F(FileFixture, SndFile);
|
BENCHMARK_REGISTER_F(FileFixture, SndFile);
|
||||||
BENCHMARK_REGISTER_F(FileFixture, DrWav);
|
BENCHMARK_REGISTER_F(FileFixture, DrWav);
|
||||||
|
BENCHMARK_REGISTER_F(FileFixture, LibNyquist);
|
||||||
BENCHMARK_MAIN();
|
BENCHMARK_MAIN();
|
||||||
|
|
|
||||||
|
|
@ -21,9 +21,9 @@
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include <benchmark/benchmark.h>
|
|
||||||
#include "SIMDHelpers.h"
|
#include "SIMDHelpers.h"
|
||||||
#include "Buffer.h"
|
#include "Buffer.h"
|
||||||
|
#include <benchmark/benchmark.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
#include <absl/types/span.h>
|
#include <absl/types/span.h>
|
||||||
|
|
|
||||||
|
|
@ -22,115 +22,133 @@ set(BENCHMARK_SIMD_SOURCES ${SFIZZ_SIMD_SOURCES})
|
||||||
list(TRANSFORM BENCHMARK_SIMD_SOURCES PREPEND "../src/")
|
list(TRANSFORM BENCHMARK_SIMD_SOURCES PREPEND "../src/")
|
||||||
|
|
||||||
add_executable(bm_opf_high_vs_low BM_OPF_high_vs_low.cpp)
|
add_executable(bm_opf_high_vs_low BM_OPF_high_vs_low.cpp)
|
||||||
target_link_libraries(bm_opf_high_vs_low benchmark absl::span)
|
target_link_libraries(bm_opf_high_vs_low PRIVATE benchmark absl::span)
|
||||||
target_include_directories(bm_opf_high_vs_low PRIVATE ../src/sfizz ../src/external)
|
target_include_directories(bm_opf_high_vs_low PRIVATE ../src/sfizz ../src/external)
|
||||||
|
|
||||||
add_executable(bm_write BM_writeInterleaved.cpp ${BENCHMARK_SIMD_SOURCES})
|
add_executable(bm_write BM_writeInterleaved.cpp ${BENCHMARK_SIMD_SOURCES})
|
||||||
target_link_libraries(bm_write benchmark absl::span)
|
target_link_libraries(bm_write PRIVATE benchmark absl::span)
|
||||||
target_include_directories(bm_write PRIVATE ../src/sfizz ../src/external)
|
target_include_directories(bm_write PRIVATE ../src/sfizz ../src/external)
|
||||||
|
|
||||||
add_executable(bm_read BM_readInterleaved.cpp ${BENCHMARK_SIMD_SOURCES})
|
add_executable(bm_read BM_readInterleaved.cpp ${BENCHMARK_SIMD_SOURCES})
|
||||||
target_link_libraries(bm_read benchmark absl::span)
|
target_link_libraries(bm_read PRIVATE benchmark absl::span)
|
||||||
target_include_directories(bm_read PRIVATE ../src/sfizz ../src/external)
|
target_include_directories(bm_read PRIVATE ../src/sfizz ../src/external)
|
||||||
|
|
||||||
add_executable(bm_fill BM_fill.cpp ${BENCHMARK_SIMD_SOURCES})
|
add_executable(bm_fill BM_fill.cpp ${BENCHMARK_SIMD_SOURCES})
|
||||||
target_link_libraries(bm_fill benchmark absl::span)
|
target_link_libraries(bm_fill PRIVATE benchmark absl::span)
|
||||||
target_include_directories(bm_fill PRIVATE ../src/sfizz ../src/external)
|
target_include_directories(bm_fill PRIVATE ../src/sfizz ../src/external)
|
||||||
|
|
||||||
add_executable(bm_mathfuns BM_mathfuns.cpp ${BENCHMARK_SIMD_SOURCES})
|
add_executable(bm_mathfuns BM_mathfuns.cpp ${BENCHMARK_SIMD_SOURCES})
|
||||||
target_link_libraries(bm_mathfuns benchmark absl::span)
|
target_link_libraries(bm_mathfuns PRIVATE benchmark absl::span)
|
||||||
target_include_directories(bm_mathfuns PRIVATE ../src/sfizz ../src/external)
|
target_include_directories(bm_mathfuns PRIVATE ../src/sfizz ../src/external)
|
||||||
|
|
||||||
add_executable(bm_gain BM_gain.cpp ${BENCHMARK_SIMD_SOURCES})
|
add_executable(bm_gain BM_gain.cpp ${BENCHMARK_SIMD_SOURCES})
|
||||||
target_link_libraries(bm_gain benchmark absl::span)
|
target_link_libraries(bm_gain PRIVATE benchmark absl::span)
|
||||||
target_include_directories(bm_gain PRIVATE ../src/sfizz ../src/external)
|
target_include_directories(bm_gain PRIVATE ../src/sfizz ../src/external)
|
||||||
|
|
||||||
add_executable(bm_divide BM_divide.cpp ${BENCHMARK_SIMD_SOURCES})
|
add_executable(bm_divide BM_divide.cpp ${BENCHMARK_SIMD_SOURCES})
|
||||||
target_link_libraries(bm_divide benchmark absl::span)
|
target_link_libraries(bm_divide PRIVATE benchmark absl::span)
|
||||||
target_include_directories(bm_divide PRIVATE ../src/sfizz ../src/external)
|
target_include_directories(bm_divide PRIVATE ../src/sfizz ../src/external)
|
||||||
|
|
||||||
add_executable(bm_looping BM_looping.cpp ${BENCHMARK_SIMD_SOURCES})
|
add_executable(bm_looping BM_looping.cpp ${BENCHMARK_SIMD_SOURCES})
|
||||||
target_link_libraries(bm_looping benchmark absl::span absl::algorithm)
|
target_link_libraries(bm_looping PRIVATE benchmark absl::span absl::algorithm)
|
||||||
target_include_directories(bm_looping PRIVATE ../src/sfizz ../src/external)
|
target_include_directories(bm_looping PRIVATE ../src/sfizz ../src/external)
|
||||||
|
|
||||||
add_executable(bm_saturating BM_saturating.cpp ${BENCHMARK_SIMD_SOURCES})
|
add_executable(bm_saturating BM_saturating.cpp ${BENCHMARK_SIMD_SOURCES})
|
||||||
target_link_libraries(bm_saturating benchmark absl::span absl::algorithm)
|
target_link_libraries(bm_saturating PRIVATE benchmark absl::span absl::algorithm)
|
||||||
target_include_directories(bm_saturating PRIVATE ../src/sfizz ../src/external)
|
target_include_directories(bm_saturating PRIVATE ../src/sfizz ../src/external)
|
||||||
|
|
||||||
add_executable(bm_ramp BM_ramp.cpp ${BENCHMARK_SIMD_SOURCES})
|
add_executable(bm_ramp BM_ramp.cpp ${BENCHMARK_SIMD_SOURCES})
|
||||||
target_link_libraries(bm_ramp benchmark absl::span absl::algorithm)
|
target_link_libraries(bm_ramp PRIVATE benchmark absl::span absl::algorithm)
|
||||||
target_include_directories(bm_ramp PRIVATE ../src/sfizz ../src/external)
|
target_include_directories(bm_ramp PRIVATE ../src/sfizz ../src/external)
|
||||||
|
|
||||||
add_executable(bm_ADSR BM_ADSR.cpp ${BENCHMARK_SIMD_SOURCES})
|
add_executable(bm_ADSR BM_ADSR.cpp ${BENCHMARK_SIMD_SOURCES})
|
||||||
target_link_libraries(bm_ADSR benchmark absl::span absl::algorithm)
|
target_link_libraries(bm_ADSR PRIVATE benchmark absl::span absl::algorithm)
|
||||||
target_include_directories(bm_ADSR PRIVATE ../src/sfizz ../src/external)
|
target_include_directories(bm_ADSR PRIVATE ../src/sfizz ../src/external)
|
||||||
|
|
||||||
add_executable(bm_add BM_add.cpp ${BENCHMARK_SIMD_SOURCES})
|
add_executable(bm_add BM_add.cpp ${BENCHMARK_SIMD_SOURCES})
|
||||||
target_link_libraries(bm_add benchmark absl::span absl::algorithm)
|
target_link_libraries(bm_add PRIVATE benchmark absl::span absl::algorithm)
|
||||||
target_include_directories(bm_add PRIVATE ../src/sfizz ../src/external)
|
target_include_directories(bm_add PRIVATE ../src/sfizz ../src/external)
|
||||||
|
|
||||||
add_executable(bm_multiplyAdd BM_multiplyAdd.cpp ${BENCHMARK_SIMD_SOURCES})
|
add_executable(bm_multiplyAdd BM_multiplyAdd.cpp ${BENCHMARK_SIMD_SOURCES})
|
||||||
target_link_libraries(bm_multiplyAdd benchmark absl::span absl::algorithm)
|
target_link_libraries(bm_multiplyAdd PRIVATE benchmark absl::span absl::algorithm)
|
||||||
target_include_directories(bm_multiplyAdd PRIVATE ../src/sfizz ../src/external)
|
target_include_directories(bm_multiplyAdd PRIVATE ../src/sfizz ../src/external)
|
||||||
|
|
||||||
add_executable(bm_subtract BM_subtract.cpp ${BENCHMARK_SIMD_SOURCES})
|
add_executable(bm_subtract BM_subtract.cpp ${BENCHMARK_SIMD_SOURCES})
|
||||||
target_link_libraries(bm_subtract benchmark absl::span absl::algorithm)
|
target_link_libraries(bm_subtract PRIVATE benchmark absl::span absl::algorithm)
|
||||||
target_include_directories(bm_subtract PRIVATE ../src/sfizz ../src/external)
|
target_include_directories(bm_subtract PRIVATE ../src/sfizz ../src/external)
|
||||||
|
|
||||||
add_executable(bm_copy BM_copy.cpp ${BENCHMARK_SIMD_SOURCES})
|
add_executable(bm_copy BM_copy.cpp ${BENCHMARK_SIMD_SOURCES})
|
||||||
target_link_libraries(bm_copy benchmark absl::span absl::algorithm)
|
target_link_libraries(bm_copy PRIVATE benchmark absl::span absl::algorithm)
|
||||||
target_include_directories(bm_copy PRIVATE ../src/sfizz ../src/external)
|
target_include_directories(bm_copy PRIVATE ../src/sfizz ../src/external)
|
||||||
|
|
||||||
add_executable(bm_pan BM_pan.cpp ${BENCHMARK_SIMD_SOURCES})
|
add_executable(bm_pan BM_pan.cpp ${BENCHMARK_SIMD_SOURCES})
|
||||||
target_link_libraries(bm_pan benchmark absl::span absl::algorithm)
|
target_link_libraries(bm_pan PRIVATE benchmark absl::span absl::algorithm)
|
||||||
target_include_directories(bm_pan PRIVATE ../src/sfizz ../src/external)
|
target_include_directories(bm_pan PRIVATE ../src/sfizz ../src/external)
|
||||||
|
|
||||||
add_executable(bm_mean BM_mean.cpp ${BENCHMARK_SIMD_SOURCES})
|
add_executable(bm_mean BM_mean.cpp ${BENCHMARK_SIMD_SOURCES})
|
||||||
target_link_libraries(bm_mean benchmark absl::span absl::algorithm)
|
target_link_libraries(bm_mean PRIVATE benchmark absl::span absl::algorithm)
|
||||||
target_include_directories(bm_mean PRIVATE ../src/sfizz ../src/external)
|
target_include_directories(bm_mean PRIVATE ../src/sfizz ../src/external)
|
||||||
|
|
||||||
add_executable(bm_meanSquared BM_meanSquared.cpp ${BENCHMARK_SIMD_SOURCES})
|
add_executable(bm_meanSquared BM_meanSquared.cpp ${BENCHMARK_SIMD_SOURCES})
|
||||||
target_link_libraries(bm_meanSquared benchmark absl::span absl::algorithm)
|
target_link_libraries(bm_meanSquared PRIVATE benchmark absl::span absl::algorithm)
|
||||||
target_include_directories(bm_meanSquared PRIVATE ../src/sfizz ../src/external)
|
target_include_directories(bm_meanSquared PRIVATE ../src/sfizz ../src/external)
|
||||||
|
|
||||||
add_executable(bm_cumsum BM_cumsum.cpp ${BENCHMARK_SIMD_SOURCES})
|
add_executable(bm_cumsum BM_cumsum.cpp ${BENCHMARK_SIMD_SOURCES})
|
||||||
target_link_libraries(bm_cumsum benchmark absl::span absl::algorithm)
|
target_link_libraries(bm_cumsum PRIVATE benchmark absl::span absl::algorithm)
|
||||||
target_include_directories(bm_cumsum PRIVATE ../src/sfizz ../src/external)
|
target_include_directories(bm_cumsum PRIVATE ../src/sfizz ../src/external)
|
||||||
|
|
||||||
add_executable(bm_diff BM_diff.cpp ${BENCHMARK_SIMD_SOURCES})
|
add_executable(bm_diff BM_diff.cpp ${BENCHMARK_SIMD_SOURCES})
|
||||||
target_link_libraries(bm_diff benchmark absl::span absl::algorithm)
|
target_link_libraries(bm_diff PRIVATE benchmark absl::span absl::algorithm)
|
||||||
target_include_directories(bm_diff PRIVATE ../src/sfizz ../src/external)
|
target_include_directories(bm_diff PRIVATE ../src/sfizz ../src/external)
|
||||||
|
|
||||||
add_executable(bm_interpolationCast BM_interpolationCast.cpp ${BENCHMARK_SIMD_SOURCES})
|
add_executable(bm_interpolationCast BM_interpolationCast.cpp ${BENCHMARK_SIMD_SOURCES})
|
||||||
target_link_libraries(bm_interpolationCast benchmark absl::span absl::algorithm)
|
target_link_libraries(bm_interpolationCast PRIVATE benchmark absl::span absl::algorithm)
|
||||||
target_include_directories(bm_interpolationCast PRIVATE ../src/sfizz ../src/external)
|
target_include_directories(bm_interpolationCast PRIVATE ../src/sfizz ../src/external)
|
||||||
|
|
||||||
add_executable(bm_pointerIterationOrOffsets BM_pointerIterationOrOffsets.cpp ${BENCHMARK_SIMD_SOURCES})
|
add_executable(bm_pointerIterationOrOffsets BM_pointerIterationOrOffsets.cpp ${BENCHMARK_SIMD_SOURCES})
|
||||||
target_link_libraries(bm_pointerIterationOrOffsets benchmark absl::span absl::algorithm)
|
target_link_libraries(bm_pointerIterationOrOffsets PRIVATE benchmark absl::span absl::algorithm)
|
||||||
target_include_directories(bm_pointerIterationOrOffsets PRIVATE ../src/sfizz ../src/external)
|
target_include_directories(bm_pointerIterationOrOffsets PRIVATE ../src/sfizz ../src/external)
|
||||||
|
|
||||||
add_executable(bm_resample BM_resample.cpp ${BENCHMARK_SIMD_SOURCES})
|
add_executable(bm_resample BM_resample.cpp ${BENCHMARK_SIMD_SOURCES})
|
||||||
target_link_libraries(bm_resample benchmark absl::span absl::algorithm sndfile samplerate)
|
target_link_libraries(bm_resample PRIVATE benchmark absl::span absl::algorithm)
|
||||||
|
sfizz_link_libsndfile(bm_resample)
|
||||||
|
sfizz_link_libsamplerate(bm_resample)
|
||||||
target_include_directories(bm_resample PRIVATE ../src/sfizz ../src/external)
|
target_include_directories(bm_resample PRIVATE ../src/sfizz ../src/external)
|
||||||
|
|
||||||
add_executable(bm_envelopes BM_envelopes.cpp ${BENCHMARK_SIMD_SOURCES})
|
add_executable(bm_envelopes BM_envelopes.cpp ${BENCHMARK_SIMD_SOURCES})
|
||||||
target_link_libraries(bm_envelopes benchmark absl::span absl::algorithm sndfile samplerate)
|
target_link_libraries(bm_envelopes PRIVATE benchmark absl::span absl::algorithm)
|
||||||
target_include_directories(bm_envelopes PRIVATE ../src/sfizz ../src/external)
|
target_include_directories(bm_envelopes PRIVATE ../src/sfizz ../src/external)
|
||||||
|
|
||||||
|
include(FetchContent)
|
||||||
|
FetchContent_Declare(
|
||||||
|
libnyquist
|
||||||
|
GIT_REPOSITORY https://github.com/paulfd/libnyquist
|
||||||
|
)
|
||||||
|
|
||||||
|
FetchContent_GetProperties(libnyquist)
|
||||||
|
if(NOT libnyquist_POPULATED)
|
||||||
|
FetchContent_Populate(libnyquist)
|
||||||
|
add_subdirectory(${libnyquist_SOURCE_DIR} ${libnyquist_BINARY_DIR} EXCLUDE_FROM_ALL)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_executable(bm_wavfile BM_wavfile.cpp ${BENCHMARK_SIMD_SOURCES})
|
add_executable(bm_wavfile BM_wavfile.cpp ${BENCHMARK_SIMD_SOURCES})
|
||||||
target_link_libraries(bm_wavfile benchmark absl::span absl::algorithm sndfile)
|
target_link_libraries(bm_wavfile PRIVATE benchmark absl::span absl::algorithm libnyquist)
|
||||||
|
sfizz_link_libsndfile(bm_wavfile)
|
||||||
target_include_directories(bm_wavfile PRIVATE ../src/sfizz ../src/external)
|
target_include_directories(bm_wavfile PRIVATE ../src/sfizz ../src/external)
|
||||||
|
|
||||||
add_executable(bm_flacfile BM_flacfile.cpp ${BENCHMARK_SIMD_SOURCES})
|
add_executable(bm_flacfile BM_flacfile.cpp ${BENCHMARK_SIMD_SOURCES})
|
||||||
target_link_libraries(bm_flacfile benchmark absl::span absl::algorithm sndfile)
|
target_link_libraries(bm_flacfile PRIVATE benchmark absl::span absl::algorithm libnyquist)
|
||||||
|
sfizz_link_libsndfile(bm_flacfile)
|
||||||
target_include_directories(bm_flacfile PRIVATE ../src/sfizz ../src/external)
|
target_include_directories(bm_flacfile PRIVATE ../src/sfizz ../src/external)
|
||||||
|
|
||||||
add_executable(bm_readChunk BM_readChunk.cpp ${BENCHMARK_SIMD_SOURCES})
|
add_executable(bm_readChunk BM_readChunk.cpp ${BENCHMARK_SIMD_SOURCES})
|
||||||
target_link_libraries(bm_readChunk benchmark absl::span absl::algorithm sndfile)
|
target_link_libraries(bm_readChunk PRIVATE benchmark absl::span absl::algorithm)
|
||||||
|
sfizz_link_libsndfile(bm_readChunk)
|
||||||
target_include_directories(bm_readChunk PRIVATE ../src/sfizz ../src/external)
|
target_include_directories(bm_readChunk PRIVATE ../src/sfizz ../src/external)
|
||||||
|
|
||||||
add_executable(bm_resampleChunk BM_resampleChunk.cpp ${BENCHMARK_SIMD_SOURCES})
|
add_executable(bm_resampleChunk BM_resampleChunk.cpp ${BENCHMARK_SIMD_SOURCES})
|
||||||
target_link_libraries(bm_resampleChunk benchmark absl::span absl::algorithm sndfile)
|
target_link_libraries(bm_resampleChunk PRIVATE benchmark absl::span absl::algorithm)
|
||||||
|
sfizz_link_libsndfile(bm_resampleChunk)
|
||||||
target_include_directories(bm_resampleChunk PRIVATE ../src/sfizz ../src/external)
|
target_include_directories(bm_resampleChunk PRIVATE ../src/sfizz ../src/external)
|
||||||
|
|
||||||
add_custom_target(sfizz_benchmarks)
|
add_custom_target(sfizz_benchmarks)
|
||||||
|
|
@ -166,5 +184,7 @@ add_dependencies(sfizz_benchmarks
|
||||||
|
|
||||||
file(COPY "sample1.wav" DESTINATION ${CMAKE_BINARY_DIR}/benchmarks)
|
file(COPY "sample1.wav" DESTINATION ${CMAKE_BINARY_DIR}/benchmarks)
|
||||||
file(COPY "sample2.wav" DESTINATION ${CMAKE_BINARY_DIR}/benchmarks)
|
file(COPY "sample2.wav" DESTINATION ${CMAKE_BINARY_DIR}/benchmarks)
|
||||||
|
file(COPY "sample3.wav" DESTINATION ${CMAKE_BINARY_DIR}/benchmarks)
|
||||||
file(COPY "sample1.flac" DESTINATION ${CMAKE_BINARY_DIR}/benchmarks)
|
file(COPY "sample1.flac" DESTINATION ${CMAKE_BINARY_DIR}/benchmarks)
|
||||||
file(COPY "sample2.flac" DESTINATION ${CMAKE_BINARY_DIR}/benchmarks)
|
file(COPY "sample2.flac" DESTINATION ${CMAKE_BINARY_DIR}/benchmarks)
|
||||||
|
file(COPY "sample3.flac" DESTINATION ${CMAKE_BINARY_DIR}/benchmarks)
|
||||||
|
|
|
||||||
BIN
benchmarks/sample3.flac
Executable file
BIN
benchmarks/sample3.flac
Executable file
Binary file not shown.
BIN
benchmarks/sample3.wav
Executable file
BIN
benchmarks/sample3.wav
Executable file
Binary file not shown.
|
|
@ -16,8 +16,34 @@ if (UNIX)
|
||||||
add_compile_options(-ffast-math)
|
add_compile_options(-ffast-math)
|
||||||
add_compile_options(-fno-omit-frame-pointer) # For debugging purposes
|
add_compile_options(-fno-omit-frame-pointer) # For debugging purposes
|
||||||
add_compile_options(-fPIC)
|
add_compile_options(-fPIC)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (WIN32)
|
||||||
|
find_package(LibSndFile REQUIRED)
|
||||||
|
find_path(SNDFILE_INCLUDE_DIR sndfile.hh)
|
||||||
|
find_path(SAMPLERATE_INCLUDE_DIR samplerate.h)
|
||||||
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
add_compile_options(/Zc:__cplusplus)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
function(SFIZZ_LINK_LIBSNDFILE TARGET)
|
||||||
|
if (WIN32)
|
||||||
|
target_link_libraries (${TARGET} PRIVATE sndfile-shared)
|
||||||
|
target_include_directories(${TARGET} PRIVATE ${SNDFILE_INCLUDE_DIR})
|
||||||
|
else()
|
||||||
|
target_link_libraries(${TARGET} PRIVATE sndfile)
|
||||||
|
endif()
|
||||||
|
endfunction(SFIZZ_LINK_LIBSNDFILE)
|
||||||
|
|
||||||
|
function(SFIZZ_LINK_LIBSAMPLERATE TARGET)
|
||||||
|
if (WIN32)
|
||||||
|
target_link_libraries (${TARGET} PRIVATE samplerate)
|
||||||
|
target_include_directories(${TARGET} PRIVATE ${SAMPLERATE_INCLUDE_DIR})
|
||||||
|
else()
|
||||||
|
target_link_libraries(${TARGET} PRIVATE samplerate)
|
||||||
|
endif()
|
||||||
|
endfunction(SFIZZ_LINK_LIBSAMPLERATE)
|
||||||
|
|
||||||
# If we build with Clang use libc++
|
# If we build with Clang use libc++
|
||||||
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT ANDROID)
|
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT ANDROID)
|
||||||
set(USE_LIBCPP ON CACHE BOOL "Use libc++ with clang")
|
set(USE_LIBCPP ON CACHE BOOL "Use libc++ with clang")
|
||||||
|
|
|
||||||
|
|
@ -45,8 +45,6 @@
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/time.h>
|
|
||||||
|
|
||||||
#define DEFAULT_SFZ_FILE "/home/paul/Documents/AVL_Percussions/AVL_Drumkits_Percussion-1.0-Alt.sfz"
|
#define DEFAULT_SFZ_FILE "/home/paul/Documents/AVL_Percussions/AVL_Drumkits_Percussion-1.0-Alt.sfz"
|
||||||
#define SFIZZ_URI "http://sfztools.github.io/sfizz"
|
#define SFIZZ_URI "http://sfztools.github.io/sfizz"
|
||||||
|
|
@ -414,7 +412,7 @@ sfizz_lv2_send_file_path(sfizz_plugin_t *self)
|
||||||
lv2_atom_forge_key(&self->forge, self->patch_property_uri);
|
lv2_atom_forge_key(&self->forge, self->patch_property_uri);
|
||||||
lv2_atom_forge_urid(&self->forge, self->sfizz_sfz_file_uri);
|
lv2_atom_forge_urid(&self->forge, self->sfizz_sfz_file_uri);
|
||||||
lv2_atom_forge_key(&self->forge, self->patch_value_uri);
|
lv2_atom_forge_key(&self->forge, self->patch_value_uri);
|
||||||
lv2_atom_forge_path(&self->forge, self->sfz_file_path, strlen(self->sfz_file_path));
|
lv2_atom_forge_path(&self->forge, self->sfz_file_path, (uint32_t)strlen(self->sfz_file_path));
|
||||||
lv2_atom_forge_pop(&self->forge, &frame);
|
lv2_atom_forge_pop(&self->forge, &frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -463,7 +461,7 @@ sfizz_lv2_handle_atom_object(sfizz_plugin_t *self, const LV2_Atom_Object *obj)
|
||||||
|
|
||||||
const uint32_t original_atom_size = lv2_atom_total_size((const LV2_Atom *)atom);
|
const uint32_t original_atom_size = lv2_atom_total_size((const LV2_Atom *)atom);
|
||||||
const uint32_t null_terminated_atom_size = original_atom_size + 1;
|
const uint32_t null_terminated_atom_size = original_atom_size + 1;
|
||||||
char atom_buffer[null_terminated_atom_size];
|
char atom_buffer[MAX_PATH_SIZE];
|
||||||
memcpy(&atom_buffer, atom, original_atom_size);
|
memcpy(&atom_buffer, atom, original_atom_size);
|
||||||
atom_buffer[original_atom_size] = 0; // Null terminate the string for safety
|
atom_buffer[original_atom_size] = 0; // Null terminate the string for safety
|
||||||
LV2_Atom *sfz_file_path = (LV2_Atom *)&atom_buffer;
|
LV2_Atom *sfz_file_path = (LV2_Atom *)&atom_buffer;
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,8 @@ target_include_directories (sfizz PUBLIC external)
|
||||||
target_link_libraries (sfizz PRIVATE sfizz_parser)
|
target_link_libraries (sfizz PRIVATE sfizz_parser)
|
||||||
find_package (Threads REQUIRED)
|
find_package (Threads REQUIRED)
|
||||||
target_link_libraries (sfizz PUBLIC absl::strings)
|
target_link_libraries (sfizz PUBLIC absl::strings)
|
||||||
target_link_libraries (sfizz PRIVATE sndfile absl::flat_hash_map Threads::Threads)
|
target_link_libraries (sfizz PRIVATE absl::flat_hash_map Threads::Threads)
|
||||||
|
sfizz_link_libsndfile(sfizz)
|
||||||
|
|
||||||
if (UNIX AND NOT APPLE)
|
if (UNIX AND NOT APPLE)
|
||||||
target_link_libraries (sfizz PUBLIC atomic)
|
target_link_libraries (sfizz PUBLIC atomic)
|
||||||
|
|
|
||||||
7
src/external/atomic_queue/defs.h
vendored
7
src/external/atomic_queue/defs.h
vendored
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
|
|
||||||
#if defined(__x86_64__)
|
#if defined(__x86_64__) || defined(_M_X64)
|
||||||
#include <emmintrin.h>
|
#include <emmintrin.h>
|
||||||
namespace atomic_queue {
|
namespace atomic_queue {
|
||||||
constexpr int CACHE_LINE_SIZE = 64;
|
constexpr int CACHE_LINE_SIZE = 64;
|
||||||
|
|
@ -30,8 +30,13 @@ static inline void spin_loop_pause() noexcept {
|
||||||
|
|
||||||
namespace atomic_queue {
|
namespace atomic_queue {
|
||||||
|
|
||||||
|
#if defined(__GNUC__)
|
||||||
#define ATOMIC_QUEUE_LIKELY(expr) __builtin_expect(static_cast<bool>(expr), 1)
|
#define ATOMIC_QUEUE_LIKELY(expr) __builtin_expect(static_cast<bool>(expr), 1)
|
||||||
#define ATOMIC_QUEUE_UNLIKELY(expr) __builtin_expect(static_cast<bool>(expr), 0)
|
#define ATOMIC_QUEUE_UNLIKELY(expr) __builtin_expect(static_cast<bool>(expr), 0)
|
||||||
|
#else
|
||||||
|
#define ATOMIC_QUEUE_LIKELY(expr) expr
|
||||||
|
#define ATOMIC_QUEUE_UNLIKELY(expr) expr
|
||||||
|
#endif
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
|
||||||
62
src/external/mathfuns/sse_mathfun.h
vendored
62
src/external/mathfuns/sse_mathfun.h
vendored
|
|
@ -77,18 +77,18 @@ _PI32_CONST(2, 2);
|
||||||
_PI32_CONST(4, 4);
|
_PI32_CONST(4, 4);
|
||||||
_PI32_CONST(0x7f, 0x7f);
|
_PI32_CONST(0x7f, 0x7f);
|
||||||
|
|
||||||
_PS_CONST(cephes_SQRTHF, 0.707106781186547524);
|
_PS_CONST(cephes_SQRTHF, 0.707106781186547524f);
|
||||||
_PS_CONST(cephes_log_p0, 7.0376836292E-2);
|
_PS_CONST(cephes_log_p0, 7.0376836292E-2f);
|
||||||
_PS_CONST(cephes_log_p1, - 1.1514610310E-1);
|
_PS_CONST(cephes_log_p1, - 1.1514610310E-1f);
|
||||||
_PS_CONST(cephes_log_p2, 1.1676998740E-1);
|
_PS_CONST(cephes_log_p2, 1.1676998740E-1f);
|
||||||
_PS_CONST(cephes_log_p3, - 1.2420140846E-1);
|
_PS_CONST(cephes_log_p3, - 1.2420140846E-1f);
|
||||||
_PS_CONST(cephes_log_p4, + 1.4249322787E-1);
|
_PS_CONST(cephes_log_p4, + 1.4249322787E-1f);
|
||||||
_PS_CONST(cephes_log_p5, - 1.6668057665E-1);
|
_PS_CONST(cephes_log_p5, - 1.6668057665E-1f);
|
||||||
_PS_CONST(cephes_log_p6, + 2.0000714765E-1);
|
_PS_CONST(cephes_log_p6, + 2.0000714765E-1f);
|
||||||
_PS_CONST(cephes_log_p7, - 2.4999993993E-1);
|
_PS_CONST(cephes_log_p7, - 2.4999993993E-1f);
|
||||||
_PS_CONST(cephes_log_p8, + 3.3333331174E-1);
|
_PS_CONST(cephes_log_p8, + 3.3333331174E-1f);
|
||||||
_PS_CONST(cephes_log_q1, -2.12194440e-4);
|
_PS_CONST(cephes_log_q1, -2.12194440e-4f);
|
||||||
_PS_CONST(cephes_log_q2, 0.693359375);
|
_PS_CONST(cephes_log_q2, 0.693359375f);
|
||||||
|
|
||||||
#ifndef USE_SSE2
|
#ifndef USE_SSE2
|
||||||
typedef union xmm_mm_union {
|
typedef union xmm_mm_union {
|
||||||
|
|
@ -202,16 +202,16 @@ v4sf log_ps(v4sf x) {
|
||||||
_PS_CONST(exp_hi, 88.3762626647949f);
|
_PS_CONST(exp_hi, 88.3762626647949f);
|
||||||
_PS_CONST(exp_lo, -88.3762626647949f);
|
_PS_CONST(exp_lo, -88.3762626647949f);
|
||||||
|
|
||||||
_PS_CONST(cephes_LOG2EF, 1.44269504088896341);
|
_PS_CONST(cephes_LOG2EF, 1.44269504088896341f);
|
||||||
_PS_CONST(cephes_exp_C1, 0.693359375);
|
_PS_CONST(cephes_exp_C1, 0.693359375f);
|
||||||
_PS_CONST(cephes_exp_C2, -2.12194440e-4);
|
_PS_CONST(cephes_exp_C2, -2.12194440e-4f);
|
||||||
|
|
||||||
_PS_CONST(cephes_exp_p0, 1.9875691500E-4);
|
_PS_CONST(cephes_exp_p0, 1.9875691500E-4f);
|
||||||
_PS_CONST(cephes_exp_p1, 1.3981999507E-3);
|
_PS_CONST(cephes_exp_p1, 1.3981999507E-3f);
|
||||||
_PS_CONST(cephes_exp_p2, 8.3334519073E-3);
|
_PS_CONST(cephes_exp_p2, 8.3334519073E-3f);
|
||||||
_PS_CONST(cephes_exp_p3, 4.1665795894E-2);
|
_PS_CONST(cephes_exp_p3, 4.1665795894E-2f);
|
||||||
_PS_CONST(cephes_exp_p4, 1.6666665459E-1);
|
_PS_CONST(cephes_exp_p4, 1.6666665459E-1f);
|
||||||
_PS_CONST(cephes_exp_p5, 5.0000001201E-1);
|
_PS_CONST(cephes_exp_p5, 5.0000001201E-1f);
|
||||||
|
|
||||||
v4sf exp_ps(v4sf x) {
|
v4sf exp_ps(v4sf x) {
|
||||||
v4sf tmp = _mm_setzero_ps(), fx;
|
v4sf tmp = _mm_setzero_ps(), fx;
|
||||||
|
|
@ -291,16 +291,16 @@ v4sf exp_ps(v4sf x) {
|
||||||
return y;
|
return y;
|
||||||
}
|
}
|
||||||
|
|
||||||
_PS_CONST(minus_cephes_DP1, -0.78515625);
|
_PS_CONST(minus_cephes_DP1, -0.78515625f);
|
||||||
_PS_CONST(minus_cephes_DP2, -2.4187564849853515625e-4);
|
_PS_CONST(minus_cephes_DP2, -2.4187564849853515625e-4f);
|
||||||
_PS_CONST(minus_cephes_DP3, -3.77489497744594108e-8);
|
_PS_CONST(minus_cephes_DP3, -3.77489497744594108e-8f);
|
||||||
_PS_CONST(sincof_p0, -1.9515295891E-4);
|
_PS_CONST(sincof_p0, -1.9515295891E-4f);
|
||||||
_PS_CONST(sincof_p1, 8.3321608736E-3);
|
_PS_CONST(sincof_p1, 8.3321608736E-3f);
|
||||||
_PS_CONST(sincof_p2, -1.6666654611E-1);
|
_PS_CONST(sincof_p2, -1.6666654611E-1f);
|
||||||
_PS_CONST(coscof_p0, 2.443315711809948E-005);
|
_PS_CONST(coscof_p0, 2.443315711809948E-005f);
|
||||||
_PS_CONST(coscof_p1, -1.388731625493765E-003);
|
_PS_CONST(coscof_p1, -1.388731625493765E-003f);
|
||||||
_PS_CONST(coscof_p2, 4.166664568298827E-002);
|
_PS_CONST(coscof_p2, 4.166664568298827E-002f);
|
||||||
_PS_CONST(cephes_FOPI, 1.27323954473516); // 4 / M_PI
|
_PS_CONST(cephes_FOPI, 1.27323954473516f); // 4 / M_PI
|
||||||
|
|
||||||
|
|
||||||
/* evaluation of 4 sines at onces, using only SSE1+MMX intrinsics so
|
/* evaluation of 4 sines at onces, using only SSE1+MMX intrinsics so
|
||||||
|
|
|
||||||
|
|
@ -107,7 +107,7 @@ int sfizz_get_num_curves(sfizz_synth_t* synth);
|
||||||
*
|
*
|
||||||
* @return int the number of preloaded samples
|
* @return int the number of preloaded samples
|
||||||
*/
|
*/
|
||||||
int sfizz_get_num_preloaded_samples(sfizz_synth_t* synth);
|
size_t sfizz_get_num_preloaded_samples(sfizz_synth_t* synth);
|
||||||
/**
|
/**
|
||||||
* @brief Returns the number of active voices. Note that this function is a
|
* @brief Returns the number of active voices. Note that this function is a
|
||||||
* basic indicator and does not aim to be perfect. In particular, it
|
* basic indicator and does not aim to be perfect. In particular, it
|
||||||
|
|
@ -116,7 +116,7 @@ int sfizz_get_num_preloaded_samples(sfizz_synth_t* synth);
|
||||||
*
|
*
|
||||||
* @param synth The synth
|
* @param synth The synth
|
||||||
*
|
*
|
||||||
* @return int the number of playing voices
|
* @return size_t the number of playing voices
|
||||||
*/
|
*/
|
||||||
int sfizz_get_num_active_voices(sfizz_synth_t* synth);
|
int sfizz_get_num_active_voices(sfizz_synth_t* synth);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ Type ADSREnvelope<Type>::getNextValue() noexcept
|
||||||
return start;
|
return start;
|
||||||
|
|
||||||
currentState = State::Attack;
|
currentState = State::Attack;
|
||||||
step = (1.0 - currentValue) / (attack > 0 ? attack : 1);
|
step = (static_cast<Type>(1.0) - currentValue) / (attack > 0 ? attack : 1);
|
||||||
[[fallthrough]];
|
[[fallthrough]];
|
||||||
case State::Attack:
|
case State::Attack:
|
||||||
if (attack-- > 0) {
|
if (attack-- > 0) {
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ namespace sfz
|
||||||
* @tparam MaxChannels the maximum number of channels in the buffer
|
* @tparam MaxChannels the maximum number of channels in the buffer
|
||||||
* @tparam Alignment the alignment for the buffers
|
* @tparam Alignment the alignment for the buffers
|
||||||
*/
|
*/
|
||||||
template <class Type, int 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 = std::remove_cv_t<Type>;
|
||||||
|
|
@ -50,7 +50,6 @@ public:
|
||||||
using const_pointer = const value_type*;
|
using const_pointer = const value_type*;
|
||||||
using iterator = pointer;
|
using iterator = pointer;
|
||||||
using const_iterator = const_pointer;
|
using const_iterator = const_pointer;
|
||||||
using size_type = size_t;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Construct a new Audio Buffer object
|
* @brief Construct a new Audio Buffer object
|
||||||
|
|
@ -67,11 +66,11 @@ public:
|
||||||
* @param numChannels
|
* @param numChannels
|
||||||
* @param numFrames
|
* @param numFrames
|
||||||
*/
|
*/
|
||||||
AudioBuffer(int numChannels, int numFrames)
|
AudioBuffer(size_t numChannels, size_t numFrames)
|
||||||
: numChannels(numChannels)
|
: numChannels(numChannels)
|
||||||
, numFrames(numFrames)
|
, numFrames(numFrames)
|
||||||
{
|
{
|
||||||
for (auto i = 0; i < numChannels; ++i)
|
for (size_t i = 0; i < numChannels; ++i)
|
||||||
buffers[i] = std::make_unique<buffer_type>(numFrames);
|
buffers[i] = std::make_unique<buffer_type>(numFrames);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -82,11 +81,11 @@ public:
|
||||||
* @return true if the resize worked
|
* @return true if the resize worked
|
||||||
* @return false otherwise
|
* @return false otherwise
|
||||||
*/
|
*/
|
||||||
bool resize(size_type newSize)
|
bool resize(size_t newSize)
|
||||||
{
|
{
|
||||||
bool returnedOK = true;
|
bool returnedOK = true;
|
||||||
|
|
||||||
for (auto i = 0; i < numChannels; ++i)
|
for (size_t i = 0; i < numChannels; ++i)
|
||||||
returnedOK &= buffers[i]->resize(newSize);
|
returnedOK &= buffers[i]->resize(newSize);
|
||||||
|
|
||||||
if (returnedOK)
|
if (returnedOK)
|
||||||
|
|
@ -101,7 +100,7 @@ public:
|
||||||
* @param channelIndex
|
* @param channelIndex
|
||||||
* @return iterator
|
* @return iterator
|
||||||
*/
|
*/
|
||||||
iterator channelWriter(int channelIndex)
|
iterator channelWriter(size_t channelIndex)
|
||||||
{
|
{
|
||||||
ASSERT(channelIndex < numChannels)
|
ASSERT(channelIndex < numChannels)
|
||||||
if (channelIndex < numChannels)
|
if (channelIndex < numChannels)
|
||||||
|
|
@ -116,7 +115,7 @@ public:
|
||||||
* @param channelIndex
|
* @param channelIndex
|
||||||
* @return iterator
|
* @return iterator
|
||||||
*/
|
*/
|
||||||
iterator channelWriterEnd(int channelIndex)
|
iterator channelWriterEnd(size_t channelIndex)
|
||||||
{
|
{
|
||||||
ASSERT(channelIndex < numChannels)
|
ASSERT(channelIndex < numChannels)
|
||||||
if (channelIndex < numChannels)
|
if (channelIndex < numChannels)
|
||||||
|
|
@ -131,7 +130,7 @@ public:
|
||||||
* @param channelIndex
|
* @param channelIndex
|
||||||
* @return const_iterator
|
* @return const_iterator
|
||||||
*/
|
*/
|
||||||
const_iterator channelReader(int channelIndex) const
|
const_iterator channelReader(size_t channelIndex) const
|
||||||
{
|
{
|
||||||
ASSERT(channelIndex < numChannels)
|
ASSERT(channelIndex < numChannels)
|
||||||
if (channelIndex < numChannels)
|
if (channelIndex < numChannels)
|
||||||
|
|
@ -146,7 +145,7 @@ public:
|
||||||
* @param channelIndex
|
* @param channelIndex
|
||||||
* @return const_iterator
|
* @return const_iterator
|
||||||
*/
|
*/
|
||||||
const_iterator channelReaderEnd(int channelIndex) const
|
const_iterator channelReaderEnd(size_t channelIndex) const
|
||||||
{
|
{
|
||||||
ASSERT(channelIndex < numChannels)
|
ASSERT(channelIndex < numChannels)
|
||||||
if (channelIndex < numChannels)
|
if (channelIndex < numChannels)
|
||||||
|
|
@ -161,7 +160,7 @@ public:
|
||||||
* @param channelIndex
|
* @param channelIndex
|
||||||
* @return absl::Span<value_type>
|
* @return absl::Span<value_type>
|
||||||
*/
|
*/
|
||||||
absl::Span<value_type> getSpan(int channelIndex) const
|
absl::Span<value_type> getSpan(size_t channelIndex) const
|
||||||
{
|
{
|
||||||
ASSERT(channelIndex < numChannels)
|
ASSERT(channelIndex < numChannels)
|
||||||
if (channelIndex < numChannels)
|
if (channelIndex < numChannels)
|
||||||
|
|
@ -176,7 +175,7 @@ public:
|
||||||
* @param channelIndex
|
* @param channelIndex
|
||||||
* @return absl::Span<const value_type>
|
* @return absl::Span<const value_type>
|
||||||
*/
|
*/
|
||||||
absl::Span<const value_type> getConstSpan(int channelIndex) const
|
absl::Span<const value_type> getConstSpan(size_t channelIndex) const
|
||||||
{
|
{
|
||||||
return getSpan(channelIndex);
|
return getSpan(channelIndex);
|
||||||
}
|
}
|
||||||
|
|
@ -194,9 +193,9 @@ public:
|
||||||
/**
|
/**
|
||||||
* @brief Get the number of elements in each buffer
|
* @brief Get the number of elements in each buffer
|
||||||
*
|
*
|
||||||
* @return size_type
|
* @return size_t
|
||||||
*/
|
*/
|
||||||
size_type getNumFrames() const
|
size_t getNumFrames() const
|
||||||
{
|
{
|
||||||
return numFrames;
|
return numFrames;
|
||||||
}
|
}
|
||||||
|
|
@ -206,7 +205,7 @@ public:
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
int getNumChannels() const
|
size_t getNumChannels() const
|
||||||
{
|
{
|
||||||
return numChannels;
|
return numChannels;
|
||||||
}
|
}
|
||||||
|
|
@ -231,7 +230,7 @@ public:
|
||||||
* @param frameIndex
|
* @param frameIndex
|
||||||
* @return Type&
|
* @return Type&
|
||||||
*/
|
*/
|
||||||
Type& getSample(int channelIndex, size_type frameIndex)
|
Type& getSample(size_t channelIndex, size_t frameIndex)
|
||||||
{
|
{
|
||||||
// Uhoh
|
// Uhoh
|
||||||
ASSERT(buffers[channelIndex] != nullptr);
|
ASSERT(buffers[channelIndex] != nullptr);
|
||||||
|
|
@ -247,7 +246,7 @@ public:
|
||||||
* @param frameIndex
|
* @param frameIndex
|
||||||
* @return Type&
|
* @return Type&
|
||||||
*/
|
*/
|
||||||
Type& operator()(int channelIndex, size_type frameIndex)
|
Type& operator()(size_t channelIndex, size_t frameIndex)
|
||||||
{
|
{
|
||||||
return getSample(channelIndex, frameIndex);
|
return getSample(channelIndex, frameIndex);
|
||||||
}
|
}
|
||||||
|
|
@ -258,7 +257,7 @@ public:
|
||||||
*/
|
*/
|
||||||
void reset()
|
void reset()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < numChannels; ++i)
|
for (size_t i = 0; i < numChannels; ++i)
|
||||||
buffers[i].reset();
|
buffers[i].reset();
|
||||||
numFrames = 0;
|
numFrames = 0;
|
||||||
numChannels = 0;
|
numChannels = 0;
|
||||||
|
|
@ -269,10 +268,10 @@ public:
|
||||||
*
|
*
|
||||||
* @param numChannels
|
* @param numChannels
|
||||||
*/
|
*/
|
||||||
void addChannels(int numChannels)
|
void addChannels(size_t numChannels)
|
||||||
{
|
{
|
||||||
ASSERT(this->numChannels + numChannels <= MaxChannels);
|
ASSERT(this->numChannels + numChannels <= MaxChannels);
|
||||||
for (int i = 0; i < numChannels; ++i)
|
for (size_t i = 0; i < numChannels; ++i)
|
||||||
addChannel();
|
addChannel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -281,7 +280,7 @@ private:
|
||||||
using buffer_ptr = std::unique_ptr<buffer_type>;
|
using buffer_ptr = std::unique_ptr<buffer_type>;
|
||||||
static_assert(MaxChannels > 0, "Need a positive number of channels");
|
static_assert(MaxChannels > 0, "Need a positive number of channels");
|
||||||
std::array<buffer_ptr, MaxChannels> buffers;
|
std::array<buffer_ptr, MaxChannels> buffers;
|
||||||
int numChannels { 0 };
|
size_t numChannels { 0 };
|
||||||
size_type numFrames { 0 };
|
size_t numFrames { 0 };
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ namespace sfz
|
||||||
* @tparam Type the underlying buffer type
|
* @tparam Type the underlying buffer type
|
||||||
* @tparam MaxChannels the maximum number of channels. Defaults to sfz::config::numChannels
|
* @tparam MaxChannels the maximum number of channels. Defaults to sfz::config::numChannels
|
||||||
*/
|
*/
|
||||||
template <class Type, int MaxChannels = sfz::config::numChannels>
|
template <class Type, size_t MaxChannels = sfz::config::numChannels>
|
||||||
class AudioSpan {
|
class AudioSpan {
|
||||||
public:
|
public:
|
||||||
using size_type = size_t;
|
using size_type = size_t;
|
||||||
|
|
@ -102,12 +102,12 @@ public:
|
||||||
* @param offset starting offset for the AudioSpan
|
* @param offset starting offset for the AudioSpan
|
||||||
* @param numFrames size of the AudioSpan
|
* @param numFrames size of the AudioSpan
|
||||||
*/
|
*/
|
||||||
AudioSpan(const std::array<Type*, MaxChannels>& spans, int numChannels, size_type offset, size_type numFrames)
|
AudioSpan(const std::array<Type*, MaxChannels>& spans, size_type numChannels, size_type offset, size_type numFrames)
|
||||||
: numFrames(numFrames)
|
: numFrames(numFrames)
|
||||||
, numChannels(numChannels)
|
, numChannels(numChannels)
|
||||||
{
|
{
|
||||||
ASSERT(numChannels <= MaxChannels);
|
ASSERT(numChannels <= MaxChannels);
|
||||||
for (auto i = 0; i < numChannels; ++i)
|
for (size_t i = 0; i < numChannels; ++i)
|
||||||
this->spans[i] = spans[i] + offset;
|
this->spans[i] = spans[i] + offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -164,12 +164,12 @@ 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, int 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 = std::enable_if<N <= MaxChannels>, typename = std::enable_if_t<std::is_const<U>::value, int>>
|
||||||
AudioSpan(AudioBuffer<U, N, Alignment>& audioBuffer)
|
AudioSpan(AudioBuffer<U, N, Alignment>& audioBuffer)
|
||||||
: numFrames(audioBuffer.getNumFrames())
|
: numFrames(audioBuffer.getNumFrames())
|
||||||
, numChannels(audioBuffer.getNumChannels())
|
, numChannels(audioBuffer.getNumChannels())
|
||||||
{
|
{
|
||||||
for (int i = 0; i < numChannels; i++) {
|
for (size_t i = 0; i < numChannels; i++) {
|
||||||
this->spans[i] = audioBuffer.channelReader(i);
|
this->spans[i] = audioBuffer.channelReader(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -185,12 +185,12 @@ 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, int N, unsigned int Alignment, typename = std::enable_if<N <= MaxChannels>>
|
template <class U, size_t N, unsigned int Alignment, typename = std::enable_if<N <= MaxChannels>>
|
||||||
AudioSpan(AudioBuffer<U, N, Alignment>& audioBuffer)
|
AudioSpan(AudioBuffer<U, N, Alignment>& audioBuffer)
|
||||||
: numFrames(audioBuffer.getNumFrames())
|
: numFrames(audioBuffer.getNumFrames())
|
||||||
, numChannels(audioBuffer.getNumChannels())
|
, numChannels(audioBuffer.getNumChannels())
|
||||||
{
|
{
|
||||||
for (int i = 0; i < numChannels; i++) {
|
for (size_t i = 0; i < numChannels; i++) {
|
||||||
this->spans[i] = audioBuffer.channelWriter(i);
|
this->spans[i] = audioBuffer.channelWriter(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -200,12 +200,12 @@ public:
|
||||||
*
|
*
|
||||||
* @param other the other AudioSpan
|
* @param other the other AudioSpan
|
||||||
*/
|
*/
|
||||||
template <class U, int N, typename = std::enable_if<N <= MaxChannels>>
|
template <class U, size_t N, typename = std::enable_if<N <= MaxChannels>>
|
||||||
AudioSpan(const AudioSpan<U, N>& other)
|
AudioSpan(const AudioSpan<U, N>& other)
|
||||||
: numFrames(other.getNumFrames())
|
: numFrames(other.getNumFrames())
|
||||||
, numChannels(other.getNumChannels())
|
, numChannels(other.getNumChannels())
|
||||||
{
|
{
|
||||||
for (int i = 0; i < numChannels; i++) {
|
for (size_t i = 0; i < numChannels; i++) {
|
||||||
this->spans[i] = other.getChannel(i);
|
this->spans[i] = other.getChannel(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -216,7 +216,7 @@ public:
|
||||||
* @param channelIndex the channel
|
* @param channelIndex the channel
|
||||||
* @return Type* the raw pointer to the channel
|
* @return Type* the raw pointer to the channel
|
||||||
*/
|
*/
|
||||||
Type* getChannel(int channelIndex)
|
Type* getChannel(size_t channelIndex)
|
||||||
{
|
{
|
||||||
ASSERT(channelIndex < numChannels);
|
ASSERT(channelIndex < numChannels);
|
||||||
if (channelIndex < numChannels)
|
if (channelIndex < numChannels)
|
||||||
|
|
@ -231,7 +231,7 @@ public:
|
||||||
* @param channelIndex the channel
|
* @param channelIndex the channel
|
||||||
* @return absl::Span<Type>
|
* @return absl::Span<Type>
|
||||||
*/
|
*/
|
||||||
absl::Span<Type> getSpan(int channelIndex)
|
absl::Span<Type> getSpan(size_t channelIndex)
|
||||||
{
|
{
|
||||||
ASSERT(channelIndex < numChannels);
|
ASSERT(channelIndex < numChannels);
|
||||||
if (channelIndex < numChannels)
|
if (channelIndex < numChannels)
|
||||||
|
|
@ -246,7 +246,7 @@ public:
|
||||||
* @param channelIndex the channel
|
* @param channelIndex the channel
|
||||||
* @return absl::Span<const Type>
|
* @return absl::Span<const Type>
|
||||||
*/
|
*/
|
||||||
absl::Span<const Type> getConstSpan(int channelIndex)
|
absl::Span<const Type> getConstSpan(size_t channelIndex)
|
||||||
{
|
{
|
||||||
ASSERT(channelIndex < numChannels);
|
ASSERT(channelIndex < numChannels);
|
||||||
if (channelIndex < numChannels)
|
if (channelIndex < numChannels)
|
||||||
|
|
@ -265,7 +265,7 @@ public:
|
||||||
if (numChannels == 0)
|
if (numChannels == 0)
|
||||||
return 0.0;
|
return 0.0;
|
||||||
Type result = 0.0;
|
Type result = 0.0;
|
||||||
for (int i = 0; i < numChannels; ++i)
|
for (size_t i = 0; i < numChannels; ++i)
|
||||||
result += sfz::meanSquared<Type>(getConstSpan(i));
|
result += sfz::meanSquared<Type>(getConstSpan(i));
|
||||||
return result / numChannels;
|
return result / numChannels;
|
||||||
}
|
}
|
||||||
|
|
@ -278,7 +278,7 @@ public:
|
||||||
void fill(Type value) noexcept
|
void fill(Type value) noexcept
|
||||||
{
|
{
|
||||||
static_assert(!std::is_const<Type>::value, "Can't allow mutating operations on const AudioSpans");
|
static_assert(!std::is_const<Type>::value, "Can't allow mutating operations on const AudioSpans");
|
||||||
for (int i = 0; i < numChannels; ++i)
|
for (size_t i = 0; i < numChannels; ++i)
|
||||||
sfz::fill<Type>(getSpan(i), value);
|
sfz::fill<Type>(getSpan(i), value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -290,7 +290,7 @@ public:
|
||||||
void applyGain(absl::Span<const Type> gain) noexcept
|
void applyGain(absl::Span<const Type> gain) noexcept
|
||||||
{
|
{
|
||||||
static_assert(!std::is_const<Type>::value, "Can't allow mutating operations on const AudioSpans");
|
static_assert(!std::is_const<Type>::value, "Can't allow mutating operations on const AudioSpans");
|
||||||
for (int i = 0; i < numChannels; ++i)
|
for (size_t i = 0; i < numChannels; ++i)
|
||||||
sfz::applyGain<Type>(gain, getSpan(i));
|
sfz::applyGain<Type>(gain, getSpan(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -302,7 +302,7 @@ public:
|
||||||
void applyGain(Type gain) noexcept
|
void applyGain(Type gain) noexcept
|
||||||
{
|
{
|
||||||
static_assert(!std::is_const<Type>::value, "Can't allow mutating operations on const AudioSpans");
|
static_assert(!std::is_const<Type>::value, "Can't allow mutating operations on const AudioSpans");
|
||||||
for (int i = 0; i < numChannels; ++i)
|
for (size_t i = 0; i < numChannels; ++i)
|
||||||
sfz::applyGain<Type>(gain, getSpan(i));
|
sfz::applyGain<Type>(gain, getSpan(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -312,13 +312,13 @@ public:
|
||||||
*
|
*
|
||||||
* @param other the other AudioSpan
|
* @param other the other AudioSpan
|
||||||
*/
|
*/
|
||||||
template <class U, int N, typename = std::enable_if<N <= MaxChannels>>
|
template <class U, size_t N, typename = std::enable_if<N <= MaxChannels>>
|
||||||
void add(AudioSpan<U, N>& other)
|
void add(AudioSpan<U, N>& other)
|
||||||
{
|
{
|
||||||
static_assert(!std::is_const<Type>::value, "Can't allow mutating operations on const AudioSpans");
|
static_assert(!std::is_const<Type>::value, "Can't allow mutating operations on const AudioSpans");
|
||||||
ASSERT(other.getNumChannels() == numChannels);
|
ASSERT(other.getNumChannels() == numChannels);
|
||||||
if (other.getNumChannels() == numChannels) {
|
if (other.getNumChannels() == numChannels) {
|
||||||
for (int i = 0; i < numChannels; ++i)
|
for (size_t i = 0; i < numChannels; ++i)
|
||||||
sfz::add<Type>(other.getConstSpan(i), getSpan(i));
|
sfz::add<Type>(other.getConstSpan(i), getSpan(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -329,13 +329,13 @@ public:
|
||||||
*
|
*
|
||||||
* @param other the other AudioSpan
|
* @param other the other AudioSpan
|
||||||
*/
|
*/
|
||||||
template <class U, int N, typename = std::enable_if<N <= MaxChannels>>
|
template <class U, size_t N, typename = std::enable_if<N <= MaxChannels>>
|
||||||
void copy(AudioSpan<U, N>& other)
|
void copy(AudioSpan<U, N>& other)
|
||||||
{
|
{
|
||||||
static_assert(!std::is_const<Type>::value, "Can't allow mutating operations on const AudioSpans");
|
static_assert(!std::is_const<Type>::value, "Can't allow mutating operations on const AudioSpans");
|
||||||
ASSERT(other.getNumChannels() == numChannels);
|
ASSERT(other.getNumChannels() == numChannels);
|
||||||
if (other.getNumChannels() == numChannels) {
|
if (other.getNumChannels() == numChannels) {
|
||||||
for (int i = 0; i < numChannels; ++i)
|
for (size_t i = 0; i < numChannels; ++i)
|
||||||
sfz::copy<Type>(other.getConstSpan(i), getSpan(i));
|
sfz::copy<Type>(other.getConstSpan(i), getSpan(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -355,7 +355,7 @@ public:
|
||||||
*
|
*
|
||||||
* @returns size_type the number of channels in the AudioSpan
|
* @returns size_type the number of channels in the AudioSpan
|
||||||
*/
|
*/
|
||||||
int getNumChannels()
|
size_t getNumChannels()
|
||||||
{
|
{
|
||||||
return numChannels;
|
return numChannels;
|
||||||
}
|
}
|
||||||
|
|
@ -413,6 +413,6 @@ private:
|
||||||
static_assert(MaxChannels > 0, "Need a positive number of channels");
|
static_assert(MaxChannels > 0, "Need a positive number of channels");
|
||||||
std::array<Type*, MaxChannels> spans;
|
std::array<Type*, MaxChannels> spans;
|
||||||
size_type numFrames { 0 };
|
size_type numFrames { 0 };
|
||||||
int numChannels { 0 };
|
size_type numChannels { 0 };
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,21 @@ public:
|
||||||
bytes.fetch_sub(size);
|
bytes.fetch_sub(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void bufferDeleted(size_t size)
|
||||||
|
{
|
||||||
|
bufferDeleted(static_cast<int>(size));
|
||||||
|
}
|
||||||
|
|
||||||
|
void bufferResized(size_t oldSize, size_t newSize)
|
||||||
|
{
|
||||||
|
bufferResized(static_cast<int>(oldSize), static_cast<int>(newSize));
|
||||||
|
}
|
||||||
|
|
||||||
|
void newBuffer(size_t size)
|
||||||
|
{
|
||||||
|
newBuffer(static_cast<int>(size));
|
||||||
|
}
|
||||||
|
|
||||||
int getNumBuffers() { return numBuffers; }
|
int getNumBuffers() { return numBuffers; }
|
||||||
int getTotalBytes() { return bytes; }
|
int getTotalBytes() { return bytes; }
|
||||||
private:
|
private:
|
||||||
|
|
@ -165,7 +180,7 @@ public:
|
||||||
*/
|
*/
|
||||||
void clear()
|
void clear()
|
||||||
{
|
{
|
||||||
counter().bufferResized(largerSize * sizeof(value_type), 0);
|
counter().bufferResized(largerSize * sizeof(value_type), static_cast<size_t>(0));
|
||||||
largerSize = 0;
|
largerSize = 0;
|
||||||
alignedSize = 0;
|
alignedSize = 0;
|
||||||
std::free(paddedData);
|
std::free(paddedData);
|
||||||
|
|
@ -235,7 +250,7 @@ public:
|
||||||
// return *this;
|
// return *this;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
Type& operator[](int idx) { return *(normalData + idx); }
|
Type& operator[](size_t idx) { return *(normalData + idx); }
|
||||||
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; }
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,12 @@
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#ifdef _WIN32
|
||||||
|
// There's a spurious min/max function in MSVC that makes everything go badly...
|
||||||
|
#define NOMINMAX
|
||||||
|
#define _SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING
|
||||||
|
#endif
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
namespace sfz {
|
namespace sfz {
|
||||||
enum class Oversampling: int {
|
enum class Oversampling: int {
|
||||||
|
|
@ -36,7 +42,7 @@ namespace config {
|
||||||
constexpr int defaultSamplesPerBlock { 1024 };
|
constexpr int defaultSamplesPerBlock { 1024 };
|
||||||
constexpr int maxBlockSize { 8192 };
|
constexpr int maxBlockSize { 8192 };
|
||||||
constexpr int preloadSize { 8192 };
|
constexpr int preloadSize { 8192 };
|
||||||
constexpr int numChannels { 2 };
|
constexpr size_t numChannels { 2 };
|
||||||
constexpr int numBackgroundThreads { 4 };
|
constexpr int numBackgroundThreads { 4 };
|
||||||
constexpr int numVoices { 64 };
|
constexpr int numVoices { 64 };
|
||||||
constexpr int maxVoices { 256 };
|
constexpr int maxVoices { 256 };
|
||||||
|
|
@ -50,12 +56,12 @@ namespace config {
|
||||||
constexpr int halfCCThreshold { 64 };
|
constexpr int halfCCThreshold { 64 };
|
||||||
constexpr int centPerSemitone { 100 };
|
constexpr int centPerSemitone { 100 };
|
||||||
constexpr float virtuallyZero { 0.00005f };
|
constexpr float virtuallyZero { 0.00005f };
|
||||||
constexpr float fastReleaseDuration { 0.01 };
|
constexpr float fastReleaseDuration { 0.01f };
|
||||||
constexpr char defineCharacter { '$' };
|
constexpr char defineCharacter { '$' };
|
||||||
constexpr Oversampling defaultOversamplingFactor { Oversampling::x1 };
|
constexpr Oversampling defaultOversamplingFactor { Oversampling::x1 };
|
||||||
constexpr float A440 { 440.0 };
|
constexpr float A440 { 440.0 };
|
||||||
constexpr unsigned powerHistoryLength { 16 };
|
constexpr size_t powerHistoryLength { 16 };
|
||||||
constexpr float voiceStealingThreshold { 0.00001 };
|
constexpr float voiceStealingThreshold { 0.00001f };
|
||||||
constexpr int numCCs { 143 };
|
constexpr int numCCs { 143 };
|
||||||
constexpr int chunkSize { 1024 };
|
constexpr int chunkSize { 1024 };
|
||||||
} // namespace config
|
} // namespace config
|
||||||
|
|
|
||||||
|
|
@ -167,7 +167,7 @@ void LinearEnvelope<Type>::getQuantizedBlock(absl::Span<Type> output, Type quant
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int numSteps = difference / quantizationStep;
|
const auto numSteps = static_cast<int>(difference / quantizationStep);
|
||||||
const auto stepLength = static_cast<int>(length / numSteps);
|
const auto stepLength = static_cast<int>(length / numSteps);
|
||||||
for (int i = 0; i < numSteps; ++i) {
|
for (int i = 0; i < numSteps; ++i) {
|
||||||
fill<Type>(output.subspan(index, stepLength), currentValue);
|
fill<Type>(output.subspan(index, stepLength), currentValue);
|
||||||
|
|
@ -257,7 +257,7 @@ void MultiplicativeEnvelope<Type>::getQuantizedBlock(absl::Span<Type> output, Ty
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int numSteps = std::log(difference) / logStep;
|
const auto numSteps = static_cast<int>(std::log(difference) / logStep);
|
||||||
const auto stepLength = static_cast<int>(length / numSteps);
|
const auto stepLength = static_cast<int>(length / numSteps);
|
||||||
for (int i = 0; i < numSteps; ++i) {
|
for (int i = 0; i < numSteps; ++i) {
|
||||||
fill<Type>(output.subspan(index, stepLength), currentValue);
|
fill<Type>(output.subspan(index, stepLength), currentValue);
|
||||||
|
|
|
||||||
|
|
@ -108,7 +108,7 @@ absl::optional<sfz::FilePool::FileInformation> sfz::FilePool::getFileInformation
|
||||||
if (!fs::exists(file))
|
if (!fs::exists(file))
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
SndfileHandle sndFile(file.c_str());
|
SndfileHandle sndFile(file.string().c_str());
|
||||||
if (sndFile.channels() != 1 && sndFile.channels() != 2) {
|
if (sndFile.channels() != 1 && sndFile.channels() != 2) {
|
||||||
DBG("Missing logic for " << sndFile.channels() << " channels, discarding sample " << filename);
|
DBG("Missing logic for " << sndFile.channels() << " channels, discarding sample " << filename);
|
||||||
return {};
|
return {};
|
||||||
|
|
@ -135,12 +135,12 @@ bool sfz::FilePool::preloadFile(const std::string& filename, uint32_t maxOffset)
|
||||||
if (!fs::exists(file))
|
if (!fs::exists(file))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
SndfileHandle sndFile(file.c_str());
|
SndfileHandle sndFile(file.string().c_str());
|
||||||
if (sndFile.channels() != 1 && sndFile.channels() != 2)
|
if (sndFile.channels() != 1 && sndFile.channels() != 2)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// FIXME: Large offsets will require large preloading; is this OK in practice? Apparently sforzando does the same
|
// FIXME: Large offsets will require large preloading; is this OK in practice? Apparently sforzando does the same
|
||||||
const uint32_t frames = sndFile.frames();
|
const auto frames = static_cast<uint32_t>(sndFile.frames());
|
||||||
const auto framesToLoad = [&]() {
|
const auto framesToLoad = [&]() {
|
||||||
if (preloadSize == 0)
|
if (preloadSize == 0)
|
||||||
return frames;
|
return frames;
|
||||||
|
|
@ -196,9 +196,9 @@ void sfz::FilePool::setPreloadSize(uint32_t preloadSize) noexcept
|
||||||
// Update all the preloaded sizes
|
// Update all the preloaded sizes
|
||||||
for (auto& preloadedFile : preloadedFiles) {
|
for (auto& preloadedFile : preloadedFiles) {
|
||||||
const auto numFrames = preloadedFile.second.preloadedData->getNumFrames() / static_cast<int>(oversamplingFactor);
|
const auto numFrames = preloadedFile.second.preloadedData->getNumFrames() / static_cast<int>(oversamplingFactor);
|
||||||
const uint32_t maxOffset = numFrames > this->preloadSize ? numFrames - this->preloadSize : 0;
|
const auto maxOffset = numFrames > this->preloadSize ? static_cast<uint32_t>(numFrames) - this->preloadSize : 0;
|
||||||
fs::path file { rootDirectory / std::string(preloadedFile.first) };
|
fs::path file { rootDirectory / std::string(preloadedFile.first) };
|
||||||
SndfileHandle sndFile(file.c_str());
|
SndfileHandle sndFile(file.string().c_str());
|
||||||
preloadedFile.second.preloadedData = readFromFile<float>(sndFile, preloadSize + maxOffset, oversamplingFactor);
|
preloadedFile.second.preloadedData = readFromFile<float>(sndFile, preloadSize + maxOffset, oversamplingFactor);
|
||||||
}
|
}
|
||||||
this->preloadSize = preloadSize;
|
this->preloadSize = preloadSize;
|
||||||
|
|
@ -248,12 +248,12 @@ void sfz::FilePool::loadingThread() noexcept
|
||||||
[[maybe_unused]] const auto waitDurationMillis = std::chrono::duration<double,std::milli>(waitDuration).count();
|
[[maybe_unused]] const auto waitDurationMillis = std::chrono::duration<double,std::milli>(waitDuration).count();
|
||||||
|
|
||||||
fs::path file { rootDirectory / std::string(promise->filename) };
|
fs::path file { rootDirectory / std::string(promise->filename) };
|
||||||
SndfileHandle sndFile(file.c_str());
|
SndfileHandle sndFile(file.string().c_str());
|
||||||
if (sndFile.error() != 0) {
|
if (sndFile.error() != 0) {
|
||||||
DBG("[sfizz] libsndfile errored for " << promise->filename << " with message " << sndFile.strError());
|
DBG("[sfizz] libsndfile errored for " << promise->filename << " with message " << sndFile.strError());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const uint32_t frames = sndFile.frames();
|
const auto frames = static_cast<uint32_t>(sndFile.frames());
|
||||||
streamFromFile<float>(sndFile, frames, oversamplingFactor, promise->fileData, &promise->availableFrames);
|
streamFromFile<float>(sndFile, frames, oversamplingFactor, promise->fileData, &promise->availableFrames);
|
||||||
promise->dataReady = true;
|
promise->dataReady = true;
|
||||||
threadsLoading--;
|
threadsLoading--;
|
||||||
|
|
@ -289,17 +289,17 @@ void sfz::FilePool::cleanupPromises() noexcept
|
||||||
// The garbage collection cleared the data from these so we can move them
|
// The garbage collection cleared the data from these so we can move them
|
||||||
// back to the empty queue
|
// back to the empty queue
|
||||||
auto clearedIterator = promisesToClear.begin();
|
auto clearedIterator = promisesToClear.begin();
|
||||||
auto clearedSentinel = promisesToClear.end() - 1;
|
auto clearedSentinel = promisesToClear.rbegin();
|
||||||
while (clearedIterator != promisesToClear.end()) {
|
while (clearedIterator < clearedSentinel.base()) {
|
||||||
if (clearedIterator->get()->dataReady == false) {
|
if (clearedIterator->get()->dataReady == false) {
|
||||||
emptyPromises.push_back(*clearedIterator);
|
emptyPromises.push_back(*clearedIterator);
|
||||||
std::iter_swap(clearedIterator, clearedSentinel);
|
std::iter_swap(clearedIterator, clearedSentinel);
|
||||||
clearedSentinel--;
|
++clearedSentinel;
|
||||||
promisesToClear.pop_back();
|
|
||||||
} else {
|
} else {
|
||||||
clearedIterator++;
|
++clearedIterator;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
promisesToClear.resize(std::distance(promisesToClear.begin(), clearedSentinel.base()));
|
||||||
|
|
||||||
FilePromisePtr promise;
|
FilePromisePtr promise;
|
||||||
// Remove the promises from the filled queue and put them in a linear
|
// Remove the promises from the filled queue and put them in a linear
|
||||||
|
|
@ -308,17 +308,17 @@ void sfz::FilePool::cleanupPromises() noexcept
|
||||||
temporaryFilePromises.push_back(promise);
|
temporaryFilePromises.push_back(promise);
|
||||||
|
|
||||||
auto filledIterator = temporaryFilePromises.begin();
|
auto filledIterator = temporaryFilePromises.begin();
|
||||||
auto filledSentinel = temporaryFilePromises.end() - 1;
|
auto filledSentinel = temporaryFilePromises.rbegin();
|
||||||
while (filledIterator != temporaryFilePromises.end()) {
|
while (filledIterator < filledSentinel.base()) {
|
||||||
if (filledIterator->use_count() == 1) {
|
if (filledIterator->use_count() == 1) {
|
||||||
promisesToClear.push_back(*filledIterator);
|
promisesToClear.push_back(*filledIterator);
|
||||||
std::iter_swap(filledIterator, filledSentinel);
|
std::iter_swap(filledIterator, filledSentinel);
|
||||||
filledSentinel--;
|
++filledSentinel;
|
||||||
temporaryFilePromises.pop_back();
|
|
||||||
} else {
|
} else {
|
||||||
filledIterator++;
|
++filledIterator;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
temporaryFilePromises.resize(std::distance(temporaryFilePromises.begin(), filledSentinel.base()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void sfz::FilePool::setOversamplingFactor(sfz::Oversampling factor) noexcept
|
void sfz::FilePool::setOversamplingFactor(sfz::Oversampling factor) noexcept
|
||||||
|
|
@ -326,9 +326,9 @@ void sfz::FilePool::setOversamplingFactor(sfz::Oversampling factor) noexcept
|
||||||
float samplerateChange { static_cast<float>(factor) / static_cast<float>(this->oversamplingFactor) };
|
float samplerateChange { static_cast<float>(factor) / static_cast<float>(this->oversamplingFactor) };
|
||||||
for (auto& preloadedFile : preloadedFiles) {
|
for (auto& preloadedFile : preloadedFiles) {
|
||||||
const auto numFrames = preloadedFile.second.preloadedData->getNumFrames() / static_cast<int>(this->oversamplingFactor);
|
const auto numFrames = preloadedFile.second.preloadedData->getNumFrames() / static_cast<int>(this->oversamplingFactor);
|
||||||
const uint32_t maxOffset = numFrames > this->preloadSize ? numFrames - this->preloadSize : 0;
|
const uint32_t maxOffset = numFrames > this->preloadSize ? static_cast<uint32_t>(numFrames) - this->preloadSize : 0;
|
||||||
fs::path file { rootDirectory / std::string(preloadedFile.first) };
|
fs::path file { rootDirectory / std::string(preloadedFile.first) };
|
||||||
SndfileHandle sndFile(file.c_str());
|
SndfileHandle sndFile(file.string().c_str());
|
||||||
preloadedFile.second.preloadedData = readFromFile<float>(sndFile, preloadSize + maxOffset, factor);
|
preloadedFile.second.preloadedData = readFromFile<float>(sndFile, preloadSize + maxOffset, factor);
|
||||||
preloadedFile.second.sampleRate *= samplerateChange;
|
preloadedFile.second.sampleRate *= samplerateChange;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ public:
|
||||||
*
|
*
|
||||||
* @param size
|
* @param size
|
||||||
*/
|
*/
|
||||||
void resize(int size)
|
void resize(size_t size)
|
||||||
{
|
{
|
||||||
buffer.resize(size);
|
buffer.resize(size);
|
||||||
fill<ValueType>(absl::MakeSpan(buffer), 0.0);
|
fill<ValueType>(absl::MakeSpan(buffer), 0.0);
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@
|
||||||
* @date 2019-11-23
|
* @date 2019-11-23
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "Config.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
@ -156,14 +157,14 @@ constexpr ValueType linearInterpolation(ValueType left, ValueType right, ValueTy
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
constexpr Type pi { 3.141592653589793238462643383279502884 };
|
constexpr Type pi { static_cast<Type>(3.141592653589793238462643383279502884) };
|
||||||
template <class Type>
|
template <class Type>
|
||||||
constexpr Type twoPi { 2 * pi<Type> };
|
constexpr Type twoPi { static_cast<Type>(2) * pi<Type> };
|
||||||
template <class Type>
|
template <class Type>
|
||||||
constexpr Type piTwo { pi<Type> / 2 };
|
constexpr Type piTwo { pi<Type> / static_cast<Type>(2) };
|
||||||
template <class Type>
|
template <class Type>
|
||||||
constexpr Type piFour { pi<Type> / 4 };
|
constexpr Type piFour { pi<Type> / static_cast<Type>(4) };
|
||||||
template <class Type>
|
template <class Type>
|
||||||
constexpr Type sqrtTwo { 1.414213562373095048801688724209698078569671875376948073176 };
|
constexpr Type sqrtTwo { static_cast<Type>(1.414213562373095048801688724209698078569671875376948073176) };
|
||||||
template <class Type>
|
template <class Type>
|
||||||
constexpr Type sqrtTwoInv { 0.707106781186547524400844362104849039284835937688474036588 };
|
constexpr Type sqrtTwoInv { static_cast<Type>(0.707106781186547524400844362104849039284835937688474036588) };
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ public:
|
||||||
|
|
||||||
Type getGain() const { return gain; }
|
Type getGain() const { return gain; }
|
||||||
|
|
||||||
int processLowpass(absl::Span<const Type> input, absl::Span<Type> lowpass)
|
size_t processLowpass(absl::Span<const Type> input, absl::Span<Type> lowpass)
|
||||||
{
|
{
|
||||||
auto in = input.begin();
|
auto in = input.begin();
|
||||||
auto out = lowpass.begin();
|
auto out = lowpass.begin();
|
||||||
|
|
@ -73,7 +73,7 @@ public:
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
int processHighpass(absl::Span<const Type> input, absl::Span<Type> highpass)
|
size_t processHighpass(absl::Span<const Type> input, absl::Span<Type> highpass)
|
||||||
{
|
{
|
||||||
auto in = input.begin();
|
auto in = input.begin();
|
||||||
auto out = highpass.begin();
|
auto out = highpass.begin();
|
||||||
|
|
@ -87,7 +87,7 @@ public:
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
int processLowpassVariableGain(absl::Span<const Type> input, absl::Span<Type> lowpass, absl::Span<const Type> gain)
|
size_t processLowpassVariableGain(absl::Span<const Type> input, absl::Span<Type> lowpass, absl::Span<const Type> gain)
|
||||||
{
|
{
|
||||||
auto in = input.begin();
|
auto in = input.begin();
|
||||||
auto out = lowpass.begin();
|
auto out = lowpass.begin();
|
||||||
|
|
@ -104,7 +104,7 @@ public:
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
int processHighpassVariableGain(absl::Span<const Type> input, absl::Span<Type> highpass, absl::Span<const Type> gain)
|
size_t processHighpassVariableGain(absl::Span<const Type> input, absl::Span<Type> highpass, absl::Span<const Type> gain)
|
||||||
{
|
{
|
||||||
auto in = input.begin();
|
auto in = input.begin();
|
||||||
auto out = highpass.begin();
|
auto out = highpass.begin();
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@ void sfz::Oversampler::stream(const sfz::AudioBuffer<float>& input, sfz::AudioBu
|
||||||
upsampler.set_coefs(coeffsStage2x.data());
|
upsampler.set_coefs(coeffsStage2x.data());
|
||||||
break;
|
break;
|
||||||
case Oversampling::x1:
|
case Oversampling::x1:
|
||||||
for (int i = 0; i < numChannels; ++i)
|
for (size_t i = 0; i < numChannels; ++i)
|
||||||
copy<float>(input.getConstSpan(i), output.getSpan(i));
|
copy<float>(input.getConstSpan(i), output.getSpan(i));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -122,22 +122,22 @@ 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 (int 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);
|
||||||
if (factor == Oversampling::x2) {
|
if (factor == Oversampling::x2) {
|
||||||
upsampler2x[chanIdx].process_block(outputChunk.data(), inputChunk.data(), thisChunkSize);
|
upsampler2x[chanIdx].process_block(outputChunk.data(), inputChunk.data(), static_cast<long>(thisChunkSize));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (factor == Oversampling::x4) {
|
if (factor == Oversampling::x4) {
|
||||||
upsampler2x[chanIdx].process_block(span1.data(), inputChunk.data(), thisChunkSize);
|
upsampler2x[chanIdx].process_block(span1.data(), inputChunk.data(), static_cast<long>(thisChunkSize));
|
||||||
upsampler4x[chanIdx].process_block(outputChunk.data(), span1.data(), thisChunkSize * 2);
|
upsampler4x[chanIdx].process_block(outputChunk.data(), span1.data(), static_cast<long>(thisChunkSize * 2));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (factor == Oversampling::x8) {
|
else if (factor == Oversampling::x8) {
|
||||||
upsampler2x[chanIdx].process_block(span1.data(), inputChunk.data(), thisChunkSize);
|
upsampler2x[chanIdx].process_block(span1.data(), inputChunk.data(), static_cast<long>(thisChunkSize));
|
||||||
upsampler4x[chanIdx].process_block(span2.data(), span1.data(), thisChunkSize * 2);
|
upsampler4x[chanIdx].process_block(span2.data(), span1.data(), static_cast<long>(thisChunkSize * 2));
|
||||||
upsampler8x[chanIdx].process_block(outputChunk.data(), span2.data(), thisChunkSize * 4);
|
upsampler8x[chanIdx].process_block(outputChunk.data(), span2.data(), static_cast<long>(thisChunkSize * 4));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,6 @@
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include "Parser.h"
|
#include "Parser.h"
|
||||||
#include "Config.h"
|
|
||||||
#include "StringViewHelpers.h"
|
#include "StringViewHelpers.h"
|
||||||
#include "SfzHelpers.h"
|
#include "SfzHelpers.h"
|
||||||
#include "absl/strings/str_join.h"
|
#include "absl/strings/str_join.h"
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "Config.h"
|
||||||
#include "Opcode.h"
|
#include "Opcode.h"
|
||||||
#include "ghc/fs_std.hpp"
|
#include "ghc/fs_std.hpp"
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
|
||||||
|
|
@ -98,9 +98,9 @@ constexpr float normalizePercents(T percentValue)
|
||||||
* @param bendValue
|
* @param bendValue
|
||||||
* @return constexpr float
|
* @return constexpr float
|
||||||
*/
|
*/
|
||||||
constexpr float normalizeBend(int bendValue)
|
constexpr float normalizeBend(float bendValue)
|
||||||
{
|
{
|
||||||
return std::min(std::max(static_cast<float>(bendValue), -8191.0f), 8191.0f) / 8191.0f;
|
return std::min(std::max(bendValue, -8191.0f), 8191.0f) / 8191.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -237,9 +237,9 @@ bool sfz::Synth::loadSfzFile(const fs::path& filename)
|
||||||
|
|
||||||
resources.filePool.setRootDirectory(this->originalDirectory);
|
resources.filePool.setRootDirectory(this->originalDirectory);
|
||||||
|
|
||||||
auto lastRegion = regions.end() - 1;
|
|
||||||
auto currentRegion = regions.begin();
|
auto currentRegion = regions.begin();
|
||||||
while (currentRegion <= lastRegion) {
|
auto lastRegion = regions.rbegin();
|
||||||
|
while (currentRegion < lastRegion.base()) {
|
||||||
auto region = currentRegion->get();
|
auto region = currentRegion->get();
|
||||||
|
|
||||||
if (!region->isGenerator()) {
|
if (!region->isGenerator()) {
|
||||||
|
|
@ -247,7 +247,7 @@ bool sfz::Synth::loadSfzFile(const fs::path& filename)
|
||||||
if (!fileInformation) {
|
if (!fileInformation) {
|
||||||
DBG("Removing the region with sample " << region->sample);
|
DBG("Removing the region with sample " << region->sample);
|
||||||
std::iter_swap(currentRegion, lastRegion);
|
std::iter_swap(currentRegion, lastRegion);
|
||||||
lastRegion--;
|
++lastRegion;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
region->sampleEnd = std::min(region->sampleEnd, fileInformation->end);
|
region->sampleEnd = std::min(region->sampleEnd, fileInformation->end);
|
||||||
|
|
@ -298,11 +298,11 @@ bool sfz::Synth::loadSfzFile(const fs::path& filename)
|
||||||
region->registerAftertouch(0);
|
region->registerAftertouch(0);
|
||||||
region->registerTempo(2.0f);
|
region->registerTempo(2.0f);
|
||||||
|
|
||||||
currentRegion++;
|
++currentRegion;
|
||||||
}
|
}
|
||||||
|
const auto remainingRegions = std::distance(regions.begin(), lastRegion.base());
|
||||||
DBG("Removed " << regions.size() - std::distance(regions.begin(), lastRegion) - 1 << " out of " << regions.size() << " regions.");
|
DBG("Removing " << (regions.size() - remainingRegions) << " out of " << regions.size() << " regions");
|
||||||
regions.resize(std::distance(regions.begin(), lastRegion) + 1);
|
regions.resize(remainingRegions);
|
||||||
modificationTime = checkModificationTime();
|
modificationTime = checkModificationTime();
|
||||||
|
|
||||||
return parserReturned;
|
return parserReturned;
|
||||||
|
|
|
||||||
|
|
@ -95,10 +95,10 @@ void sfz::Voice::startVoice(Region* region, int delay, int number, uint8_t value
|
||||||
|
|
||||||
pitchBendEnvelope.setFunction([region](float pitchValue){
|
pitchBendEnvelope.setFunction([region](float pitchValue){
|
||||||
const auto normalizedBend = normalizeBend(pitchValue);
|
const auto normalizedBend = normalizeBend(pitchValue);
|
||||||
const auto bendInCents = normalizedBend > 0 ? normalizedBend * region->bendUp : -normalizedBend * region->bendDown;
|
const auto bendInCents = normalizedBend > 0.0f ? normalizedBend * region->bendUp : -normalizedBend * region->bendDown;
|
||||||
return centsFactor(bendInCents);
|
return centsFactor(bendInCents);
|
||||||
});
|
});
|
||||||
pitchBendEnvelope.reset(midiState.getPitchBend());
|
pitchBendEnvelope.reset(static_cast<float>(midiState.getPitchBend()));
|
||||||
|
|
||||||
sourcePosition = region->getOffset();
|
sourcePosition = region->getOffset();
|
||||||
triggerDelay = delay;
|
triggerDelay = delay;
|
||||||
|
|
@ -209,7 +209,7 @@ void sfz::Voice::registerPitchWheel(int delay, int pitch) noexcept
|
||||||
if (state == State::idle)
|
if (state == State::idle)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
pitchBendEnvelope.registerEvent(delay, 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 [[maybe_unused]], uint8_t aftertouch [[maybe_unused]]) noexcept
|
||||||
|
|
@ -246,13 +246,13 @@ void sfz::Voice::renderBlock(AudioSpan<float> buffer) noexcept
|
||||||
buffer.fill(0.0f);
|
buffer.fill(0.0f);
|
||||||
|
|
||||||
if (state == State::idle || region == nullptr) {
|
if (state == State::idle || region == nullptr) {
|
||||||
powerHistory.push(0.0);
|
powerHistory.push(0.0f);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto delay = min(static_cast<size_t>(initialDelay), buffer.getNumFrames());
|
const auto delay = min(static_cast<size_t>(initialDelay), buffer.getNumFrames());
|
||||||
auto delayed_buffer = buffer.subspan(delay);
|
auto delayed_buffer = buffer.subspan(delay);
|
||||||
initialDelay -= delay;
|
initialDelay -= static_cast<int>(delay);
|
||||||
|
|
||||||
if (region->isGenerator())
|
if (region->isGenerator())
|
||||||
fillWithGenerator(delayed_buffer);
|
fillWithGenerator(delayed_buffer);
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,8 @@
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "ADSREnvelope.h"
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
#include "ADSREnvelope.h"
|
||||||
#include "EventEnvelopes.h"
|
#include "EventEnvelopes.h"
|
||||||
#include "HistoricalBuffer.h"
|
#include "HistoricalBuffer.h"
|
||||||
#include "Region.h"
|
#include "Region.h"
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ int sfizz_get_num_curves(sfizz_synth_t* synth)
|
||||||
auto self = reinterpret_cast<sfz::Synth*>(synth);
|
auto self = reinterpret_cast<sfz::Synth*>(synth);
|
||||||
return self->getNumCurves();
|
return self->getNumCurves();
|
||||||
}
|
}
|
||||||
int sfizz_get_num_preloaded_samples(sfizz_synth_t* synth)
|
size_t sfizz_get_num_preloaded_samples(sfizz_synth_t* synth)
|
||||||
{
|
{
|
||||||
auto self = reinterpret_cast<sfz::Synth*>(synth);
|
auto self = reinterpret_cast<sfz::Synth*>(synth);
|
||||||
return self->getNumPreloadedSamples();
|
return self->getNumPreloadedSamples();
|
||||||
|
|
@ -220,7 +220,7 @@ char* sfizz_get_unknown_opcodes(sfizz_synth_t* synth)
|
||||||
{
|
{
|
||||||
auto self = reinterpret_cast<sfz::Synth*>(synth);
|
auto self = reinterpret_cast<sfz::Synth*>(synth);
|
||||||
const auto unknownOpcodes = self->getUnknownOpcodes();
|
const auto unknownOpcodes = self->getUnknownOpcodes();
|
||||||
int totalLength = 0;
|
size_t totalLength = 0;
|
||||||
for (auto& opcode: unknownOpcodes)
|
for (auto& opcode: unknownOpcodes)
|
||||||
totalLength += opcode.length() + 1;
|
totalLength += opcode.length() + 1;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ TEST_CASE("[ADSREnvelope] Basic state")
|
||||||
out = envelope.getNextValue();
|
out = envelope.getNextValue();
|
||||||
REQUIRE(approxEqual<float>(output, expected));
|
REQUIRE(approxEqual<float>(output, expected));
|
||||||
|
|
||||||
absl::c_fill(output, -1.0);
|
absl::c_fill(output, -1.0f);
|
||||||
envelope.getBlock(absl::MakeSpan(output));
|
envelope.getBlock(absl::MakeSpan(output));
|
||||||
REQUIRE(approxEqual<float>(output, expected));
|
REQUIRE(approxEqual<float>(output, expected));
|
||||||
}
|
}
|
||||||
|
|
@ -64,13 +64,13 @@ TEST_CASE("[ADSREnvelope] Attack")
|
||||||
sfz::ADSREnvelope<float> envelope;
|
sfz::ADSREnvelope<float> envelope;
|
||||||
envelope.reset(2, 0);
|
envelope.reset(2, 0);
|
||||||
std::array<float, 5> output;
|
std::array<float, 5> output;
|
||||||
std::array<float, 5> expected { 0.5, 1.0, 1.0, 1.0, 1.0 };
|
std::array<float, 5> expected { 0.5f, 1.0f, 1.0f, 1.0f, 1.0f };
|
||||||
for (auto& out : output)
|
for (auto& out : output)
|
||||||
out = envelope.getNextValue();
|
out = envelope.getNextValue();
|
||||||
REQUIRE(approxEqual<float>(output, expected));
|
REQUIRE(approxEqual<float>(output, expected));
|
||||||
|
|
||||||
envelope.reset(2, 0);
|
envelope.reset(2, 0);
|
||||||
absl::c_fill(output, -1.0);
|
absl::c_fill(output, -1.0f);
|
||||||
envelope.getBlock(absl::MakeSpan(output));
|
envelope.getBlock(absl::MakeSpan(output));
|
||||||
REQUIRE(approxEqual<float>(output, expected));
|
REQUIRE(approxEqual<float>(output, expected));
|
||||||
}
|
}
|
||||||
|
|
@ -80,13 +80,13 @@ TEST_CASE("[ADSREnvelope] Attack again")
|
||||||
sfz::ADSREnvelope<float> envelope;
|
sfz::ADSREnvelope<float> envelope;
|
||||||
envelope.reset(3, 0);
|
envelope.reset(3, 0);
|
||||||
std::array<float, 5> output;
|
std::array<float, 5> output;
|
||||||
std::array<float, 5> expected { 0.33333, 0.66667, 1.0, 1.0, 1.0 };
|
std::array<float, 5> expected { 0.33333f, 0.66667f, 1.0f, 1.0f, 1.0f };
|
||||||
for (auto& out : output)
|
for (auto& out : output)
|
||||||
out = envelope.getNextValue();
|
out = envelope.getNextValue();
|
||||||
REQUIRE(approxEqual<float>(output, expected));
|
REQUIRE(approxEqual<float>(output, expected));
|
||||||
|
|
||||||
envelope.reset(3, 0);
|
envelope.reset(3, 0);
|
||||||
absl::c_fill(output, -1.0);
|
absl::c_fill(output, -1.0f);
|
||||||
envelope.getBlock(absl::MakeSpan(output));
|
envelope.getBlock(absl::MakeSpan(output));
|
||||||
REQUIRE(approxEqual<float>(output, expected));
|
REQUIRE(approxEqual<float>(output, expected));
|
||||||
}
|
}
|
||||||
|
|
@ -97,14 +97,14 @@ TEST_CASE("[ADSREnvelope] Release")
|
||||||
envelope.reset(2, 4);
|
envelope.reset(2, 4);
|
||||||
envelope.startRelease(2);
|
envelope.startRelease(2);
|
||||||
std::array<float, 8> output;
|
std::array<float, 8> output;
|
||||||
std::array<float, 8> expected { 0.5, 1.0, 0.08409f, 0.00707f, 0.000594604f, 0.00005f, 0.0f, 0.0f };
|
std::array<float, 8> expected { 0.5f, 1.0f, 0.08409f, 0.00707f, 0.000594604f, 0.00005f, 0.0f, 0.0f };
|
||||||
for (auto& out : output)
|
for (auto& out : output)
|
||||||
out = envelope.getNextValue();
|
out = envelope.getNextValue();
|
||||||
REQUIRE(approxEqual<float>(output, expected));
|
REQUIRE(approxEqual<float>(output, expected));
|
||||||
|
|
||||||
envelope.reset(2, 4);
|
envelope.reset(2, 4);
|
||||||
envelope.startRelease(2);
|
envelope.startRelease(2);
|
||||||
absl::c_fill(output, -1.0);
|
absl::c_fill(output, -1.0f);
|
||||||
envelope.getBlock(absl::MakeSpan(output));
|
envelope.getBlock(absl::MakeSpan(output));
|
||||||
REQUIRE(approxEqual<float>(output, expected));
|
REQUIRE(approxEqual<float>(output, expected));
|
||||||
}
|
}
|
||||||
|
|
@ -115,14 +115,14 @@ TEST_CASE("[ADSREnvelope] Delay")
|
||||||
envelope.reset(2, 4, 1.0f, 2);
|
envelope.reset(2, 4, 1.0f, 2);
|
||||||
std::array<float, 10> output;
|
std::array<float, 10> output;
|
||||||
envelope.startRelease(4);
|
envelope.startRelease(4);
|
||||||
std::array<float, 10> expected { 0.0, 0.0, 0.5, 1.0, 0.08409f, 0.00707f, 0.000594604f, 0.00005f, 0.0f, 0.0f };
|
std::array<float, 10> expected { 0.0f, 0.0f, 0.5f, 1.0f, 0.08409f, 0.00707f, 0.000594604f, 0.00005f, 0.0f, 0.0f };
|
||||||
for (auto& out : output)
|
for (auto& out : output)
|
||||||
out = envelope.getNextValue();
|
out = envelope.getNextValue();
|
||||||
REQUIRE(approxEqual<float>(output, expected));
|
REQUIRE(approxEqual<float>(output, expected));
|
||||||
|
|
||||||
envelope.reset(2, 4, 1.0f, 2);
|
envelope.reset(2, 4, 1.0f, 2);
|
||||||
envelope.startRelease(4);
|
envelope.startRelease(4);
|
||||||
absl::c_fill(output, -1.0);
|
absl::c_fill(output, -1.0f);
|
||||||
envelope.getBlock(absl::MakeSpan(output));
|
envelope.getBlock(absl::MakeSpan(output));
|
||||||
REQUIRE(approxEqual<float>(output, expected));
|
REQUIRE(approxEqual<float>(output, expected));
|
||||||
}
|
}
|
||||||
|
|
@ -130,15 +130,15 @@ TEST_CASE("[ADSREnvelope] Delay")
|
||||||
TEST_CASE("[ADSREnvelope] Lower sustain")
|
TEST_CASE("[ADSREnvelope] Lower sustain")
|
||||||
{
|
{
|
||||||
sfz::ADSREnvelope<float> envelope;
|
sfz::ADSREnvelope<float> envelope;
|
||||||
envelope.reset(2, 4, 0.5, 2);
|
envelope.reset(2, 4, 0.5f, 2);
|
||||||
std::array<float, 10> output;
|
std::array<float, 10> output;
|
||||||
std::array<float, 10> expected { 0.0, 0.0, 0.5, 1.0, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5 };
|
std::array<float, 10> expected { 0.0f, 0.0f, 0.5f, 1.0f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f };
|
||||||
for (auto& out : output)
|
for (auto& out : output)
|
||||||
out = envelope.getNextValue();
|
out = envelope.getNextValue();
|
||||||
REQUIRE(approxEqual<float>(output, expected));
|
REQUIRE(approxEqual<float>(output, expected));
|
||||||
|
|
||||||
envelope.reset(2, 4, 0.5, 2);
|
envelope.reset(2, 4, 0.5, 2);
|
||||||
absl::c_fill(output, -1.0);
|
absl::c_fill(output, -1.0f);
|
||||||
envelope.getBlock(absl::MakeSpan(output));
|
envelope.getBlock(absl::MakeSpan(output));
|
||||||
REQUIRE(approxEqual<float>(output, expected));
|
REQUIRE(approxEqual<float>(output, expected));
|
||||||
}
|
}
|
||||||
|
|
@ -146,15 +146,15 @@ TEST_CASE("[ADSREnvelope] Lower sustain")
|
||||||
TEST_CASE("[ADSREnvelope] Decay")
|
TEST_CASE("[ADSREnvelope] Decay")
|
||||||
{
|
{
|
||||||
sfz::ADSREnvelope<float> envelope;
|
sfz::ADSREnvelope<float> envelope;
|
||||||
envelope.reset(2, 4, 0.5, 2, 2);
|
envelope.reset(2, 4, 0.5f, 2, 2);
|
||||||
std::array<float, 10> output;
|
std::array<float, 10> output;
|
||||||
std::array<float, 10> expected { 0.0, 0.0, 0.5, 1.0, 0.707107, 0.5, 0.5, 0.5, 0.5, 0.5 };
|
std::array<float, 10> expected { 0.0f, 0.0f, 0.5f, 1.0f, 0.707107f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5 };
|
||||||
for (auto& out : output)
|
for (auto& out : output)
|
||||||
out = envelope.getNextValue();
|
out = envelope.getNextValue();
|
||||||
REQUIRE(approxEqual<float>(output, expected));
|
REQUIRE(approxEqual<float>(output, expected));
|
||||||
|
|
||||||
envelope.reset(2, 4, 0.5, 2, 2);
|
envelope.reset(2, 4, 0.5f, 2, 2);
|
||||||
absl::c_fill(output, -1.0);
|
absl::c_fill(output, -1.0f);
|
||||||
envelope.getBlock(absl::MakeSpan(output));
|
envelope.getBlock(absl::MakeSpan(output));
|
||||||
REQUIRE(approxEqual<float>(output, expected));
|
REQUIRE(approxEqual<float>(output, expected));
|
||||||
}
|
}
|
||||||
|
|
@ -162,15 +162,15 @@ TEST_CASE("[ADSREnvelope] Decay")
|
||||||
TEST_CASE("[ADSREnvelope] Hold")
|
TEST_CASE("[ADSREnvelope] Hold")
|
||||||
{
|
{
|
||||||
sfz::ADSREnvelope<float> envelope;
|
sfz::ADSREnvelope<float> envelope;
|
||||||
envelope.reset(2, 4, 0.5, 2, 2, 2);
|
envelope.reset(2, 4, 0.5f, 2, 2, 2);
|
||||||
std::array<float, 12> output;
|
std::array<float, 12> output;
|
||||||
std::array<float, 12> expected { 0.0, 0.0, 0.5, 1.0, 1.0, 1.0, 0.707107, 0.5, 0.5, 0.5, 0.5, 0.5 };
|
std::array<float, 12> expected { 0.0f, 0.0f, 0.5f, 1.0f, 1.0f, 1.0f, 0.707107f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f };
|
||||||
for (auto& out : output)
|
for (auto& out : output)
|
||||||
out = envelope.getNextValue();
|
out = envelope.getNextValue();
|
||||||
REQUIRE(approxEqual<float>(output, expected));
|
REQUIRE(approxEqual<float>(output, expected));
|
||||||
|
|
||||||
envelope.reset(2, 4, 0.5, 2, 2, 2);
|
envelope.reset(2, 4, 0.5f, 2, 2, 2);
|
||||||
absl::c_fill(output, -1.0);
|
absl::c_fill(output, -1.0f);
|
||||||
envelope.getBlock(absl::MakeSpan(output));
|
envelope.getBlock(absl::MakeSpan(output));
|
||||||
REQUIRE(approxEqual<float>(output, expected));
|
REQUIRE(approxEqual<float>(output, expected));
|
||||||
}
|
}
|
||||||
|
|
@ -178,17 +178,17 @@ TEST_CASE("[ADSREnvelope] Hold")
|
||||||
TEST_CASE("[ADSREnvelope] Hold with release")
|
TEST_CASE("[ADSREnvelope] Hold with release")
|
||||||
{
|
{
|
||||||
sfz::ADSREnvelope<float> envelope;
|
sfz::ADSREnvelope<float> envelope;
|
||||||
envelope.reset(2, 4, 0.5, 2, 2, 2);
|
envelope.reset(2, 4, 0.5f, 2, 2, 2);
|
||||||
envelope.startRelease(8);
|
envelope.startRelease(8);
|
||||||
std::array<float, 14> output;
|
std::array<float, 14> output;
|
||||||
std::array<float, 14> expected { 0.0, 0.0, 0.5, 1.0, 1.0, 1.0, 0.707107, 0.5, 0.05, 0.005, 0.0005, 0.00005, 0.0, 0.0 };
|
std::array<float, 14> expected { 0.0f, 0.0f, 0.5f, 1.0f, 1.0f, 1.0f, 0.707107f, 0.5f, 0.05f, 0.005f, 0.0005f, 0.00005f, 0.0f, 0.0f };
|
||||||
for (auto& out : output)
|
for (auto& out : output)
|
||||||
out = envelope.getNextValue();
|
out = envelope.getNextValue();
|
||||||
|
|
||||||
REQUIRE(approxEqual<float>(output, expected));
|
REQUIRE(approxEqual<float>(output, expected));
|
||||||
envelope.reset(2, 4, 0.5, 2, 2, 2);
|
envelope.reset(2, 4, 0.5f, 2, 2, 2);
|
||||||
envelope.startRelease(8);
|
envelope.startRelease(8);
|
||||||
absl::c_fill(output, -1.0);
|
absl::c_fill(output, -1.0f);
|
||||||
envelope.getBlock(absl::MakeSpan(output));
|
envelope.getBlock(absl::MakeSpan(output));
|
||||||
REQUIRE(approxEqual<float>(output, expected));
|
REQUIRE(approxEqual<float>(output, expected));
|
||||||
}
|
}
|
||||||
|
|
@ -196,16 +196,16 @@ TEST_CASE("[ADSREnvelope] Hold with release")
|
||||||
TEST_CASE("[ADSREnvelope] Hold with release 2")
|
TEST_CASE("[ADSREnvelope] Hold with release 2")
|
||||||
{
|
{
|
||||||
sfz::ADSREnvelope<float> envelope;
|
sfz::ADSREnvelope<float> envelope;
|
||||||
envelope.reset(2, 4, 0.5, 2, 2, 2);
|
envelope.reset(2, 4, 0.5f, 2, 2, 2);
|
||||||
envelope.startRelease(4);
|
envelope.startRelease(4);
|
||||||
std::array<float, 14> output;
|
std::array<float, 14> output;
|
||||||
std::array<float, 14> expected { 0.0, 0.0, 0.5, 1.0, 0.08409, 0.00707, 0.000594604, 0.00005, 0.0, 0.0, 0.0, 0.0 };
|
std::array<float, 14> expected { 0.0f, 0.0f, 0.5f, 1.0f, 0.08409f, 0.00707f, 0.000594604f, 0.00005f, 0.0f, 0.0f, 0.0f, 0.0 };
|
||||||
for (auto& out : output)
|
for (auto& out : output)
|
||||||
out = envelope.getNextValue();
|
out = envelope.getNextValue();
|
||||||
REQUIRE(approxEqual<float>(output, expected));
|
REQUIRE(approxEqual<float>(output, expected));
|
||||||
envelope.reset(2, 4, 0.5, 2, 2, 2);
|
envelope.reset(2, 4, 0.5f, 2, 2, 2);
|
||||||
envelope.startRelease(4);
|
envelope.startRelease(4);
|
||||||
absl::c_fill(output, -1.0);
|
absl::c_fill(output, -1.0f);
|
||||||
envelope.getBlock(absl::MakeSpan(output));
|
envelope.getBlock(absl::MakeSpan(output));
|
||||||
REQUIRE(approxEqual<float>(output, expected));
|
REQUIRE(approxEqual<float>(output, expected));
|
||||||
}
|
}
|
||||||
|
|
@ -61,15 +61,15 @@ TEST_CASE("[AudioBuffer] Access")
|
||||||
const int size { 5 };
|
const int size { 5 };
|
||||||
sfz::AudioBuffer<float> buffer(2, size);
|
sfz::AudioBuffer<float> buffer(2, size);
|
||||||
for (size_t frameIdx = 0; frameIdx < buffer.getNumFrames(); ++frameIdx) {
|
for (size_t frameIdx = 0; frameIdx < buffer.getNumFrames(); ++frameIdx) {
|
||||||
buffer.getSample(0, frameIdx) = static_cast<double>(buffer.getNumFrames()) + frameIdx;
|
buffer.getSample(0, frameIdx) = static_cast<float>(buffer.getNumFrames()) + frameIdx;
|
||||||
buffer.getSample(1, frameIdx) = static_cast<double>(buffer.getNumFrames()) - frameIdx;
|
buffer.getSample(1, frameIdx) = static_cast<float>(buffer.getNumFrames()) - frameIdx;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t frameIdx = 0; frameIdx < buffer.getNumFrames(); ++frameIdx) {
|
for (size_t frameIdx = 0; frameIdx < buffer.getNumFrames(); ++frameIdx) {
|
||||||
REQUIRE(buffer.getSample(0, frameIdx) == static_cast<double>(buffer.getNumFrames()) + frameIdx);
|
REQUIRE(buffer.getSample(0, frameIdx) == static_cast<float>(buffer.getNumFrames()) + frameIdx);
|
||||||
REQUIRE(buffer(0, frameIdx) == static_cast<double>(buffer.getNumFrames()) + frameIdx);
|
REQUIRE(buffer(0, frameIdx) == static_cast<float>(buffer.getNumFrames()) + frameIdx);
|
||||||
REQUIRE(buffer.getSample(1, frameIdx) == static_cast<double>(buffer.getNumFrames()) - frameIdx);
|
REQUIRE(buffer.getSample(1, frameIdx) == static_cast<float>(buffer.getNumFrames()) - frameIdx);
|
||||||
REQUIRE(buffer(1, frameIdx) == static_cast<double>(buffer.getNumFrames()) - frameIdx);
|
REQUIRE(buffer(1, frameIdx) == static_cast<float>(buffer.getNumFrames()) - frameIdx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -98,5 +98,5 @@ TEST_CASE("[AudioSpan] Constructions")
|
||||||
sfz::AudioSpan<float> manualSpan { { buffer.channelWriter(0), buffer.channelWriter(1) }, buffer.getNumFrames() };
|
sfz::AudioSpan<float> manualSpan { { buffer.channelWriter(0), buffer.channelWriter(1) }, buffer.getNumFrames() };
|
||||||
sfz::AudioSpan<const float> manualConstSpan { { buffer.channelReader(0), buffer.channelReader(1) }, buffer.getNumFrames() };
|
sfz::AudioSpan<const float> manualConstSpan { { buffer.channelReader(0), buffer.channelReader(1) }, buffer.getNumFrames() };
|
||||||
sfz::AudioSpan<float> manualSpan2 { {buffer.getSpan(0), buffer.getSpan(1) } };
|
sfz::AudioSpan<float> manualSpan2 { {buffer.getSpan(0), buffer.getSpan(1) } };
|
||||||
sfz::AudioSpan<const float> manualConstSpan2 { {buffer.getConstSpan(0), buffer.getConstSpan(1) } };
|
sfz::AudioSpan<const float> manualConstSpan2 { { buffer.getConstSpan(0), buffer.getConstSpan(1) } };
|
||||||
}
|
}
|
||||||
|
|
@ -28,17 +28,14 @@ set(SFIZZ_TEST_SOURCES
|
||||||
|
|
||||||
find_package(ZLIB REQUIRED)
|
find_package(ZLIB REQUIRED)
|
||||||
add_library(cnpy cnpy/cnpy.cpp)
|
add_library(cnpy cnpy/cnpy.cpp)
|
||||||
target_link_libraries(cnpy PRIVATE ZLIB::ZLIB)
|
target_link_libraries(cnpy PUBLIC ZLIB::ZLIB)
|
||||||
target_include_directories(cnpy PUBLIC cnpy)
|
target_include_directories(cnpy PUBLIC cnpy)
|
||||||
|
|
||||||
add_executable(sfizz_tests ${SFIZZ_TEST_SOURCES})
|
add_executable(sfizz_tests ${SFIZZ_TEST_SOURCES})
|
||||||
target_link_libraries(sfizz_tests PRIVATE sfizz::sfizz)
|
target_link_libraries(sfizz_tests PRIVATE sfizz::sfizz)
|
||||||
|
sfizz_link_libsndfile(sfizz_tests)
|
||||||
|
|
||||||
# Per OS properties
|
target_link_libraries(sfizz_tests PRIVATE absl::strings absl::str_format absl::flat_hash_map cnpy absl::span absl::algorithm)
|
||||||
if(UNIX)
|
|
||||||
target_link_libraries(sfizz_tests PRIVATE atomic)
|
|
||||||
endif(UNIX)
|
|
||||||
target_link_libraries(sfizz_tests PRIVATE absl::strings absl::str_format absl::flat_hash_map sndfile cnpy absl::span absl::algorithm)
|
|
||||||
target_include_directories(sfizz_tests SYSTEM PRIVATE sources)
|
target_include_directories(sfizz_tests SYSTEM PRIVATE sources)
|
||||||
sfizz_enable_lto_if_needed(sfizz_tests)
|
sfizz_enable_lto_if_needed(sfizz_tests)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ TEST_CASE("[EGDescription] Attack range")
|
||||||
sfz::EGDescription eg;
|
sfz::EGDescription eg;
|
||||||
sfz::SfzCCArray ccArray { 0 };
|
sfz::SfzCCArray ccArray { 0 };
|
||||||
eg.attack = 1;
|
eg.attack = 1;
|
||||||
eg.vel2attack = -1.27;
|
eg.vel2attack = -1.27f;
|
||||||
eg.ccAttack = { 63, 1.27f };
|
eg.ccAttack = { 63, 1.27f };
|
||||||
REQUIRE( eg.getAttack(ccArray, 0) == 1.0f );
|
REQUIRE( eg.getAttack(ccArray, 0) == 1.0f );
|
||||||
REQUIRE( eg.getAttack(ccArray, 127) == 0.0f );
|
REQUIRE( eg.getAttack(ccArray, 127) == 0.0f );
|
||||||
|
|
@ -47,7 +47,7 @@ TEST_CASE("[EGDescription] Delay range")
|
||||||
sfz::EGDescription eg;
|
sfz::EGDescription eg;
|
||||||
sfz::SfzCCArray ccArray { 0 };
|
sfz::SfzCCArray ccArray { 0 };
|
||||||
eg.delay = 1;
|
eg.delay = 1;
|
||||||
eg.vel2delay = -1.27;
|
eg.vel2delay = -1.27f;
|
||||||
eg.ccDelay = { 63, 1.27f };
|
eg.ccDelay = { 63, 1.27f };
|
||||||
REQUIRE( eg.getDelay(ccArray, 0) == 1.0f );
|
REQUIRE( eg.getDelay(ccArray, 0) == 1.0f );
|
||||||
REQUIRE( eg.getDelay(ccArray, 127) == 0.0f );
|
REQUIRE( eg.getDelay(ccArray, 127) == 0.0f );
|
||||||
|
|
@ -79,7 +79,7 @@ TEST_CASE("[EGDescription] Release range")
|
||||||
sfz::EGDescription eg;
|
sfz::EGDescription eg;
|
||||||
sfz::SfzCCArray ccArray { 0 };
|
sfz::SfzCCArray ccArray { 0 };
|
||||||
eg.release = 1;
|
eg.release = 1;
|
||||||
eg.vel2release = -1.27;
|
eg.vel2release = -1.27f;
|
||||||
eg.ccRelease = { 63, 1.27f };
|
eg.ccRelease = { 63, 1.27f };
|
||||||
REQUIRE( eg.getRelease(ccArray, 0) == 1.0f );
|
REQUIRE( eg.getRelease(ccArray, 0) == 1.0f );
|
||||||
REQUIRE( eg.getRelease(ccArray, 127) == 0.0f );
|
REQUIRE( eg.getRelease(ccArray, 127) == 0.0f );
|
||||||
|
|
@ -95,7 +95,7 @@ TEST_CASE("[EGDescription] Hold range")
|
||||||
sfz::EGDescription eg;
|
sfz::EGDescription eg;
|
||||||
sfz::SfzCCArray ccArray { 0 };
|
sfz::SfzCCArray ccArray { 0 };
|
||||||
eg.hold = 1;
|
eg.hold = 1;
|
||||||
eg.vel2hold = -1.27;
|
eg.vel2hold = -1.27f;
|
||||||
eg.ccHold = { 63, 1.27f };
|
eg.ccHold = { 63, 1.27f };
|
||||||
REQUIRE( eg.getHold(ccArray, 0) == 1.0f );
|
REQUIRE( eg.getHold(ccArray, 0) == 1.0f );
|
||||||
REQUIRE( eg.getHold(ccArray, 127) == 0.0f );
|
REQUIRE( eg.getHold(ccArray, 127) == 0.0f );
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ TEST_CASE("[LinearEnvelope] Basic state")
|
||||||
{
|
{
|
||||||
sfz::LinearEnvelope<float> envelope;
|
sfz::LinearEnvelope<float> envelope;
|
||||||
std::array<float, 5> output;
|
std::array<float, 5> output;
|
||||||
std::array<float, 5> expected { 0.0, 0.0, 0.0, 0.0, 0.0 };
|
std::array<float, 5> expected { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f };
|
||||||
envelope.getBlock(absl::MakeSpan(output));
|
envelope.getBlock(absl::MakeSpan(output));
|
||||||
REQUIRE(output == expected);
|
REQUIRE(output == expected);
|
||||||
}
|
}
|
||||||
|
|
@ -59,9 +59,9 @@ TEST_CASE("[LinearEnvelope] Basic state")
|
||||||
TEST_CASE("[LinearEnvelope] Basic event")
|
TEST_CASE("[LinearEnvelope] Basic event")
|
||||||
{
|
{
|
||||||
sfz::LinearEnvelope<float> envelope;
|
sfz::LinearEnvelope<float> envelope;
|
||||||
envelope.registerEvent(4, 1.0);
|
envelope.registerEvent(4, 1.0f);
|
||||||
std::array<float, 8> output;
|
std::array<float, 8> output;
|
||||||
std::array<float, 8> expected { 0.25, 0.5, 0.75, 1.0, 1.0, 1.0, 1.0, 1.0 };
|
std::array<float, 8> expected { 0.25f, 0.5f, 0.75f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f };
|
||||||
envelope.getBlock(absl::MakeSpan(output));
|
envelope.getBlock(absl::MakeSpan(output));
|
||||||
REQUIRE(output == expected);
|
REQUIRE(output == expected);
|
||||||
}
|
}
|
||||||
|
|
@ -69,10 +69,10 @@ TEST_CASE("[LinearEnvelope] Basic event")
|
||||||
TEST_CASE("[LinearEnvelope] 2 events, close")
|
TEST_CASE("[LinearEnvelope] 2 events, close")
|
||||||
{
|
{
|
||||||
sfz::LinearEnvelope<float> envelope;
|
sfz::LinearEnvelope<float> envelope;
|
||||||
envelope.registerEvent(4, 1.0);
|
envelope.registerEvent(4, 1.0f);
|
||||||
envelope.registerEvent(5, 2.0);
|
envelope.registerEvent(5, 2.0f);
|
||||||
std::array<float, 8> output;
|
std::array<float, 8> output;
|
||||||
std::array<float, 8> expected { 0.25, 0.5, 0.75, 1.0, 2.0, 2.0, 2.0, 2.0 };
|
std::array<float, 8> expected { 0.25f, 0.5f, 0.75f, 1.0f, 2.0f, 2.0f, 2.0f, 2.0f };
|
||||||
envelope.getBlock(absl::MakeSpan(output));
|
envelope.getBlock(absl::MakeSpan(output));
|
||||||
REQUIRE(output == expected);
|
REQUIRE(output == expected);
|
||||||
}
|
}
|
||||||
|
|
@ -80,10 +80,10 @@ TEST_CASE("[LinearEnvelope] 2 events, close")
|
||||||
TEST_CASE("[LinearEnvelope] 2 events, far")
|
TEST_CASE("[LinearEnvelope] 2 events, far")
|
||||||
{
|
{
|
||||||
sfz::LinearEnvelope<float> envelope;
|
sfz::LinearEnvelope<float> envelope;
|
||||||
envelope.registerEvent(2, 1.0);
|
envelope.registerEvent(2, 1.0f);
|
||||||
envelope.registerEvent(6, 2.0);
|
envelope.registerEvent(6, 2.0f);
|
||||||
std::array<float, 8> output;
|
std::array<float, 8> output;
|
||||||
std::array<float, 8> expected { 0.5, 1, 1.25, 1.5, 1.75, 2.0, 2.0, 2.0 };
|
std::array<float, 8> expected { 0.5f, 1.0f, 1.25f, 1.5f, 1.75f, 2.0f, 2.0f, 2.0f };
|
||||||
envelope.getBlock(absl::MakeSpan(output));
|
envelope.getBlock(absl::MakeSpan(output));
|
||||||
REQUIRE(output == expected);
|
REQUIRE(output == expected);
|
||||||
}
|
}
|
||||||
|
|
@ -91,10 +91,10 @@ TEST_CASE("[LinearEnvelope] 2 events, far")
|
||||||
TEST_CASE("[LinearEnvelope] 2 events, reversed")
|
TEST_CASE("[LinearEnvelope] 2 events, reversed")
|
||||||
{
|
{
|
||||||
sfz::LinearEnvelope<float> envelope;
|
sfz::LinearEnvelope<float> envelope;
|
||||||
envelope.registerEvent(6, 2.0);
|
envelope.registerEvent(6, 2.0f);
|
||||||
envelope.registerEvent(2, 1.0);
|
envelope.registerEvent(2, 1.0f);
|
||||||
std::array<float, 8> output;
|
std::array<float, 8> output;
|
||||||
std::array<float, 8> expected { 0.5, 1, 1.25, 1.5, 1.75, 2.0, 2.0, 2.0 };
|
std::array<float, 8> expected { 0.5f, 1.0f, 1.25f, 1.5f, 1.75f, 2.0f, 2.0f, 2.0f };
|
||||||
envelope.getBlock(absl::MakeSpan(output));
|
envelope.getBlock(absl::MakeSpan(output));
|
||||||
REQUIRE(output == expected);
|
REQUIRE(output == expected);
|
||||||
}
|
}
|
||||||
|
|
@ -102,11 +102,11 @@ TEST_CASE("[LinearEnvelope] 2 events, reversed")
|
||||||
TEST_CASE("[LinearEnvelope] 3 events, overlapping")
|
TEST_CASE("[LinearEnvelope] 3 events, overlapping")
|
||||||
{
|
{
|
||||||
sfz::LinearEnvelope<float> envelope;
|
sfz::LinearEnvelope<float> envelope;
|
||||||
envelope.registerEvent(2, 1.0);
|
envelope.registerEvent(2, 1.0f);
|
||||||
envelope.registerEvent(6, 2.0);
|
envelope.registerEvent(6, 2.0f);
|
||||||
envelope.registerEvent(6, 3.0);
|
envelope.registerEvent(6, 3.0f);
|
||||||
std::array<float, 8> output;
|
std::array<float, 8> output;
|
||||||
std::array<float, 8> expected { 0.5, 1, 1.25, 1.5, 1.75, 2.0, 3.0, 3.0 };
|
std::array<float, 8> expected { 0.5f, 1.0f, 1.25f, 1.5f, 1.75f, 2.0f, 3.0f, 3.0f };
|
||||||
envelope.getBlock(absl::MakeSpan(output));
|
envelope.getBlock(absl::MakeSpan(output));
|
||||||
REQUIRE(output == expected);
|
REQUIRE(output == expected);
|
||||||
}
|
}
|
||||||
|
|
@ -114,11 +114,11 @@ TEST_CASE("[LinearEnvelope] 3 events, overlapping")
|
||||||
TEST_CASE("[LinearEnvelope] 3 events, out of block")
|
TEST_CASE("[LinearEnvelope] 3 events, out of block")
|
||||||
{
|
{
|
||||||
sfz::LinearEnvelope<float> envelope;
|
sfz::LinearEnvelope<float> envelope;
|
||||||
envelope.registerEvent(2, 1.0);
|
envelope.registerEvent(2, 1.0f);
|
||||||
envelope.registerEvent(6, 2.0);
|
envelope.registerEvent(6, 2.0f);
|
||||||
envelope.registerEvent(10, 3.0);
|
envelope.registerEvent(10, 3.0f);
|
||||||
std::array<float, 8> output;
|
std::array<float, 8> output;
|
||||||
std::array<float, 8> expected { 0.5, 1, 1.25, 1.5, 1.75, 2.0, 2.5, 3.0 };
|
std::array<float, 8> expected { 0.5f, 1.0f, 1.25f, 1.5f, 1.75f, 2.0f, 2.5f, 3.0f };
|
||||||
envelope.getBlock(absl::MakeSpan(output));
|
envelope.getBlock(absl::MakeSpan(output));
|
||||||
REQUIRE(output == expected);
|
REQUIRE(output == expected);
|
||||||
}
|
}
|
||||||
|
|
@ -126,11 +126,11 @@ TEST_CASE("[LinearEnvelope] 3 events, out of block")
|
||||||
TEST_CASE("[LinearEnvelope] 3 events, out of block, with another block call")
|
TEST_CASE("[LinearEnvelope] 3 events, out of block, with another block call")
|
||||||
{
|
{
|
||||||
sfz::LinearEnvelope<float> envelope;
|
sfz::LinearEnvelope<float> envelope;
|
||||||
envelope.registerEvent(2, 1.0);
|
envelope.registerEvent(2, 1.0f);
|
||||||
envelope.registerEvent(6, 2.0);
|
envelope.registerEvent(6, 2.0f);
|
||||||
envelope.registerEvent(10, 3.0);
|
envelope.registerEvent(10, 3.0f);
|
||||||
std::array<float, 8> output;
|
std::array<float, 8> output;
|
||||||
std::array<float, 8> expected { 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0 };
|
std::array<float, 8> expected { 3.0f, 3.0f, 3.0f, 3.0f, 3.0f, 3.0f, 3.0f, 3.0f };
|
||||||
envelope.getBlock(absl::MakeSpan(output));
|
envelope.getBlock(absl::MakeSpan(output));
|
||||||
envelope.getBlock(absl::MakeSpan(output));
|
envelope.getBlock(absl::MakeSpan(output));
|
||||||
REQUIRE(output == expected);
|
REQUIRE(output == expected);
|
||||||
|
|
@ -139,10 +139,10 @@ TEST_CASE("[LinearEnvelope] 3 events, out of block, with another block call")
|
||||||
TEST_CASE("[LinearEnvelope] 2 events, with another block call")
|
TEST_CASE("[LinearEnvelope] 2 events, with another block call")
|
||||||
{
|
{
|
||||||
sfz::LinearEnvelope<float> envelope;
|
sfz::LinearEnvelope<float> envelope;
|
||||||
envelope.registerEvent(2, 1.0);
|
envelope.registerEvent(2, 1.0f);
|
||||||
envelope.registerEvent(6, 2.0);
|
envelope.registerEvent(6, 2.0f);
|
||||||
std::array<float, 8> output;
|
std::array<float, 8> output;
|
||||||
std::array<float, 8> expected { 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0 };
|
std::array<float, 8> expected { 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f };
|
||||||
envelope.getBlock(absl::MakeSpan(output));
|
envelope.getBlock(absl::MakeSpan(output));
|
||||||
envelope.getBlock(absl::MakeSpan(output));
|
envelope.getBlock(absl::MakeSpan(output));
|
||||||
REQUIRE(output == expected);
|
REQUIRE(output == expected);
|
||||||
|
|
@ -152,10 +152,10 @@ TEST_CASE("[LinearEnvelope] 2 events, function")
|
||||||
{
|
{
|
||||||
sfz::LinearEnvelope<float> envelope;
|
sfz::LinearEnvelope<float> envelope;
|
||||||
envelope.setFunction([](auto x) { return 2 * x; });
|
envelope.setFunction([](auto x) { return 2 * x; });
|
||||||
envelope.registerEvent(2, 1.0);
|
envelope.registerEvent(2, 1.0f);
|
||||||
envelope.registerEvent(6, 2.0);
|
envelope.registerEvent(6, 2.0f);
|
||||||
std::array<float, 8> output;
|
std::array<float, 8> output;
|
||||||
std::array<float, 8> expected { 1, 2, 2.5, 3, 3.5, 4.0, 4.0, 4.0 };
|
std::array<float, 8> expected { 1.0f, 2.0f, 2.5f, 3.0f, 3.5f, 4.0f, 4.0f, 4.0f };
|
||||||
envelope.getBlock(absl::MakeSpan(output));
|
envelope.getBlock(absl::MakeSpan(output));
|
||||||
REQUIRE(output == expected);
|
REQUIRE(output == expected);
|
||||||
}
|
}
|
||||||
|
|
@ -163,10 +163,10 @@ TEST_CASE("[LinearEnvelope] 2 events, function")
|
||||||
TEST_CASE("[LinearEnvelope] Get quantized")
|
TEST_CASE("[LinearEnvelope] Get quantized")
|
||||||
{
|
{
|
||||||
sfz::LinearEnvelope<float> envelope;
|
sfz::LinearEnvelope<float> envelope;
|
||||||
envelope.registerEvent(2, 1.0);
|
envelope.registerEvent(2, 1.0f);
|
||||||
envelope.registerEvent(6, 2.0);
|
envelope.registerEvent(6, 2.0f);
|
||||||
std::array<float, 8> output;
|
std::array<float, 8> output;
|
||||||
std::array<float, 8> expected { 0.0, 1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0 };
|
std::array<float, 8> expected { 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 2.0f, 2.0f, 2.0f };
|
||||||
envelope.getQuantizedBlock(absl::MakeSpan(output), 1.0f);
|
envelope.getQuantizedBlock(absl::MakeSpan(output), 1.0f);
|
||||||
REQUIRE(output == expected);
|
REQUIRE(output == expected);
|
||||||
}
|
}
|
||||||
|
|
@ -174,10 +174,10 @@ TEST_CASE("[LinearEnvelope] Get quantized")
|
||||||
TEST_CASE("[LinearEnvelope] Get quantized with unquantized targets")
|
TEST_CASE("[LinearEnvelope] Get quantized with unquantized targets")
|
||||||
{
|
{
|
||||||
sfz::LinearEnvelope<float> envelope;
|
sfz::LinearEnvelope<float> envelope;
|
||||||
envelope.registerEvent(2, 1.1);
|
envelope.registerEvent(2, 1.1f);
|
||||||
envelope.registerEvent(6, 1.9);
|
envelope.registerEvent(6, 1.9f);
|
||||||
std::array<float, 8> output;
|
std::array<float, 8> output;
|
||||||
std::array<float, 8> expected { 0.0, 1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0 };
|
std::array<float, 8> expected { 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 2.0f, 2.0f, 2.0f };
|
||||||
envelope.getQuantizedBlock(absl::MakeSpan(output), 1.0f);
|
envelope.getQuantizedBlock(absl::MakeSpan(output), 1.0f);
|
||||||
REQUIRE(output == expected);
|
REQUIRE(output == expected);
|
||||||
}
|
}
|
||||||
|
|
@ -185,10 +185,10 @@ TEST_CASE("[LinearEnvelope] Get quantized with unquantized targets")
|
||||||
TEST_CASE("[LinearEnvelope] Get quantized with 2 steps")
|
TEST_CASE("[LinearEnvelope] Get quantized with 2 steps")
|
||||||
{
|
{
|
||||||
sfz::LinearEnvelope<float> envelope;
|
sfz::LinearEnvelope<float> envelope;
|
||||||
envelope.registerEvent(2, 1.0);
|
envelope.registerEvent(2, 1.0f);
|
||||||
envelope.registerEvent(6, 3.0);
|
envelope.registerEvent(6, 3.0f);
|
||||||
std::array<float, 8> output;
|
std::array<float, 8> output;
|
||||||
std::array<float, 8> expected { 0.0, 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 3.0 };
|
std::array<float, 8> expected { 0.0f, 1.0f, 1.0f, 2.0f, 2.0f, 3.0f, 3.0f, 3.0f };
|
||||||
envelope.getQuantizedBlock(absl::MakeSpan(output), 1.0f);
|
envelope.getQuantizedBlock(absl::MakeSpan(output), 1.0f);
|
||||||
REQUIRE(output == expected);
|
REQUIRE(output == expected);
|
||||||
}
|
}
|
||||||
|
|
@ -196,12 +196,12 @@ TEST_CASE("[LinearEnvelope] Get quantized with 2 steps")
|
||||||
TEST_CASE("[LinearEnvelope] Get quantized with 2 steps and an unquantized out of block step")
|
TEST_CASE("[LinearEnvelope] Get quantized with 2 steps and an unquantized out of block step")
|
||||||
{
|
{
|
||||||
sfz::LinearEnvelope<float> envelope;
|
sfz::LinearEnvelope<float> envelope;
|
||||||
envelope.registerEvent(2, 1.0);
|
envelope.registerEvent(2, 1.0f);
|
||||||
envelope.registerEvent(6, 3.0);
|
envelope.registerEvent(6, 3.0f);
|
||||||
envelope.registerEvent(10, 4.2);
|
envelope.registerEvent(10, 4.2f);
|
||||||
std::array<float, 8> output;
|
std::array<float, 8> output;
|
||||||
std::array<float, 8> expected { 0.0, 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 3.0 };
|
std::array<float, 8> expected { 0.0f, 1.0f, 1.0f, 2.0f, 2.0f, 3.0f, 3.0f, 3.0f };
|
||||||
std::array<float, 8> expected2 { 4.0, 4.0, 4.0,4.0, 4.0, 4.0, 4.0, 4.0 };
|
std::array<float, 8> expected2 { 4.0f, 4.0f, 4.0f,4.0f, 4.0f, 4.0f, 4.0f, 4.0f };
|
||||||
envelope.getQuantizedBlock(absl::MakeSpan(output), 1.0f);
|
envelope.getQuantizedBlock(absl::MakeSpan(output), 1.0f);
|
||||||
REQUIRE(output == expected);
|
REQUIRE(output == expected);
|
||||||
envelope.getQuantizedBlock(absl::MakeSpan(output), 1.0f);
|
envelope.getQuantizedBlock(absl::MakeSpan(output), 1.0f);
|
||||||
|
|
@ -212,11 +212,11 @@ TEST_CASE("[LinearEnvelope] Get quantized with 2 steps and an unquantized out of
|
||||||
TEST_CASE("[LinearEnvelope] Going down quantized with 2 steps")
|
TEST_CASE("[LinearEnvelope] Going down quantized with 2 steps")
|
||||||
{
|
{
|
||||||
sfz::LinearEnvelope<float> envelope;
|
sfz::LinearEnvelope<float> envelope;
|
||||||
envelope.reset(3.0);
|
envelope.reset(3.0f);
|
||||||
envelope.registerEvent(2, 2.0);
|
envelope.registerEvent(2, 2.0f);
|
||||||
envelope.registerEvent(6, 0.0);
|
envelope.registerEvent(6, 0.0f);
|
||||||
std::array<float, 8> output;
|
std::array<float, 8> output;
|
||||||
std::array<float, 8> expected { 3.0, 2.0, 2.0, 1.0, 1.0, 0.0, 0.0, 0.0 };
|
std::array<float, 8> expected { 3.0f, 2.0f, 2.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f };
|
||||||
envelope.getQuantizedBlock(absl::MakeSpan(output), 1.0f);
|
envelope.getQuantizedBlock(absl::MakeSpan(output), 1.0f);
|
||||||
REQUIRE(output == expected);
|
REQUIRE(output == expected);
|
||||||
}
|
}
|
||||||
|
|
@ -224,11 +224,11 @@ TEST_CASE("[LinearEnvelope] Going down quantized with 2 steps")
|
||||||
TEST_CASE("[LinearEnvelope] Get quantized with 2 steps and starting unquantized")
|
TEST_CASE("[LinearEnvelope] Get quantized with 2 steps and starting unquantized")
|
||||||
{
|
{
|
||||||
sfz::LinearEnvelope<float> envelope;
|
sfz::LinearEnvelope<float> envelope;
|
||||||
envelope.reset(0.1);
|
envelope.reset(0.1f);
|
||||||
envelope.registerEvent(3, 1.0);
|
envelope.registerEvent(3, 1.0f);
|
||||||
envelope.registerEvent(7, 3.0);
|
envelope.registerEvent(7, 3.0f);
|
||||||
std::array<float, 8> output;
|
std::array<float, 8> output;
|
||||||
std::array<float, 8> expected { 0.1, 0.1, 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 };
|
std::array<float, 8> expected { 0.1f, 0.1f, 1.0f, 1.0f, 2.0f, 2.0f, 3.0f, 3.0f };
|
||||||
envelope.getQuantizedBlock(absl::MakeSpan(output), 1.0f);
|
envelope.getQuantizedBlock(absl::MakeSpan(output), 1.0f);
|
||||||
REQUIRE(output == expected);
|
REQUIRE(output == expected);
|
||||||
}
|
}
|
||||||
|
|
@ -237,11 +237,11 @@ TEST_CASE("[LinearEnvelope] Get quantized with 2 steps and starting unquantized"
|
||||||
TEST_CASE("[LinearEnvelope] Going down quantized with 2 steps and starting unquantized")
|
TEST_CASE("[LinearEnvelope] Going down quantized with 2 steps and starting unquantized")
|
||||||
{
|
{
|
||||||
sfz::LinearEnvelope<float> envelope;
|
sfz::LinearEnvelope<float> envelope;
|
||||||
envelope.reset(3.6);
|
envelope.reset(3.6f);
|
||||||
envelope.registerEvent(4, 1.0);
|
envelope.registerEvent(4, 1.0f);
|
||||||
envelope.registerEvent(7, 0.0);
|
envelope.registerEvent(7, 0.0);
|
||||||
std::array<float, 8> output;
|
std::array<float, 8> output;
|
||||||
std::array<float, 8> expected { 3.6, 3.0, 2.0, 2.0, 1.0, 1.0, 0.0, 0.0 };
|
std::array<float, 8> expected { 3.6f, 3.0f, 2.0f, 2.0f, 1.0f, 1.0f, 0.0f, 0.0f };
|
||||||
envelope.getQuantizedBlock(absl::MakeSpan(output), 1.0f);
|
envelope.getQuantizedBlock(absl::MakeSpan(output), 1.0f);
|
||||||
REQUIRE(output == expected);
|
REQUIRE(output == expected);
|
||||||
}
|
}
|
||||||
|
|
@ -249,10 +249,10 @@ TEST_CASE("[LinearEnvelope] Going down quantized with 2 steps and starting unqua
|
||||||
TEST_CASE("[LinearEnvelope] Get quantized with unclean events")
|
TEST_CASE("[LinearEnvelope] Get quantized with unclean events")
|
||||||
{
|
{
|
||||||
sfz::LinearEnvelope<float> envelope;
|
sfz::LinearEnvelope<float> envelope;
|
||||||
envelope.registerEvent(2, 1.2);
|
envelope.registerEvent(2, 1.2f);
|
||||||
envelope.registerEvent(6, 2.5);
|
envelope.registerEvent(6, 2.5f);
|
||||||
std::array<float, 8> output;
|
std::array<float, 8> output;
|
||||||
std::array<float, 8> expected { 0.0, 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 3.0 };
|
std::array<float, 8> expected { 0.0f, 1.0f, 1.0f, 2.0f, 2.0f, 3.0f, 3.0f, 3.0f };
|
||||||
envelope.getQuantizedBlock(absl::MakeSpan(output), 1.0f);
|
envelope.getQuantizedBlock(absl::MakeSpan(output), 1.0f);
|
||||||
REQUIRE(output == expected);
|
REQUIRE(output == expected);
|
||||||
}
|
}
|
||||||
|
|
@ -260,12 +260,12 @@ TEST_CASE("[LinearEnvelope] Get quantized with unclean events")
|
||||||
TEST_CASE("[LinearEnvelope] Get quantized 3 events, one out of block")
|
TEST_CASE("[LinearEnvelope] Get quantized 3 events, one out of block")
|
||||||
{
|
{
|
||||||
sfz::LinearEnvelope<float> envelope;
|
sfz::LinearEnvelope<float> envelope;
|
||||||
envelope.registerEvent(2, 1.0);
|
envelope.registerEvent(2, 1.0f);
|
||||||
envelope.registerEvent(6, 2.0);
|
envelope.registerEvent(6, 2.0f);
|
||||||
envelope.registerEvent(10, 3.0);
|
envelope.registerEvent(10, 3.0f);
|
||||||
std::array<float, 8> output;
|
std::array<float, 8> output;
|
||||||
std::array<float, 8> expected { 0.0, 1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0 };
|
std::array<float, 8> expected { 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 2.0f, 2.0f, 2.0f };
|
||||||
std::array<float, 8> expected2 { 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0 };
|
std::array<float, 8> expected2 { 3.0f, 3.0f, 3.0f, 3.0f, 3.0f, 3.0f, 3.0f, 3.0f };
|
||||||
envelope.getQuantizedBlock(absl::MakeSpan(output), 1.0f);
|
envelope.getQuantizedBlock(absl::MakeSpan(output), 1.0f);
|
||||||
REQUIRE(output == expected);
|
REQUIRE(output == expected);
|
||||||
envelope.getQuantizedBlock(absl::MakeSpan(output), 1.0f);
|
envelope.getQuantizedBlock(absl::MakeSpan(output), 1.0f);
|
||||||
|
|
@ -277,7 +277,7 @@ TEST_CASE("[MultiplicativeEnvelope] Basic state")
|
||||||
{
|
{
|
||||||
sfz::MultiplicativeEnvelope<float> envelope;
|
sfz::MultiplicativeEnvelope<float> envelope;
|
||||||
std::array<float, 5> output;
|
std::array<float, 5> output;
|
||||||
std::array<float, 5> expected { 1.0, 1.0, 1.0, 1.0, 1.0 };
|
std::array<float, 5> expected { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f };
|
||||||
envelope.getBlock(absl::MakeSpan(output));
|
envelope.getBlock(absl::MakeSpan(output));
|
||||||
REQUIRE(output == expected);
|
REQUIRE(output == expected);
|
||||||
}
|
}
|
||||||
|
|
@ -285,9 +285,9 @@ TEST_CASE("[MultiplicativeEnvelope] Basic state")
|
||||||
TEST_CASE("[MultiplicativeEnvelope] Basic event")
|
TEST_CASE("[MultiplicativeEnvelope] Basic event")
|
||||||
{
|
{
|
||||||
sfz::MultiplicativeEnvelope<float> envelope;
|
sfz::MultiplicativeEnvelope<float> envelope;
|
||||||
envelope.registerEvent(4, 2.0);
|
envelope.registerEvent(4, 2.0f);
|
||||||
std::array<float, 8> output;
|
std::array<float, 8> output;
|
||||||
std::array<float, 8> expected { 1.1892, 1.4142, 1.68176, 2.0, 2.0, 2.0, 2.0, 2.0 };
|
std::array<float, 8> expected { 1.1892f, 1.4142f, 1.68176f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f };
|
||||||
envelope.getBlock(absl::MakeSpan(output));
|
envelope.getBlock(absl::MakeSpan(output));
|
||||||
REQUIRE(approxEqual<float>(output, expected));
|
REQUIRE(approxEqual<float>(output, expected));
|
||||||
}
|
}
|
||||||
|
|
@ -295,10 +295,10 @@ TEST_CASE("[MultiplicativeEnvelope] Basic event")
|
||||||
TEST_CASE("[MultiplicativeEnvelope] 2 events")
|
TEST_CASE("[MultiplicativeEnvelope] 2 events")
|
||||||
{
|
{
|
||||||
sfz::MultiplicativeEnvelope<float> envelope;
|
sfz::MultiplicativeEnvelope<float> envelope;
|
||||||
envelope.registerEvent(4, 2.0);
|
envelope.registerEvent(4, 2.0f);
|
||||||
envelope.registerEvent(5, 4.0);
|
envelope.registerEvent(5, 4.0f);
|
||||||
std::array<float, 8> output;
|
std::array<float, 8> output;
|
||||||
std::array<float, 8> expected { 1.1892, 1.4142, 1.68176, 2.0, 4.0, 4.0, 4.0, 4.0 };
|
std::array<float, 8> expected { 1.1892f, 1.4142f, 1.68176f, 2.0f, 4.0f, 4.0f, 4.0f, 4.0f };
|
||||||
envelope.getBlock(absl::MakeSpan(output));
|
envelope.getBlock(absl::MakeSpan(output));
|
||||||
REQUIRE(approxEqual<float>(output, expected));
|
REQUIRE(approxEqual<float>(output, expected));
|
||||||
}
|
}
|
||||||
|
|
@ -306,10 +306,10 @@ TEST_CASE("[MultiplicativeEnvelope] 2 events")
|
||||||
TEST_CASE("[MultiplicativeEnvelope] 2 events, far")
|
TEST_CASE("[MultiplicativeEnvelope] 2 events, far")
|
||||||
{
|
{
|
||||||
sfz::MultiplicativeEnvelope<float> envelope;
|
sfz::MultiplicativeEnvelope<float> envelope;
|
||||||
envelope.registerEvent(2, 2.0);
|
envelope.registerEvent(2, 2.0f);
|
||||||
envelope.registerEvent(6, 4.0);
|
envelope.registerEvent(6, 4.0f);
|
||||||
std::array<float, 8> output;
|
std::array<float, 8> output;
|
||||||
std::array<float, 8> expected { 1.4142, 2.0, 2.37841, 2.82843, 3.36358, 4.0, 4.0, 4.0 };
|
std::array<float, 8> expected { 1.4142f, 2.0f, 2.37841f, 2.82843f, 3.36358f, 4.0f, 4.0f, 4.0f };
|
||||||
envelope.getBlock(absl::MakeSpan(output));
|
envelope.getBlock(absl::MakeSpan(output));
|
||||||
REQUIRE(approxEqual<float>(output, expected));
|
REQUIRE(approxEqual<float>(output, expected));
|
||||||
}
|
}
|
||||||
|
|
@ -317,10 +317,10 @@ TEST_CASE("[MultiplicativeEnvelope] 2 events, far")
|
||||||
TEST_CASE("[MultiplicativeEnvelope] Get quantized with 2 steps")
|
TEST_CASE("[MultiplicativeEnvelope] Get quantized with 2 steps")
|
||||||
{
|
{
|
||||||
sfz::MultiplicativeEnvelope<float> envelope;
|
sfz::MultiplicativeEnvelope<float> envelope;
|
||||||
envelope.registerEvent(2, 2.0);
|
envelope.registerEvent(2, 2.0f);
|
||||||
envelope.registerEvent(6, 4.0);
|
envelope.registerEvent(6, 4.0f);
|
||||||
std::array<float, 8> output;
|
std::array<float, 8> output;
|
||||||
std::array<float, 8> expected { 1.0, 2.0, 2.0, 2.0, 2.0, 4.0, 4.0, 4.0 };
|
std::array<float, 8> expected { 1.0f, 2.0f, 2.0f, 2.0f, 2.0f, 4.0f, 4.0f, 4.0f };
|
||||||
envelope.getQuantizedBlock(absl::MakeSpan(output), 2.0f);
|
envelope.getQuantizedBlock(absl::MakeSpan(output), 2.0f);
|
||||||
REQUIRE(output == expected);
|
REQUIRE(output == expected);
|
||||||
}
|
}
|
||||||
|
|
@ -328,12 +328,12 @@ TEST_CASE("[MultiplicativeEnvelope] Get quantized with 2 steps")
|
||||||
TEST_CASE("[MultiplicativeEnvelope] Get quantized with an unquantized out of range step")
|
TEST_CASE("[MultiplicativeEnvelope] Get quantized with an unquantized out of range step")
|
||||||
{
|
{
|
||||||
sfz::MultiplicativeEnvelope<float> envelope;
|
sfz::MultiplicativeEnvelope<float> envelope;
|
||||||
envelope.registerEvent(2, 2.0);
|
envelope.registerEvent(2, 2.0f);
|
||||||
envelope.registerEvent(6, 4.0);
|
envelope.registerEvent(6, 4.0f);
|
||||||
envelope.registerEvent(10, 8.2);
|
envelope.registerEvent(10, 8.2f);
|
||||||
std::array<float, 8> output;
|
std::array<float, 8> output;
|
||||||
std::array<float, 8> expected { 1.0, 2.0, 2.0, 2.0, 2.0, 4.0, 4.0, 4.0 };
|
std::array<float, 8> expected { 1.0f, 2.0f, 2.0f, 2.0f, 2.0f, 4.0f, 4.0f, 4.0f };
|
||||||
std::array<float, 8> expected2 { 8.0, 8.0, 8.0, 8.0, 8.0, 8.0, 8.0, 8.0 };
|
std::array<float, 8> expected2 { 8.0f, 8.0f, 8.0f, 8.0f, 8.0f, 8.0f, 8.0f, 8.0f };
|
||||||
envelope.getQuantizedBlock(absl::MakeSpan(output), 2.0f);
|
envelope.getQuantizedBlock(absl::MakeSpan(output), 2.0f);
|
||||||
REQUIRE(output == expected);
|
REQUIRE(output == expected);
|
||||||
envelope.getQuantizedBlock(absl::MakeSpan(output), 2.0f);
|
envelope.getQuantizedBlock(absl::MakeSpan(output), 2.0f);
|
||||||
|
|
@ -343,11 +343,11 @@ TEST_CASE("[MultiplicativeEnvelope] Get quantized with an unquantized out of ran
|
||||||
TEST_CASE("[MultiplicativeEnvelope] Going down quantized with 2 steps")
|
TEST_CASE("[MultiplicativeEnvelope] Going down quantized with 2 steps")
|
||||||
{
|
{
|
||||||
sfz::MultiplicativeEnvelope<float> envelope;
|
sfz::MultiplicativeEnvelope<float> envelope;
|
||||||
envelope.reset(4.0);
|
envelope.reset(4.0f);
|
||||||
envelope.registerEvent(2, 2.0);
|
envelope.registerEvent(2, 2.0f);
|
||||||
envelope.registerEvent(6, 0.5);
|
envelope.registerEvent(6, 0.5f);
|
||||||
std::array<float, 8> output;
|
std::array<float, 8> output;
|
||||||
std::array<float, 8> expected { 4.0, 2.0, 2.0, 1.0, 1.0, 0.5, 0.5, 0.5 };
|
std::array<float, 8> expected { 4.0f, 2.0f, 2.0f, 1.0f, 1.0f, 0.5f, 0.5f, 0.5f };
|
||||||
envelope.getQuantizedBlock(absl::MakeSpan(output), 2.0f);
|
envelope.getQuantizedBlock(absl::MakeSpan(output), 2.0f);
|
||||||
REQUIRE(output == expected);
|
REQUIRE(output == expected);
|
||||||
}
|
}
|
||||||
|
|
@ -355,10 +355,10 @@ TEST_CASE("[MultiplicativeEnvelope] Going down quantized with 2 steps")
|
||||||
TEST_CASE("[MultiplicativeEnvelope] Get quantized with unclean events")
|
TEST_CASE("[MultiplicativeEnvelope] Get quantized with unclean events")
|
||||||
{
|
{
|
||||||
sfz::MultiplicativeEnvelope<float> envelope;
|
sfz::MultiplicativeEnvelope<float> envelope;
|
||||||
envelope.registerEvent(2, 1.2);
|
envelope.registerEvent(2, 1.2f);
|
||||||
envelope.registerEvent(6, 2.5);
|
envelope.registerEvent(6, 2.5f);
|
||||||
std::array<float, 8> output;
|
std::array<float, 8> output;
|
||||||
std::array<float, 8> expected { 1.0, 1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0 };
|
std::array<float, 8> expected { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 2.0f, 2.0f, 2.0f };
|
||||||
envelope.getQuantizedBlock(absl::MakeSpan(output), 2.0f);
|
envelope.getQuantizedBlock(absl::MakeSpan(output), 2.0f);
|
||||||
REQUIRE(output == expected);
|
REQUIRE(output == expected);
|
||||||
}
|
}
|
||||||
|
|
@ -366,11 +366,11 @@ TEST_CASE("[MultiplicativeEnvelope] Get quantized with unclean events")
|
||||||
TEST_CASE("[MultiplicativeEnvelope] Get quantized with 2 steps and starting unquantized")
|
TEST_CASE("[MultiplicativeEnvelope] Get quantized with 2 steps and starting unquantized")
|
||||||
{
|
{
|
||||||
sfz::MultiplicativeEnvelope<float> envelope;
|
sfz::MultiplicativeEnvelope<float> envelope;
|
||||||
envelope.reset(0.9);
|
envelope.reset(0.9f);
|
||||||
envelope.registerEvent(3, 1.0);
|
envelope.registerEvent(3, 1.0f);
|
||||||
envelope.registerEvent(7, 4.0);
|
envelope.registerEvent(7, 4.0f);
|
||||||
std::array<float, 8> output;
|
std::array<float, 8> output;
|
||||||
std::array<float, 8> expected { 0.9, 0.9, 1.0, 1.0, 2.0, 2.0, 4.0, 4.0 };
|
std::array<float, 8> expected { 0.9f, 0.9f, 1.0f, 1.0f, 2.0f, 2.0f, 4.0f, 4.0f };
|
||||||
envelope.getQuantizedBlock(absl::MakeSpan(output), 2.0f);
|
envelope.getQuantizedBlock(absl::MakeSpan(output), 2.0f);
|
||||||
REQUIRE(output == expected);
|
REQUIRE(output == expected);
|
||||||
}
|
}
|
||||||
|
|
@ -379,11 +379,11 @@ TEST_CASE("[MultiplicativeEnvelope] Get quantized with 2 steps and starting unqu
|
||||||
TEST_CASE("[MultiplicativeEnvelope] Going down quantized with 2 steps and starting unquantized")
|
TEST_CASE("[MultiplicativeEnvelope] Going down quantized with 2 steps and starting unquantized")
|
||||||
{
|
{
|
||||||
sfz::MultiplicativeEnvelope<float> envelope;
|
sfz::MultiplicativeEnvelope<float> envelope;
|
||||||
envelope.reset(4.6);
|
envelope.reset(4.6f);
|
||||||
envelope.registerEvent(4, 1.0);
|
envelope.registerEvent(4, 1.0f);
|
||||||
envelope.registerEvent(7, 0.25);
|
envelope.registerEvent(7, 0.25f);
|
||||||
std::array<float, 8> output;
|
std::array<float, 8> output;
|
||||||
std::array<float, 8> expected { 4.6, 2.0, 1.0, 1.0, 0.5, 0.5, 0.25, 0.25 };
|
std::array<float, 8> expected { 4.6f, 2.0f, 1.0f, 1.0f, 0.5f, 0.5f, 0.25f, 0.25f };
|
||||||
envelope.getQuantizedBlock(absl::MakeSpan(output), 2.0f);
|
envelope.getQuantizedBlock(absl::MakeSpan(output), 2.0f);
|
||||||
REQUIRE(output == expected);
|
REQUIRE(output == expected);
|
||||||
}
|
}
|
||||||
|
|
@ -394,13 +394,13 @@ TEST_CASE("[MultiplicativeEnvelope] Pitch envelope basic function")
|
||||||
sfz::MultiplicativeEnvelope<float> envelope;
|
sfz::MultiplicativeEnvelope<float> envelope;
|
||||||
envelope.setFunction([](float pitchValue){
|
envelope.setFunction([](float pitchValue){
|
||||||
const auto normalizedBend = sfz::normalizeBend(pitchValue);
|
const auto normalizedBend = sfz::normalizeBend(pitchValue);
|
||||||
const auto bendInCents = normalizedBend * 200;
|
const auto bendInCents = normalizedBend * 200.0f;
|
||||||
return sfz::centsFactor(bendInCents);
|
return sfz::centsFactor(bendInCents);
|
||||||
});
|
});
|
||||||
envelope.reset(0);
|
envelope.reset(0.0f);
|
||||||
envelope.getBlock(absl::MakeSpan(output));
|
envelope.getBlock(absl::MakeSpan(output));
|
||||||
REQUIRE(output[255] == 1.0_a);
|
REQUIRE(output[255] == 1.0_a);
|
||||||
envelope.registerEvent(252, -6020);
|
envelope.registerEvent(252, -6020.0f);
|
||||||
envelope.getBlock(absl::MakeSpan(output));
|
envelope.getBlock(absl::MakeSpan(output));
|
||||||
REQUIRE(output[255] == Approx(0.9168).epsilon(0.01));
|
REQUIRE(output[255] == Approx(0.9168).epsilon(0.01));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,15 @@ TEST_CASE("[Files] Underscore opcodes (underscore_opcodes.sfz)")
|
||||||
REQUIRE(synth.getRegionView(0)->loopMode == SfzLoopMode::loop_sustain);
|
REQUIRE(synth.getRegionView(0)->loopMode == SfzLoopMode::loop_sustain);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("[Files] (regions_bad.sfz)")
|
||||||
|
{
|
||||||
|
sfz::Synth synth;
|
||||||
|
synth.loadSfzFile(fs::current_path() / "tests/TestFiles/Regions/regions_bad.sfz");
|
||||||
|
REQUIRE(synth.getNumRegions() == 2);
|
||||||
|
REQUIRE(synth.getRegionView(0)->sample == "dummy.wav");
|
||||||
|
REQUIRE(synth.getRegionView(1)->sample == "dummy.wav");
|
||||||
|
}
|
||||||
|
|
||||||
TEST_CASE("[Files] Local include")
|
TEST_CASE("[Files] Local include")
|
||||||
{
|
{
|
||||||
sfz::Synth synth;
|
sfz::Synth synth;
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ void testLowpass(const fs::path& inputNumpyFile, const fs::path& outputNumpyFile
|
||||||
REQUIRE(approxEqual(outputData, expectedData));
|
REQUIRE(approxEqual(outputData, expectedData));
|
||||||
|
|
||||||
filter.reset();
|
filter.reset();
|
||||||
std::fill(outputData.begin(), outputData.end(), 0.0);
|
std::fill(outputData.begin(), outputData.end(), 0.0f);
|
||||||
std::vector<Type> gains(size);
|
std::vector<Type> gains(size);
|
||||||
std::fill(gains.begin(), gains.end(), gain);
|
std::fill(gains.begin(), gains.end(), gain);
|
||||||
filter.processLowpassVariableGain(inputData, absl::MakeSpan(outputData), gains);
|
filter.processLowpassVariableGain(inputData, absl::MakeSpan(outputData), gains);
|
||||||
|
|
@ -108,7 +108,7 @@ void testHighpass(const fs::path& inputNumpyFile, const fs::path& outputNumpyFil
|
||||||
REQUIRE(approxEqual(outputData, expectedData));
|
REQUIRE(approxEqual(outputData, expectedData));
|
||||||
|
|
||||||
filter.reset();
|
filter.reset();
|
||||||
std::fill(outputData.begin(), outputData.end(), 0.0);
|
std::fill(outputData.begin(), outputData.end(), 0.0f);
|
||||||
std::vector<Type> gains(size);
|
std::vector<Type> gains(size);
|
||||||
std::fill(gains.begin(), gains.end(), gain);
|
std::fill(gains.begin(), gains.end(), gain);
|
||||||
filter.processHighpassVariableGain(inputData, absl::MakeSpan(outputData), gains);
|
filter.processHighpassVariableGain(inputData, absl::MakeSpan(outputData), gains);
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ using namespace Catch::literals;
|
||||||
constexpr int smallBufferSize { 3 };
|
constexpr int smallBufferSize { 3 };
|
||||||
constexpr int bigBufferSize { 4095 };
|
constexpr int bigBufferSize { 4095 };
|
||||||
constexpr int medBufferSize { 127 };
|
constexpr int medBufferSize { 127 };
|
||||||
constexpr double fillValue { 1.3 };
|
constexpr float fillValue { 1.3f };
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
inline bool approxEqualMargin(absl::Span<const Type> lhs, absl::Span<const Type> rhs, Type eps = 1e-3)
|
inline bool approxEqualMargin(absl::Span<const Type> lhs, absl::Span<const Type> rhs, Type eps = 1e-3)
|
||||||
|
|
@ -334,7 +334,7 @@ TEST_CASE("[Helpers] Interleaved write SIMD vs Scalar")
|
||||||
std::array<float, medBufferSize * 2> outputScalar;
|
std::array<float, medBufferSize * 2> outputScalar;
|
||||||
std::array<float, medBufferSize * 2> outputSIMD;
|
std::array<float, medBufferSize * 2> outputSIMD;
|
||||||
std::iota(leftInput.begin(), leftInput.end(), 0.0f);
|
std::iota(leftInput.begin(), leftInput.end(), 0.0f);
|
||||||
std::iota(rightInput.begin(), rightInput.end(), medBufferSize);
|
std::iota(rightInput.begin(), rightInput.end(), static_cast<float>(medBufferSize));
|
||||||
sfz::writeInterleaved<float, false>(leftInput, rightInput, absl::MakeSpan(outputScalar));
|
sfz::writeInterleaved<float, false>(leftInput, rightInput, absl::MakeSpan(outputScalar));
|
||||||
sfz::writeInterleaved<float, true>(leftInput, rightInput, absl::MakeSpan(outputSIMD));
|
sfz::writeInterleaved<float, true>(leftInput, rightInput, absl::MakeSpan(outputSIMD));
|
||||||
REQUIRE(outputScalar == outputSIMD);
|
REQUIRE(outputScalar == outputSIMD);
|
||||||
|
|
@ -414,7 +414,7 @@ TEST_CASE("[Helpers] Gain, spans and inplace (SIMD)")
|
||||||
|
|
||||||
TEST_CASE("[Helpers] SFZ looping index")
|
TEST_CASE("[Helpers] SFZ looping index")
|
||||||
{
|
{
|
||||||
std::array<float, 6> jumps { 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f }; // 1.1 2.3 3.6 5.0 6.5 8.1
|
std::array<float, 6> jumps { 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f }; // 1.1 2.3 3.6 5.0f 6.5 8.1
|
||||||
std::array<int, 6> indices;
|
std::array<int, 6> indices;
|
||||||
std::array<float, 6> leftCoeffs;
|
std::array<float, 6> leftCoeffs;
|
||||||
std::array<float, 6> rightCoeffs;
|
std::array<float, 6> rightCoeffs;
|
||||||
|
|
@ -429,7 +429,7 @@ TEST_CASE("[Helpers] SFZ looping index")
|
||||||
|
|
||||||
TEST_CASE("[Helpers] SFZ looping index (SIMD)")
|
TEST_CASE("[Helpers] SFZ looping index (SIMD)")
|
||||||
{
|
{
|
||||||
std::array<float, 6> jumps { 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f }; // 1.1 2.3 3.6 5.0 6.5 8.1
|
std::array<float, 6> jumps { 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f }; // 1.1 2.3 3.6 5.0f 6.5 8.1
|
||||||
std::array<int, 6> indices;
|
std::array<int, 6> indices;
|
||||||
std::array<float, 6> leftCoeffs;
|
std::array<float, 6> leftCoeffs;
|
||||||
std::array<float, 6> rightCoeffs;
|
std::array<float, 6> rightCoeffs;
|
||||||
|
|
@ -464,7 +464,7 @@ TEST_CASE("[Helpers] SFZ looping index (SIMD)")
|
||||||
|
|
||||||
TEST_CASE("[Helpers] SFZ saturating index")
|
TEST_CASE("[Helpers] SFZ saturating index")
|
||||||
{
|
{
|
||||||
std::array<float, 6> jumps { 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f }; // 1.1 2.3 3.6 5.0 6.5 8.1
|
std::array<float, 6> jumps { 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f }; // 1.1 2.3 3.6 5.0f 6.5 8.1
|
||||||
std::array<int, 6> indices;
|
std::array<int, 6> indices;
|
||||||
std::array<float, 6> leftCoeffs;
|
std::array<float, 6> leftCoeffs;
|
||||||
std::array<float, 6> rightCoeffs;
|
std::array<float, 6> rightCoeffs;
|
||||||
|
|
@ -479,7 +479,7 @@ TEST_CASE("[Helpers] SFZ saturating index")
|
||||||
|
|
||||||
TEST_CASE("[Helpers] SFZ saturating index (SIMD)")
|
TEST_CASE("[Helpers] SFZ saturating index (SIMD)")
|
||||||
{
|
{
|
||||||
std::array<float, 6> jumps { 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f }; // 1.1 2.3 3.6 5.0 6.5 8.1
|
std::array<float, 6> jumps { 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f }; // 1.1 2.3 3.6 5.0f 6.5 8.1
|
||||||
std::array<int, 6> indices;
|
std::array<int, 6> indices;
|
||||||
std::array<float, 6> leftCoeffs;
|
std::array<float, 6> leftCoeffs;
|
||||||
std::array<float, 6> rightCoeffs;
|
std::array<float, 6> rightCoeffs;
|
||||||
|
|
@ -558,7 +558,7 @@ TEST_CASE("[Helpers] Multiplicative Ramp")
|
||||||
std::array<float, 6> output;
|
std::array<float, 6> output;
|
||||||
std::array<float, 6> expected { v, v * v, v * v * v, v * v * v * v, v * v * v * v * v, v * v * v * v * v * v };
|
std::array<float, 6> expected { v, v * v, v * v * v, v * v * v * v, v * v * v * v * v, v * v * v * v * v * v };
|
||||||
sfz::multiplicativeRamp<float, false>(absl::MakeSpan(output), start, v);
|
sfz::multiplicativeRamp<float, false>(absl::MakeSpan(output), start, v);
|
||||||
REQUIRE(output == expected);
|
REQUIRE(approxEqual<float>(output, expected));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("[Helpers] Multiplicative Ramp (SIMD)")
|
TEST_CASE("[Helpers] Multiplicative Ramp (SIMD)")
|
||||||
|
|
@ -568,7 +568,7 @@ TEST_CASE("[Helpers] Multiplicative Ramp (SIMD)")
|
||||||
std::array<float, 6> output;
|
std::array<float, 6> output;
|
||||||
std::array<float, 6> expected { v, v * v, v * v * v, v * v * v * v, v * v * v * v * v, v * v * v * v * v * v };
|
std::array<float, 6> expected { v, v * v, v * v * v, v * v * v * v, v * v * v * v * v, v * v * v * v * v * v };
|
||||||
sfz::multiplicativeRamp<float, true>(absl::MakeSpan(output), start, v);
|
sfz::multiplicativeRamp<float, true>(absl::MakeSpan(output), start, v);
|
||||||
REQUIRE(output == expected);
|
REQUIRE(approxEqual<float>(output, expected));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("[Helpers] Multiplicative Ramp (SIMD vs scalar)")
|
TEST_CASE("[Helpers] Multiplicative Ramp (SIMD vs scalar)")
|
||||||
|
|
@ -595,7 +595,7 @@ TEST_CASE("[Helpers] Add")
|
||||||
{
|
{
|
||||||
std::array<float, 5> input { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f };
|
std::array<float, 5> input { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f };
|
||||||
std::array<float, 5> output { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f };
|
std::array<float, 5> output { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f };
|
||||||
std::array<float, 5> expected { 2.0, 3.0, 4.0, 5.0, 6.0 };
|
std::array<float, 5> expected { 2.0f, 3.0f, 4.0f, 5.0f, 6.0f };
|
||||||
sfz::add<float, false>(input, absl::MakeSpan(output));
|
sfz::add<float, false>(input, absl::MakeSpan(output));
|
||||||
REQUIRE(output == expected);
|
REQUIRE(output == expected);
|
||||||
}
|
}
|
||||||
|
|
@ -604,7 +604,7 @@ TEST_CASE("[Helpers] Add (SIMD)")
|
||||||
{
|
{
|
||||||
std::array<float, 5> input { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f };
|
std::array<float, 5> input { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f };
|
||||||
std::array<float, 5> output { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f };
|
std::array<float, 5> output { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f };
|
||||||
std::array<float, 5> expected { 2.0, 3.0, 4.0, 5.0, 6.0 };
|
std::array<float, 5> expected { 2.0f, 3.0f, 4.0f, 5.0f, 6.0f };
|
||||||
sfz::add<float, true>(input, absl::MakeSpan(output));
|
sfz::add<float, true>(input, absl::MakeSpan(output));
|
||||||
REQUIRE(output == expected);
|
REQUIRE(output == expected);
|
||||||
}
|
}
|
||||||
|
|
@ -614,9 +614,9 @@ TEST_CASE("[Helpers] Add (SIMD vs scalar)")
|
||||||
std::vector<float> input(bigBufferSize);
|
std::vector<float> input(bigBufferSize);
|
||||||
std::vector<float> outputScalar(bigBufferSize);
|
std::vector<float> outputScalar(bigBufferSize);
|
||||||
std::vector<float> outputSIMD(bigBufferSize);
|
std::vector<float> outputSIMD(bigBufferSize);
|
||||||
absl::c_iota(input, 0.0);
|
absl::c_iota(input, 0.0f);
|
||||||
absl::c_fill(outputScalar, 0.0);
|
absl::c_fill(outputScalar, 0.0f);
|
||||||
absl::c_fill(outputSIMD, 0.0);
|
absl::c_fill(outputSIMD, 0.0f);
|
||||||
|
|
||||||
sfz::add<float, false>(input, absl::MakeSpan(outputScalar));
|
sfz::add<float, false>(input, absl::MakeSpan(outputScalar));
|
||||||
sfz::add<float, true>(input, absl::MakeSpan(outputSIMD));
|
sfz::add<float, true>(input, absl::MakeSpan(outputSIMD));
|
||||||
|
|
@ -627,7 +627,7 @@ TEST_CASE("[Helpers] Subtract")
|
||||||
{
|
{
|
||||||
std::array<float, 5> input { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f };
|
std::array<float, 5> input { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f };
|
||||||
std::array<float, 5> output { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f };
|
std::array<float, 5> output { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f };
|
||||||
std::array<float, 5> expected { 0.0, -1.0, -2.0, -3.0, -4.0 };
|
std::array<float, 5> expected { 0.0f, -1.0f, -2.0f, -3.0f, -4.0f };
|
||||||
sfz::subtract<float, false>(input, absl::MakeSpan(output));
|
sfz::subtract<float, false>(input, absl::MakeSpan(output));
|
||||||
REQUIRE(output == expected);
|
REQUIRE(output == expected);
|
||||||
}
|
}
|
||||||
|
|
@ -635,7 +635,7 @@ TEST_CASE("[Helpers] Subtract")
|
||||||
TEST_CASE("[Helpers] Subtract 2")
|
TEST_CASE("[Helpers] Subtract 2")
|
||||||
{
|
{
|
||||||
std::array<float, 5> output { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f };
|
std::array<float, 5> output { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f };
|
||||||
std::array<float, 5> expected { 0.0, 1.0, 2.0, 3.0, 4.0 };
|
std::array<float, 5> expected { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f };
|
||||||
sfz::subtract<float, false>(1.0f, absl::MakeSpan(output));
|
sfz::subtract<float, false>(1.0f, absl::MakeSpan(output));
|
||||||
REQUIRE(output == expected);
|
REQUIRE(output == expected);
|
||||||
}
|
}
|
||||||
|
|
@ -645,7 +645,7 @@ TEST_CASE("[Helpers] Subtract (SIMD)")
|
||||||
{
|
{
|
||||||
std::array<float, 5> input { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f };
|
std::array<float, 5> input { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f };
|
||||||
std::array<float, 5> output { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f };
|
std::array<float, 5> output { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f };
|
||||||
std::array<float, 5> expected { 0.0, -1.0, -2.0, -3.0, -4.0 };
|
std::array<float, 5> expected { 0.0f, -1.0f, -2.0f, -3.0f, -4.0f };
|
||||||
sfz::subtract<float, true>(input, absl::MakeSpan(output));
|
sfz::subtract<float, true>(input, absl::MakeSpan(output));
|
||||||
REQUIRE(output == expected);
|
REQUIRE(output == expected);
|
||||||
}
|
}
|
||||||
|
|
@ -655,9 +655,9 @@ TEST_CASE("[Helpers] Subtract (SIMD vs scalar)")
|
||||||
std::vector<float> input(bigBufferSize);
|
std::vector<float> input(bigBufferSize);
|
||||||
std::vector<float> outputScalar(bigBufferSize);
|
std::vector<float> outputScalar(bigBufferSize);
|
||||||
std::vector<float> outputSIMD(bigBufferSize);
|
std::vector<float> outputSIMD(bigBufferSize);
|
||||||
absl::c_iota(input, 0.0);
|
absl::c_iota(input, 0.0f);
|
||||||
absl::c_fill(outputScalar, 0.0);
|
absl::c_fill(outputScalar, 0.0f);
|
||||||
absl::c_fill(outputSIMD, 0.0);
|
absl::c_fill(outputSIMD, 0.0f);
|
||||||
|
|
||||||
sfz::subtract<float, false>(input, absl::MakeSpan(outputScalar));
|
sfz::subtract<float, false>(input, absl::MakeSpan(outputScalar));
|
||||||
sfz::subtract<float, true>(input, absl::MakeSpan(outputSIMD));
|
sfz::subtract<float, true>(input, absl::MakeSpan(outputSIMD));
|
||||||
|
|
@ -668,8 +668,8 @@ TEST_CASE("[Helpers] Subtract 2 (SIMD vs scalar)")
|
||||||
{
|
{
|
||||||
std::vector<float> outputScalar(bigBufferSize);
|
std::vector<float> outputScalar(bigBufferSize);
|
||||||
std::vector<float> outputSIMD(bigBufferSize);
|
std::vector<float> outputSIMD(bigBufferSize);
|
||||||
absl::c_iota(outputScalar, 0.0);
|
absl::c_iota(outputScalar, 0.0f);
|
||||||
absl::c_iota(outputSIMD, 0.0);
|
absl::c_iota(outputSIMD, 0.0f);
|
||||||
|
|
||||||
sfz::subtract<float, false>(1.2f, absl::MakeSpan(outputScalar));
|
sfz::subtract<float, false>(1.2f, absl::MakeSpan(outputScalar));
|
||||||
sfz::subtract<float, true>(1.2f, absl::MakeSpan(outputSIMD));
|
sfz::subtract<float, true>(1.2f, absl::MakeSpan(outputSIMD));
|
||||||
|
|
@ -697,9 +697,9 @@ TEST_CASE("[Helpers] copy (SIMD vs scalar)")
|
||||||
std::vector<float> input(bigBufferSize);
|
std::vector<float> input(bigBufferSize);
|
||||||
std::vector<float> outputScalar(bigBufferSize);
|
std::vector<float> outputScalar(bigBufferSize);
|
||||||
std::vector<float> outputSIMD(bigBufferSize);
|
std::vector<float> outputSIMD(bigBufferSize);
|
||||||
absl::c_iota(input, 0.0);
|
absl::c_iota(input, 0.0f);
|
||||||
absl::c_fill(outputScalar, 0.0);
|
absl::c_fill(outputScalar, 0.0f);
|
||||||
absl::c_fill(outputSIMD, 0.0);
|
absl::c_fill(outputSIMD, 0.0f);
|
||||||
|
|
||||||
sfz::add<float, false>(input, absl::MakeSpan(outputScalar));
|
sfz::add<float, false>(input, absl::MakeSpan(outputScalar));
|
||||||
sfz::add<float, true>(input, absl::MakeSpan(outputSIMD));
|
sfz::add<float, true>(input, absl::MakeSpan(outputSIMD));
|
||||||
|
|
@ -716,7 +716,7 @@ TEST_CASE("[Helpers] Mean")
|
||||||
TEST_CASE("[Helpers] Mean (SIMD vs scalar)")
|
TEST_CASE("[Helpers] Mean (SIMD vs scalar)")
|
||||||
{
|
{
|
||||||
std::vector<float> input(bigBufferSize);
|
std::vector<float> input(bigBufferSize);
|
||||||
absl::c_iota(input, 0.0);
|
absl::c_iota(input, 0.0f);
|
||||||
REQUIRE(sfz::mean<float, false>(input) == Approx(sfz::mean<float, true>(input)).margin(0.001));
|
REQUIRE(sfz::mean<float, false>(input) == Approx(sfz::mean<float, true>(input)).margin(0.001));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -730,13 +730,13 @@ TEST_CASE("[Helpers] Mean Squared")
|
||||||
TEST_CASE("[Helpers] Mean Squared (SIMD vs scalar)")
|
TEST_CASE("[Helpers] Mean Squared (SIMD vs scalar)")
|
||||||
{
|
{
|
||||||
std::vector<float> input(medBufferSize);
|
std::vector<float> input(medBufferSize);
|
||||||
absl::c_iota(input, 0.0);
|
absl::c_iota(input, 0.0f);
|
||||||
REQUIRE(sfz::meanSquared<float, false>(input) == sfz::meanSquared<float, true>(input));
|
REQUIRE(sfz::meanSquared<float, false>(input) == sfz::meanSquared<float, true>(input));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("[Helpers] Cumulative sum ")
|
TEST_CASE("[Helpers] Cumulative sum ")
|
||||||
{
|
{
|
||||||
std::array<float, 6> input { 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f }; // 1.1 2.3 3.6 5.0 6.5 8.1
|
std::array<float, 6> input { 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f }; // 1.1 2.3 3.6 5.0f 6.5 8.1
|
||||||
std::array<float, 6> output;
|
std::array<float, 6> output;
|
||||||
std::array<float, 6> expected { 1.1f, 2.3f, 3.6f, 5.0f, 6.5f, 8.1f };
|
std::array<float, 6> expected { 1.1f, 2.3f, 3.6f, 5.0f, 6.5f, 8.1f };
|
||||||
sfz::cumsum<float, false>(input, absl::MakeSpan(output));
|
sfz::cumsum<float, false>(input, absl::MakeSpan(output));
|
||||||
|
|
@ -748,7 +748,7 @@ TEST_CASE("[Helpers] Cumulative sum (SIMD vs Scalar)")
|
||||||
std::vector<float> input(bigBufferSize);
|
std::vector<float> input(bigBufferSize);
|
||||||
std::vector<float> outputScalar(bigBufferSize);
|
std::vector<float> outputScalar(bigBufferSize);
|
||||||
std::vector<float> outputSIMD(bigBufferSize);
|
std::vector<float> outputSIMD(bigBufferSize);
|
||||||
sfz::linearRamp<float>(absl::MakeSpan(input), 0.0, 0.1);
|
sfz::linearRamp<float>(absl::MakeSpan(input), 0.0f, 0.1f);
|
||||||
sfz::cumsum<float, false>(input, absl::MakeSpan(outputScalar));
|
sfz::cumsum<float, false>(input, absl::MakeSpan(outputScalar));
|
||||||
sfz::cumsum<float, true>(input, absl::MakeSpan(outputSIMD));
|
sfz::cumsum<float, true>(input, absl::MakeSpan(outputSIMD));
|
||||||
REQUIRE(approxEqual<float>(outputScalar, outputSIMD));
|
REQUIRE(approxEqual<float>(outputScalar, outputSIMD));
|
||||||
|
|
@ -768,7 +768,7 @@ TEST_CASE("[Helpers] Diff (SIMD vs Scalar)")
|
||||||
std::vector<float> input(bigBufferSize);
|
std::vector<float> input(bigBufferSize);
|
||||||
std::vector<float> outputScalar(bigBufferSize);
|
std::vector<float> outputScalar(bigBufferSize);
|
||||||
std::vector<float> outputSIMD(bigBufferSize);
|
std::vector<float> outputSIMD(bigBufferSize);
|
||||||
sfz::linearRamp<float>(absl::MakeSpan(input), 0.0, 0.1);
|
sfz::linearRamp<float>(absl::MakeSpan(input), 0.0f, 0.1f);
|
||||||
sfz::diff<float, false>(input, absl::MakeSpan(outputScalar));
|
sfz::diff<float, false>(input, absl::MakeSpan(outputScalar));
|
||||||
sfz::diff<float, true>(input, absl::MakeSpan(outputSIMD));
|
sfz::diff<float, true>(input, absl::MakeSpan(outputSIMD));
|
||||||
REQUIRE(approxEqual<float>(outputScalar, outputSIMD));
|
REQUIRE(approxEqual<float>(outputScalar, outputSIMD));
|
||||||
|
|
|
||||||
4
tests/TestFiles/Regions/regions_bad.sfz
Normal file
4
tests/TestFiles/Regions/regions_bad.sfz
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
<region> sample=dummy.wav
|
||||||
|
<region> sample=nonexistent.wav
|
||||||
|
<region> sample=nonexistent.wav
|
||||||
|
<region> sample=dummy.wav
|
||||||
Loading…
Add table
Reference in a new issue