From dfb6264ce0d0d8ee886623d1d829a68f8f0357f3 Mon Sep 17 00:00:00 2001 From: yaw-man <85530488+yaw-man@users.noreply.github.com> Date: Sat, 15 Apr 2023 09:27:44 -0300 Subject: [PATCH] MS Toolchain; Tuning Knob (#17) * CMake and Visual Studio build files ignored * Add CMakeLists * Replace POSIX mutex with std::mutex * Mutex unlock return value isn't used, changed signature to void * C++ preprocessor demands different VA_ARGS syntax * Superfluous include directory * Expand tuning knob range to +/-1 octave. --------- Co-authored-by: yaw-man Co-authored-by: wan-may --- .gitignore | 3 +++ CMakeLists.txt | 3 +++ plugins/Nekobi/CMakeLists.txt | 12 ++++++++++++ plugins/Nekobi/DistrhoPluginNekobi.cpp | 11 ++++------- plugins/Nekobi/DistrhoPluginNekobi.hpp | 2 -- plugins/Nekobi/nekobee-src/nekobee.h | 4 ++-- plugins/Nekobi/nekobee-src/nekobee_synth.c | 2 +- plugins/Nekobi/nekobee-src/nekobee_synth.h | 4 ++-- 8 files changed, 27 insertions(+), 14 deletions(-) create mode 100644 CMakeLists.txt create mode 100644 plugins/Nekobi/CMakeLists.txt diff --git a/.gitignore b/.gitignore index 63b889b..74dc1c7 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,6 @@ bin/ build/ + +.vs/ +out/ \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..2fa8863 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.11) +add_subdirectory(dpf) +add_subdirectory(plugins/Nekobi) \ No newline at end of file diff --git a/plugins/Nekobi/CMakeLists.txt b/plugins/Nekobi/CMakeLists.txt new file mode 100644 index 0000000..82f88ae --- /dev/null +++ b/plugins/Nekobi/CMakeLists.txt @@ -0,0 +1,12 @@ +DPF_ADD_PLUGIN(Nekobi + TARGETS vst2 + FILES_DSP + DistrhoPluginNekobi.cpp + FILES_UI + DistrhoArtworkNekobi.cpp + DistrhoUINekobi.cpp) + +target_include_directories(Nekobi PUBLIC + "." + "nekobee-src" +) diff --git a/plugins/Nekobi/DistrhoPluginNekobi.cpp b/plugins/Nekobi/DistrhoPluginNekobi.cpp index f405969..ca73cde 100644 --- a/plugins/Nekobi/DistrhoPluginNekobi.cpp +++ b/plugins/Nekobi/DistrhoPluginNekobi.cpp @@ -18,7 +18,6 @@ #include "DistrhoPluginNekobi.hpp" -extern "C" { #include "nekobee-src/nekobee_synth.c" #include "nekobee-src/nekobee_voice.c" @@ -31,7 +30,7 @@ extern "C" { bool dssp_voicelist_mutex_trylock(nekobee_synth_t* const synth) { /* Attempt the mutex lock */ - if (pthread_mutex_trylock(&synth->voicelist_mutex) != 0) + if (!synth->voicelist_mutex.try_lock()) { synth->voicelist_mutex_grab_failed = 1; return false; @@ -47,9 +46,9 @@ bool dssp_voicelist_mutex_trylock(nekobee_synth_t* const synth) return true; } -bool dssp_voicelist_mutex_unlock(nekobee_synth_t* const synth) +void dssp_voicelist_mutex_unlock(nekobee_synth_t* const synth) { - return (pthread_mutex_unlock(&synth->voicelist_mutex) == 0); + synth->voicelist_mutex.unlock(); } // ----------------------------------------------------------------------- @@ -79,7 +78,6 @@ void nekobee_handle_raw_event(nekobee_synth_t* const synth, const uint8_t size, } } -} /* extern "C" */ START_NAMESPACE_DISTRHO @@ -109,7 +107,6 @@ DistrhoPluginNekobi::DistrhoPluginNekobi() fSynth.voice = nekobee_voice_new(); fSynth.voicelist_mutex_grab_failed = 0; - pthread_mutex_init(&fSynth.voicelist_mutex, nullptr); fSynth.channel_pressure = 0; fSynth.pitch_wheel_sensitivity = 0; @@ -299,7 +296,7 @@ void DistrhoPluginNekobi::setParameterValue(uint32_t index, float value) break; case paramTuning: fParams.tuning = value; - fSynth.tuning = (value+12.0f)/24.0f * 1.5 + 0.5f; // FIXME: log? + fSynth.tuning = exp2f( value / 12.0f ); DISTRHO_SAFE_ASSERT(fSynth.tuning >= 0.5f && fSynth.tuning <= 2.0f); break; case paramCutoff: diff --git a/plugins/Nekobi/DistrhoPluginNekobi.hpp b/plugins/Nekobi/DistrhoPluginNekobi.hpp index 363f80d..19621a1 100644 --- a/plugins/Nekobi/DistrhoPluginNekobi.hpp +++ b/plugins/Nekobi/DistrhoPluginNekobi.hpp @@ -21,9 +21,7 @@ #include "DistrhoPlugin.hpp" -extern "C" { #include "nekobee-src/nekobee_synth.h" -} START_NAMESPACE_DISTRHO diff --git a/plugins/Nekobi/nekobee-src/nekobee.h b/plugins/Nekobi/nekobee-src/nekobee.h index 9d6db7d..718cc26 100644 --- a/plugins/Nekobi/nekobee-src/nekobee.h +++ b/plugins/Nekobi/nekobee-src/nekobee.h @@ -63,8 +63,8 @@ #else /* !XSYNTH_DEBUG */ -#define XDB_MESSAGE(type, fmt...) -#define GDB_MESSAGE(type, fmt...) +#define XDB_MESSAGE(type, fmt, ...) +#define GDB_MESSAGE(type, fmt, ...) #define XSYNTH_DEBUG_INIT(x) #endif /* XSYNTH_DEBUG */ diff --git a/plugins/Nekobi/nekobee-src/nekobee_synth.c b/plugins/Nekobi/nekobee-src/nekobee_synth.c index 94b8376..a021151 100644 --- a/plugins/Nekobi/nekobee-src/nekobee_synth.c +++ b/plugins/Nekobi/nekobee-src/nekobee_synth.c @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include "nekobee.h" #include "nekobee_synth.h" diff --git a/plugins/Nekobi/nekobee-src/nekobee_synth.h b/plugins/Nekobi/nekobee-src/nekobee_synth.h index 675d5bf..aa2e72b 100644 --- a/plugins/Nekobi/nekobee-src/nekobee_synth.h +++ b/plugins/Nekobi/nekobee-src/nekobee_synth.h @@ -26,7 +26,7 @@ #ifndef _XSYNTH_SYNTH_H #define _XSYNTH_SYNTH_H -#include +#include #include "nekobee.h" #include "nekobee_types.h" @@ -64,7 +64,7 @@ struct _nekobee_synth_t { //nekobee_voice_t *voice[XSYNTH_MAX_POLYPHONY]; nekobee_voice_t *voice; - pthread_mutex_t voicelist_mutex; + std::mutex voicelist_mutex; int voicelist_mutex_grab_failed; /* current non-paramter-mapped controller values */