From f3d2df8bc4bcf09148ef3299bf2885b6f89874f6 Mon Sep 17 00:00:00 2001 From: Paul Ferrand Date: Sat, 23 Nov 2019 17:12:32 +0100 Subject: [PATCH 01/32] Move catch --- {tests => external}/catch2/catch.hpp | 0 {tests => external}/catch2/catch_reporter_automake.hpp | 0 {tests => external}/catch2/catch_reporter_tap.hpp | 0 {tests => external}/catch2/catch_reporter_teamcity.hpp | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename {tests => external}/catch2/catch.hpp (100%) rename {tests => external}/catch2/catch_reporter_automake.hpp (100%) rename {tests => external}/catch2/catch_reporter_tap.hpp (100%) rename {tests => external}/catch2/catch_reporter_teamcity.hpp (100%) diff --git a/tests/catch2/catch.hpp b/external/catch2/catch.hpp similarity index 100% rename from tests/catch2/catch.hpp rename to external/catch2/catch.hpp diff --git a/tests/catch2/catch_reporter_automake.hpp b/external/catch2/catch_reporter_automake.hpp similarity index 100% rename from tests/catch2/catch_reporter_automake.hpp rename to external/catch2/catch_reporter_automake.hpp diff --git a/tests/catch2/catch_reporter_tap.hpp b/external/catch2/catch_reporter_tap.hpp similarity index 100% rename from tests/catch2/catch_reporter_tap.hpp rename to external/catch2/catch_reporter_tap.hpp diff --git a/tests/catch2/catch_reporter_teamcity.hpp b/external/catch2/catch_reporter_teamcity.hpp similarity index 100% rename from tests/catch2/catch_reporter_teamcity.hpp rename to external/catch2/catch_reporter_teamcity.hpp From b975da1c07a96076ec9e18f080c01119ddd5da65 Mon Sep 17 00:00:00 2001 From: Paul Ferrand Date: Sat, 23 Nov 2019 17:12:56 +0100 Subject: [PATCH 02/32] Move CNPY --- {tests => external/cnpy}/cnpy.cpp | 0 {tests => external/cnpy}/cnpy.h | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename {tests => external/cnpy}/cnpy.cpp (100%) rename {tests => external/cnpy}/cnpy.h (100%) diff --git a/tests/cnpy.cpp b/external/cnpy/cnpy.cpp similarity index 100% rename from tests/cnpy.cpp rename to external/cnpy/cnpy.cpp diff --git a/tests/cnpy.h b/external/cnpy/cnpy.h similarity index 100% rename from tests/cnpy.h rename to external/cnpy/cnpy.h From a02f6a5176cfdbd495207b7559dbca3149678cb2 Mon Sep 17 00:00:00 2001 From: Paul Ferrand Date: Sat, 23 Nov 2019 17:13:12 +0100 Subject: [PATCH 03/32] Move GHC --- {sfizz => external}/ghc/filesystem.hpp | 0 {sfizz => external}/ghc/fs_fwd.hpp | 0 {sfizz => external}/ghc/fs_impl.hpp | 0 {sfizz => external}/ghc/fs_std.hpp | 0 {sfizz => external}/ghc/fs_std_fwd.hpp | 0 {sfizz => external}/ghc/fs_std_impl.hpp | 0 6 files changed, 0 insertions(+), 0 deletions(-) rename {sfizz => external}/ghc/filesystem.hpp (100%) rename {sfizz => external}/ghc/fs_fwd.hpp (100%) rename {sfizz => external}/ghc/fs_impl.hpp (100%) rename {sfizz => external}/ghc/fs_std.hpp (100%) rename {sfizz => external}/ghc/fs_std_fwd.hpp (100%) rename {sfizz => external}/ghc/fs_std_impl.hpp (100%) diff --git a/sfizz/ghc/filesystem.hpp b/external/ghc/filesystem.hpp similarity index 100% rename from sfizz/ghc/filesystem.hpp rename to external/ghc/filesystem.hpp diff --git a/sfizz/ghc/fs_fwd.hpp b/external/ghc/fs_fwd.hpp similarity index 100% rename from sfizz/ghc/fs_fwd.hpp rename to external/ghc/fs_fwd.hpp diff --git a/sfizz/ghc/fs_impl.hpp b/external/ghc/fs_impl.hpp similarity index 100% rename from sfizz/ghc/fs_impl.hpp rename to external/ghc/fs_impl.hpp diff --git a/sfizz/ghc/fs_std.hpp b/external/ghc/fs_std.hpp similarity index 100% rename from sfizz/ghc/fs_std.hpp rename to external/ghc/fs_std.hpp diff --git a/sfizz/ghc/fs_std_fwd.hpp b/external/ghc/fs_std_fwd.hpp similarity index 100% rename from sfizz/ghc/fs_std_fwd.hpp rename to external/ghc/fs_std_fwd.hpp diff --git a/sfizz/ghc/fs_std_impl.hpp b/external/ghc/fs_std_impl.hpp similarity index 100% rename from sfizz/ghc/fs_std_impl.hpp rename to external/ghc/fs_std_impl.hpp From ce5ab12ac1aaa2f7188b4531ef70484850f670f8 Mon Sep 17 00:00:00 2001 From: Paul Ferrand Date: Sat, 23 Nov 2019 17:13:28 +0100 Subject: [PATCH 04/32] Move mathfuns --- {sfizz => external}/mathfuns/neon_mathfun.h | 0 {sfizz => external}/mathfuns/sse_mathfun.h | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename {sfizz => external}/mathfuns/neon_mathfun.h (100%) rename {sfizz => external}/mathfuns/sse_mathfun.h (100%) diff --git a/sfizz/mathfuns/neon_mathfun.h b/external/mathfuns/neon_mathfun.h similarity index 100% rename from sfizz/mathfuns/neon_mathfun.h rename to external/mathfuns/neon_mathfun.h diff --git a/sfizz/mathfuns/sse_mathfun.h b/external/mathfuns/sse_mathfun.h similarity index 100% rename from sfizz/mathfuns/sse_mathfun.h rename to external/mathfuns/sse_mathfun.h From 0115fd7435444d3c654bffba165143d737a66319 Mon Sep 17 00:00:00 2001 From: Paul Ferrand Date: Sat, 23 Nov 2019 17:13:46 +0100 Subject: [PATCH 05/32] Move readerwriterqueue --- {sfizz => external/readerwriterqueue}/atomicops.h | 0 {sfizz => external/readerwriterqueue}/readerwriterqueue.h | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename {sfizz => external/readerwriterqueue}/atomicops.h (100%) rename {sfizz => external/readerwriterqueue}/readerwriterqueue.h (100%) diff --git a/sfizz/atomicops.h b/external/readerwriterqueue/atomicops.h similarity index 100% rename from sfizz/atomicops.h rename to external/readerwriterqueue/atomicops.h diff --git a/sfizz/readerwriterqueue.h b/external/readerwriterqueue/readerwriterqueue.h similarity index 100% rename from sfizz/readerwriterqueue.h rename to external/readerwriterqueue/readerwriterqueue.h From cf9330e387c567155b85c31debd4bb7ea45802a0 Mon Sep 17 00:00:00 2001 From: Paul Ferrand Date: Sat, 23 Nov 2019 17:15:13 +0100 Subject: [PATCH 06/32] Change folder --- {sfizz => src}/ADSREnvelope.cpp | 0 {sfizz => src}/ADSREnvelope.h | 0 {sfizz => src}/AtomicGuard.h | 0 {sfizz => src}/AudioBuffer.h | 0 {sfizz => src}/AudioSpan.h | 0 {sfizz => src}/Buffer.h | 0 {sfizz => src}/CCMap.h | 0 {sfizz => src}/CMakeLists.txt | 0 {sfizz => src}/Config.h | 0 {sfizz => src}/Debug.h | 0 {sfizz => src}/Defaults.h | 0 {sfizz => src}/EGDescription.h | 0 {sfizz => src}/FilePool.cpp | 0 {sfizz => src}/FilePool.h | 0 {sfizz => src}/FloatEnvelopes.cpp | 0 {sfizz => src}/HistoricalBuffer.h | 0 {sfizz => src}/LeakDetector.h | 0 {sfizz => src}/LinearEnvelope.cpp | 0 {sfizz => src}/LinearEnvelope.h | 0 {sfizz => src}/MathHelpers.h | 0 {sfizz => src}/MidiState.h | 0 {sfizz => src}/OnePoleFilter.h | 0 {sfizz => src}/Opcode.cpp | 0 {sfizz => src}/Opcode.h | 0 {sfizz => src}/Parser.cpp | 0 {sfizz => src}/Parser.h | 0 {sfizz => src}/Range.h | 0 {sfizz => src}/Regexes.h | 0 {sfizz => src}/Region.cpp | 0 {sfizz => src}/Region.h | 0 {sfizz => src}/SIMDDummy.cpp | 0 {sfizz => src}/SIMDHelpers.h | 0 {sfizz => src}/SIMDSSE.cpp | 0 {sfizz => src}/ScopedFTZ.cpp | 0 {sfizz => src}/ScopedFTZ.h | 0 {sfizz => src}/SfzHelpers.cpp | 0 {sfizz => src}/SfzHelpers.h | 0 {sfizz => src}/StringViewHelpers.h | 0 {sfizz => src}/Synth.cpp | 0 {sfizz => src}/Synth.h | 0 {sfizz => src}/Voice.cpp | 0 {sfizz => src}/Voice.h | 0 42 files changed, 0 insertions(+), 0 deletions(-) rename {sfizz => src}/ADSREnvelope.cpp (100%) rename {sfizz => src}/ADSREnvelope.h (100%) rename {sfizz => src}/AtomicGuard.h (100%) rename {sfizz => src}/AudioBuffer.h (100%) rename {sfizz => src}/AudioSpan.h (100%) rename {sfizz => src}/Buffer.h (100%) rename {sfizz => src}/CCMap.h (100%) rename {sfizz => src}/CMakeLists.txt (100%) rename {sfizz => src}/Config.h (100%) rename {sfizz => src}/Debug.h (100%) rename {sfizz => src}/Defaults.h (100%) rename {sfizz => src}/EGDescription.h (100%) rename {sfizz => src}/FilePool.cpp (100%) rename {sfizz => src}/FilePool.h (100%) rename {sfizz => src}/FloatEnvelopes.cpp (100%) rename {sfizz => src}/HistoricalBuffer.h (100%) rename {sfizz => src}/LeakDetector.h (100%) rename {sfizz => src}/LinearEnvelope.cpp (100%) rename {sfizz => src}/LinearEnvelope.h (100%) rename {sfizz => src}/MathHelpers.h (100%) rename {sfizz => src}/MidiState.h (100%) rename {sfizz => src}/OnePoleFilter.h (100%) rename {sfizz => src}/Opcode.cpp (100%) rename {sfizz => src}/Opcode.h (100%) rename {sfizz => src}/Parser.cpp (100%) rename {sfizz => src}/Parser.h (100%) rename {sfizz => src}/Range.h (100%) rename {sfizz => src}/Regexes.h (100%) rename {sfizz => src}/Region.cpp (100%) rename {sfizz => src}/Region.h (100%) rename {sfizz => src}/SIMDDummy.cpp (100%) rename {sfizz => src}/SIMDHelpers.h (100%) rename {sfizz => src}/SIMDSSE.cpp (100%) rename {sfizz => src}/ScopedFTZ.cpp (100%) rename {sfizz => src}/ScopedFTZ.h (100%) rename {sfizz => src}/SfzHelpers.cpp (100%) rename {sfizz => src}/SfzHelpers.h (100%) rename {sfizz => src}/StringViewHelpers.h (100%) rename {sfizz => src}/Synth.cpp (100%) rename {sfizz => src}/Synth.h (100%) rename {sfizz => src}/Voice.cpp (100%) rename {sfizz => src}/Voice.h (100%) diff --git a/sfizz/ADSREnvelope.cpp b/src/ADSREnvelope.cpp similarity index 100% rename from sfizz/ADSREnvelope.cpp rename to src/ADSREnvelope.cpp diff --git a/sfizz/ADSREnvelope.h b/src/ADSREnvelope.h similarity index 100% rename from sfizz/ADSREnvelope.h rename to src/ADSREnvelope.h diff --git a/sfizz/AtomicGuard.h b/src/AtomicGuard.h similarity index 100% rename from sfizz/AtomicGuard.h rename to src/AtomicGuard.h diff --git a/sfizz/AudioBuffer.h b/src/AudioBuffer.h similarity index 100% rename from sfizz/AudioBuffer.h rename to src/AudioBuffer.h diff --git a/sfizz/AudioSpan.h b/src/AudioSpan.h similarity index 100% rename from sfizz/AudioSpan.h rename to src/AudioSpan.h diff --git a/sfizz/Buffer.h b/src/Buffer.h similarity index 100% rename from sfizz/Buffer.h rename to src/Buffer.h diff --git a/sfizz/CCMap.h b/src/CCMap.h similarity index 100% rename from sfizz/CCMap.h rename to src/CCMap.h diff --git a/sfizz/CMakeLists.txt b/src/CMakeLists.txt similarity index 100% rename from sfizz/CMakeLists.txt rename to src/CMakeLists.txt diff --git a/sfizz/Config.h b/src/Config.h similarity index 100% rename from sfizz/Config.h rename to src/Config.h diff --git a/sfizz/Debug.h b/src/Debug.h similarity index 100% rename from sfizz/Debug.h rename to src/Debug.h diff --git a/sfizz/Defaults.h b/src/Defaults.h similarity index 100% rename from sfizz/Defaults.h rename to src/Defaults.h diff --git a/sfizz/EGDescription.h b/src/EGDescription.h similarity index 100% rename from sfizz/EGDescription.h rename to src/EGDescription.h diff --git a/sfizz/FilePool.cpp b/src/FilePool.cpp similarity index 100% rename from sfizz/FilePool.cpp rename to src/FilePool.cpp diff --git a/sfizz/FilePool.h b/src/FilePool.h similarity index 100% rename from sfizz/FilePool.h rename to src/FilePool.h diff --git a/sfizz/FloatEnvelopes.cpp b/src/FloatEnvelopes.cpp similarity index 100% rename from sfizz/FloatEnvelopes.cpp rename to src/FloatEnvelopes.cpp diff --git a/sfizz/HistoricalBuffer.h b/src/HistoricalBuffer.h similarity index 100% rename from sfizz/HistoricalBuffer.h rename to src/HistoricalBuffer.h diff --git a/sfizz/LeakDetector.h b/src/LeakDetector.h similarity index 100% rename from sfizz/LeakDetector.h rename to src/LeakDetector.h diff --git a/sfizz/LinearEnvelope.cpp b/src/LinearEnvelope.cpp similarity index 100% rename from sfizz/LinearEnvelope.cpp rename to src/LinearEnvelope.cpp diff --git a/sfizz/LinearEnvelope.h b/src/LinearEnvelope.h similarity index 100% rename from sfizz/LinearEnvelope.h rename to src/LinearEnvelope.h diff --git a/sfizz/MathHelpers.h b/src/MathHelpers.h similarity index 100% rename from sfizz/MathHelpers.h rename to src/MathHelpers.h diff --git a/sfizz/MidiState.h b/src/MidiState.h similarity index 100% rename from sfizz/MidiState.h rename to src/MidiState.h diff --git a/sfizz/OnePoleFilter.h b/src/OnePoleFilter.h similarity index 100% rename from sfizz/OnePoleFilter.h rename to src/OnePoleFilter.h diff --git a/sfizz/Opcode.cpp b/src/Opcode.cpp similarity index 100% rename from sfizz/Opcode.cpp rename to src/Opcode.cpp diff --git a/sfizz/Opcode.h b/src/Opcode.h similarity index 100% rename from sfizz/Opcode.h rename to src/Opcode.h diff --git a/sfizz/Parser.cpp b/src/Parser.cpp similarity index 100% rename from sfizz/Parser.cpp rename to src/Parser.cpp diff --git a/sfizz/Parser.h b/src/Parser.h similarity index 100% rename from sfizz/Parser.h rename to src/Parser.h diff --git a/sfizz/Range.h b/src/Range.h similarity index 100% rename from sfizz/Range.h rename to src/Range.h diff --git a/sfizz/Regexes.h b/src/Regexes.h similarity index 100% rename from sfizz/Regexes.h rename to src/Regexes.h diff --git a/sfizz/Region.cpp b/src/Region.cpp similarity index 100% rename from sfizz/Region.cpp rename to src/Region.cpp diff --git a/sfizz/Region.h b/src/Region.h similarity index 100% rename from sfizz/Region.h rename to src/Region.h diff --git a/sfizz/SIMDDummy.cpp b/src/SIMDDummy.cpp similarity index 100% rename from sfizz/SIMDDummy.cpp rename to src/SIMDDummy.cpp diff --git a/sfizz/SIMDHelpers.h b/src/SIMDHelpers.h similarity index 100% rename from sfizz/SIMDHelpers.h rename to src/SIMDHelpers.h diff --git a/sfizz/SIMDSSE.cpp b/src/SIMDSSE.cpp similarity index 100% rename from sfizz/SIMDSSE.cpp rename to src/SIMDSSE.cpp diff --git a/sfizz/ScopedFTZ.cpp b/src/ScopedFTZ.cpp similarity index 100% rename from sfizz/ScopedFTZ.cpp rename to src/ScopedFTZ.cpp diff --git a/sfizz/ScopedFTZ.h b/src/ScopedFTZ.h similarity index 100% rename from sfizz/ScopedFTZ.h rename to src/ScopedFTZ.h diff --git a/sfizz/SfzHelpers.cpp b/src/SfzHelpers.cpp similarity index 100% rename from sfizz/SfzHelpers.cpp rename to src/SfzHelpers.cpp diff --git a/sfizz/SfzHelpers.h b/src/SfzHelpers.h similarity index 100% rename from sfizz/SfzHelpers.h rename to src/SfzHelpers.h diff --git a/sfizz/StringViewHelpers.h b/src/StringViewHelpers.h similarity index 100% rename from sfizz/StringViewHelpers.h rename to src/StringViewHelpers.h diff --git a/sfizz/Synth.cpp b/src/Synth.cpp similarity index 100% rename from sfizz/Synth.cpp rename to src/Synth.cpp diff --git a/sfizz/Synth.h b/src/Synth.h similarity index 100% rename from sfizz/Synth.h rename to src/Synth.h diff --git a/sfizz/Voice.cpp b/src/Voice.cpp similarity index 100% rename from sfizz/Voice.cpp rename to src/Voice.cpp diff --git a/sfizz/Voice.h b/src/Voice.h similarity index 100% rename from sfizz/Voice.h rename to src/Voice.h From 8ee911e218cd1a05874818a6f98995ba6b4b7fd2 Mon Sep 17 00:00:00 2001 From: Paul Ferrand Date: Sat, 23 Nov 2019 17:26:40 +0100 Subject: [PATCH 07/32] Add LV2 --- lv2/CMakeLists.txt | 19 ++ lv2/manifest.ttl | 8 + lv2/sfizz.c | 769 +++++++++++++++++++++++++++++++++++++++++++++ lv2/sfizz.ttl | 95 ++++++ 4 files changed, 891 insertions(+) create mode 100644 lv2/CMakeLists.txt create mode 100644 lv2/manifest.ttl create mode 100644 lv2/sfizz.c create mode 100644 lv2/sfizz.ttl diff --git a/lv2/CMakeLists.txt b/lv2/CMakeLists.txt new file mode 100644 index 00000000..b7f33978 --- /dev/null +++ b/lv2/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 3.11) +project(sfizz-lv2) + +find_package(PkgConfig REQUIRED) +pkg_check_modules(sfizz REQUIRED IMPORTED_TARGET sfizz) + +# Force add relocation to the flags globally. It's ugly but what can you do... +# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") + +# Export the compile_commands.json file +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + +add_library(sfizz-lv2 SHARED sfizz.c) +set_target_properties(sfizz-lv2 PROPERTIES PREFIX "") +set_target_properties(sfizz-lv2 PROPERTIES OUTPUT_NAME "sfizz") +target_link_libraries(sfizz-lv2 sfizz) +if(UNIX) +target_compile_options(sfizz-lv2 PRIVATE -Wextra -pedantic -Wall -Werror) +endif() \ No newline at end of file diff --git a/lv2/manifest.ttl b/lv2/manifest.ttl new file mode 100644 index 00000000..deda193d --- /dev/null +++ b/lv2/manifest.ttl @@ -0,0 +1,8 @@ +@prefix lv2: . +@prefix rdfs: . + + + a lv2:Plugin ; + lv2:binary ; + rdfs:seeAlso . + diff --git a/lv2/sfizz.c b/lv2/sfizz.c new file mode 100644 index 00000000..87c09234 --- /dev/null +++ b/lv2/sfizz.c @@ -0,0 +1,769 @@ +/* + Sfizz LV2 plugin + + Copyright 2019, Paul Ferrand + + This file was based on skeleton and example code from the LV2 plugin + distribution available at http://lv2plug.in/ + + The LV2 sample plugins have the following copyright and notice, which are + extended to the current work: + Copyright 2011-2016 David Robillard + Copyright 2011 Gabriel M. Beddingfield + Copyright 2011 James Morris + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#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_PREFIX SFIZZ_URI "#" +#define SFIZZ__sfzFile "http://sfztools.github.io/sfizz:sfzfile" +#define SFIZZ__numVoices "http://sfztools.github.io/sfizz:numvoices" + +#define CHANNEL_MASK 0x0F +#define MIDI_CHANNEL(byte) (byte & CHANNEL_MASK) +#define MIDI_STATUS(byte) (byte & ~CHANNEL_MASK) +#define MAX_BLOCK_SIZE 8192 +#define MAX_PATH_SIZE 1024 +#define MAX_VOICES 256 +#define DEFAULT_VOICES 64 +#define UNUSED(x) (void)(x) + +typedef struct +{ + // Features + LV2_URID_Map *map; + LV2_URID_Unmap *unmap; + LV2_Worker_Schedule *worker; + LV2_Log_Log *log; + + // Ports + const LV2_Atom_Sequence *control_port; + LV2_Atom_Sequence *notify_port; + float *output_buffers[2]; + const float *volume_port; + const float *polyphony_port; + + // Atom forge + LV2_Atom_Forge forge; ///< Forge for writing atoms in run thread + LV2_Atom_Forge_Frame notify_frame; ///< Cached for worker replies + + // Logger + LV2_Log_Logger logger; + + // URIs + LV2_URID midi_event_uri; + LV2_URID options_interface_uri; + LV2_URID max_block_length_uri; + LV2_URID nominal_block_length_uri; + LV2_URID sample_rate_uri; + LV2_URID atom_object_uri; + LV2_URID atom_float_uri; + LV2_URID atom_int_uri; + LV2_URID atom_urid_uri; + LV2_URID atom_path_uri; + LV2_URID patch_set_uri; + LV2_URID patch_get_uri; + LV2_URID patch_put_uri; + LV2_URID patch_property_uri; + LV2_URID patch_value_uri; + LV2_URID patch_body_uri; + LV2_URID state_changed_uri; + LV2_URID sfizz_sfz_file_uri; + LV2_URID sfizz_num_voices_uri; + + // Sfizz related data + sfizz_synth_t *synth; + bool expect_nominal_block_length; + char sfz_file_path[MAX_PATH_SIZE]; + int num_voices; + bool changing_voices; + int max_block_size; + float sample_rate; +} sfizz_plugin_t; + +enum +{ + SFIZZ_CONTROL = 0, + SFIZZ_NOTIFY = 1, + SFIZZ_LEFT = 2, + SFIZZ_RIGHT = 3, + SFIZZ_VOLUME = 4, + SFIZZ_POLYPHONY = 5 +}; + +static void +sfizz_lv2_map_required_uris(sfizz_plugin_t *self) +{ + LV2_URID_Map *map = self->map; + self->midi_event_uri = map->map(map->handle, LV2_MIDI__MidiEvent); + self->max_block_length_uri = map->map(map->handle, LV2_BUF_SIZE__maxBlockLength); + self->nominal_block_length_uri = map->map(map->handle, LV2_BUF_SIZE__nominalBlockLength); + self->sample_rate_uri = map->map(map->handle, LV2_PARAMETERS__sampleRate); + self->atom_float_uri = map->map(map->handle, LV2_ATOM__Float); + self->atom_int_uri = map->map(map->handle, LV2_ATOM__Int); + self->atom_path_uri = map->map(map->handle, LV2_ATOM__Path); + self->atom_urid_uri = map->map(map->handle, LV2_ATOM__URID); + self->atom_object_uri = map->map(map->handle, LV2_ATOM__Object); + self->patch_set_uri = map->map(map->handle, LV2_PATCH__Set); + self->patch_get_uri = map->map(map->handle, LV2_PATCH__Get); + self->patch_put_uri = map->map(map->handle, LV2_PATCH__Put); + self->patch_body_uri = map->map(map->handle, LV2_PATCH__body); + self->patch_property_uri = map->map(map->handle, LV2_PATCH__property); + self->patch_value_uri = map->map(map->handle, LV2_PATCH__value); + self->state_changed_uri = map->map(map->handle, LV2_STATE__StateChanged); + self->sfizz_sfz_file_uri = map->map(map->handle, SFIZZ__sfzFile); + self->sfizz_num_voices_uri = map->map(map->handle, SFIZZ__numVoices); +} + +static void +connect_port(LV2_Handle instance, + uint32_t port, + void *data) +{ + sfizz_plugin_t *self = (sfizz_plugin_t *)instance; + switch (port) + { + case SFIZZ_CONTROL: + self->control_port = (const LV2_Atom_Sequence *)data; + break; + case SFIZZ_NOTIFY: + self->notify_port = (LV2_Atom_Sequence *)data; + break; + case SFIZZ_LEFT: + self->output_buffers[0] = (float *)data; + break; + case SFIZZ_RIGHT: + self->output_buffers[1] = (float *)data; + break; + case SFIZZ_VOLUME: + self->volume_port = (const float *)data; + break; + case SFIZZ_POLYPHONY: + self->polyphony_port = (const float *)data; + break; + default: + break; + } +} + +static LV2_Handle +instantiate(const LV2_Descriptor *descriptor, + double rate, + const char *path, + const LV2_Feature *const *features) +{ + UNUSED(descriptor); + UNUSED(path); + LV2_Options_Option *options; + bool supports_bounded_block_size = false; + bool options_has_block_size = false; + bool supports_fixed_block_size = false; + + // Allocate and initialise instance structure. + sfizz_plugin_t *self = (sfizz_plugin_t *)calloc(1, sizeof(sfizz_plugin_t)); + if (!self) + return NULL; + + // Set defaults + self->max_block_size = MAX_BLOCK_SIZE; + self->sample_rate = (float)rate; + self->expect_nominal_block_length = false; + self->sfz_file_path[0] = '\0'; + self->num_voices = DEFAULT_VOICES; + self->changing_voices = false; + + // Get the features from the host and populate the structure + for (const LV2_Feature *const *f = features; *f; f++) + { + // lv2_log_note(&self->logger, "Feature URI: %s\n", (**f).URI); + + if (!strcmp((**f).URI, LV2_URID__map)) + self->map = (**f).data; + + if (!strcmp((**f).URI, LV2_URID__unmap)) + self->unmap = (**f).data; + + if (!strcmp((**f).URI, LV2_BUF_SIZE__boundedBlockLength)) + supports_bounded_block_size = true; + + if (!strcmp((**f).URI, LV2_BUF_SIZE__fixedBlockLength)) + supports_fixed_block_size = true; + + if (!strcmp((**f).URI, LV2_OPTIONS__options)) + options = (**f).data; + + if (!strcmp((**f).URI, LV2_WORKER__schedule)) + self->worker = (**f).data; + + if (!strcmp((**f).URI, LV2_LOG__log)) + self->log = (**f).data; + } + + // Setup the loggers + lv2_log_logger_init(&self->logger, self->map, self->log); + + // The map feature is required + if (!self->map) + { + lv2_log_error(&self->logger, "Map feature not found, aborting...\n"); + free(self); + return NULL; + } + + // The worker feature is required + if (!self->worker) + { + lv2_log_error(&self->logger, "Worker feature not found, aborting...\n"); + free(self); + return NULL; + } + + // Map the URIs we will need + sfizz_lv2_map_required_uris(self); + + // Initialize the forge + lv2_atom_forge_init(&self->forge, self->map); + + // Check the options for the block size and sample rate parameters + if (options) + { + for (const LV2_Options_Option *opt = options; opt->value; ++opt) + { + if (opt->key == self->sample_rate_uri) + { + if (opt->type != self->atom_float_uri) + { + lv2_log_warning(&self->logger, "Got a sample rate but the type was wrong\n"); + continue; + } + self->sample_rate = *(float *)opt->value; + } + else if (!self->expect_nominal_block_length && opt->key == self->max_block_length_uri) + { + if (opt->type != self->atom_int_uri) + { + lv2_log_warning(&self->logger, "Got a max block size but the type was wrong\n"); + continue; + } + self->max_block_size = *(int *)opt->value; + options_has_block_size = true; + } + else if (opt->key == self->nominal_block_length_uri) + { + if (opt->type != self->atom_int_uri) + { + lv2_log_warning(&self->logger, "Got a nominal block size but the type was wrong\n"); + continue; + } + self->max_block_size = *(int *)opt->value; + self->expect_nominal_block_length = true; + options_has_block_size = true; + } + } + } + else + { + lv2_log_warning(&self->logger, + "No option array was given upon instantiation; will use default values\n."); + } + + // We need _some_ information on the block size + if (!supports_bounded_block_size && !supports_fixed_block_size && !options_has_block_size) + { + lv2_log_error(&self->logger, + "Bounded block size not supported and options gave no block size, aborting...\n"); + free(self); + return NULL; + } + + return (LV2_Handle)self; +} + +static void +cleanup(LV2_Handle instance) +{ + sfizz_plugin_t *self = (sfizz_plugin_t *)instance; + free(self); +} + +static void +activate(LV2_Handle instance) +{ + sfizz_plugin_t *self = (sfizz_plugin_t *)instance; + self->synth = sfizz_create_synth(); + sfizz_set_samples_per_block(self->synth, self->max_block_size); + sfizz_set_sample_rate(self->synth, self->sample_rate); + if (self->sfz_file_path && strlen(self->sfz_file_path) > 0) + { + lv2_log_note(&self->logger, "Current file is: %s\n", self->sfz_file_path); + sfizz_load_file(self->synth, self->sfz_file_path); + } +} + +static void +deactivate(LV2_Handle instance) +{ + sfizz_plugin_t *self = (sfizz_plugin_t *)instance; + sfizz_free(self->synth); +} + +static void +sfizz_lv2_handle_atom_object(sfizz_plugin_t *self, const LV2_Atom_Object *obj) +{ + const LV2_Atom *property = NULL; + lv2_atom_object_get(obj, self->patch_property_uri, &property, 0); + if (!property) + { + lv2_log_error(&self->logger, + "[handle_object] Could not get the property from the patch object, aborting.\n"); + return; + } + + if (property->type != self->atom_urid_uri) + { + lv2_log_error(&self->logger, + "[handle_object] Atom type was not a URID, aborting.\n"); + return; + } + + const uint32_t key = ((const LV2_Atom_URID *)property)->body; + const LV2_Atom *atom = NULL; + lv2_atom_object_get(obj, self->patch_value_uri, &atom, 0); + if (!atom) + { + lv2_log_error(&self->logger, "[handle_object] Error retrieving the atom, aborting.\n"); + if (self->unmap) + lv2_log_warning(&self->logger, + "Atom URI: %s\n", + self->unmap->unmap(self->unmap->handle, key)); + return; + } + + if (key == self->sfizz_sfz_file_uri) + { + + 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; + char atom_buffer[null_terminated_atom_size]; + memcpy(&atom_buffer, atom, original_atom_size); + atom_buffer[original_atom_size] = 0; // Null terminate the string for safety + LV2_Atom *sfz_file_path = (LV2_Atom *)&atom_buffer; + sfz_file_path->type = self->sfizz_sfz_file_uri; + + // If the parameter is different from the current one we send it through + if (strcmp(self->sfz_file_path, LV2_ATOM_BODY_CONST(sfz_file_path))) + self->worker->schedule_work(self->worker->handle, null_terminated_atom_size, sfz_file_path); + lv2_log_note(&self->logger, "[handle_object] Received an SFZ file: %s\n", (char*)LV2_ATOM_BODY_CONST(sfz_file_path)); + } + else + { + lv2_log_warning(&self->logger, "[handle_object] Unknown or unsupported object.\n"); + if (self->unmap) + lv2_log_warning(&self->logger, + "Object URI: %s\n", + self->unmap->unmap(self->unmap->handle, key)); + return; + } + + // Pfiou, we got a valid parameter, so send it to the worker +} + +static void +sfizz_lv2_process_midi_event(sfizz_plugin_t *self, const LV2_Atom_Event *ev) +{ + const uint8_t *const msg = (const uint8_t *)(ev + 1); + switch (lv2_midi_message_type(msg)) + { + case LV2_MIDI_MSG_NOTE_ON: + // lv2_log_note(&self->logger, + // "[process_midi] Received note on %d/%d at time %d\n", msg[0], msg[1], ev->time.frames); + sfizz_send_note_on(self->synth, + (int)ev->time.frames, + (int)MIDI_CHANNEL(msg[0]) + 1, + (int)msg[1], + msg[2]); + break; + case LV2_MIDI_MSG_NOTE_OFF: + // lv2_log_note(&self->logger, + // "[process_midi] Received note off %d/%d at time %d\n", msg[0], msg[1], ev->time.frames); + sfizz_send_note_off(self->synth, + (int)ev->time.frames, + (int)MIDI_CHANNEL(msg[0]) + 1, + (int)msg[1], + msg[2]); + break; + case LV2_MIDI_MSG_CONTROLLER: + // lv2_log_note(&self->logger, + // "[process_midi] Received CC %d/%d at time %d\n", msg[0], msg[1], ev->time.frames); + sfizz_send_cc(self->synth, + (int)ev->time.frames, + (int)MIDI_CHANNEL(msg[0]) + 1, + (int)msg[1], + msg[2]); + break; + default: + break; + } +} + +static void sfizz_lv2_send_file_path(sfizz_plugin_t *self) +{ + LV2_Atom_Forge_Frame frame; + lv2_atom_forge_frame_time(&self->forge, 0); + lv2_atom_forge_object(&self->forge, &frame, 0, self->patch_set_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_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_pop(&self->forge, &frame); +} + +static void +run(LV2_Handle instance, uint32_t sample_count) +{ + sfizz_plugin_t *self = (sfizz_plugin_t *)instance; + if (!self->control_port || !self->notify_port) + return; + + // Set up forge to write directly to notify output port. + const size_t notify_capacity = self->notify_port->atom.size; + lv2_atom_forge_set_buffer(&self->forge, (uint8_t *)self->notify_port, notify_capacity); + + // Start a sequence in the notify output port. + lv2_atom_forge_sequence_head(&self->forge, &self->notify_frame, 0); + + LV2_ATOM_SEQUENCE_FOREACH(self->control_port, ev) + { + // If the received atom is an object/patch message + if (ev->body.type == self->atom_object_uri) + { + const LV2_Atom_Object *obj = (const LV2_Atom_Object *)&ev->body; + if (obj->body.otype == self->patch_set_uri) + { + sfizz_lv2_handle_atom_object(self, obj); + } + else if (obj->body.otype == self->patch_get_uri) + { + const LV2_Atom_URID *property = NULL; + lv2_atom_object_get(obj, self->patch_property_uri, &property, 0); + if (!property) // Send the full state + { + sfizz_lv2_send_file_path(self); + } + else if (property->body == self->sfizz_sfz_file_uri) + { + sfizz_lv2_send_file_path(self); + } + } + else + { + lv2_log_warning(&self->logger, "Got an Object atom but it was not supported.\n"); + if (self->unmap) + lv2_log_warning(&self->logger, + "Object URI: %s\n", + self->unmap->unmap(self->unmap->handle, obj->body.otype)); + continue; + } + // Got an atom that is a MIDI event + } + else if (ev->body.type == self->midi_event_uri) + { + sfizz_lv2_process_midi_event(self, ev); + } + } + + float volume = *(self->volume_port); + sfizz_set_volume(self->synth, volume); + + int num_voices = (int)*self->polyphony_port; + if (num_voices != self->num_voices && !self->changing_voices) + { + lv2_log_note(&self->logger, "[run] Number of voices changed to %d\n", num_voices); + LV2_Atom_Int num_voices_atom; + num_voices_atom.atom.type = self->sfizz_num_voices_uri; + num_voices_atom.atom.size = sizeof(int); + num_voices_atom.body = num_voices; + if (self->worker->schedule_work(self->worker->handle, + lv2_atom_total_size((LV2_Atom*)&num_voices_atom), + &num_voices_atom) == LV2_WORKER_SUCCESS) + { + self->changing_voices = true; + } + } + + // Render the block + sfizz_render_block(self->synth, self->output_buffers, 2, (int)sample_count); +} + +static uint32_t +lv2_get_options(LV2_Handle instance, LV2_Options_Option *options) +{ + UNUSED(instance); + UNUSED(options); + // We have no options + return LV2_OPTIONS_ERR_UNKNOWN; +} + +static uint32_t +lv2_set_options(LV2_Handle instance, const LV2_Options_Option *options) +{ + sfizz_plugin_t *self = (sfizz_plugin_t *)instance; + + // Update the block size and sample rate as needed + for (const LV2_Options_Option *opt = options; opt->value; ++opt) + { + if (opt->key == self->sample_rate_uri) + { + if (opt->type != self->atom_float_uri) + { + lv2_log_warning(&self->logger, "Got a sample rate but the type was wrong\n"); + continue; + } + self->sample_rate = *(float *)opt->value; + sfizz_set_sample_rate(self->synth, self->sample_rate); + } + else if (!self->expect_nominal_block_length && opt->key == self->max_block_length_uri) + { + if (opt->type != self->atom_int_uri) + { + lv2_log_warning(&self->logger, "Got a max block size but the type was wrong\n"); + continue; + } + self->max_block_size = *(int *)opt->value; + sfizz_set_samples_per_block(self->synth, self->max_block_size); + } + else if (opt->key == self->nominal_block_length_uri) + { + if (opt->type != self->atom_int_uri) + { + lv2_log_warning(&self->logger, "Got a nominal block size but the type was wrong\n"); + continue; + } + self->max_block_size = *(int *)opt->value; + sfizz_set_samples_per_block(self->synth, self->max_block_size); + } + } + return LV2_OPTIONS_SUCCESS; +} + +static LV2_State_Status +restore(LV2_Handle instance, + LV2_State_Retrieve_Function retrieve, + LV2_State_Handle handle, + uint32_t flags, + const LV2_Feature *const *features) +{ + UNUSED(flags); + UNUSED(features); + sfizz_plugin_t *self = (sfizz_plugin_t *)instance; + + // Fetch back the saved file path, if any + size_t size; + uint32_t type; + uint32_t val_flags; + const void *value; + value = retrieve(handle, self->sfizz_sfz_file_uri, &size, &type, &val_flags); + if (value) + { + lv2_log_note(&self->logger, "Restoring the file %s\n", (const char *)value); + if (sfizz_load_file(self->synth, (const char *)value)) + strcpy(self->sfz_file_path, (const char *)value); + } + + value = retrieve(handle, self->sfizz_num_voices_uri, &size, &type, &val_flags); + if (value) + { + int num_voices = *(const int *)value; + if (num_voices > 0 && num_voices <= MAX_VOICES && num_voices != self->num_voices) + { + lv2_log_note(&self->logger, "Restoring the number of voices to %d\n", num_voices); + sfizz_set_num_voices(self->synth, num_voices); + self->num_voices = num_voices; + } + } + return LV2_STATE_SUCCESS; +} + +static LV2_State_Status +save(LV2_Handle instance, + LV2_State_Store_Function store, + LV2_State_Handle handle, + uint32_t flags, + const LV2_Feature *const *features) +{ + UNUSED(flags); + UNUSED(features); + sfizz_plugin_t *self = (sfizz_plugin_t *)instance; + // Save the file path + store(handle, + self->sfizz_sfz_file_uri, + self->sfz_file_path, + strlen(self->sfz_file_path) + 1, + self->atom_path_uri, + LV2_STATE_IS_POD); + + // Save the number of voices + store(handle, + self->sfizz_num_voices_uri, + &self->num_voices, + sizeof(int), + self->atom_int_uri, + LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE); + + return LV2_STATE_SUCCESS; +} + +// This runs in a lower priority thread +static LV2_Worker_Status +work(LV2_Handle instance, + LV2_Worker_Respond_Function respond, + LV2_Worker_Respond_Handle handle, + uint32_t size, + const void *data) +{ + sfizz_plugin_t *self = (sfizz_plugin_t *)instance; + if (!data) + { + lv2_log_error(&self->logger, "[worker] Got an empty data.\n"); + return LV2_WORKER_ERR_UNKNOWN; + } + + const LV2_Atom *atom = (const LV2_Atom *)data; + if (atom->type == self->sfizz_sfz_file_uri) + { + const char *sfz_file_path = LV2_ATOM_BODY_CONST(atom); + lv2_log_note(&self->logger, "[work] Loading file: %s\n", sfz_file_path); + sfizz_load_file(self->synth, sfz_file_path); + } + else if (atom->type == self->sfizz_num_voices_uri) + { + const int num_voices = *(const int *)LV2_ATOM_BODY_CONST(atom); + lv2_log_note(&self->logger, "[work] Changing number of voices to: %d\n", num_voices); + sfizz_set_num_voices(self->synth, num_voices); + } + else + { + lv2_log_error(&self->logger, "[worker] Got an unknown atom.\n"); + if (self->unmap) + lv2_log_error(&self->logger, + "URI: %s\n", + self->unmap->unmap(self->unmap->handle, atom->type)); + return LV2_WORKER_ERR_UNKNOWN; + } + + respond(handle, size, data); + return LV2_WORKER_SUCCESS; +} + +// This runs in the audio thread +static LV2_Worker_Status +work_response(LV2_Handle instance, + uint32_t size, + const void *data) +{ + UNUSED(size); + sfizz_plugin_t *self = (sfizz_plugin_t *)instance; + + if (!data) + return LV2_WORKER_ERR_UNKNOWN; + + const LV2_Atom *atom = (const LV2_Atom *)data; + if (atom->type == self->sfizz_sfz_file_uri) + { + const char *sfz_file_path = LV2_ATOM_BODY_CONST(atom); + strcpy(self->sfz_file_path, sfz_file_path); + lv2_log_note(&self->logger, "[work_response] File changed to: %s\n", self->sfz_file_path); + } + else if (atom->type == self->sfizz_num_voices_uri) + { + const int num_voices = *(const int *)LV2_ATOM_BODY_CONST(atom); + self->num_voices = num_voices; + self->changing_voices = false; + lv2_log_note(&self->logger, "[work_response] Number of voices changed to: %d\n", self->num_voices); + } + else + { + lv2_log_error(&self->logger, "[work_response] Got an unknown atom.\n"); + if (self->unmap) + lv2_log_error(&self->logger, + "URI: %s\n", + self->unmap->unmap(self->unmap->handle, atom->type)); + return LV2_WORKER_ERR_UNKNOWN; + } + + return LV2_WORKER_SUCCESS; +} + +static const void * +extension_data(const char *uri) +{ + static const LV2_Options_Interface options = {lv2_get_options, lv2_set_options}; + static const LV2_State_Interface state = {save, restore}; + static const LV2_Worker_Interface worker = {work, work_response, NULL}; + + // Advertise the extensions we support + if (!strcmp(uri, LV2_OPTIONS__interface)) + return &options; + else if (!strcmp(uri, LV2_STATE__interface)) + return &state; + else if (!strcmp(uri, LV2_WORKER__interface)) + return &worker; + + return NULL; +} + +static const LV2_Descriptor descriptor = { + SFIZZ_URI, + instantiate, + connect_port, + activate, + run, + deactivate, + cleanup, + extension_data}; + +LV2_SYMBOL_EXPORT +const LV2_Descriptor * +lv2_descriptor(uint32_t index) +{ + switch (index) + { + case 0: + return &descriptor; + default: + return NULL; + } +} diff --git a/lv2/sfizz.ttl b/lv2/sfizz.ttl new file mode 100644 index 00000000..f818c27a --- /dev/null +++ b/lv2/sfizz.ttl @@ -0,0 +1,95 @@ +@prefix atom: . +@prefix doap: . +@prefix lv2: . +@prefix rdfs: . +@prefix rdf: . +@prefix urid: . +@prefix midi: . +@prefix bufsize: . +@prefix opts: . +@prefix patch: . +@prefix units: . +@prefix state: . +@prefix work: . +@prefix pprop: . +@prefix pg: . + +<#config> + a pg:Group ; + lv2:symbol "config" ; + lv2:name "Configuration" . + + + a lv2:Parameter ; + rdfs:label "SFZ file" ; + rdfs:range atom:Path . + + + a lv2:Parameter ; + rdfs:label "Polyphony" ; + rdfs:range atom:Int . + + + a doap:Project, lv2:Plugin, lv2:InstrumentPlugin; + doap:name "Sfizz" ; + lv2:requiredFeature urid:map, bufsize:boundedBlockLength, work:schedule; + rdfs:comment "SFZ sampler" ; + lv2:optionalFeature lv2:hardRTCapable, opts:options; + lv2:extensionData opts:interface, state:interface, work:interface ; + patch:writable ; + lv2:port [ + a lv2:InputPort, atom:AtomPort ; + atom:bufferType atom:Sequence ; + atom:supports patch:Message, midi:MidiEvent; + lv2:designation lv2:control ; + lv2:index 0 ; + lv2:symbol "control" ; + lv2:name "Control" + ] , [ + a lv2:OutputPort, atom:AtomPort ; + atom:bufferType atom:Sequence ; + atom:supports patch:Message ; + lv2:designation lv2:control ; + lv2:index 1 ; + lv2:symbol "notify" ; + lv2:name "Notify" ; + ] , [ + a lv2:AudioPort , lv2:OutputPort ; + lv2:index 2 ; + lv2:symbol "out_left" ; + lv2:name "Left Output" + ] , [ + a lv2:AudioPort , lv2:OutputPort ; + lv2:index 3 ; + lv2:symbol "out_right" ; + lv2:name "Right Output" + ] , [ + a lv2:InputPort, lv2:ControlPort ; + lv2:index 4 ; + lv2:symbol "volume" ; + lv2:name "Volume" ; + lv2:default 0.0 ; + lv2:minimum -80.0 ; + lv2:maximum 6.0; + lv2:portProperty pprop:notAutomatic; + units:unit units:db + ], [ + a lv2:InputPort, lv2:ControlPort ; + lv2:index 5 ; + lv2:symbol "num_voices" ; + lv2:name "Polyphony" ; + pg:group <#config>; + lv2:portProperty pprop:notAutomatic ; + lv2:portProperty pprop:expensive ; + lv2:portProperty lv2:integer; + lv2:portProperty lv2:enumeration ; + lv2:default 64 ; + lv2:minimum 8 ; + lv2:maximum 256 ; + lv2:scalePoint [ rdfs:label "8 voices"; rdf:value 8 ] ; + lv2:scalePoint [ rdfs:label "16 voices"; rdf:value 16 ] ; + lv2:scalePoint [ rdfs:label "32 voices"; rdf:value 32 ] ; + lv2:scalePoint [ rdfs:label "64 voices"; rdf:value 64 ] ; + lv2:scalePoint [ rdfs:label "128 voices"; rdf:value 128 ] ; + lv2:scalePoint [ rdfs:label "256 voices"; rdf:value 256 ] ; + ]. From ea00d59f5abca408d6ff46842f8fc31a151a5e20 Mon Sep 17 00:00:00 2001 From: Paul Ferrand Date: Sat, 23 Nov 2019 17:28:11 +0100 Subject: [PATCH 08/32] Move the last stuff around and add an hpp include for c++ --- {sfizz => include/sfizz}/sfizz.h | 0 include/sfizz/sfizz.hpp | 1 + {sfizz => scripts}/sfizz.pc.in | 0 sfizz/sfizz.cpp => src/sfizz_wrapper.cpp | 0 4 files changed, 1 insertion(+) rename {sfizz => include/sfizz}/sfizz.h (100%) create mode 100644 include/sfizz/sfizz.hpp rename {sfizz => scripts}/sfizz.pc.in (100%) rename sfizz/sfizz.cpp => src/sfizz_wrapper.cpp (100%) diff --git a/sfizz/sfizz.h b/include/sfizz/sfizz.h similarity index 100% rename from sfizz/sfizz.h rename to include/sfizz/sfizz.h diff --git a/include/sfizz/sfizz.hpp b/include/sfizz/sfizz.hpp new file mode 100644 index 00000000..8d1c8b69 --- /dev/null +++ b/include/sfizz/sfizz.hpp @@ -0,0 +1 @@ + diff --git a/sfizz/sfizz.pc.in b/scripts/sfizz.pc.in similarity index 100% rename from sfizz/sfizz.pc.in rename to scripts/sfizz.pc.in diff --git a/sfizz/sfizz.cpp b/src/sfizz_wrapper.cpp similarity index 100% rename from sfizz/sfizz.cpp rename to src/sfizz_wrapper.cpp From 34fd01a2eaf4c811b36218b21d4129b97221ae59 Mon Sep 17 00:00:00 2001 From: Paul Ferrand Date: Sat, 23 Nov 2019 17:30:56 +0100 Subject: [PATCH 09/32] Move the old cmakefiles to create the new ones --- .../CMakeLists.txt => old_cmake/benchmark.txt | 13 +++++++++++++ clients/CMakeLists.txt => old_cmake/client.txt | 0 lv2/CMakeLists.txt => old_cmake/lv2.txt | 0 CMakeLists.txt => old_cmake/root.txt | 0 src/CMakeLists.txt => old_cmake/sfizz_source.txt | 0 tests/CMakeLists.txt => old_cmake/tests.txt | 0 6 files changed, 13 insertions(+) rename benchmarks/CMakeLists.txt => old_cmake/benchmark.txt (92%) rename clients/CMakeLists.txt => old_cmake/client.txt (100%) rename lv2/CMakeLists.txt => old_cmake/lv2.txt (100%) rename CMakeLists.txt => old_cmake/root.txt (100%) rename src/CMakeLists.txt => old_cmake/sfizz_source.txt (100%) rename tests/CMakeLists.txt => old_cmake/tests.txt (100%) diff --git a/benchmarks/CMakeLists.txt b/old_cmake/benchmark.txt similarity index 92% rename from benchmarks/CMakeLists.txt rename to old_cmake/benchmark.txt index 2a4e0342..350482ab 100644 --- a/benchmarks/CMakeLists.txt +++ b/old_cmake/benchmark.txt @@ -1,5 +1,18 @@ project(sfizz) +include(FetchContent) +FetchContent_Declare( + benchmark + GIT_REPOSITORY https://github.com/google/benchmark.git + GIT_TAG v1.5.0 +) + +FetchContent_GetProperties(benchmark) +if(NOT benchmark_POPULATED) + FetchContent_Populate(benchmark) + add_subdirectory(${benchmark_SOURCE_DIR} ${benchmark_BINARY_DIR}) +endif() + # Check SIMD include(CheckIncludeFiles) CHECK_INCLUDE_FILES(x86intrin.h HAVE_X86INTRIN_H) diff --git a/clients/CMakeLists.txt b/old_cmake/client.txt similarity index 100% rename from clients/CMakeLists.txt rename to old_cmake/client.txt diff --git a/lv2/CMakeLists.txt b/old_cmake/lv2.txt similarity index 100% rename from lv2/CMakeLists.txt rename to old_cmake/lv2.txt diff --git a/CMakeLists.txt b/old_cmake/root.txt similarity index 100% rename from CMakeLists.txt rename to old_cmake/root.txt diff --git a/src/CMakeLists.txt b/old_cmake/sfizz_source.txt similarity index 100% rename from src/CMakeLists.txt rename to old_cmake/sfizz_source.txt diff --git a/tests/CMakeLists.txt b/old_cmake/tests.txt similarity index 100% rename from tests/CMakeLists.txt rename to old_cmake/tests.txt From 2c6e9b051011d4cc927a76bdf51321429296620d Mon Sep 17 00:00:00 2001 From: Paul Ferrand Date: Sat, 23 Nov 2019 17:40:55 +0100 Subject: [PATCH 10/32] reflush things around --- {include/sfizz => src}/sfizz.h | 0 {include/sfizz => src}/sfizz.hpp | 0 src/{ => sfizz}/ADSREnvelope.cpp | 0 src/{ => sfizz}/ADSREnvelope.h | 0 src/{ => sfizz}/AtomicGuard.h | 0 src/{ => sfizz}/AudioBuffer.h | 0 src/{ => sfizz}/AudioSpan.h | 0 src/{ => sfizz}/Buffer.h | 0 src/{ => sfizz}/CCMap.h | 0 src/{ => sfizz}/Config.h | 0 src/{ => sfizz}/Debug.h | 0 src/{ => sfizz}/Defaults.h | 0 src/{ => sfizz}/EGDescription.h | 0 src/{ => sfizz}/FilePool.cpp | 0 src/{ => sfizz}/FilePool.h | 0 src/{ => sfizz}/FloatEnvelopes.cpp | 0 src/{ => sfizz}/HistoricalBuffer.h | 0 src/{ => sfizz}/LeakDetector.h | 0 src/{ => sfizz}/LinearEnvelope.cpp | 0 src/{ => sfizz}/LinearEnvelope.h | 0 src/{ => sfizz}/MathHelpers.h | 0 src/{ => sfizz}/MidiState.h | 0 src/{ => sfizz}/OnePoleFilter.h | 0 src/{ => sfizz}/Opcode.cpp | 0 src/{ => sfizz}/Opcode.h | 0 src/{ => sfizz}/Parser.cpp | 0 src/{ => sfizz}/Parser.h | 0 src/{ => sfizz}/Range.h | 0 src/{ => sfizz}/Regexes.h | 0 src/{ => sfizz}/Region.cpp | 0 src/{ => sfizz}/Region.h | 0 src/{ => sfizz}/SIMDDummy.cpp | 0 src/{ => sfizz}/SIMDHelpers.h | 0 src/{ => sfizz}/SIMDSSE.cpp | 0 src/{ => sfizz}/ScopedFTZ.cpp | 0 src/{ => sfizz}/ScopedFTZ.h | 0 src/{ => sfizz}/SfzHelpers.cpp | 0 src/{ => sfizz}/SfzHelpers.h | 0 src/{ => sfizz}/StringViewHelpers.h | 0 src/{ => sfizz}/Synth.cpp | 0 src/{ => sfizz}/Synth.h | 0 src/{ => sfizz}/Voice.cpp | 0 src/{ => sfizz}/Voice.h | 0 src/{ => sfizz}/sfizz_wrapper.cpp | 0 44 files changed, 0 insertions(+), 0 deletions(-) rename {include/sfizz => src}/sfizz.h (100%) rename {include/sfizz => src}/sfizz.hpp (100%) rename src/{ => sfizz}/ADSREnvelope.cpp (100%) rename src/{ => sfizz}/ADSREnvelope.h (100%) rename src/{ => sfizz}/AtomicGuard.h (100%) rename src/{ => sfizz}/AudioBuffer.h (100%) rename src/{ => sfizz}/AudioSpan.h (100%) rename src/{ => sfizz}/Buffer.h (100%) rename src/{ => sfizz}/CCMap.h (100%) rename src/{ => sfizz}/Config.h (100%) rename src/{ => sfizz}/Debug.h (100%) rename src/{ => sfizz}/Defaults.h (100%) rename src/{ => sfizz}/EGDescription.h (100%) rename src/{ => sfizz}/FilePool.cpp (100%) rename src/{ => sfizz}/FilePool.h (100%) rename src/{ => sfizz}/FloatEnvelopes.cpp (100%) rename src/{ => sfizz}/HistoricalBuffer.h (100%) rename src/{ => sfizz}/LeakDetector.h (100%) rename src/{ => sfizz}/LinearEnvelope.cpp (100%) rename src/{ => sfizz}/LinearEnvelope.h (100%) rename src/{ => sfizz}/MathHelpers.h (100%) rename src/{ => sfizz}/MidiState.h (100%) rename src/{ => sfizz}/OnePoleFilter.h (100%) rename src/{ => sfizz}/Opcode.cpp (100%) rename src/{ => sfizz}/Opcode.h (100%) rename src/{ => sfizz}/Parser.cpp (100%) rename src/{ => sfizz}/Parser.h (100%) rename src/{ => sfizz}/Range.h (100%) rename src/{ => sfizz}/Regexes.h (100%) rename src/{ => sfizz}/Region.cpp (100%) rename src/{ => sfizz}/Region.h (100%) rename src/{ => sfizz}/SIMDDummy.cpp (100%) rename src/{ => sfizz}/SIMDHelpers.h (100%) rename src/{ => sfizz}/SIMDSSE.cpp (100%) rename src/{ => sfizz}/ScopedFTZ.cpp (100%) rename src/{ => sfizz}/ScopedFTZ.h (100%) rename src/{ => sfizz}/SfzHelpers.cpp (100%) rename src/{ => sfizz}/SfzHelpers.h (100%) rename src/{ => sfizz}/StringViewHelpers.h (100%) rename src/{ => sfizz}/Synth.cpp (100%) rename src/{ => sfizz}/Synth.h (100%) rename src/{ => sfizz}/Voice.cpp (100%) rename src/{ => sfizz}/Voice.h (100%) rename src/{ => sfizz}/sfizz_wrapper.cpp (100%) diff --git a/include/sfizz/sfizz.h b/src/sfizz.h similarity index 100% rename from include/sfizz/sfizz.h rename to src/sfizz.h diff --git a/include/sfizz/sfizz.hpp b/src/sfizz.hpp similarity index 100% rename from include/sfizz/sfizz.hpp rename to src/sfizz.hpp diff --git a/src/ADSREnvelope.cpp b/src/sfizz/ADSREnvelope.cpp similarity index 100% rename from src/ADSREnvelope.cpp rename to src/sfizz/ADSREnvelope.cpp diff --git a/src/ADSREnvelope.h b/src/sfizz/ADSREnvelope.h similarity index 100% rename from src/ADSREnvelope.h rename to src/sfizz/ADSREnvelope.h diff --git a/src/AtomicGuard.h b/src/sfizz/AtomicGuard.h similarity index 100% rename from src/AtomicGuard.h rename to src/sfizz/AtomicGuard.h diff --git a/src/AudioBuffer.h b/src/sfizz/AudioBuffer.h similarity index 100% rename from src/AudioBuffer.h rename to src/sfizz/AudioBuffer.h diff --git a/src/AudioSpan.h b/src/sfizz/AudioSpan.h similarity index 100% rename from src/AudioSpan.h rename to src/sfizz/AudioSpan.h diff --git a/src/Buffer.h b/src/sfizz/Buffer.h similarity index 100% rename from src/Buffer.h rename to src/sfizz/Buffer.h diff --git a/src/CCMap.h b/src/sfizz/CCMap.h similarity index 100% rename from src/CCMap.h rename to src/sfizz/CCMap.h diff --git a/src/Config.h b/src/sfizz/Config.h similarity index 100% rename from src/Config.h rename to src/sfizz/Config.h diff --git a/src/Debug.h b/src/sfizz/Debug.h similarity index 100% rename from src/Debug.h rename to src/sfizz/Debug.h diff --git a/src/Defaults.h b/src/sfizz/Defaults.h similarity index 100% rename from src/Defaults.h rename to src/sfizz/Defaults.h diff --git a/src/EGDescription.h b/src/sfizz/EGDescription.h similarity index 100% rename from src/EGDescription.h rename to src/sfizz/EGDescription.h diff --git a/src/FilePool.cpp b/src/sfizz/FilePool.cpp similarity index 100% rename from src/FilePool.cpp rename to src/sfizz/FilePool.cpp diff --git a/src/FilePool.h b/src/sfizz/FilePool.h similarity index 100% rename from src/FilePool.h rename to src/sfizz/FilePool.h diff --git a/src/FloatEnvelopes.cpp b/src/sfizz/FloatEnvelopes.cpp similarity index 100% rename from src/FloatEnvelopes.cpp rename to src/sfizz/FloatEnvelopes.cpp diff --git a/src/HistoricalBuffer.h b/src/sfizz/HistoricalBuffer.h similarity index 100% rename from src/HistoricalBuffer.h rename to src/sfizz/HistoricalBuffer.h diff --git a/src/LeakDetector.h b/src/sfizz/LeakDetector.h similarity index 100% rename from src/LeakDetector.h rename to src/sfizz/LeakDetector.h diff --git a/src/LinearEnvelope.cpp b/src/sfizz/LinearEnvelope.cpp similarity index 100% rename from src/LinearEnvelope.cpp rename to src/sfizz/LinearEnvelope.cpp diff --git a/src/LinearEnvelope.h b/src/sfizz/LinearEnvelope.h similarity index 100% rename from src/LinearEnvelope.h rename to src/sfizz/LinearEnvelope.h diff --git a/src/MathHelpers.h b/src/sfizz/MathHelpers.h similarity index 100% rename from src/MathHelpers.h rename to src/sfizz/MathHelpers.h diff --git a/src/MidiState.h b/src/sfizz/MidiState.h similarity index 100% rename from src/MidiState.h rename to src/sfizz/MidiState.h diff --git a/src/OnePoleFilter.h b/src/sfizz/OnePoleFilter.h similarity index 100% rename from src/OnePoleFilter.h rename to src/sfizz/OnePoleFilter.h diff --git a/src/Opcode.cpp b/src/sfizz/Opcode.cpp similarity index 100% rename from src/Opcode.cpp rename to src/sfizz/Opcode.cpp diff --git a/src/Opcode.h b/src/sfizz/Opcode.h similarity index 100% rename from src/Opcode.h rename to src/sfizz/Opcode.h diff --git a/src/Parser.cpp b/src/sfizz/Parser.cpp similarity index 100% rename from src/Parser.cpp rename to src/sfizz/Parser.cpp diff --git a/src/Parser.h b/src/sfizz/Parser.h similarity index 100% rename from src/Parser.h rename to src/sfizz/Parser.h diff --git a/src/Range.h b/src/sfizz/Range.h similarity index 100% rename from src/Range.h rename to src/sfizz/Range.h diff --git a/src/Regexes.h b/src/sfizz/Regexes.h similarity index 100% rename from src/Regexes.h rename to src/sfizz/Regexes.h diff --git a/src/Region.cpp b/src/sfizz/Region.cpp similarity index 100% rename from src/Region.cpp rename to src/sfizz/Region.cpp diff --git a/src/Region.h b/src/sfizz/Region.h similarity index 100% rename from src/Region.h rename to src/sfizz/Region.h diff --git a/src/SIMDDummy.cpp b/src/sfizz/SIMDDummy.cpp similarity index 100% rename from src/SIMDDummy.cpp rename to src/sfizz/SIMDDummy.cpp diff --git a/src/SIMDHelpers.h b/src/sfizz/SIMDHelpers.h similarity index 100% rename from src/SIMDHelpers.h rename to src/sfizz/SIMDHelpers.h diff --git a/src/SIMDSSE.cpp b/src/sfizz/SIMDSSE.cpp similarity index 100% rename from src/SIMDSSE.cpp rename to src/sfizz/SIMDSSE.cpp diff --git a/src/ScopedFTZ.cpp b/src/sfizz/ScopedFTZ.cpp similarity index 100% rename from src/ScopedFTZ.cpp rename to src/sfizz/ScopedFTZ.cpp diff --git a/src/ScopedFTZ.h b/src/sfizz/ScopedFTZ.h similarity index 100% rename from src/ScopedFTZ.h rename to src/sfizz/ScopedFTZ.h diff --git a/src/SfzHelpers.cpp b/src/sfizz/SfzHelpers.cpp similarity index 100% rename from src/SfzHelpers.cpp rename to src/sfizz/SfzHelpers.cpp diff --git a/src/SfzHelpers.h b/src/sfizz/SfzHelpers.h similarity index 100% rename from src/SfzHelpers.h rename to src/sfizz/SfzHelpers.h diff --git a/src/StringViewHelpers.h b/src/sfizz/StringViewHelpers.h similarity index 100% rename from src/StringViewHelpers.h rename to src/sfizz/StringViewHelpers.h diff --git a/src/Synth.cpp b/src/sfizz/Synth.cpp similarity index 100% rename from src/Synth.cpp rename to src/sfizz/Synth.cpp diff --git a/src/Synth.h b/src/sfizz/Synth.h similarity index 100% rename from src/Synth.h rename to src/sfizz/Synth.h diff --git a/src/Voice.cpp b/src/sfizz/Voice.cpp similarity index 100% rename from src/Voice.cpp rename to src/sfizz/Voice.cpp diff --git a/src/Voice.h b/src/sfizz/Voice.h similarity index 100% rename from src/Voice.h rename to src/sfizz/Voice.h diff --git a/src/sfizz_wrapper.cpp b/src/sfizz/sfizz_wrapper.cpp similarity index 100% rename from src/sfizz_wrapper.cpp rename to src/sfizz/sfizz_wrapper.cpp From bac43b5aa9dddcc84d6371ed96c3020d20867ac6 Mon Sep 17 00:00:00 2001 From: Paul Ferrand Date: Sat, 23 Nov 2019 18:03:17 +0100 Subject: [PATCH 11/32] Move stuff again... --- {external => src}/catch2/catch.hpp | 0 {external => src}/catch2/catch_reporter_automake.hpp | 0 {external => src}/catch2/catch_reporter_tap.hpp | 0 {external => src}/catch2/catch_reporter_teamcity.hpp | 0 {external => src/external}/ghc/filesystem.hpp | 0 {external => src/external}/ghc/fs_fwd.hpp | 0 {external => src/external}/ghc/fs_impl.hpp | 0 {external => src/external}/ghc/fs_std.hpp | 0 {external => src/external}/ghc/fs_std_fwd.hpp | 0 {external => src/external}/ghc/fs_std_impl.hpp | 0 {external => src/external}/mathfuns/neon_mathfun.h | 0 {external => src/external}/mathfuns/sse_mathfun.h | 0 {external => src/external}/readerwriterqueue/atomicops.h | 0 {external => src/external}/readerwriterqueue/readerwriterqueue.h | 0 {external => tests}/cnpy/cnpy.cpp | 0 {external => tests}/cnpy/cnpy.h | 0 16 files changed, 0 insertions(+), 0 deletions(-) rename {external => src}/catch2/catch.hpp (100%) rename {external => src}/catch2/catch_reporter_automake.hpp (100%) rename {external => src}/catch2/catch_reporter_tap.hpp (100%) rename {external => src}/catch2/catch_reporter_teamcity.hpp (100%) rename {external => src/external}/ghc/filesystem.hpp (100%) rename {external => src/external}/ghc/fs_fwd.hpp (100%) rename {external => src/external}/ghc/fs_impl.hpp (100%) rename {external => src/external}/ghc/fs_std.hpp (100%) rename {external => src/external}/ghc/fs_std_fwd.hpp (100%) rename {external => src/external}/ghc/fs_std_impl.hpp (100%) rename {external => src/external}/mathfuns/neon_mathfun.h (100%) rename {external => src/external}/mathfuns/sse_mathfun.h (100%) rename {external => src/external}/readerwriterqueue/atomicops.h (100%) rename {external => src/external}/readerwriterqueue/readerwriterqueue.h (100%) rename {external => tests}/cnpy/cnpy.cpp (100%) rename {external => tests}/cnpy/cnpy.h (100%) diff --git a/external/catch2/catch.hpp b/src/catch2/catch.hpp similarity index 100% rename from external/catch2/catch.hpp rename to src/catch2/catch.hpp diff --git a/external/catch2/catch_reporter_automake.hpp b/src/catch2/catch_reporter_automake.hpp similarity index 100% rename from external/catch2/catch_reporter_automake.hpp rename to src/catch2/catch_reporter_automake.hpp diff --git a/external/catch2/catch_reporter_tap.hpp b/src/catch2/catch_reporter_tap.hpp similarity index 100% rename from external/catch2/catch_reporter_tap.hpp rename to src/catch2/catch_reporter_tap.hpp diff --git a/external/catch2/catch_reporter_teamcity.hpp b/src/catch2/catch_reporter_teamcity.hpp similarity index 100% rename from external/catch2/catch_reporter_teamcity.hpp rename to src/catch2/catch_reporter_teamcity.hpp diff --git a/external/ghc/filesystem.hpp b/src/external/ghc/filesystem.hpp similarity index 100% rename from external/ghc/filesystem.hpp rename to src/external/ghc/filesystem.hpp diff --git a/external/ghc/fs_fwd.hpp b/src/external/ghc/fs_fwd.hpp similarity index 100% rename from external/ghc/fs_fwd.hpp rename to src/external/ghc/fs_fwd.hpp diff --git a/external/ghc/fs_impl.hpp b/src/external/ghc/fs_impl.hpp similarity index 100% rename from external/ghc/fs_impl.hpp rename to src/external/ghc/fs_impl.hpp diff --git a/external/ghc/fs_std.hpp b/src/external/ghc/fs_std.hpp similarity index 100% rename from external/ghc/fs_std.hpp rename to src/external/ghc/fs_std.hpp diff --git a/external/ghc/fs_std_fwd.hpp b/src/external/ghc/fs_std_fwd.hpp similarity index 100% rename from external/ghc/fs_std_fwd.hpp rename to src/external/ghc/fs_std_fwd.hpp diff --git a/external/ghc/fs_std_impl.hpp b/src/external/ghc/fs_std_impl.hpp similarity index 100% rename from external/ghc/fs_std_impl.hpp rename to src/external/ghc/fs_std_impl.hpp diff --git a/external/mathfuns/neon_mathfun.h b/src/external/mathfuns/neon_mathfun.h similarity index 100% rename from external/mathfuns/neon_mathfun.h rename to src/external/mathfuns/neon_mathfun.h diff --git a/external/mathfuns/sse_mathfun.h b/src/external/mathfuns/sse_mathfun.h similarity index 100% rename from external/mathfuns/sse_mathfun.h rename to src/external/mathfuns/sse_mathfun.h diff --git a/external/readerwriterqueue/atomicops.h b/src/external/readerwriterqueue/atomicops.h similarity index 100% rename from external/readerwriterqueue/atomicops.h rename to src/external/readerwriterqueue/atomicops.h diff --git a/external/readerwriterqueue/readerwriterqueue.h b/src/external/readerwriterqueue/readerwriterqueue.h similarity index 100% rename from external/readerwriterqueue/readerwriterqueue.h rename to src/external/readerwriterqueue/readerwriterqueue.h diff --git a/external/cnpy/cnpy.cpp b/tests/cnpy/cnpy.cpp similarity index 100% rename from external/cnpy/cnpy.cpp rename to tests/cnpy/cnpy.cpp diff --git a/external/cnpy/cnpy.h b/tests/cnpy/cnpy.h similarity index 100% rename from external/cnpy/cnpy.h rename to tests/cnpy/cnpy.h From 1042a06e242c205c27e56a911dca5bc884412657 Mon Sep 17 00:00:00 2001 From: Paul Ferrand Date: Sat, 23 Nov 2019 18:03:37 +0100 Subject: [PATCH 12/32] Update the headers --- src/sfizz.h | 2 +- src/sfizz.hpp | 3 ++- src/sfizz_parser.hpp | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 src/sfizz_parser.hpp diff --git a/src/sfizz.h b/src/sfizz.h index 86f578c4..34f75085 100644 --- a/src/sfizz.h +++ b/src/sfizz.h @@ -23,7 +23,7 @@ /** @file - @brief sfizz public API. + @brief sfizz public C API */ #pragma once diff --git a/src/sfizz.hpp b/src/sfizz.hpp index 8d1c8b69..4dd6ab25 100644 --- a/src/sfizz.hpp +++ b/src/sfizz.hpp @@ -1 +1,2 @@ - +#include "sfizz/AudioSpan.h" +#include "sfizz/Synth.h" \ No newline at end of file diff --git a/src/sfizz_parser.hpp b/src/sfizz_parser.hpp new file mode 100644 index 00000000..49ef76bc --- /dev/null +++ b/src/sfizz_parser.hpp @@ -0,0 +1,2 @@ +#include "sfizz/Parser.h" +#include "sfizz/Opcode.h" \ No newline at end of file From 460de7fa73797e02a230af0a1e5001ef7aad4079 Mon Sep 17 00:00:00 2001 From: Paul Ferrand Date: Sat, 23 Nov 2019 18:30:45 +0100 Subject: [PATCH 13/32] Move moodycamel's queue --- src/external/{readerwriterqueue => moodycamel}/atomicops.h | 0 .../{readerwriterqueue => moodycamel}/readerwriterqueue.h | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename src/external/{readerwriterqueue => moodycamel}/atomicops.h (100%) rename src/external/{readerwriterqueue => moodycamel}/readerwriterqueue.h (100%) diff --git a/src/external/readerwriterqueue/atomicops.h b/src/external/moodycamel/atomicops.h similarity index 100% rename from src/external/readerwriterqueue/atomicops.h rename to src/external/moodycamel/atomicops.h diff --git a/src/external/readerwriterqueue/readerwriterqueue.h b/src/external/moodycamel/readerwriterqueue.h similarity index 100% rename from src/external/readerwriterqueue/readerwriterqueue.h rename to src/external/moodycamel/readerwriterqueue.h From 3892f776574326f6e4a127fcaeab6ab83e4f10ac Mon Sep 17 00:00:00 2001 From: Paul Ferrand Date: Sat, 23 Nov 2019 18:31:14 +0100 Subject: [PATCH 14/32] Libraries should build! --- CMakeLists.txt | 35 ++++++++++++++++++++ src/CMakeLists.txt | 78 ++++++++++++++++++++++++++++++++++++++++++++ src/sfizz/FilePool.h | 2 +- 3 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 CMakeLists.txt create mode 100644 src/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..0c498d66 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,35 @@ +cmake_minimum_required(VERSION 3.13) +project(sfizz VERSION 1.0.0 LANGUAGES CXX) + +# Do not override the C++ standard if set to more than 14 +if (NOT CMAKE_CXX_STANDARD OR CMAKE_CXX_STANDARD LESS 14) + set(CMAKE_CXX_STANDARD 14) +endif() + +# Export the compile_commands.json file +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + +# Add required flags for the builds +if (UNIX) + add_compile_options(-Wall) + add_compile_options(-Wextra) + add_compile_options(-ffast-math) + add_compile_options(-fno-omit-frame-pointer) # For debugging purposes + add_compile_options(-fPIC) +endif() + +# If we build with Clang use libc++ +if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT ANDROID) + set(USE_LIBCPP ON CACHE BOOL "Use libc++ with clang") + add_compile_options(-stdlib=libc++) + # Presumably need the above for linking too, maybe other options missing as well + add_link_options(-stdlib=libc++) # New command on CMake master, not in 3.12 release + add_link_options(-lc++abi) # New command on CMake master, not in 3.12 release +endif() + +# Add Abseil +set(BUILD_TESTING OFF CACHE BOOL "Disable Abseil's tests") +add_subdirectory(external/abseil-cpp EXCLUDE_FROM_ALL) + +# Add the static library targets and sources +add_subdirectory(src) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 00000000..3a26fda2 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,78 @@ +project(sfizz) + +set(SFIZZ_SOURCES + sfizz/Synth.cpp + sfizz/FilePool.cpp + sfizz/Region.cpp + sfizz/Voice.cpp + sfizz/ScopedFTZ.cpp + sfizz/SfzHelpers.cpp + sfizz/FloatEnvelopes.cpp +) + +# Check SIMD +include(CheckIncludeFiles) +CHECK_INCLUDE_FILES(x86intrin.h HAVE_X86INTRIN_H) +CHECK_INCLUDE_FILES(intrin.h HAVE_INTRIN_H) +if (!APPLE) + CHECK_INCLUDE_FILES(arm_neon.h HAVE_ARM_NEON_H) +endif() + +# SIMD checks +if (HAVE_X86INTRIN_H AND UNIX) + add_compile_options(-DHAVE_X86INTRIN_H) + set(SFIZZ_SIMD_SOURCES sfizz/SIMDSSE.cpp) +elseif (HAVE_INTRIN_H AND WIN32) + add_compile_options(/DHAVE_INTRIN_H) + set(SFIZZ_SIMD_SOURCES sfizz/SIMDSSE.cpp) +elseif (HAVE_ARM_NEON_H AND UNIX) + add_compile_options(-DHAVE_ARM_NEON_H) + add_compile_options(-mfpu=neon-fp-armv8) + add_compile_options(-march=native) + add_compile_options(-mtune=cortex-a53) + add_compile_options(-funsafe-math-optimizations) + set(SFIZZ_SIMD_SOURCES sfizz/SIMDDummy.cpp) +else() + set(SFIZZ_SIMD_SOURCES sfizz/SIMDDummy.cpp) +endif() + +set(SFIZZ_SOURCES ${SFIZZ_SOURCES} ${SFIZZ_SIMD_SOURCES}) + +add_library(sfizz_parser STATIC) +target_sources(sfizz_parser PRIVATE sfizz/Parser.cpp sfizz/Opcode.cpp) +target_include_directories(sfizz_parser PUBLIC sfizz) +target_include_directories(sfizz_parser PUBLIC external) +target_link_libraries(sfizz_parser PRIVATE absl::strings) + +add_library(sfizz STATIC ${SFIZZ_SOURCES} sfizz/sfizz_wrapper.cpp) +target_include_directories(sfizz PUBLIC sfizz) +target_include_directories(sfizz PUBLIC external) +target_link_libraries(sfizz PRIVATE sfizz_parser) +find_package(Threads REQUIRED) +target_link_libraries(sfizz PUBLIC absl::strings) +target_link_libraries(sfizz PRIVATE sndfile absl::flat_hash_map Threads::Threads) +if(UNIX) + target_link_libraries(sfizz PUBLIC atomic) +endif(UNIX) + +add_library(sfizz::parser ALIAS sfizz_parser) +add_library(sfizz::sfizz ALIAS sfizz) + +# install(TARGETS sfizz_parser DESTINATION . EXCLUDE_FROM_ALL) +# install(TARGETS sfizz DESTINATION . EXCLUDE_FROM_ALL) + +# Shared library and installation target + +add_library(sfizz_shared SHARED sfizz/sfizz_wrapper.cpp) +set_target_properties(sfizz_shared PROPERTIES OUTPUT_NAME sfizz PUBLIC_HEADER sfizz.h) +target_link_libraries(sfizz_shared sfizz::sfizz) +configure_file(${CMAKE_SOURCE_DIR}/scripts/sfizz.pc.in sfizz.pc @ONLY) +if(UNIX) + include(GNUInstallDirs) + install(TARGETS sfizz_shared + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/static + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + install(FILES + ${CMAKE_BINARY_DIR}/src/sfizz.pc DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig) +endif() \ No newline at end of file diff --git a/src/sfizz/FilePool.h b/src/sfizz/FilePool.h index eee11e7a..c8d43c7b 100644 --- a/src/sfizz/FilePool.h +++ b/src/sfizz/FilePool.h @@ -28,7 +28,7 @@ #include "AudioBuffer.h" #include "Voice.h" #include "ghc/fs_std.hpp" -#include "readerwriterqueue.h" +#include "moodycamel/readerwriterqueue.h" #include #include #include From 5edca806c7a65083831096c21938986b434a6b61 Mon Sep 17 00:00:00 2001 From: Paul Ferrand Date: Sat, 23 Nov 2019 18:58:51 +0100 Subject: [PATCH 15/32] Updated the benchmarks makefiles and files --- benchmarks/BM_ADSR.cpp | 4 +- benchmarks/BM_add.cpp | 2 +- benchmarks/BM_copy.cpp | 2 +- benchmarks/BM_cumsum.cpp | 2 +- benchmarks/BM_diff.cpp | 2 +- benchmarks/BM_fill.cpp | 4 +- benchmarks/BM_gain.cpp | 2 +- benchmarks/BM_interpolationCast.cpp | 2 +- benchmarks/BM_looping.cpp | 2 +- benchmarks/BM_mathfuns.cpp | 2 +- benchmarks/BM_mean.cpp | 2 +- benchmarks/BM_meanSquared.cpp | 2 +- benchmarks/BM_multiplyAdd.cpp | 2 +- benchmarks/BM_pan.cpp | 4 +- benchmarks/BM_pointerIterationOrOffsets.cpp | 2 +- benchmarks/BM_ramp.cpp | 4 +- benchmarks/BM_readInterleaved.cpp | 4 +- benchmarks/BM_saturating.cpp | 2 +- benchmarks/BM_subtract.cpp | 2 +- benchmarks/BM_writeInterleaved.cpp | 4 +- benchmarks/CMakeLists.txt | 149 ++++++++++++++++++++ 21 files changed, 175 insertions(+), 26 deletions(-) create mode 100644 benchmarks/CMakeLists.txt diff --git a/benchmarks/BM_ADSR.cpp b/benchmarks/BM_ADSR.cpp index ff654eb8..850c4e7c 100644 --- a/benchmarks/BM_ADSR.cpp +++ b/benchmarks/BM_ADSR.cpp @@ -22,7 +22,7 @@ // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include -#include "../sfizz/ADSREnvelope.h" +#include "ADSREnvelope.h" #include #include #include @@ -35,7 +35,7 @@ constexpr int release = attack; constexpr int releaseTime = envelopeSize - static_cast(envelopeSize / 4); // Explicitely instantiate class -#include "../sfizz/ADSREnvelope.cpp" +#include "ADSREnvelope.cpp" template class sfz::ADSREnvelope; static void Point(benchmark::State& state) { diff --git a/benchmarks/BM_add.cpp b/benchmarks/BM_add.cpp index b65f076c..26b3c62f 100644 --- a/benchmarks/BM_add.cpp +++ b/benchmarks/BM_add.cpp @@ -27,7 +27,7 @@ #include #include #include -#include "../sfizz/SIMDHelpers.h" +#include "SIMDHelpers.h" class AddArray : public benchmark::Fixture { public: diff --git a/benchmarks/BM_copy.cpp b/benchmarks/BM_copy.cpp index 7d612e9c..9a9298d3 100644 --- a/benchmarks/BM_copy.cpp +++ b/benchmarks/BM_copy.cpp @@ -27,7 +27,7 @@ #include #include #include -#include "../sfizz/SIMDHelpers.h" +#include "SIMDHelpers.h" class CopyArray : public benchmark::Fixture { public: diff --git a/benchmarks/BM_cumsum.cpp b/benchmarks/BM_cumsum.cpp index 9407e6e1..fb2cb28c 100644 --- a/benchmarks/BM_cumsum.cpp +++ b/benchmarks/BM_cumsum.cpp @@ -27,7 +27,7 @@ #include #include #include -#include "../sfizz/SIMDHelpers.h" +#include "SIMDHelpers.h" class CumArray : public benchmark::Fixture { public: diff --git a/benchmarks/BM_diff.cpp b/benchmarks/BM_diff.cpp index bacfe5f7..bdc3b4b5 100644 --- a/benchmarks/BM_diff.cpp +++ b/benchmarks/BM_diff.cpp @@ -27,7 +27,7 @@ #include #include #include -#include "../sfizz/SIMDHelpers.h" +#include "SIMDHelpers.h" #include "absl/types/span.h" class DiffArray : public benchmark::Fixture { diff --git a/benchmarks/BM_fill.cpp b/benchmarks/BM_fill.cpp index a437531e..056a3dc1 100644 --- a/benchmarks/BM_fill.cpp +++ b/benchmarks/BM_fill.cpp @@ -22,8 +22,8 @@ // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include -#include "../sfizz/SIMDHelpers.h" -#include "../sfizz/Buffer.h" +#include "SIMDHelpers.h" +#include "Buffer.h" #include #include #include diff --git a/benchmarks/BM_gain.cpp b/benchmarks/BM_gain.cpp index f5385eaa..a8855760 100644 --- a/benchmarks/BM_gain.cpp +++ b/benchmarks/BM_gain.cpp @@ -27,7 +27,7 @@ #include #include #include -#include "../sfizz/SIMDHelpers.h" +#include "SIMDHelpers.h" class GainSingle : public benchmark::Fixture { public: diff --git a/benchmarks/BM_interpolationCast.cpp b/benchmarks/BM_interpolationCast.cpp index 2411cadd..f7c2b8a7 100644 --- a/benchmarks/BM_interpolationCast.cpp +++ b/benchmarks/BM_interpolationCast.cpp @@ -26,7 +26,7 @@ #include #include #include -#include "../sfizz/SIMDHelpers.h" +#include "SIMDHelpers.h" // In this one we have an array of jumps diff --git a/benchmarks/BM_looping.cpp b/benchmarks/BM_looping.cpp index 4e1ba5e5..b036da82 100644 --- a/benchmarks/BM_looping.cpp +++ b/benchmarks/BM_looping.cpp @@ -26,7 +26,7 @@ #include #include #include -#include "../sfizz/SIMDHelpers.h" +#include "SIMDHelpers.h" // In this one we have an array of indices diff --git a/benchmarks/BM_mathfuns.cpp b/benchmarks/BM_mathfuns.cpp index 08e9a50e..1b4339b4 100644 --- a/benchmarks/BM_mathfuns.cpp +++ b/benchmarks/BM_mathfuns.cpp @@ -21,7 +21,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#include "../sfizz/SIMDHelpers.h" +#include "SIMDHelpers.h" #include "absl/types/span.h" #include #include diff --git a/benchmarks/BM_mean.cpp b/benchmarks/BM_mean.cpp index 7a457842..4519cd06 100644 --- a/benchmarks/BM_mean.cpp +++ b/benchmarks/BM_mean.cpp @@ -21,7 +21,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#include "../sfizz/SIMDHelpers.h" +#include "SIMDHelpers.h" #include #include #include diff --git a/benchmarks/BM_meanSquared.cpp b/benchmarks/BM_meanSquared.cpp index a207f528..43858b00 100644 --- a/benchmarks/BM_meanSquared.cpp +++ b/benchmarks/BM_meanSquared.cpp @@ -21,7 +21,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#include "../sfizz/SIMDHelpers.h" +#include "SIMDHelpers.h" #include #include #include diff --git a/benchmarks/BM_multiplyAdd.cpp b/benchmarks/BM_multiplyAdd.cpp index 218d98ad..25218ea4 100644 --- a/benchmarks/BM_multiplyAdd.cpp +++ b/benchmarks/BM_multiplyAdd.cpp @@ -27,7 +27,7 @@ #include #include #include -#include "../sfizz/SIMDHelpers.h" +#include "SIMDHelpers.h" class MultiplyAdd : public benchmark::Fixture { public: diff --git a/benchmarks/BM_pan.cpp b/benchmarks/BM_pan.cpp index 5792b476..20d6b539 100644 --- a/benchmarks/BM_pan.cpp +++ b/benchmarks/BM_pan.cpp @@ -27,8 +27,8 @@ #include #include #include -#include "../sfizz/SIMDHelpers.h" -#include "../sfizz/Config.h" +#include "SIMDHelpers.h" +#include "Config.h" #include "absl/types/span.h" class PanArray : public benchmark::Fixture { diff --git a/benchmarks/BM_pointerIterationOrOffsets.cpp b/benchmarks/BM_pointerIterationOrOffsets.cpp index 118eccd3..57a891ea 100644 --- a/benchmarks/BM_pointerIterationOrOffsets.cpp +++ b/benchmarks/BM_pointerIterationOrOffsets.cpp @@ -24,7 +24,7 @@ #include #include #include -#include "../sfizz/SIMDHelpers.h" +#include "SIMDHelpers.h" #include "absl/types/span.h" constexpr int bigNumber { 2399132 }; diff --git a/benchmarks/BM_ramp.cpp b/benchmarks/BM_ramp.cpp index 2a57b5dc..313372ad 100644 --- a/benchmarks/BM_ramp.cpp +++ b/benchmarks/BM_ramp.cpp @@ -23,8 +23,8 @@ #include #include -#include "../sfizz/SIMDHelpers.h" -#include "../sfizz/Buffer.h" +#include "SIMDHelpers.h" +#include "Buffer.h" static void Dummy(benchmark::State& state) { diff --git a/benchmarks/BM_readInterleaved.cpp b/benchmarks/BM_readInterleaved.cpp index e2e6e79e..48692243 100644 --- a/benchmarks/BM_readInterleaved.cpp +++ b/benchmarks/BM_readInterleaved.cpp @@ -22,8 +22,8 @@ // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include -#include "../sfizz/SIMDHelpers.h" -#include "../sfizz/Buffer.h" +#include "SIMDHelpers.h" +#include "Buffer.h" #include #include #include diff --git a/benchmarks/BM_saturating.cpp b/benchmarks/BM_saturating.cpp index 81d82141..e41c420f 100644 --- a/benchmarks/BM_saturating.cpp +++ b/benchmarks/BM_saturating.cpp @@ -26,7 +26,7 @@ #include #include #include -#include "../sfizz/SIMDHelpers.h" +#include "SIMDHelpers.h" // In this one we have an array of indices diff --git a/benchmarks/BM_subtract.cpp b/benchmarks/BM_subtract.cpp index 2062dcdf..7eb8cf18 100644 --- a/benchmarks/BM_subtract.cpp +++ b/benchmarks/BM_subtract.cpp @@ -27,7 +27,7 @@ #include #include #include -#include "../sfizz/SIMDHelpers.h" +#include "SIMDHelpers.h" class SubArray : public benchmark::Fixture { public: diff --git a/benchmarks/BM_writeInterleaved.cpp b/benchmarks/BM_writeInterleaved.cpp index 72932392..dd6c2884 100644 --- a/benchmarks/BM_writeInterleaved.cpp +++ b/benchmarks/BM_writeInterleaved.cpp @@ -22,8 +22,8 @@ // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include -#include "../sfizz/SIMDHelpers.h" -#include "../sfizz/Buffer.h" +#include "SIMDHelpers.h" +#include "Buffer.h" #include #include #include diff --git a/benchmarks/CMakeLists.txt b/benchmarks/CMakeLists.txt new file mode 100644 index 00000000..f6ca9391 --- /dev/null +++ b/benchmarks/CMakeLists.txt @@ -0,0 +1,149 @@ +project(sfizz) + +set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "Disable Google Benchmark tests") +set(BENCHMARK_ENABLE_INSTALL OFF CACHE BOOL "Disable Google Benchmark install") + +include(FetchContent) +FetchContent_Declare( + benchmark + GIT_REPOSITORY https://github.com/google/benchmark.git + GIT_TAG v1.5.0 +) + +FetchContent_GetProperties(benchmark) +if(NOT benchmark_POPULATED) + FetchContent_Populate(benchmark) + add_subdirectory(${benchmark_SOURCE_DIR} ${benchmark_BINARY_DIR}) +endif() + +# Check SIMD +include(CheckIncludeFiles) +CHECK_INCLUDE_FILES(x86intrin.h HAVE_X86INTRIN_H) +CHECK_INCLUDE_FILES(intrin.h HAVE_INTRIN_H) +CHECK_INCLUDE_FILES(arm_neon.h HAVE_ARM_NEON_H) + +# SIMD checks +if (HAVE_X86INTRIN_H AND UNIX) + add_compile_options(-DHAVE_X86INTRIN_H) + set(SFIZZ_SIMD_SOURCES ../src/sfizz/SIMDSSE.cpp) +elseif (HAVE_INTRIN_H AND WIN32) + add_compile_options(/DHAVE_INTRIN_H) + set(SFIZZ_SIMD_SOURCES ../src/sfizz/SIMDSSE.cpp) +elseif (HAVE_ARM_NEON_H AND UNIX) + add_compile_options(-DHAVE_ARM_NEON_H) + add_compile_options(-mfpu=neon-fp-armv8) + add_compile_options(-march=native) + add_compile_options(-mtune=cortex-a53) + add_compile_options(-funsafe-math-optimizations) + set(SFIZZ_SIMD_SOURCES ../src/sfizz/SIMDDummy.cpp) +else() + set(SFIZZ_SIMD_SOURCES ../src/sfizz/SIMDDummy.cpp) +endif() + +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_include_directories(bm_opf_high_vs_low PRIVATE ../src/sfizz) + +add_executable(bm_write BM_writeInterleaved.cpp ${SFIZZ_SIMD_SOURCES}) +target_link_libraries(bm_write benchmark absl::span) +target_include_directories(bm_write PRIVATE ../src/sfizz) + +add_executable(bm_read BM_readInterleaved.cpp ${SFIZZ_SIMD_SOURCES}) +target_link_libraries(bm_read benchmark absl::span) +target_include_directories(bm_read PRIVATE ../src/sfizz) + +add_executable(bm_fill BM_fill.cpp ${SFIZZ_SIMD_SOURCES}) +target_link_libraries(bm_fill benchmark absl::span) +target_include_directories(bm_fill PRIVATE ../src/sfizz) + +add_executable(bm_mathfuns BM_mathfuns.cpp ${SFIZZ_SIMD_SOURCES}) +target_link_libraries(bm_mathfuns benchmark absl::span) +target_include_directories(bm_mathfuns PRIVATE ../src/sfizz) + +add_executable(bm_gain BM_gain.cpp ${SFIZZ_SIMD_SOURCES}) +target_link_libraries(bm_gain benchmark absl::span) +target_include_directories(bm_gain PRIVATE ../src/sfizz) + +add_executable(bm_looping BM_looping.cpp ${SFIZZ_SIMD_SOURCES}) +target_link_libraries(bm_looping benchmark absl::span absl::algorithm) +target_include_directories(bm_looping PRIVATE ../src/sfizz) + +add_executable(bm_saturating BM_saturating.cpp ${SFIZZ_SIMD_SOURCES}) +target_link_libraries(bm_saturating benchmark absl::span absl::algorithm) +target_include_directories(bm_saturating PRIVATE ../src/sfizz) + +add_executable(bm_ramp BM_ramp.cpp ${SFIZZ_SIMD_SOURCES}) +target_link_libraries(bm_ramp benchmark absl::span absl::algorithm) +target_include_directories(bm_ramp PRIVATE ../src/sfizz) + +add_executable(bm_ADSR BM_ADSR.cpp ${SFIZZ_SIMD_SOURCES}) +target_link_libraries(bm_ADSR benchmark absl::span absl::algorithm) +target_include_directories(bm_ADSR PRIVATE ../src/sfizz) + +add_executable(bm_add BM_add.cpp ${SFIZZ_SIMD_SOURCES}) +target_link_libraries(bm_add benchmark absl::span absl::algorithm) +target_include_directories(bm_add PRIVATE ../src/sfizz) + +add_executable(bm_multiplyAdd BM_multiplyAdd.cpp ${SFIZZ_SIMD_SOURCES}) +target_link_libraries(bm_multiplyAdd benchmark absl::span absl::algorithm) +target_include_directories(bm_multiplyAdd PRIVATE ../src/sfizz) + +add_executable(bm_subtract BM_subtract.cpp ${SFIZZ_SIMD_SOURCES}) +target_link_libraries(bm_subtract benchmark absl::span absl::algorithm) +target_include_directories(bm_subtract PRIVATE ../src/sfizz) + +add_executable(bm_copy BM_copy.cpp ${SFIZZ_SIMD_SOURCES}) +target_link_libraries(bm_copy benchmark absl::span absl::algorithm) +target_include_directories(bm_copy PRIVATE ../src/sfizz) + +add_executable(bm_pan BM_pan.cpp ${SFIZZ_SIMD_SOURCES}) +target_link_libraries(bm_pan benchmark absl::span absl::algorithm) +target_include_directories(bm_pan PRIVATE ../src/sfizz) + +add_executable(bm_mean BM_mean.cpp ${SFIZZ_SIMD_SOURCES}) +target_link_libraries(bm_mean benchmark absl::span absl::algorithm) +target_include_directories(bm_mean PRIVATE ../src/sfizz) + +add_executable(bm_meanSquared BM_meanSquared.cpp ${SFIZZ_SIMD_SOURCES}) +target_link_libraries(bm_meanSquared benchmark absl::span absl::algorithm) +target_include_directories(bm_meanSquared PRIVATE ../src/sfizz) + +add_executable(bm_cumsum BM_cumsum.cpp ${SFIZZ_SIMD_SOURCES}) +target_link_libraries(bm_cumsum benchmark absl::span absl::algorithm) +target_include_directories(bm_cumsum PRIVATE ../src/sfizz) + +add_executable(bm_diff BM_diff.cpp ${SFIZZ_SIMD_SOURCES}) +target_link_libraries(bm_diff benchmark absl::span absl::algorithm) +target_include_directories(bm_diff PRIVATE ../src/sfizz) + +add_executable(bm_interpolationCast BM_interpolationCast.cpp ${SFIZZ_SIMD_SOURCES}) +target_link_libraries(bm_interpolationCast benchmark absl::span absl::algorithm) +target_include_directories(bm_interpolationCast PRIVATE ../src/sfizz) + +add_executable(bm_pointerIterationOrOffsets BM_pointerIterationOrOffsets.cpp ${SFIZZ_SIMD_SOURCES}) +target_link_libraries(bm_pointerIterationOrOffsets benchmark absl::span absl::algorithm) +target_include_directories(bm_pointerIterationOrOffsets PRIVATE ../src/sfizz) + +add_custom_target(sfizz_benchmarks) +add_dependencies(sfizz_benchmarks + bm_opf_high_vs_low + bm_write + bm_pointerIterationOrOffsets + bm_read + bm_mean + bm_meanSquared + bm_fill + bm_cumsum + bm_diff + bm_interpolationCast + bm_mathfuns + bm_gain + bm_looping + bm_saturating + bm_ramp + bm_ADSR + bm_add + bm_pan + bm_subtract + bm_multiplyAdd +) From a17a7b3b0b3d6b23b50533b26fa74700fed398b9 Mon Sep 17 00:00:00 2001 From: Paul Ferrand Date: Sat, 23 Nov 2019 18:59:29 +0100 Subject: [PATCH 16/32] Commit all the Makefiles --- CMakeLists.txt | 12 ++++++++++++ clients/CMakeLists.txt | 10 ++++++++++ lv2/CMakeLists.txt | 6 ++++++ 3 files changed, 28 insertions(+) create mode 100644 clients/CMakeLists.txt create mode 100644 lv2/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 0c498d66..e5de902f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,3 +33,15 @@ add_subdirectory(external/abseil-cpp EXCLUDE_FROM_ALL) # Add the static library targets and sources add_subdirectory(src) + +if (SFIZZ_CLIENTS) +add_subdirectory(clients) +endif() + +if (SFIZZ_LV2) +add_subdirectory(lv2) +endif() + +if (SFIZZ_BENCHMARKS) +add_subdirectory(benchmarks) +endif() \ No newline at end of file diff --git a/clients/CMakeLists.txt b/clients/CMakeLists.txt new file mode 100644 index 00000000..ee4e41f2 --- /dev/null +++ b/clients/CMakeLists.txt @@ -0,0 +1,10 @@ +project(sfizz) + +############################### +add_executable(sfzprint sfzprint.cpp) +target_link_libraries(sfzprint sfizz::parser absl::flags_parse) +install(TARGETS sfzprint DESTINATION . OPTIONAL) + +add_executable(sfizz_jack jack_client.cpp) +target_link_libraries(sfizz_jack sfizz::sfizz jack absl::flags_parse) +install(TARGETS sfizz_jack DESTINATION . OPTIONAL) \ No newline at end of file diff --git a/lv2/CMakeLists.txt b/lv2/CMakeLists.txt new file mode 100644 index 00000000..4d8b1dc5 --- /dev/null +++ b/lv2/CMakeLists.txt @@ -0,0 +1,6 @@ +project(sfizz) + +add_library(sfizz_lv2 SHARED sfizz.c) +set_target_properties(sfizz_lv2 PROPERTIES PREFIX "") +set_target_properties(sfizz_lv2 PROPERTIES OUTPUT_NAME "sfizz") +target_link_libraries(sfizz_lv2 sfizz::sfizz) \ No newline at end of file From e638ef8f4e4b7832e0e0602b6c91a8c4b2e53255 Mon Sep 17 00:00:00 2001 From: Paul Ferrand Date: Sat, 23 Nov 2019 19:03:23 +0100 Subject: [PATCH 17/32] Corrected a bug --- benchmarks/CMakeLists.txt | 42 +++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/benchmarks/CMakeLists.txt b/benchmarks/CMakeLists.txt index f6ca9391..eae12e7b 100644 --- a/benchmarks/CMakeLists.txt +++ b/benchmarks/CMakeLists.txt @@ -42,87 +42,87 @@ endif() 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_include_directories(bm_opf_high_vs_low PRIVATE ../src/sfizz) +target_include_directories(bm_opf_high_vs_low PRIVATE ../src/sfizz ../src/external) add_executable(bm_write BM_writeInterleaved.cpp ${SFIZZ_SIMD_SOURCES}) target_link_libraries(bm_write benchmark absl::span) -target_include_directories(bm_write PRIVATE ../src/sfizz) +target_include_directories(bm_write PRIVATE ../src/sfizz ../src/external) add_executable(bm_read BM_readInterleaved.cpp ${SFIZZ_SIMD_SOURCES}) target_link_libraries(bm_read benchmark absl::span) -target_include_directories(bm_read PRIVATE ../src/sfizz) +target_include_directories(bm_read PRIVATE ../src/sfizz ../src/external) add_executable(bm_fill BM_fill.cpp ${SFIZZ_SIMD_SOURCES}) target_link_libraries(bm_fill benchmark absl::span) -target_include_directories(bm_fill PRIVATE ../src/sfizz) +target_include_directories(bm_fill PRIVATE ../src/sfizz ../src/external) add_executable(bm_mathfuns BM_mathfuns.cpp ${SFIZZ_SIMD_SOURCES}) target_link_libraries(bm_mathfuns benchmark absl::span) -target_include_directories(bm_mathfuns PRIVATE ../src/sfizz) +target_include_directories(bm_mathfuns PRIVATE ../src/sfizz ../src/external) add_executable(bm_gain BM_gain.cpp ${SFIZZ_SIMD_SOURCES}) target_link_libraries(bm_gain benchmark absl::span) -target_include_directories(bm_gain PRIVATE ../src/sfizz) +target_include_directories(bm_gain PRIVATE ../src/sfizz ../src/external) add_executable(bm_looping BM_looping.cpp ${SFIZZ_SIMD_SOURCES}) target_link_libraries(bm_looping benchmark absl::span absl::algorithm) -target_include_directories(bm_looping PRIVATE ../src/sfizz) +target_include_directories(bm_looping PRIVATE ../src/sfizz ../src/external) add_executable(bm_saturating BM_saturating.cpp ${SFIZZ_SIMD_SOURCES}) target_link_libraries(bm_saturating benchmark absl::span absl::algorithm) -target_include_directories(bm_saturating PRIVATE ../src/sfizz) +target_include_directories(bm_saturating PRIVATE ../src/sfizz ../src/external) add_executable(bm_ramp BM_ramp.cpp ${SFIZZ_SIMD_SOURCES}) target_link_libraries(bm_ramp benchmark absl::span absl::algorithm) -target_include_directories(bm_ramp PRIVATE ../src/sfizz) +target_include_directories(bm_ramp PRIVATE ../src/sfizz ../src/external) add_executable(bm_ADSR BM_ADSR.cpp ${SFIZZ_SIMD_SOURCES}) target_link_libraries(bm_ADSR benchmark absl::span absl::algorithm) -target_include_directories(bm_ADSR PRIVATE ../src/sfizz) +target_include_directories(bm_ADSR PRIVATE ../src/sfizz ../src/external) add_executable(bm_add BM_add.cpp ${SFIZZ_SIMD_SOURCES}) target_link_libraries(bm_add benchmark absl::span absl::algorithm) -target_include_directories(bm_add PRIVATE ../src/sfizz) +target_include_directories(bm_add PRIVATE ../src/sfizz ../src/external) add_executable(bm_multiplyAdd BM_multiplyAdd.cpp ${SFIZZ_SIMD_SOURCES}) target_link_libraries(bm_multiplyAdd benchmark absl::span absl::algorithm) -target_include_directories(bm_multiplyAdd PRIVATE ../src/sfizz) +target_include_directories(bm_multiplyAdd PRIVATE ../src/sfizz ../src/external) add_executable(bm_subtract BM_subtract.cpp ${SFIZZ_SIMD_SOURCES}) target_link_libraries(bm_subtract benchmark absl::span absl::algorithm) -target_include_directories(bm_subtract PRIVATE ../src/sfizz) +target_include_directories(bm_subtract PRIVATE ../src/sfizz ../src/external) add_executable(bm_copy BM_copy.cpp ${SFIZZ_SIMD_SOURCES}) target_link_libraries(bm_copy benchmark absl::span absl::algorithm) -target_include_directories(bm_copy PRIVATE ../src/sfizz) +target_include_directories(bm_copy PRIVATE ../src/sfizz ../src/external) add_executable(bm_pan BM_pan.cpp ${SFIZZ_SIMD_SOURCES}) target_link_libraries(bm_pan benchmark absl::span absl::algorithm) -target_include_directories(bm_pan PRIVATE ../src/sfizz) +target_include_directories(bm_pan PRIVATE ../src/sfizz ../src/external) add_executable(bm_mean BM_mean.cpp ${SFIZZ_SIMD_SOURCES}) target_link_libraries(bm_mean benchmark absl::span absl::algorithm) -target_include_directories(bm_mean PRIVATE ../src/sfizz) +target_include_directories(bm_mean PRIVATE ../src/sfizz ../src/external) add_executable(bm_meanSquared BM_meanSquared.cpp ${SFIZZ_SIMD_SOURCES}) target_link_libraries(bm_meanSquared benchmark absl::span absl::algorithm) -target_include_directories(bm_meanSquared PRIVATE ../src/sfizz) +target_include_directories(bm_meanSquared PRIVATE ../src/sfizz ../src/external) add_executable(bm_cumsum BM_cumsum.cpp ${SFIZZ_SIMD_SOURCES}) target_link_libraries(bm_cumsum benchmark absl::span absl::algorithm) -target_include_directories(bm_cumsum PRIVATE ../src/sfizz) +target_include_directories(bm_cumsum PRIVATE ../src/sfizz ../src/external) add_executable(bm_diff BM_diff.cpp ${SFIZZ_SIMD_SOURCES}) target_link_libraries(bm_diff benchmark absl::span absl::algorithm) -target_include_directories(bm_diff PRIVATE ../src/sfizz) +target_include_directories(bm_diff PRIVATE ../src/sfizz ../src/external) add_executable(bm_interpolationCast BM_interpolationCast.cpp ${SFIZZ_SIMD_SOURCES}) target_link_libraries(bm_interpolationCast benchmark absl::span absl::algorithm) -target_include_directories(bm_interpolationCast PRIVATE ../src/sfizz) +target_include_directories(bm_interpolationCast PRIVATE ../src/sfizz ../src/external) add_executable(bm_pointerIterationOrOffsets BM_pointerIterationOrOffsets.cpp ${SFIZZ_SIMD_SOURCES}) target_link_libraries(bm_pointerIterationOrOffsets benchmark absl::span absl::algorithm) -target_include_directories(bm_pointerIterationOrOffsets PRIVATE ../src/sfizz) +target_include_directories(bm_pointerIterationOrOffsets PRIVATE ../src/sfizz ../src/external) add_custom_target(sfizz_benchmarks) add_dependencies(sfizz_benchmarks From d485cace00f01f5d677b933cb98b50338ce4dfa2 Mon Sep 17 00:00:00 2001 From: Paul Ferrand Date: Sat, 23 Nov 2019 19:08:33 +0100 Subject: [PATCH 18/32] Move catch2 --- {src => tests}/catch2/catch.hpp | 0 {src => tests}/catch2/catch_reporter_automake.hpp | 0 {src => tests}/catch2/catch_reporter_tap.hpp | 0 {src => tests}/catch2/catch_reporter_teamcity.hpp | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename {src => tests}/catch2/catch.hpp (100%) rename {src => tests}/catch2/catch_reporter_automake.hpp (100%) rename {src => tests}/catch2/catch_reporter_tap.hpp (100%) rename {src => tests}/catch2/catch_reporter_teamcity.hpp (100%) diff --git a/src/catch2/catch.hpp b/tests/catch2/catch.hpp similarity index 100% rename from src/catch2/catch.hpp rename to tests/catch2/catch.hpp diff --git a/src/catch2/catch_reporter_automake.hpp b/tests/catch2/catch_reporter_automake.hpp similarity index 100% rename from src/catch2/catch_reporter_automake.hpp rename to tests/catch2/catch_reporter_automake.hpp diff --git a/src/catch2/catch_reporter_tap.hpp b/tests/catch2/catch_reporter_tap.hpp similarity index 100% rename from src/catch2/catch_reporter_tap.hpp rename to tests/catch2/catch_reporter_tap.hpp diff --git a/src/catch2/catch_reporter_teamcity.hpp b/tests/catch2/catch_reporter_teamcity.hpp similarity index 100% rename from src/catch2/catch_reporter_teamcity.hpp rename to tests/catch2/catch_reporter_teamcity.hpp From 8e6955e43a840b3570e626b16f6417698180402e Mon Sep 17 00:00:00 2001 From: Paul Ferrand Date: Sat, 23 Nov 2019 19:10:37 +0100 Subject: [PATCH 19/32] Added tests --- CMakeLists.txt | 4 ++++ src/CMakeLists.txt | 28 ++++++++++++++------------- tests/CMakeLists.txt | 41 ++++++++++++++++++++++++++++++++++++++++ tests/FilesT.cpp | 2 +- tests/OnePoleFilterT.cpp | 2 +- 5 files changed, 62 insertions(+), 15 deletions(-) create mode 100644 tests/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index e5de902f..9ca5cb4c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,4 +44,8 @@ endif() if (SFIZZ_BENCHMARKS) add_subdirectory(benchmarks) +endif() + +if (SFIZZ_TESTS) +add_subdirectory(tests) endif() \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3a26fda2..fe37b34b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -63,16 +63,18 @@ add_library(sfizz::sfizz ALIAS sfizz) # Shared library and installation target -add_library(sfizz_shared SHARED sfizz/sfizz_wrapper.cpp) -set_target_properties(sfizz_shared PROPERTIES OUTPUT_NAME sfizz PUBLIC_HEADER sfizz.h) -target_link_libraries(sfizz_shared sfizz::sfizz) -configure_file(${CMAKE_SOURCE_DIR}/scripts/sfizz.pc.in sfizz.pc @ONLY) -if(UNIX) - include(GNUInstallDirs) - install(TARGETS sfizz_shared - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/static - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) - install(FILES - ${CMAKE_BINARY_DIR}/src/sfizz.pc DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig) -endif() \ No newline at end of file +if (SFIZZ_SHARED) + add_library(sfizz_shared SHARED sfizz/sfizz_wrapper.cpp) + set_target_properties(sfizz_shared PROPERTIES OUTPUT_NAME sfizz PUBLIC_HEADER sfizz.h) + target_link_libraries(sfizz_shared sfizz::sfizz) + configure_file(${CMAKE_SOURCE_DIR}/scripts/sfizz.pc.in sfizz.pc @ONLY) + if(UNIX) + include(GNUInstallDirs) + install(TARGETS sfizz_shared + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/static + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + install(FILES + ${CMAKE_BINARY_DIR}/src/sfizz.pc DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig) + endif() +endif(SFIZZ_SHARED) \ No newline at end of file diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 00000000..ab383ecd --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,41 @@ +############################### +# Test application + +project(sfizz) + +set(SFIZZ_TEST_SOURCES + RegionT.cpp + RegexT.cpp + HelpersT.cpp + HelpersT.cpp + AudioBufferT.cpp + RangeT.cpp + OpcodeT.cpp + BufferT.cpp + SIMDHelpersT.cpp + FilesT.cpp + OnePoleFilterT.cpp + RegionActivationT.cpp + RegionCrossfadesT.cpp + ADSREnvelopeT.cpp + LinearEnvelopeT.cpp + MainT.cpp + RegionTriggersT.cpp +) + +find_package(ZLIB REQUIRED) +add_library(cnpy cnpy/cnpy.cpp) +target_link_libraries(cnpy PRIVATE ZLIB::ZLIB) +target_include_directories(cnpy PUBLIC cnpy) + +add_executable(sfizz_tests ${SFIZZ_TEST_SOURCES}) +target_link_libraries(sfizz_tests PRIVATE sfizz::sfizz) + +# Per OS properties +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) + +file(COPY "." DESTINATION ${CMAKE_BINARY_DIR}/tests) \ No newline at end of file diff --git a/tests/FilesT.cpp b/tests/FilesT.cpp index 06a65b63..3dd5a1cd 100644 --- a/tests/FilesT.cpp +++ b/tests/FilesT.cpp @@ -23,7 +23,7 @@ #include "Synth.h" #include "catch2/catch.hpp" -#include "../sfizz/ghc/fs_std.hpp" +#include "ghc/fs_std.hpp" using namespace Catch::literals; TEST_CASE("[Files] Single region (regions_one.sfz)") diff --git a/tests/OnePoleFilterT.cpp b/tests/OnePoleFilterT.cpp index 6df0b485..378271db 100644 --- a/tests/OnePoleFilterT.cpp +++ b/tests/OnePoleFilterT.cpp @@ -24,7 +24,7 @@ #include "OnePoleFilter.h" #include "catch2/catch.hpp" #include "cnpy.h" -#include "../sfizz/ghc/fs_std.hpp" +#include "ghc/fs_std.hpp" #include #include #include From 21bb69e41b3d92dd93c69410d3dad565f299881d Mon Sep 17 00:00:00 2001 From: Paul Ferrand Date: Sat, 23 Nov 2019 19:20:44 +0100 Subject: [PATCH 20/32] Add ttl files to the lv2 build --- lv2/CMakeLists.txt | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lv2/CMakeLists.txt b/lv2/CMakeLists.txt index 4d8b1dc5..69603fa4 100644 --- a/lv2/CMakeLists.txt +++ b/lv2/CMakeLists.txt @@ -3,4 +3,16 @@ project(sfizz) add_library(sfizz_lv2 SHARED sfizz.c) set_target_properties(sfizz_lv2 PROPERTIES PREFIX "") set_target_properties(sfizz_lv2 PROPERTIES OUTPUT_NAME "sfizz") -target_link_libraries(sfizz_lv2 sfizz::sfizz) \ No newline at end of file +target_link_libraries(sfizz_lv2 sfizz::sfizz) + +add_custom_command( TARGET sfizz_lv2 POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_SOURCE_DIR}/lv2/sfizz.ttl + ${CMAKE_CURRENT_BINARY_DIR}/sfizz.ttl) + +add_custom_command( TARGET sfizz_lv2 POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_SOURCE_DIR}/lv2/manifest.ttl + ${CMAKE_CURRENT_BINARY_DIR}/manifest.ttl) + +# TODO: install target for the LV2 plugin \ No newline at end of file From 12115ffa7240a6d42b9bb3b0ee891583a4ab6b52 Mon Sep 17 00:00:00 2001 From: Paul Ferrand Date: Sat, 23 Nov 2019 19:43:34 +0100 Subject: [PATCH 21/32] Cleanup and fixes --- CMakeLists.txt | 5 +++++ clients/CMakeLists.txt | 4 ++-- src/CMakeLists.txt | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9ca5cb4c..8694ff63 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,9 @@ endif() # Export the compile_commands.json file set(CMAKE_EXPORT_COMPILE_COMMANDS ON) +# Only install what's explicitely said +set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY true) + # Add required flags for the builds if (UNIX) add_compile_options(-Wall) @@ -34,6 +37,8 @@ add_subdirectory(external/abseil-cpp EXCLUDE_FROM_ALL) # Add the static library targets and sources add_subdirectory(src) +# Optional targets + if (SFIZZ_CLIENTS) add_subdirectory(clients) endif() diff --git a/clients/CMakeLists.txt b/clients/CMakeLists.txt index ee4e41f2..784064f7 100644 --- a/clients/CMakeLists.txt +++ b/clients/CMakeLists.txt @@ -3,8 +3,8 @@ project(sfizz) ############################### add_executable(sfzprint sfzprint.cpp) target_link_libraries(sfzprint sfizz::parser absl::flags_parse) -install(TARGETS sfzprint DESTINATION . OPTIONAL) +# install(TARGETS sfzprint DESTINATION . OPTIONAL) add_executable(sfizz_jack jack_client.cpp) target_link_libraries(sfizz_jack sfizz::sfizz jack absl::flags_parse) -install(TARGETS sfizz_jack DESTINATION . OPTIONAL) \ No newline at end of file +# install(TARGETS sfizz_jack DESTINATION . OPTIONAL) \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fe37b34b..dcc2a37a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -64,7 +64,7 @@ add_library(sfizz::sfizz ALIAS sfizz) # Shared library and installation target if (SFIZZ_SHARED) - add_library(sfizz_shared SHARED sfizz/sfizz_wrapper.cpp) + add_library(sfizz_shared SHARED sfizz.h) set_target_properties(sfizz_shared PROPERTIES OUTPUT_NAME sfizz PUBLIC_HEADER sfizz.h) target_link_libraries(sfizz_shared sfizz::sfizz) configure_file(${CMAKE_SOURCE_DIR}/scripts/sfizz.pc.in sfizz.pc @ONLY) From a5ba25fc9a574b533890e27014a14a494ec28bd6 Mon Sep 17 00:00:00 2001 From: Paul Ferrand Date: Sat, 23 Nov 2019 22:34:50 +0100 Subject: [PATCH 22/32] include sfizz hpp for the static library --- clients/jack_client.cpp | 3 +-- src/CMakeLists.txt | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/clients/jack_client.cpp b/clients/jack_client.cpp index ed001020..f2e8c11b 100644 --- a/clients/jack_client.cpp +++ b/clients/jack_client.cpp @@ -21,8 +21,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#include "AudioSpan.h" -#include "Synth.h" +#include "sfizz.hpp" #include #include #include diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index dcc2a37a..9092091b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -46,6 +46,7 @@ target_link_libraries(sfizz_parser PRIVATE absl::strings) add_library(sfizz STATIC ${SFIZZ_SOURCES} sfizz/sfizz_wrapper.cpp) target_include_directories(sfizz PUBLIC sfizz) +target_include_directories(sfizz PUBLIC .) target_include_directories(sfizz PUBLIC external) target_link_libraries(sfizz PRIVATE sfizz_parser) find_package(Threads REQUIRED) From 8b1f5d011c79f2d7ef1b2ffef1b432ab9f1d46e3 Mon Sep 17 00:00:00 2001 From: Paul Ferrand Date: Sat, 23 Nov 2019 23:37:14 +0100 Subject: [PATCH 23/32] Added an LV2 install target --- lv2/CMakeLists.txt | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lv2/CMakeLists.txt b/lv2/CMakeLists.txt index 69603fa4..3c744046 100644 --- a/lv2/CMakeLists.txt +++ b/lv2/CMakeLists.txt @@ -15,4 +15,16 @@ add_custom_command( TARGET sfizz_lv2 POST_BUILD ${CMAKE_SOURCE_DIR}/lv2/manifest.ttl ${CMAKE_CURRENT_BINARY_DIR}/manifest.ttl) -# TODO: install target for the LV2 plugin \ No newline at end of file +set_property(TARGET sfizz_lv2 PROPERTY INTERPROCEDURAL_OPTIMIZATION True) + + +if(UNIX) + if (NOT LV2_INSTALL_PREFIX) + set(LV2_INSTALL_PREFIX ${CMAKE_INSTALL_LIBDIR}/lv2/sfizz.lv2) + endif() + install(TARGETS sfizz_lv2 + ARCHIVE DESTINATION ${LV2_INSTALL_PREFIX} + LIBRARY DESTINATION ${LV2_INSTALL_PREFIX}) + install(FILES ${CMAKE_BINARY_DIR}/lv2/sfizz.ttl DESTINATION ${LV2_INSTALL_PREFIX}) + install(FILES ${CMAKE_BINARY_DIR}/lv2/manifest.ttl DESTINATION ${LV2_INSTALL_PREFIX}) +endif() \ No newline at end of file From 13e2dbee04c0fb1f88c409409fca1e3d13841f75 Mon Sep 17 00:00:00 2001 From: Paul Ferrand Date: Sat, 23 Nov 2019 23:37:26 +0100 Subject: [PATCH 24/32] Added interprocedural optimization for the static lib --- src/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9092091b..a542c389 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -55,6 +55,8 @@ target_link_libraries(sfizz PRIVATE sndfile absl::flat_hash_map Threads::Threads if(UNIX) target_link_libraries(sfizz PUBLIC atomic) endif(UNIX) +set_property(TARGET sfizz_parser PROPERTY INTERPROCEDURAL_OPTIMIZATION True) +set_property(TARGET sfizz PROPERTY INTERPROCEDURAL_OPTIMIZATION True) add_library(sfizz::parser ALIAS sfizz_parser) add_library(sfizz::sfizz ALIAS sfizz) From 11ade33e9d80e1c37dd7388dbfa20f960a303c4c Mon Sep 17 00:00:00 2001 From: redtide Date: Mon, 25 Nov 2019 16:10:30 +0100 Subject: [PATCH 25/32] Organize CMake files --- CMakeLists.txt | 76 +++++++++++----------- cmake/SfizzConfig.cmake | 28 ++++++++ cmake/SfizzSimdSourceFilesCheck.cmake | 28 ++++++++ lv2/CMakeLists.txt | 32 +++++----- src/CMakeLists.txt | 92 ++++++++++----------------- src/CMakeLists.txt.autosave | 61 ++++++++++++++++++ 6 files changed, 208 insertions(+), 109 deletions(-) create mode 100644 cmake/SfizzConfig.cmake create mode 100644 cmake/SfizzSimdSourceFilesCheck.cmake create mode 100644 src/CMakeLists.txt.autosave diff --git a/CMakeLists.txt b/CMakeLists.txt index 8694ff63..79f91226 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,56 +1,60 @@ cmake_minimum_required(VERSION 3.13) -project(sfizz VERSION 1.0.0 LANGUAGES CXX) +project (sfizz VERSION 1.0.0 LANGUAGES CXX) -# Do not override the C++ standard if set to more than 14 -if (NOT CMAKE_CXX_STANDARD OR CMAKE_CXX_STANDARD LESS 14) - set(CMAKE_CXX_STANDARD 14) -endif() +# External configuration CMake scripts +set (CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_SOURCE_DIR}/cmake") +include (SfizzConfig) -# Export the compile_commands.json file -set(CMAKE_EXPORT_COMPILE_COMMANDS ON) +# Build Options +set (BUILD_TESTING OFF CACHE BOOL "Disable Abseil's tests [default: OFF]") -# Only install what's explicitely said -set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY true) +set (SFIZZ_LV2_DIR "${CMAKE_INSTALL_PREFIX}/lib/lv2" CACHE STRING + "Install destination for LV2 bundle [default: ${CMAKE_INSTALL_PREFIX}/lib/lv2]") -# Add required flags for the builds -if (UNIX) - add_compile_options(-Wall) - add_compile_options(-Wextra) - add_compile_options(-ffast-math) - add_compile_options(-fno-omit-frame-pointer) # For debugging purposes - add_compile_options(-fPIC) -endif() - -# If we build with Clang use libc++ -if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT ANDROID) - set(USE_LIBCPP ON CACHE BOOL "Use libc++ with clang") - add_compile_options(-stdlib=libc++) - # Presumably need the above for linking too, maybe other options missing as well - add_link_options(-stdlib=libc++) # New command on CMake master, not in 3.12 release - add_link_options(-lc++abi) # New command on CMake master, not in 3.12 release -endif() +option (SFIZZ_USE_LTO "Enable Link Time Optimization [default: ON]" ON) +option (SFIZZ_JACK "Enable JACK stand-alone build [default: ON]" ON) +option (SFIZZ_LV2 "Enable LV2 plug-in build [default: ON]" ON) +option (SFIZZ_BENCHMARKS "Enable benchmarks build [default: OFF]" OFF) +option (SFIZZ_TESTS "Enable tests build [default: OFF]" OFF) +option (SFIZZ_SHARED "Enable shared library build [default: ON]" ON) # Add Abseil -set(BUILD_TESTING OFF CACHE BOOL "Disable Abseil's tests") -add_subdirectory(external/abseil-cpp EXCLUDE_FROM_ALL) +add_subdirectory (external/abseil-cpp EXCLUDE_FROM_ALL) # Add the static library targets and sources -add_subdirectory(src) +add_subdirectory (src) # Optional targets - -if (SFIZZ_CLIENTS) -add_subdirectory(clients) +if (SFIZZ_JACK) + add_subdirectory (clients) endif() if (SFIZZ_LV2) -add_subdirectory(lv2) + add_subdirectory (lv2) endif() if (SFIZZ_BENCHMARKS) -add_subdirectory(benchmarks) + add_subdirectory (benchmarks) endif() if (SFIZZ_TESTS) -add_subdirectory(tests) -endif() \ No newline at end of file + add_subdirectory (tests) +endif() + +message (STATUS " +Project name: ${CMAKE_PROJECT_NAME} +Build type: ${CMAKE_BUILD_TYPE} +Build using LTO: ${SFIZZ_USE_LTO} +Build as shared library: ${SFIZZ_SHARED} +Build JACK stand-alone client: ${SFIZZ_JACK} +Build LV2 plug-in: ${SFIZZ_LV2} +Build benchmarks: ${SFIZZ_BENCHMARKS} +Build tests: ${SFIZZ_TESTS} + +Install prefix: ${CMAKE_INSTALL_PREFIX} +LV2 destination directory: ${SFIZZ_LV2_DIR} + +Compiler CXX debug flags: ${CMAKE_CXX_FLAGS_DEBUG} +Compiler CXX release flags: ${CMAKE_CXX_FLAGS_RELEASE} +Compiler CXX min size flags: ${CMAKE_CXX_FLAGS_MINSIZEREL} +") diff --git a/cmake/SfizzConfig.cmake b/cmake/SfizzConfig.cmake new file mode 100644 index 00000000..90450eb1 --- /dev/null +++ b/cmake/SfizzConfig.cmake @@ -0,0 +1,28 @@ +# Do not override the C++ standard if set to more than 14 +if (NOT CMAKE_CXX_STANDARD OR CMAKE_CXX_STANDARD LESS 14) + set(CMAKE_CXX_STANDARD 14) +endif() + +# Export the compile_commands.json file +set (CMAKE_EXPORT_COMPILE_COMMANDS ON) + +# Only install what's explicitely said +set (CMAKE_SKIP_INSTALL_ALL_DEPENDENCY true) + +# Add required flags for the builds +if (UNIX) + add_compile_options(-Wall) + add_compile_options(-Wextra) + add_compile_options(-ffast-math) + add_compile_options(-fno-omit-frame-pointer) # For debugging purposes + add_compile_options(-fPIC) +endif() + +# If we build with Clang use libc++ +if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT ANDROID) + set(USE_LIBCPP ON CACHE BOOL "Use libc++ with clang") + add_compile_options(-stdlib=libc++) + # Presumably need the above for linking too, maybe other options missing as well + add_link_options(-stdlib=libc++) # New command on CMake master, not in 3.12 release + add_link_options(-lc++abi) # New command on CMake master, not in 3.12 release +endif() diff --git a/cmake/SfizzSimdSourceFilesCheck.cmake b/cmake/SfizzSimdSourceFilesCheck.cmake new file mode 100644 index 00000000..1237b3bc --- /dev/null +++ b/cmake/SfizzSimdSourceFilesCheck.cmake @@ -0,0 +1,28 @@ +# Check SIMD +include (CheckIncludeFiles) +CHECK_INCLUDE_FILES(x86intrin.h HAVE_X86INTRIN_H) +CHECK_INCLUDE_FILES(intrin.h HAVE_INTRIN_H) + +if (!APPLE) + CHECK_INCLUDE_FILES (arm_neon.h HAVE_ARM_NEON_H) +endif() + +# SIMD checks +if (HAVE_X86INTRIN_H AND UNIX) + add_compile_options (-DHAVE_X86INTRIN_H) + set (SFIZZ_SIMD_SOURCES sfizz/SIMDSSE.cpp) +elseif (HAVE_INTRIN_H AND WIN32) + add_compile_options (/DHAVE_INTRIN_H) + set (SFIZZ_SIMD_SOURCES sfizz/SIMDSSE.cpp) +elseif (HAVE_ARM_NEON_H AND UNIX) + add_compile_options (-DHAVE_ARM_NEON_H) + add_compile_options (-mfpu=neon-fp-armv8) + add_compile_options (-march=native) + add_compile_options (-mtune=cortex-a53) + add_compile_options (-funsafe-math-optimizations) + set (SFIZZ_SIMD_SOURCES sfizz/SIMDDummy.cpp) +else() + set (SFIZZ_SIMD_SOURCES sfizz/SIMDDummy.cpp) +endif() + +set (SFIZZ_SOURCES ${SFIZZ_SOURCES} ${SFIZZ_SIMD_SOURCES}) diff --git a/lv2/CMakeLists.txt b/lv2/CMakeLists.txt index 3c744046..6017b21c 100644 --- a/lv2/CMakeLists.txt +++ b/lv2/CMakeLists.txt @@ -1,30 +1,30 @@ -project(sfizz) +project (sfizz) -add_library(sfizz_lv2 SHARED sfizz.c) -set_target_properties(sfizz_lv2 PROPERTIES PREFIX "") -set_target_properties(sfizz_lv2 PROPERTIES OUTPUT_NAME "sfizz") -target_link_libraries(sfizz_lv2 sfizz::sfizz) +add_library (sfizz_lv2 SHARED sfizz.c) +set_target_properties (sfizz_lv2 PROPERTIES PREFIX "") +set_target_properties (sfizz_lv2 PROPERTIES OUTPUT_NAME "sfizz") +target_link_libraries (sfizz_lv2 sfizz::sfizz) -add_custom_command( TARGET sfizz_lv2 POST_BUILD +add_custom_command (TARGET sfizz_lv2 POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/lv2/sfizz.ttl ${CMAKE_CURRENT_BINARY_DIR}/sfizz.ttl) -add_custom_command( TARGET sfizz_lv2 POST_BUILD +add_custom_command (TARGET sfizz_lv2 POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/lv2/manifest.ttl ${CMAKE_CURRENT_BINARY_DIR}/manifest.ttl) +if (SFIZZ_USE_LTO) + set_property (TARGET sfizz_lv2 PROPERTY INTERPROCEDURAL_OPTIMIZATION True) +endif() -set_property(TARGET sfizz_lv2 PROPERTY INTERPROCEDURAL_OPTIMIZATION True) - - -if(UNIX) +if (UNIX) if (NOT LV2_INSTALL_PREFIX) - set(LV2_INSTALL_PREFIX ${CMAKE_INSTALL_LIBDIR}/lv2/sfizz.lv2) + set (LV2_INSTALL_PREFIX ${CMAKE_INSTALL_LIBDIR}/lv2/sfizz.lv2) endif() - install(TARGETS sfizz_lv2 + install (TARGETS sfizz_lv2 ARCHIVE DESTINATION ${LV2_INSTALL_PREFIX} LIBRARY DESTINATION ${LV2_INSTALL_PREFIX}) - install(FILES ${CMAKE_BINARY_DIR}/lv2/sfizz.ttl DESTINATION ${LV2_INSTALL_PREFIX}) - install(FILES ${CMAKE_BINARY_DIR}/lv2/manifest.ttl DESTINATION ${LV2_INSTALL_PREFIX}) -endif() \ No newline at end of file + install (FILES ${CMAKE_BINARY_DIR}/lv2/sfizz.ttl DESTINATION ${LV2_INSTALL_PREFIX}) + install (FILES ${CMAKE_BINARY_DIR}/lv2/manifest.ttl DESTINATION ${LV2_INSTALL_PREFIX}) +endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a542c389..1dee9676 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,6 +1,6 @@ project(sfizz) -set(SFIZZ_SOURCES +set (SFIZZ_SOURCES sfizz/Synth.cpp sfizz/FilePool.cpp sfizz/Region.cpp @@ -9,75 +9,53 @@ set(SFIZZ_SOURCES sfizz/SfzHelpers.cpp sfizz/FloatEnvelopes.cpp ) +include (SfizzSimdSourceFilesCheck) -# Check SIMD -include(CheckIncludeFiles) -CHECK_INCLUDE_FILES(x86intrin.h HAVE_X86INTRIN_H) -CHECK_INCLUDE_FILES(intrin.h HAVE_INTRIN_H) -if (!APPLE) - CHECK_INCLUDE_FILES(arm_neon.h HAVE_ARM_NEON_H) +# Parser core library +add_library (sfizz_parser STATIC) +target_sources (sfizz_parser PRIVATE sfizz/Parser.cpp sfizz/Opcode.cpp) +target_include_directories (sfizz_parser PUBLIC sfizz) +target_include_directories (sfizz_parser PUBLIC external) +target_link_libraries (sfizz_parser PRIVATE absl::strings) + +# Sfizz core library +add_library (sfizz STATIC ${SFIZZ_SOURCES} sfizz/sfizz_wrapper.cpp) +target_include_directories (sfizz PUBLIC sfizz) +target_include_directories (sfizz PUBLIC .) +target_include_directories (sfizz PUBLIC external) +target_link_libraries (sfizz PRIVATE sfizz_parser) +find_package (Threads REQUIRED) +target_link_libraries (sfizz PUBLIC absl::strings) +target_link_libraries (sfizz PRIVATE sndfile absl::flat_hash_map Threads::Threads) + +if (UNIX) + target_link_libraries (sfizz PUBLIC atomic) endif() -# SIMD checks -if (HAVE_X86INTRIN_H AND UNIX) - add_compile_options(-DHAVE_X86INTRIN_H) - set(SFIZZ_SIMD_SOURCES sfizz/SIMDSSE.cpp) -elseif (HAVE_INTRIN_H AND WIN32) - add_compile_options(/DHAVE_INTRIN_H) - set(SFIZZ_SIMD_SOURCES sfizz/SIMDSSE.cpp) -elseif (HAVE_ARM_NEON_H AND UNIX) - add_compile_options(-DHAVE_ARM_NEON_H) - add_compile_options(-mfpu=neon-fp-armv8) - add_compile_options(-march=native) - add_compile_options(-mtune=cortex-a53) - add_compile_options(-funsafe-math-optimizations) - set(SFIZZ_SIMD_SOURCES sfizz/SIMDDummy.cpp) -else() - set(SFIZZ_SIMD_SOURCES sfizz/SIMDDummy.cpp) +if (SFIZZ_USE_LTO) + set_property (TARGET sfizz_parser PROPERTY INTERPROCEDURAL_OPTIMIZATION True) + set_property (TARGET sfizz PROPERTY INTERPROCEDURAL_OPTIMIZATION True) endif() -set(SFIZZ_SOURCES ${SFIZZ_SOURCES} ${SFIZZ_SIMD_SOURCES}) - -add_library(sfizz_parser STATIC) -target_sources(sfizz_parser PRIVATE sfizz/Parser.cpp sfizz/Opcode.cpp) -target_include_directories(sfizz_parser PUBLIC sfizz) -target_include_directories(sfizz_parser PUBLIC external) -target_link_libraries(sfizz_parser PRIVATE absl::strings) - -add_library(sfizz STATIC ${SFIZZ_SOURCES} sfizz/sfizz_wrapper.cpp) -target_include_directories(sfizz PUBLIC sfizz) -target_include_directories(sfizz PUBLIC .) -target_include_directories(sfizz PUBLIC external) -target_link_libraries(sfizz PRIVATE sfizz_parser) -find_package(Threads REQUIRED) -target_link_libraries(sfizz PUBLIC absl::strings) -target_link_libraries(sfizz PRIVATE sndfile absl::flat_hash_map Threads::Threads) -if(UNIX) - target_link_libraries(sfizz PUBLIC atomic) -endif(UNIX) -set_property(TARGET sfizz_parser PROPERTY INTERPROCEDURAL_OPTIMIZATION True) -set_property(TARGET sfizz PROPERTY INTERPROCEDURAL_OPTIMIZATION True) - -add_library(sfizz::parser ALIAS sfizz_parser) -add_library(sfizz::sfizz ALIAS sfizz) +add_library (sfizz::parser ALIAS sfizz_parser) +add_library (sfizz::sfizz ALIAS sfizz) # install(TARGETS sfizz_parser DESTINATION . EXCLUDE_FROM_ALL) # install(TARGETS sfizz DESTINATION . EXCLUDE_FROM_ALL) # Shared library and installation target - if (SFIZZ_SHARED) - add_library(sfizz_shared SHARED sfizz.h) - set_target_properties(sfizz_shared PROPERTIES OUTPUT_NAME sfizz PUBLIC_HEADER sfizz.h) - target_link_libraries(sfizz_shared sfizz::sfizz) - configure_file(${CMAKE_SOURCE_DIR}/scripts/sfizz.pc.in sfizz.pc @ONLY) - if(UNIX) - include(GNUInstallDirs) - install(TARGETS sfizz_shared + add_library (sfizz_shared SHARED sfizz.h) + set_target_properties (sfizz_shared PROPERTIES OUTPUT_NAME sfizz PUBLIC_HEADER sfizz.h) + target_link_libraries (sfizz_shared sfizz::sfizz) + configure_file (${CMAKE_SOURCE_DIR}/scripts/sfizz.pc.in sfizz.pc @ONLY) + if (UNIX) + include (GNUInstallDirs) + install (TARGETS sfizz_shared ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/static LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) - install(FILES + install (FILES ${CMAKE_BINARY_DIR}/src/sfizz.pc DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig) endif() -endif(SFIZZ_SHARED) \ No newline at end of file +endif () diff --git a/src/CMakeLists.txt.autosave b/src/CMakeLists.txt.autosave new file mode 100644 index 00000000..abaf82c9 --- /dev/null +++ b/src/CMakeLists.txt.autosave @@ -0,0 +1,61 @@ +project(sfizz) + +set (SFIZZ_SOURCES + sfizz/Synth.cpp + sfizz/FilePool.cpp + sfizz/Region.cpp + sfizz/Voice.cpp + sfizz/ScopedFTZ.cpp + sfizz/SfzHelpers.cpp + sfizz/FloatEnvelopes.cpp +) +include (SfizzSimdSourceFilesCheck) + +# Parser core library +add_library (sfizz_parser STATIC) +target_sources (sfizz_parser PRIVATE sfizz/Parser.cpp sfizz/Opcode.cpp) +target_include_directories (sfizz_parser PUBLIC sfizz) +target_include_directories (sfizz_parser PUBLIC external) +target_link_libraries (sfizz_parser PRIVATE absl::strings) + +# Sfizz core library +add_library (sfizz STATIC ${SFIZZ_SOURCES} sfizz/sfizz_wrapper.cpp) +target_include_directories (sfizz PUBLIC sfizz) +target_include_directories (sfizz PUBLIC .) +target_include_directories (sfizz PUBLIC external) +target_link_libraries (sfizz PRIVATE sfizz_parser) +find_package (Threads REQUIRED) +target_link_libraries (sfizz PUBLIC absl::strings) +target_link_libraries (sfizz PRIVATE sndfile absl::flat_hash_map Threads::Threads) + +if (UNIX) + target_link_libraries (sfizz PUBLIC atomic) +endif() + +if (SFIZZ_USE_LTO) + set_property (TARGET sfizz_parser PROPERTY INTERPROCEDURAL_OPTIMIZATION True) + set_property (TARGET sfizz PROPERTY INTERPROCEDURAL_OPTIMIZATION True) +endif() + +add_library (sfizz::parser ALIAS sfizz_parser) +add_library (sfizz::sfizz ALIAS sfizz) + +# install(TARGETS sfizz_parser DESTINATION . EXCLUDE_FROM_ALL) +# install(TARGETS sfizz DESTINATION . EXCLUDE_FROM_ALL) + +# Shared library and installation target +if (SFIZZ_SHARED) + add_library (sfizz_shared SHARED sfizz.h) + set_target_properties (sfizz_shared PROPERTIES OUTPUT_NAME sfizz PUBLIC_HEADER sfizz.h) + target_link_libraries (sfizz_shared sfizz::sfizz) + configure_file (${CMAKE_SOURCE_DIR}/scripts/sfizz.pc.in sfizz.pc @ONLY) + if (UNIX) + include (GNUInstallDirs) + install (TARGETS sfizz_shared + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/static + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + install (FILES + ${CMAKE_BINARY_DIR}/src/sfizz.pc DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig) + endif() +endif() From 45a7168035caaf90f5001c80622c82766b995b4b Mon Sep 17 00:00:00 2001 From: redtide Date: Mon, 25 Nov 2019 16:11:39 +0100 Subject: [PATCH 26/32] Organize CMake files --- src/CMakeLists.txt | 2 +- src/CMakeLists.txt.autosave | 61 ------------------------------------- 2 files changed, 1 insertion(+), 62 deletions(-) delete mode 100644 src/CMakeLists.txt.autosave diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1dee9676..abaf82c9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -58,4 +58,4 @@ if (SFIZZ_SHARED) install (FILES ${CMAKE_BINARY_DIR}/src/sfizz.pc DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig) endif() -endif () +endif() diff --git a/src/CMakeLists.txt.autosave b/src/CMakeLists.txt.autosave deleted file mode 100644 index abaf82c9..00000000 --- a/src/CMakeLists.txt.autosave +++ /dev/null @@ -1,61 +0,0 @@ -project(sfizz) - -set (SFIZZ_SOURCES - sfizz/Synth.cpp - sfizz/FilePool.cpp - sfizz/Region.cpp - sfizz/Voice.cpp - sfizz/ScopedFTZ.cpp - sfizz/SfzHelpers.cpp - sfizz/FloatEnvelopes.cpp -) -include (SfizzSimdSourceFilesCheck) - -# Parser core library -add_library (sfizz_parser STATIC) -target_sources (sfizz_parser PRIVATE sfizz/Parser.cpp sfizz/Opcode.cpp) -target_include_directories (sfizz_parser PUBLIC sfizz) -target_include_directories (sfizz_parser PUBLIC external) -target_link_libraries (sfizz_parser PRIVATE absl::strings) - -# Sfizz core library -add_library (sfizz STATIC ${SFIZZ_SOURCES} sfizz/sfizz_wrapper.cpp) -target_include_directories (sfizz PUBLIC sfizz) -target_include_directories (sfizz PUBLIC .) -target_include_directories (sfizz PUBLIC external) -target_link_libraries (sfizz PRIVATE sfizz_parser) -find_package (Threads REQUIRED) -target_link_libraries (sfizz PUBLIC absl::strings) -target_link_libraries (sfizz PRIVATE sndfile absl::flat_hash_map Threads::Threads) - -if (UNIX) - target_link_libraries (sfizz PUBLIC atomic) -endif() - -if (SFIZZ_USE_LTO) - set_property (TARGET sfizz_parser PROPERTY INTERPROCEDURAL_OPTIMIZATION True) - set_property (TARGET sfizz PROPERTY INTERPROCEDURAL_OPTIMIZATION True) -endif() - -add_library (sfizz::parser ALIAS sfizz_parser) -add_library (sfizz::sfizz ALIAS sfizz) - -# install(TARGETS sfizz_parser DESTINATION . EXCLUDE_FROM_ALL) -# install(TARGETS sfizz DESTINATION . EXCLUDE_FROM_ALL) - -# Shared library and installation target -if (SFIZZ_SHARED) - add_library (sfizz_shared SHARED sfizz.h) - set_target_properties (sfizz_shared PROPERTIES OUTPUT_NAME sfizz PUBLIC_HEADER sfizz.h) - target_link_libraries (sfizz_shared sfizz::sfizz) - configure_file (${CMAKE_SOURCE_DIR}/scripts/sfizz.pc.in sfizz.pc @ONLY) - if (UNIX) - include (GNUInstallDirs) - install (TARGETS sfizz_shared - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/static - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) - install (FILES - ${CMAKE_BINARY_DIR}/src/sfizz.pc DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig) - endif() -endif() From e41ef4121bbdf7a9de941a85a24a0095ee8902a8 Mon Sep 17 00:00:00 2001 From: redtide Date: Mon, 25 Nov 2019 16:21:02 +0100 Subject: [PATCH 27/32] Update .gitignore --- .gitignore | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index e18ae90c..707f5cef 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,4 @@ -build -build-arm -build-asan -build-release -build-reldeb -build-debug +build* docs .vscode perf.data @@ -16,6 +11,7 @@ cmake_install.cmake compile_commands.json *.a *.txt.user +*.autosave .DS_Store @@ -23,11 +19,9 @@ clients/sfizz_jack clients/sfzprint # gh-pages unstaged files: - _site/ .bundle/ api/ assets/ node_modules/ -Gemfile.lock -yarn.lock +*.lock From f38c538ee1030e74cd034fb4bf68b9af13b83228 Mon Sep 17 00:00:00 2001 From: redtide Date: Mon, 25 Nov 2019 23:19:40 +0100 Subject: [PATCH 28/32] Update CMake files, generic LV2 configuration --- .editorconfig | 12 +++-- CMakeLists.txt | 8 ++-- lv2/CMakeLists.txt | 71 +++++++++++++++++++---------- lv2/manifest.ttl.in | 7 +++ lv2/sfizz.ttl.in | 108 ++++++++++++++++++++++++++++++++++++++++++++ src/CMakeLists.txt | 2 +- 6 files changed, 175 insertions(+), 33 deletions(-) create mode 100644 lv2/manifest.ttl.in create mode 100644 lv2/sfizz.ttl.in diff --git a/.editorconfig b/.editorconfig index 44554ce7..ea67a2e5 100644 --- a/.editorconfig +++ b/.editorconfig @@ -4,11 +4,15 @@ # Top-most EditorConfig file root = true -# No trailing whitespaces, but with a newline ending every file, -# UTF-8 charset, set indent to spaces with width of four +# UTF-8 charset, set indent to spaces with width of four, +# with no trailing whitespaces and a newline ending every file. [*] +charset = utf-8 +indent_size = 4 +indent_style = space insert_final_newline = true trim_trailing_whitespace = true -charset = utf-8 + +[*.{ttl,ttl.in}] +indent_size = 2 indent_style = space -indent_size = 4 diff --git a/CMakeLists.txt b/CMakeLists.txt index 79f91226..54a9bd05 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,10 +8,10 @@ include (SfizzConfig) # Build Options set (BUILD_TESTING OFF CACHE BOOL "Disable Abseil's tests [default: OFF]") -set (SFIZZ_LV2_DIR "${CMAKE_INSTALL_PREFIX}/lib/lv2" CACHE STRING +set (LV2PLUGIN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib/lv2" CACHE STRING "Install destination for LV2 bundle [default: ${CMAKE_INSTALL_PREFIX}/lib/lv2]") -option (SFIZZ_USE_LTO "Enable Link Time Optimization [default: ON]" ON) +option (ENABLE_LTO "Enable Link Time Optimization [default: ON]" ON) option (SFIZZ_JACK "Enable JACK stand-alone build [default: ON]" ON) option (SFIZZ_LV2 "Enable LV2 plug-in build [default: ON]" ON) option (SFIZZ_BENCHMARKS "Enable benchmarks build [default: OFF]" OFF) @@ -44,7 +44,7 @@ endif() message (STATUS " Project name: ${CMAKE_PROJECT_NAME} Build type: ${CMAKE_BUILD_TYPE} -Build using LTO: ${SFIZZ_USE_LTO} +Build using LTO: ${ENABLE_LTO} Build as shared library: ${SFIZZ_SHARED} Build JACK stand-alone client: ${SFIZZ_JACK} Build LV2 plug-in: ${SFIZZ_LV2} @@ -52,7 +52,7 @@ Build benchmarks: ${SFIZZ_BENCHMARKS} Build tests: ${SFIZZ_TESTS} Install prefix: ${CMAKE_INSTALL_PREFIX} -LV2 destination directory: ${SFIZZ_LV2_DIR} +LV2 destination directory: ${LV2PLUGIN_INSTALL_DIR} Compiler CXX debug flags: ${CMAKE_CXX_FLAGS_DEBUG} Compiler CXX release flags: ${CMAKE_CXX_FLAGS_RELEASE} diff --git a/lv2/CMakeLists.txt b/lv2/CMakeLists.txt index 6017b21c..46c9d3f9 100644 --- a/lv2/CMakeLists.txt +++ b/lv2/CMakeLists.txt @@ -1,30 +1,53 @@ -project (sfizz) +project (lv2plugin) -add_library (sfizz_lv2 SHARED sfizz.c) -set_target_properties (sfizz_lv2 PROPERTIES PREFIX "") -set_target_properties (sfizz_lv2 PROPERTIES OUTPUT_NAME "sfizz") -target_link_libraries (sfizz_lv2 sfizz::sfizz) +# CMAKE_PROJECT_NAME is the top level project name, not the current one +set (LV2PLUGIN_PRJ_NAME "${CMAKE_PROJECT_NAME}_lv2") -add_custom_command (TARGET sfizz_lv2 POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy - ${CMAKE_SOURCE_DIR}/lv2/sfizz.ttl - ${CMAKE_CURRENT_BINARY_DIR}/sfizz.ttl) +# Set the build directory as /lv2/.lv2/ +set (PROJECT_BINARY_DIR "${PROJECT_BINARY_DIR}/${CMAKE_PROJECT_NAME}.lv2") -add_custom_command (TARGET sfizz_lv2 POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy - ${CMAKE_SOURCE_DIR}/lv2/manifest.ttl - ${CMAKE_CURRENT_BINARY_DIR}/manifest.ttl) -if (SFIZZ_USE_LTO) - set_property (TARGET sfizz_lv2 PROPERTY INTERPROCEDURAL_OPTIMIZATION True) +# Configuration for this plugin +# TODO: generate version from git +set (LV2PLUGIN_VERSION_MINOR 0) +set (LV2PLUGIN_VERSION_MICRO 1) +set (LV2PLUGIN_NAME "Sfizz") +set (LV2PLUGIN_COMMENT "SFZ sampler") +set (LV2PLUGIN_URI "http://sfztools.github.io/sfizz") +set (LV2PLUGIN_AUTHOR "Paul Ferrand") +set (LV2PLUGIN_SPDX_LICENSE_ID "BSD-2-Clause") + +if (WIN32) + set (LV2PLUGIN_EXT "dll") +elseif (APPLE) + set (LV2PLUGIN_EXT "dylib") +else() + set (LV2PLUGIN_EXT "so") endif() -if (UNIX) - if (NOT LV2_INSTALL_PREFIX) - set (LV2_INSTALL_PREFIX ${CMAKE_INSTALL_LIBDIR}/lv2/sfizz.lv2) - endif() - install (TARGETS sfizz_lv2 - ARCHIVE DESTINATION ${LV2_INSTALL_PREFIX} - LIBRARY DESTINATION ${LV2_INSTALL_PREFIX}) - install (FILES ${CMAKE_BINARY_DIR}/lv2/sfizz.ttl DESTINATION ${LV2_INSTALL_PREFIX}) - install (FILES ${CMAKE_BINARY_DIR}/lv2/manifest.ttl DESTINATION ${LV2_INSTALL_PREFIX}) +# Keep non build turtle files in IDE +set (LV2PLUGIN_TTL_SRC_FILES + manifest.ttl.in + ${CMAKE_PROJECT_NAME}.ttl.in +) +add_library (${LV2PLUGIN_PRJ_NAME} SHARED ${CMAKE_PROJECT_NAME}.c ${LV2PLUGIN_TTL_SRC_FILES}) +target_link_libraries (${LV2PLUGIN_PRJ_NAME} ${CMAKE_PROJECT_NAME}::${CMAKE_PROJECT_NAME}) + +if (ENABLE_LTO) + set_property (TARGET ${LV2PLUGIN_PRJ_NAME} PROPERTY INTERPROCEDURAL_OPTIMIZATION True) endif() + +# Remove the "lib" prefix, rename the target name and build it in the .lv build dir +# /lv2/_lv2. to +# /lv2/.lv2/. +set_target_properties (${LV2PLUGIN_PRJ_NAME} PROPERTIES PREFIX "") +set_target_properties (${LV2PLUGIN_PRJ_NAME} PROPERTIES OUTPUT_NAME "${CMAKE_PROJECT_NAME}") +set_target_properties (${LV2PLUGIN_PRJ_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}") + +# Generate *.ttl files from *.in sources, +# create the destination directory if it doesn't exists and copy needed files +file (MAKE_DIRECTORY ${PROJECT_BINARY_DIR}) +configure_file (manifest.ttl.in ${PROJECT_BINARY_DIR}/manifest.ttl) +configure_file (${CMAKE_PROJECT_NAME}.ttl.in ${PROJECT_BINARY_DIR}/${CMAKE_PROJECT_NAME}.ttl) + +# Installation +install (DIRECTORY ${PROJECT_BINARY_DIR} DESTINATION ${LV2PLUGIN_INSTALL_DIR}) diff --git a/lv2/manifest.ttl.in b/lv2/manifest.ttl.in new file mode 100644 index 00000000..ee608fb7 --- /dev/null +++ b/lv2/manifest.ttl.in @@ -0,0 +1,7 @@ +@prefix lv2: . +@prefix rdfs: . + +<@LV2PLUGIN_URI@> + a lv2:Plugin ; + lv2:binary <@CMAKE_PROJECT_NAME@.@LV2PLUGIN_EXT@> ; + rdfs:seeAlso <@CMAKE_PROJECT_NAME@.ttl> . diff --git a/lv2/sfizz.ttl.in b/lv2/sfizz.ttl.in new file mode 100644 index 00000000..032d51ff --- /dev/null +++ b/lv2/sfizz.ttl.in @@ -0,0 +1,108 @@ +@prefix atom: . +@prefix bufsize: . +@prefix doap: . +@prefix foaf: . +@prefix lv2: . +@prefix midi: . +@prefix opts: . +@prefix patch: . +@prefix pg: . +@prefix pprop: . +@prefix rdf: . +@prefix rdfs: . +@prefix state: . +@prefix units: . +@prefix urid: . +@prefix work: . + +<#config> + a pg:Group ; + lv2:symbol "config" ; + lv2:name "Configuration" . + +<@LV2PLUGIN_URI@:sfzfile> + a lv2:Parameter ; + rdfs:label "SFZ file" ; + rdfs:range atom:Path . + +<@LV2PLUGIN_URI@:numvoices> + a lv2:Parameter ; + rdfs:label "Polyphony" ; + rdfs:range atom:Int . + +<@LV2PLUGIN_URI@> + a doap:Project, lv2:Plugin, lv2:InstrumentPlugin ; + + doap:name "@LV2PLUGIN_NAME@" ; + doap:license ; + doap:maintainer [ + foaf:name "@LV2PLUGIN_AUTHOR@" ; + foaf:homepage <@LV2PLUGIN_URI@> ; + ] ; + rdfs:comment "@LV2PLUGIN_COMMENT@" ; + + lv2:minorVersion @LV2PLUGIN_VERSION_MINOR@ ; + lv2:microVersion @LV2PLUGIN_VERSION_MICRO@ ; + + lv2:requiredFeature urid:map, bufsize:boundedBlockLength, work:schedule ; + lv2:optionalFeature lv2:hardRTCapable, opts:options ; + lv2:extensionData opts:interface, state:interface, work:interface ; + + patch:writable <@LV2PLUGIN_URI@:sfzfile> ; + + lv2:port [ + a lv2:InputPort, atom:AtomPort ; + atom:bufferType atom:Sequence ; + atom:supports patch:Message, midi:MidiEvent ; + lv2:designation lv2:control ; + lv2:index 0 ; + lv2:symbol "control" ; + lv2:name "Control" + ] , [ + a lv2:OutputPort, atom:AtomPort ; + atom:bufferType atom:Sequence ; + atom:supports patch:Message ; + lv2:designation lv2:control ; + lv2:index 1 ; + lv2:symbol "notify" ; + lv2:name "Notify" ; + ] , [ + a lv2:AudioPort , lv2:OutputPort ; + lv2:index 2 ; + lv2:symbol "out_left" ; + lv2:name "Left Output" + ] , [ + a lv2:AudioPort , lv2:OutputPort ; + lv2:index 3 ; + lv2:symbol "out_right" ; + lv2:name "Right Output" + ] , [ + a lv2:InputPort, lv2:ControlPort ; + lv2:index 4 ; + lv2:symbol "volume" ; + lv2:name "Volume" ; + lv2:default 0.0 ; + lv2:minimum -80.0 ; + lv2:maximum 6.0 ; + lv2:portProperty pprop:notAutomatic ; + units:unit units:db + ] , [ + a lv2:InputPort, lv2:ControlPort ; + lv2:index 5 ; + lv2:symbol "num_voices" ; + lv2:name "Polyphony" ; + pg:group <#config> ; + lv2:portProperty pprop:notAutomatic ; + lv2:portProperty pprop:expensive ; + lv2:portProperty lv2:integer ; + lv2:portProperty lv2:enumeration ; + lv2:default 64 ; + lv2:minimum 8 ; + lv2:maximum 256 ; + lv2:scalePoint [ rdfs:label "8 voices"; rdf:value 8 ] ; + lv2:scalePoint [ rdfs:label "16 voices"; rdf:value 16 ] ; + lv2:scalePoint [ rdfs:label "32 voices"; rdf:value 32 ] ; + lv2:scalePoint [ rdfs:label "64 voices"; rdf:value 64 ] ; + lv2:scalePoint [ rdfs:label "128 voices"; rdf:value 128 ] ; + lv2:scalePoint [ rdfs:label "256 voices"; rdf:value 256 ] ; + ] . diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index abaf82c9..58ab0ead 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -32,7 +32,7 @@ if (UNIX) target_link_libraries (sfizz PUBLIC atomic) endif() -if (SFIZZ_USE_LTO) +if (ENABLE_LTO) set_property (TARGET sfizz_parser PROPERTY INTERPROCEDURAL_OPTIMIZATION True) set_property (TARGET sfizz PROPERTY INTERPROCEDURAL_OPTIMIZATION True) endif() From 2087502c40b5dd087c8096b2e1b0d1f2ff1fb275 Mon Sep 17 00:00:00 2001 From: redtide Date: Mon, 25 Nov 2019 23:28:16 +0100 Subject: [PATCH 29/32] Completed generic LV2 configuration --- cmake/LV2Config.cmake | 9 +++++++++ lv2/CMakeLists.txt | 11 ++--------- 2 files changed, 11 insertions(+), 9 deletions(-) create mode 100644 cmake/LV2Config.cmake diff --git a/cmake/LV2Config.cmake b/cmake/LV2Config.cmake new file mode 100644 index 00000000..97a6f3c3 --- /dev/null +++ b/cmake/LV2Config.cmake @@ -0,0 +1,9 @@ +# Configuration for this plugin +# TODO: generate version from git +set (LV2PLUGIN_VERSION_MINOR 0) +set (LV2PLUGIN_VERSION_MICRO 1) +set (LV2PLUGIN_NAME "Sfizz") +set (LV2PLUGIN_COMMENT "SFZ sampler") +set (LV2PLUGIN_URI "http://sfztools.github.io/sfizz") +set (LV2PLUGIN_AUTHOR "Paul Ferrand") +set (LV2PLUGIN_SPDX_LICENSE_ID "BSD-2-Clause") diff --git a/lv2/CMakeLists.txt b/lv2/CMakeLists.txt index 46c9d3f9..7ea112c5 100644 --- a/lv2/CMakeLists.txt +++ b/lv2/CMakeLists.txt @@ -6,15 +6,8 @@ set (LV2PLUGIN_PRJ_NAME "${CMAKE_PROJECT_NAME}_lv2") # Set the build directory as /lv2/.lv2/ set (PROJECT_BINARY_DIR "${PROJECT_BINARY_DIR}/${CMAKE_PROJECT_NAME}.lv2") -# Configuration for this plugin -# TODO: generate version from git -set (LV2PLUGIN_VERSION_MINOR 0) -set (LV2PLUGIN_VERSION_MICRO 1) -set (LV2PLUGIN_NAME "Sfizz") -set (LV2PLUGIN_COMMENT "SFZ sampler") -set (LV2PLUGIN_URI "http://sfztools.github.io/sfizz") -set (LV2PLUGIN_AUTHOR "Paul Ferrand") -set (LV2PLUGIN_SPDX_LICENSE_ID "BSD-2-Clause") +# LV2 plugin specific settings +include (LV2Config) if (WIN32) set (LV2PLUGIN_EXT "dll") From a39b05fe42e4aa6e91cf4c452103d70d0d1cb560 Mon Sep 17 00:00:00 2001 From: redtide Date: Tue, 26 Nov 2019 13:42:04 +0100 Subject: [PATCH 30/32] Script rename --- ...mdSourceFilesCheck.cmake => SfizzSIMDSourceFilesCheck.cmake} | 0 src/CMakeLists.txt | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename cmake/{SfizzSimdSourceFilesCheck.cmake => SfizzSIMDSourceFilesCheck.cmake} (100%) diff --git a/cmake/SfizzSimdSourceFilesCheck.cmake b/cmake/SfizzSIMDSourceFilesCheck.cmake similarity index 100% rename from cmake/SfizzSimdSourceFilesCheck.cmake rename to cmake/SfizzSIMDSourceFilesCheck.cmake diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 58ab0ead..98d6ed36 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -9,7 +9,7 @@ set (SFIZZ_SOURCES sfizz/SfzHelpers.cpp sfizz/FloatEnvelopes.cpp ) -include (SfizzSimdSourceFilesCheck) +include (SfizzSIMDSourceFilesCheck) # Parser core library add_library (sfizz_parser STATIC) From 4d139137cc020056f0c9d2a925eea81b678f8ad5 Mon Sep 17 00:00:00 2001 From: redtide Date: Tue, 26 Nov 2019 13:43:07 +0100 Subject: [PATCH 31/32] Check for IPO --- CMakeLists.txt | 3 +++ cmake/CheckIPO.cmake | 14 ++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 cmake/CheckIPO.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 54a9bd05..dbe4223c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,9 @@ option (SFIZZ_BENCHMARKS "Enable benchmarks build [default: OFF]" OFF) option (SFIZZ_TESTS "Enable tests build [default: OFF]" OFF) option (SFIZZ_SHARED "Enable shared library build [default: ON]" ON) +# Don't use IPO in non Release builds +include (CheckIPO) + # Add Abseil add_subdirectory (external/abseil-cpp EXCLUDE_FROM_ALL) diff --git a/cmake/CheckIPO.cmake b/cmake/CheckIPO.cmake new file mode 100644 index 00000000..73b53d5a --- /dev/null +++ b/cmake/CheckIPO.cmake @@ -0,0 +1,14 @@ +# Added in CMake 3.9 +include (CheckIPOSupported) +check_ipo_supported (RESULT result OUTPUT output) + +if (result AND ENABLE_LTO AND ${CMAKE_BUILD_TYPE} MATCHES Release) + message (STATUS "\nLTO enabled.") +else() + if (${output}) + message (WARNING "\nIPO disabled: ${output}") + else() + message (WARNING "\nIPO was disabled, not in a Release build?") + endif() + set (ENABLE_LTO OFF) +endif() From 4a268be333fad5fed6b3d982dc6e8f88ab65f541 Mon Sep 17 00:00:00 2001 From: redtide Date: Tue, 26 Nov 2019 14:25:18 +0100 Subject: [PATCH 32/32] Detail fix for previous commit --- cmake/CheckIPO.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/CheckIPO.cmake b/cmake/CheckIPO.cmake index 73b53d5a..5213cbda 100644 --- a/cmake/CheckIPO.cmake +++ b/cmake/CheckIPO.cmake @@ -2,7 +2,7 @@ include (CheckIPOSupported) check_ipo_supported (RESULT result OUTPUT output) -if (result AND ENABLE_LTO AND ${CMAKE_BUILD_TYPE} MATCHES Release) +if (result AND ENABLE_LTO AND ${CMAKE_BUILD_TYPE} STREQUAL "Release") message (STATUS "\nLTO enabled.") else() if (${output})