From 7948f66eb4261c7bfeb7fdd7f6922a3a0c811c3f Mon Sep 17 00:00:00 2001 From: falkTX Date: Thu, 11 Apr 2024 10:34:10 +0200 Subject: [PATCH] Continue biset changes, plugin-accessible cardinal context Signed-off-by: falkTX --- include/midi.hpp | 14 ++- plugins/Biset | 2 +- plugins/Cardinal/src/AIDA-X.cpp | 10 +- plugins/Cardinal/src/AudioFile.cpp | 8 +- plugins/Cardinal/src/AudioToCVPitch.cpp | 6 +- plugins/Cardinal/src/Carla.cpp | 7 +- plugins/Cardinal/src/HostAudio.cpp | 4 +- plugins/Cardinal/src/HostCV.cpp | 4 +- plugins/Cardinal/src/HostMIDI-CC.cpp | 4 +- plugins/Cardinal/src/HostMIDI-Gate.cpp | 4 +- plugins/Cardinal/src/HostMIDI-Map.cpp | 4 +- plugins/Cardinal/src/HostMIDI.cpp | 4 +- plugins/Cardinal/src/HostParameters-Map.cpp | 4 +- plugins/Cardinal/src/HostParameters.cpp | 4 +- plugins/Cardinal/src/HostTime.cpp | 4 +- plugins/Cardinal/src/Ildaeil.cpp | 10 +- plugins/Cardinal/src/MPV.cpp | 5 +- plugins/Cardinal/src/SassyScope.cpp | 4 +- plugins/Cardinal/src/TextEditor.cpp | 6 +- plugins/Cardinal/src/plugin.hpp | 9 +- plugins/Cardinal/src/plugincontext.hpp | 89 -------------- plugins/Makefile | 5 +- plugins/plugins.cpp | 46 ++++--- src/CardinalCommon.cpp | 127 +++++++++++++++++++- src/CardinalCommon.hpp | 3 +- src/PluginContext.hpp | 95 +-------------- 26 files changed, 223 insertions(+), 259 deletions(-) delete mode 100644 plugins/Cardinal/src/plugincontext.hpp diff --git a/include/midi.hpp b/include/midi.hpp index 1a6425a..20f2cb1 100644 --- a/include/midi.hpp +++ b/include/midi.hpp @@ -1,6 +1,6 @@ /* * DISTRHO Cardinal Plugin - * Copyright (C) 2021-2022 Filipe Coelho + * Copyright (C) 2021-2024 Filipe Coelho * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -111,6 +111,18 @@ struct Message { }; +struct InputQueue { + struct Internal; + Internal* internal; + + InputQueue(); + ~InputQueue(); + bool tryPop(Message* const messageOut, int64_t maxFrame); + json_t* toJson() const; + void fromJson(json_t* rootJ); +}; + + /* NOTE all the other MIDI stuff (drivers, ports etc) is purposefully missing here, unwanted in Cardinal */ struct Port; diff --git a/plugins/Biset b/plugins/Biset index 43dc87d..a3acddc 160000 --- a/plugins/Biset +++ b/plugins/Biset @@ -1 +1 @@ -Subproject commit 43dc87d98e0da2e99b1f03f7f0c4b7e5bccab01d +Subproject commit a3acddc30732700b91f27075488b914c38b9dcdf diff --git a/plugins/Cardinal/src/AIDA-X.cpp b/plugins/Cardinal/src/AIDA-X.cpp index 5ec02cf..1c9f889 100644 --- a/plugins/Cardinal/src/AIDA-X.cpp +++ b/plugins/Cardinal/src/AIDA-X.cpp @@ -1,11 +1,11 @@ /* * AIDA-X Cardinal plugin * Copyright (C) 2022-2023 Massimo Pennazio - * Copyright (C) 2023 Filipe Coelho + * Copyright (C) 2023-2024 Filipe Coelho * SPDX-License-Identifier: GPL-3.0-or-later */ -#include "plugincontext.hpp" +#include "plugin.hpp" #include "ModuleWidgets.hpp" #ifndef HEADLESS @@ -250,7 +250,6 @@ struct AidaPluginModule : Module { NUM_LIGHTS }; - CardinalPluginContext* const pcontext; bool fileChanged = false; std::string currentFile; @@ -272,7 +271,6 @@ struct AidaPluginModule : Module { #endif AidaPluginModule() - : pcontext(static_cast(APP)) { config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS); @@ -656,8 +654,6 @@ struct AidaPluginModule : Module { cachedParams[kParameterPRESENCE]); } #endif - - DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(AidaPluginModule) }; // -------------------------------------------------------------------------------------------------------------------- @@ -1093,8 +1089,6 @@ struct AidaWidget : ModuleWidgetWithSideScrews<23> { menu->addChild(new LoadModelFileItem(module)); } - - DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(AidaWidget) }; #else struct AidaWidget : ModuleWidget { diff --git a/plugins/Cardinal/src/AudioFile.cpp b/plugins/Cardinal/src/AudioFile.cpp index 699cb59..53e8933 100644 --- a/plugins/Cardinal/src/AudioFile.cpp +++ b/plugins/Cardinal/src/AudioFile.cpp @@ -1,6 +1,6 @@ /* * DISTRHO Cardinal Plugin - * Copyright (C) 2021-2022 Filipe Coelho + * Copyright (C) 2021-2024 Filipe Coelho * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -15,6 +15,7 @@ * For a full copy of the GNU General Public License see the LICENSE file. */ +#include "plugin.hpp" #include "plugincontext.hpp" #include "ModuleWidgets.hpp" #include "extra/Runner.hpp" @@ -39,6 +40,7 @@ const NativePluginDescriptor* carla_getNativePluginDescriptor(const std::size_t // -------------------------------------------------------------------------------------------------------------------- using namespace CARLA_BACKEND_NAMESPACE; +using namespace DISTRHO_NAMESPACE; static uint32_t host_get_buffer_size(NativeHostHandle); static double host_get_sample_rate(NativeHostHandle); @@ -335,8 +337,6 @@ struct CarlaInternalPluginModule : Module, Runner { 0, 0, nullptr, e.sampleRate); fCarlaPluginDescriptor->activate(fCarlaPluginHandle); } - - DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaInternalPluginModule) }; // ----------------------------------------------------------------------------------------------------------- @@ -679,8 +679,6 @@ struct AudioFileWidget : ModuleWidgetWithSideScrews<23> { menu->addChild(new LoadAudioFileItem(module)); } - - DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(AudioFileWidget) }; #else struct AudioFileWidget : ModuleWidget { diff --git a/plugins/Cardinal/src/AudioToCVPitch.cpp b/plugins/Cardinal/src/AudioToCVPitch.cpp index 2c79720..9fc982a 100644 --- a/plugins/Cardinal/src/AudioToCVPitch.cpp +++ b/plugins/Cardinal/src/AudioToCVPitch.cpp @@ -1,7 +1,7 @@ /* * DISTRHO Cardinal Plugin * Copyright (C) 2021-2022 Bram Giesen - * Copyright (C) 2022 Filipe Coelho + * Copyright (C) 2022-2024 Filipe Coelho * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -16,7 +16,7 @@ * For a full copy of the GNU General Public License see the LICENSE file. */ -#include "plugincontext.hpp" +#include "plugin.hpp" #include "ModuleWidgets.hpp" #include "Widgets.hpp" @@ -24,8 +24,6 @@ extern "C" { #include "aubio.h" } -USE_NAMESPACE_DISTRHO; - // -------------------------------------------------------------------------------------------------------------------- // aubio setup values (tested under 48 kHz sample rate) diff --git a/plugins/Cardinal/src/Carla.cpp b/plugins/Cardinal/src/Carla.cpp index b912283..bf51a29 100644 --- a/plugins/Cardinal/src/Carla.cpp +++ b/plugins/Cardinal/src/Carla.cpp @@ -1,6 +1,6 @@ /* * DISTRHO Cardinal Plugin - * Copyright (C) 2021-2023 Filipe Coelho + * Copyright (C) 2021-2024 Filipe Coelho * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -15,6 +15,7 @@ * For a full copy of the GNU General Public License see the LICENSE file. */ +#include "plugin.hpp" #include "plugincontext.hpp" #include "Expander.hpp" #include "ModuleWidgets.hpp" @@ -427,8 +428,6 @@ struct CarlaModule : Module { 0, 0, nullptr, e.sampleRate); fCarlaPluginDescriptor->activate(fCarlaPluginHandle); } - - DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaModule) }; static_assert((int)CarlaModule::NUM_INPUTS == (int)CarlaModule::NUM_OUTPUTS, "inputs must match outputs"); @@ -715,8 +714,6 @@ struct CarlaModuleWidget : ModuleWidgetWith9HP, IdleCallback { e.consume(this); showUI(); } - - DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaModuleWidget) }; static void host_ui_closed(NativeHostHandle handle) diff --git a/plugins/Cardinal/src/HostAudio.cpp b/plugins/Cardinal/src/HostAudio.cpp index 09c7949..7a5ad52 100644 --- a/plugins/Cardinal/src/HostAudio.cpp +++ b/plugins/Cardinal/src/HostAudio.cpp @@ -1,6 +1,6 @@ /* * DISTRHO Cardinal Plugin - * Copyright (C) 2021-2022 Filipe Coelho + * Copyright (C) 2021-2024 Filipe Coelho * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -15,9 +15,11 @@ * For a full copy of the GNU General Public License see the LICENSE file. */ +#include "plugin.hpp" #include "plugincontext.hpp" #include "ModuleWidgets.hpp" #include "Widgets.hpp" +#include "engine/TerminalModule.hpp" // ----------------------------------------------------------------------------------------------------------- diff --git a/plugins/Cardinal/src/HostCV.cpp b/plugins/Cardinal/src/HostCV.cpp index fee8aec..763922a 100644 --- a/plugins/Cardinal/src/HostCV.cpp +++ b/plugins/Cardinal/src/HostCV.cpp @@ -1,6 +1,6 @@ /* * DISTRHO Cardinal Plugin - * Copyright (C) 2021-2022 Filipe Coelho + * Copyright (C) 2021-2024 Filipe Coelho * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -15,8 +15,10 @@ * For a full copy of the GNU General Public License see the LICENSE file. */ +#include "plugin.hpp" #include "plugincontext.hpp" #include "ModuleWidgets.hpp" +#include "engine/TerminalModule.hpp" // ----------------------------------------------------------------------------------------------------------- diff --git a/plugins/Cardinal/src/HostMIDI-CC.cpp b/plugins/Cardinal/src/HostMIDI-CC.cpp index 3c71a86..2f5c103 100644 --- a/plugins/Cardinal/src/HostMIDI-CC.cpp +++ b/plugins/Cardinal/src/HostMIDI-CC.cpp @@ -1,6 +1,6 @@ /* * DISTRHO Cardinal Plugin - * Copyright (C) 2021-2022 Filipe Coelho + * Copyright (C) 2021-2024 Filipe Coelho * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -25,9 +25,11 @@ * the License, or (at your option) any later version. */ +#include "plugin.hpp" #include "plugincontext.hpp" #include "ModuleWidgets.hpp" #include "Widgets.hpp" +#include "engine/TerminalModule.hpp" #include diff --git a/plugins/Cardinal/src/HostMIDI-Gate.cpp b/plugins/Cardinal/src/HostMIDI-Gate.cpp index 77d34f7..c2153cd 100644 --- a/plugins/Cardinal/src/HostMIDI-Gate.cpp +++ b/plugins/Cardinal/src/HostMIDI-Gate.cpp @@ -1,6 +1,6 @@ /* * DISTRHO Cardinal Plugin - * Copyright (C) 2021-2022 Filipe Coelho + * Copyright (C) 2021-2024 Filipe Coelho * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -25,9 +25,11 @@ * the License, or (at your option) any later version. */ +#include "plugin.hpp" #include "plugincontext.hpp" #include "ModuleWidgets.hpp" #include "Widgets.hpp" +#include "engine/TerminalModule.hpp" #include diff --git a/plugins/Cardinal/src/HostMIDI-Map.cpp b/plugins/Cardinal/src/HostMIDI-Map.cpp index 46bb16e..1af8bf3 100644 --- a/plugins/Cardinal/src/HostMIDI-Map.cpp +++ b/plugins/Cardinal/src/HostMIDI-Map.cpp @@ -1,6 +1,6 @@ /* * DISTRHO Cardinal Plugin - * Copyright (C) 2021-2022 Filipe Coelho + * Copyright (C) 2021-2024 Filipe Coelho * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -25,9 +25,11 @@ * the License, or (at your option) any later version. */ +#include "plugin.hpp" #include "plugincontext.hpp" #include "ModuleWidgets.hpp" #include "Widgets.hpp" +#include "engine/TerminalModule.hpp" #include diff --git a/plugins/Cardinal/src/HostMIDI.cpp b/plugins/Cardinal/src/HostMIDI.cpp index ebb8105..22b8348 100644 --- a/plugins/Cardinal/src/HostMIDI.cpp +++ b/plugins/Cardinal/src/HostMIDI.cpp @@ -1,6 +1,6 @@ /* * DISTRHO Cardinal Plugin - * Copyright (C) 2021-2022 Filipe Coelho + * Copyright (C) 2021-2024 Filipe Coelho * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -25,7 +25,9 @@ * the License, or (at your option) any later version. */ +#include "plugin.hpp" #include "plugincontext.hpp" +#include "engine/TerminalModule.hpp" #include "ModuleWidgets.hpp" #include diff --git a/plugins/Cardinal/src/HostParameters-Map.cpp b/plugins/Cardinal/src/HostParameters-Map.cpp index eed89b5..d40d83b 100644 --- a/plugins/Cardinal/src/HostParameters-Map.cpp +++ b/plugins/Cardinal/src/HostParameters-Map.cpp @@ -1,6 +1,6 @@ /* * DISTRHO Cardinal Plugin - * Copyright (C) 2021-2022 Filipe Coelho + * Copyright (C) 2021-2024 Filipe Coelho * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -25,9 +25,11 @@ * the License, or (at your option) any later version. */ +#include "plugin.hpp" #include "plugincontext.hpp" #include "ModuleWidgets.hpp" #include "Widgets.hpp" +#include "engine/TerminalModule.hpp" // ----------------------------------------------------------------------------------------------------------- diff --git a/plugins/Cardinal/src/HostParameters.cpp b/plugins/Cardinal/src/HostParameters.cpp index 97c8912..1cbb37f 100644 --- a/plugins/Cardinal/src/HostParameters.cpp +++ b/plugins/Cardinal/src/HostParameters.cpp @@ -1,6 +1,6 @@ /* * DISTRHO Cardinal Plugin - * Copyright (C) 2021-2022 Filipe Coelho + * Copyright (C) 2021-2024 Filipe Coelho * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -15,8 +15,10 @@ * For a full copy of the GNU General Public License see the LICENSE file. */ +#include "plugin.hpp" #include "plugincontext.hpp" #include "ModuleWidgets.hpp" +#include "engine/TerminalModule.hpp" // ----------------------------------------------------------------------------------------------------------- diff --git a/plugins/Cardinal/src/HostTime.cpp b/plugins/Cardinal/src/HostTime.cpp index f853379..a28c4cd 100644 --- a/plugins/Cardinal/src/HostTime.cpp +++ b/plugins/Cardinal/src/HostTime.cpp @@ -1,6 +1,6 @@ /* * DISTRHO Cardinal Plugin - * Copyright (C) 2021-2022 Filipe Coelho + * Copyright (C) 2021-2024 Filipe Coelho * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -15,8 +15,10 @@ * For a full copy of the GNU General Public License see the LICENSE file. */ +#include "plugin.hpp" #include "plugincontext.hpp" #include "ModuleWidgets.hpp" +#include "engine/TerminalModule.hpp" // -------------------------------------------------------------------------------------------------------------------- diff --git a/plugins/Cardinal/src/Ildaeil.cpp b/plugins/Cardinal/src/Ildaeil.cpp index 55a2b65..9ed7212 100644 --- a/plugins/Cardinal/src/Ildaeil.cpp +++ b/plugins/Cardinal/src/Ildaeil.cpp @@ -1,6 +1,6 @@ /* * DISTRHO Cardinal Plugin - * Copyright (C) 2021-2023 Filipe Coelho + * Copyright (C) 2021-2024 Filipe Coelho * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -25,6 +25,7 @@ * the License, or (at your option) any later version. */ +#include "plugin.hpp" #include "plugincontext.hpp" #include "Expander.hpp" @@ -98,6 +99,7 @@ namespace ildaeil { // -------------------------------------------------------------------------------------------------------------------- using namespace CARLA_BACKEND_NAMESPACE; +using namespace DISTRHO_NAMESPACE; static uint32_t host_get_buffer_size(NativeHostHandle); static double host_get_sample_rate(NativeHostHandle); @@ -768,8 +770,6 @@ struct IldaeilModule : Module { 0, 0, nullptr, e.sampleRate); fCarlaPluginDescriptor->activate(fCarlaPluginHandle); } - - DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(IldaeilModule) }; // ----------------------------------------------------------------------------------------------------------- @@ -2252,8 +2252,6 @@ struct IldaeilWidget : ImGuiWidget, IdleCallback, Runner { ImGui::End(); } - - DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(IldaeilWidget) }; // -------------------------------------------------------------------------------------------------------------------- @@ -2435,8 +2433,6 @@ struct IldaeilModuleWidget : ModuleWidgetWithSideScrews<26> { ModuleWidgetWithSideScrews<26>::step(); } - - DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(IldaeilModuleWidget) }; #else static void host_ui_parameter_changed(NativeHostHandle, uint32_t, float) {} diff --git a/plugins/Cardinal/src/MPV.cpp b/plugins/Cardinal/src/MPV.cpp index df29019..acd0c1c 100644 --- a/plugins/Cardinal/src/MPV.cpp +++ b/plugins/Cardinal/src/MPV.cpp @@ -1,6 +1,6 @@ /* * DISTRHO Cardinal Plugin - * Copyright (C) 2021-2022 Filipe Coelho + * Copyright (C) 2021-2024 Filipe Coelho * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -15,12 +15,15 @@ * For a full copy of the GNU General Public License see the LICENSE file. */ +#include "plugin.hpp" #include "plugincontext.hpp" #ifndef HEADLESS # include "EmbedWidget.hpp" # include "extra/ExternalWindow.hpp" #endif +USE_NAMESPACE_DISTRHO; + // -------------------------------------------------------------------------------------------------------------------- struct CardinalEmbedModule : Module { diff --git a/plugins/Cardinal/src/SassyScope.cpp b/plugins/Cardinal/src/SassyScope.cpp index 392fa2a..bc836a1 100644 --- a/plugins/Cardinal/src/SassyScope.cpp +++ b/plugins/Cardinal/src/SassyScope.cpp @@ -1,6 +1,6 @@ /* * DISTRHO Cardinal Plugin - * Copyright (C) 2021-2022 Filipe Coelho + * Copyright (C) 2021-2024 Filipe Coelho * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -15,7 +15,7 @@ * For a full copy of the GNU General Public License see the LICENSE file. */ -#include "plugincontext.hpp" +#include "plugin.hpp" #include "ImGuiWidget.hpp" #include "sassy/sassy.hpp" #include "sassy/sassy_scope.cpp" diff --git a/plugins/Cardinal/src/TextEditor.cpp b/plugins/Cardinal/src/TextEditor.cpp index e16e9a2..5fa67ed 100644 --- a/plugins/Cardinal/src/TextEditor.cpp +++ b/plugins/Cardinal/src/TextEditor.cpp @@ -1,6 +1,6 @@ /* * DISTRHO Cardinal Plugin - * Copyright (C) 2021-2022 Filipe Coelho + * Copyright (C) 2021-2024 Filipe Coelho * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -15,7 +15,7 @@ * For a full copy of the GNU General Public License see the LICENSE file. */ -#include "plugincontext.hpp" +#include "plugin.hpp" #ifndef HEADLESS # include "ImGuiTextEditor.hpp" @@ -412,8 +412,6 @@ struct TextEditorModuleWidget : ModuleWidget { menu->addChild(new ui::MenuSeparator); menu->addChild(createMenuItem("Select all", RACK_MOD_CTRL_NAME "+A", [=]{ textEditorWidget->selectAll(); })); } - - DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(TextEditorModuleWidget) }; #else struct TextEditorModuleWidget : ModuleWidget { diff --git a/plugins/Cardinal/src/plugin.hpp b/plugins/Cardinal/src/plugin.hpp index 0b55a02..d31a261 100644 --- a/plugins/Cardinal/src/plugin.hpp +++ b/plugins/Cardinal/src/plugin.hpp @@ -1,6 +1,6 @@ /* * DISTRHO Cardinal Plugin - * Copyright (C) 2021-2022 Filipe Coelho + * Copyright (C) 2021-2024 Filipe Coelho * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -18,11 +18,8 @@ #pragma once #include "rack.hpp" -#include "engine/TerminalModule.hpp" - -#ifdef NDEBUG -# undef DEBUG -#endif +// #include "engine/TerminalModule.hpp" +// #include "plugincontext.hpp" using namespace rack; diff --git a/plugins/Cardinal/src/plugincontext.hpp b/plugins/Cardinal/src/plugincontext.hpp deleted file mode 100644 index f7fcc03..0000000 --- a/plugins/Cardinal/src/plugincontext.hpp +++ /dev/null @@ -1,89 +0,0 @@ -/* - * DISTRHO Cardinal Plugin - * Copyright (C) 2021-2022 Filipe Coelho - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 3 of - * the License, or any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * For a full copy of the GNU General Public License see the LICENSE file. - */ - -#pragma once - -#include "plugin.hpp" -#include "DistrhoUtils.hpp" - -#include "../dgl/Base.hpp" - -// ----------------------------------------------------------------------------------------------------------- -// from PluginContext.hpp - -START_NAMESPACE_DGL -class TopLevelWidget; -template class NanoBaseWidget; -typedef NanoBaseWidget NanoTopLevelWidget; -END_NAMESPACE_DGL - -START_NAMESPACE_DISTRHO - -static constexpr const uint32_t kModuleParameterCount = 24; - -enum CardinalVariant { - kCardinalVariantMain, - kCardinalVariantMini, - kCardinalVariantFX, - kCardinalVariantNative, - kCardinalVariantSynth, -}; - -class Plugin; -class UI; - -struct MidiEvent { - static const uint32_t kDataSize = 4; - uint32_t frame; - uint32_t size; - uint8_t data[kDataSize]; - const uint8_t* dataExt; -}; - -struct CardinalPluginContext : rack::Context { - uint32_t bufferSize, processCounter; - double sampleRate; - float parameters[kModuleParameterCount]; - CardinalVariant variant; - bool bypassed, playing, reset, bbtValid; - int32_t bar, beat, beatsPerBar, beatType; - uint64_t frame; - double barStartTick, beatsPerMinute; - double tick, tickClock, ticksPerBeat, ticksPerClock, ticksPerFrame; - uintptr_t nativeWindowId; - const float* const* dataIns; - float** dataOuts; - const MidiEvent* midiEvents; - uint32_t midiEventCount; - Plugin* const plugin; - DGL_NAMESPACE::NanoTopLevelWidget* tlw; - UI* ui; - CardinalPluginContext(Plugin* const p); - void writeMidiMessage(const rack::midi::Message& message, uint8_t channel); -#ifndef HEADLESS - bool addIdleCallback(IdleCallback* cb) const; - void removeIdleCallback(IdleCallback* cb) const; -#endif -}; - -#ifndef HEADLESS -void handleHostParameterDrag(const CardinalPluginContext* pcontext, uint index, bool started); -#endif - -END_NAMESPACE_DISTRHO - -// ----------------------------------------------------------------------------------------------------------- diff --git a/plugins/Makefile b/plugins/Makefile index d64f6e6..9536c73 100644 --- a/plugins/Makefile +++ b/plugins/Makefile @@ -578,8 +578,8 @@ BIDOO_CUSTOM_PER_FILE = channel channel filterType PLUGIN_FILES += $(filter-out Biset/src/plugin.cpp,$(wildcard Biset/src/*.cpp)) PLUGIN_FILES += $(wildcard Biset/src/*/*.cpp) -# # modules/types which are present in other plugins -BISET_CUSTOM = Blank +# modules/types which are present in other plugins +BISET_CUSTOM = Blank ButtonTrigger Clock Tree # -------------------------------------------------------------- # BogaudioModules @@ -1318,6 +1318,7 @@ BUILD_DIR = ../build/plugins endif BASE_FLAGS += -DBUILDING_PLUGIN_MODULES +BASE_FLAGS += -DDONT_SET_USING_DISTRHO_NAMESPACE BASE_FLAGS += -I$(abspath $(ROOT)/include/osdialog-stub) ifeq ($(BSD)$(WASM),true) diff --git a/plugins/plugins.cpp b/plugins/plugins.cpp index f9bad02..9fb9a15 100644 --- a/plugins/plugins.cpp +++ b/plugins/plugins.cpp @@ -147,9 +147,13 @@ extern Model* modelChord; #include "Bidoo/src/plugin.hpp" // Biset +#define modelBlank modelBisetBlank +#define modelTree modelBisetTree #define Clock BisetClock #define ButtonTrigger BisetButtonTrigger #include "Biset/src/plugin.hpp" +#undef modelBlank +#undef modelTree #undef ButtonTrigger #undef Clock @@ -1629,31 +1633,35 @@ static void initStatic__Biset() const StaticPluginLoader spl(p, "Biset"); if (spl.ok()) { +#define modelBlank modelBisetBlank +#define modelTree modelBisetTree p->addModel(modelTracker); - p->addModel(modelTrackerSynth); - p->addModel(modelTrackerDrum); - p->addModel(modelTrackerClock); - p->addModel(modelTrackerPhase); - p->addModel(modelTrackerQuant); - p->addModel(modelTrackerState); - p->addModel(modelTrackerControl); + p->addModel(modelTrackerSynth); + p->addModel(modelTrackerDrum); + p->addModel(modelTrackerClock); + p->addModel(modelTrackerPhase); + p->addModel(modelTrackerQuant); + p->addModel(modelTrackerState); + p->addModel(modelTrackerControl); - p->addModel(modelRegex); - p->addModel(modelRegexCondensed); - p->addModel(modelRegexExp); + p->addModel(modelRegex); + p->addModel(modelRegexCondensed); + p->addModel(modelRegexExp); - p->addModel(modelBisetTree); - p->addModel(modelBisetTreeSeed); + p->addModel(modelTree); + p->addModel(modelTreeSeed); - p->addModel(modelGbu); - p->addModel(modelPkm); + p->addModel(modelGbu); + p->addModel(modelPkm); - p->addModel(modelIgc); - p->addModel(modelOmega3); - p->addModel(modelOmega6); + p->addModel(modelIgc); + p->addModel(modelOmega3); + p->addModel(modelOmega6); - p->addModel(modelSegfault); - p->addModel(modelBlank); + p->addModel(modelSegfault); + p->addModel(modelBlank); +#undef modelBlank +#undef modelTree } } diff --git a/src/CardinalCommon.cpp b/src/CardinalCommon.cpp index b616872..003438a 100644 --- a/src/CardinalCommon.cpp +++ b/src/CardinalCommon.cpp @@ -101,8 +101,6 @@ void destroyStaticPlugins(); const std::string CARDINAL_VERSION = "24.04"; -START_NAMESPACE_DISTRHO - // ----------------------------------------------------------------------------------------------------------- #ifndef HEADLESS @@ -126,6 +124,51 @@ void handleHostParameterDrag(const CardinalPluginContext* pcontext, uint index, // -------------------------------------------------------------------------------------------------------------------- +CardinalPluginContext::CardinalPluginContext(Plugin* const p) + : bufferSize(p != nullptr ? p->getBufferSize() : 0), + processCounter(0), + sampleRate(p != nullptr ? p->getSampleRate() : 0.0), + #if CARDINAL_VARIANT_MAIN + variant(kCardinalVariantMain), + #elif CARDINAL_VARIANT_MINI + variant(kCardinalVariantMini), + #elif CARDINAL_VARIANT_FX + variant(kCardinalVariantFX), + #elif CARDINAL_VARIANT_NATIVE + variant(kCardinalVariantNative), + #elif CARDINAL_VARIANT_SYNTH + variant(kCardinalVariantSynth), + #else + #error cardinal variant not set + #endif + bypassed(false), + playing(false), + reset(false), + bbtValid(false), + bar(1), + beat(1), + beatsPerBar(4), + beatType(4), + frame(0), + barStartTick(0.0), + beatsPerMinute(120.0), + tick(0.0), + tickClock(0.0), + ticksPerBeat(0.0), + ticksPerClock(0.0), + ticksPerFrame(0.0), + nativeWindowId(0), + dataIns(nullptr), + dataOuts(nullptr), + midiEvents(nullptr), + midiEventCount(0), + plugin(p), + tlw(nullptr), + ui(nullptr) +{ + std::memset(parameters, 0, sizeof(parameters)); +} + #ifndef HEADLESS bool CardinalPluginContext::addIdleCallback(IdleCallback* const cb) const { @@ -224,6 +267,86 @@ void CardinalPluginContext::writeMidiMessage(const rack::midi::Message& message, // ----------------------------------------------------------------------------------------------------------- +namespace rack { +namespace midi { + +struct InputQueue::Internal { + CardinalPluginContext* const pcontext = static_cast(APP); + const CardinalDISTRHO::MidiEvent* midiEvents = nullptr; + uint32_t midiEventsLeft = 0; + uint32_t lastProcessCounter = 0; + int64_t lastBlockFrame = 0; +}; + +InputQueue::InputQueue() { + internal = new Internal; +} + +InputQueue::~InputQueue() { + delete internal; +} + +bool InputQueue::tryPop(Message* const messageOut, int64_t maxFrame) +{ + const uint32_t processCounter = internal->pcontext->processCounter; + const bool processCounterChanged = internal->lastProcessCounter != processCounter; + + if (processCounterChanged) + { + internal->lastBlockFrame = pcontext->engine->getBlockFrame(); + internal->lastProcessCounter = processCounter; + + internal->midiEvents = pcontext->midiEvents; + internal->midiEventsLeft = pcontext->midiEventCount; + } + + if (internal->midiEventsLeft == 0 || maxFrame < internal->lastBlockFrame) + return false; + + const uint32_t frame = maxFrame - internal->lastBlockFrame; + + if (frame > internal->midiEvents->frame) + return false; + + const CardinalDISTRHO::MidiEvent& midiEvent(*internal->midiEvents); + + const uint8_t* data; + if (midiEvent.size > CardinalDISTRHO::MidiEvent::kDataSize) + { + data = midiEvent.dataExt; + messageOut->bytes.resize(midiEvent.size); + } + else + { + data = midiEvent.data; + } + + messageOut->frame = frame; + std::memcpy(messageOut->bytes.data(), data, midiEvent.size); + + ++internal->midiEvents; + --internal->midiEventsLeft; + return true; +} + +json_t* InputQueue::toJson() const +{ + return nullptr; +} + +void InputQueue::fromJson(json_t* rootJ) +{ +} + +} +} + +// ----------------------------------------------------------------------------------------------------------- + +START_NAMESPACE_DISTRHO + +// ----------------------------------------------------------------------------------------------------------- + #ifdef HAVE_LIBLO static void osc_error_handler(int num, const char* msg, const char* path) { diff --git a/src/CardinalCommon.hpp b/src/CardinalCommon.hpp index 653b506..31b81b1 100644 --- a/src/CardinalCommon.hpp +++ b/src/CardinalCommon.hpp @@ -12,6 +12,8 @@ extern const std::string CARDINAL_VERSION; +struct CardinalPluginContext; + // ----------------------------------------------------------------------------------------------------------- namespace rack { @@ -84,7 +86,6 @@ START_NAMESPACE_DISTRHO class CardinalBasePlugin; class CardinalBaseUI; -struct CardinalPluginContext; struct Initializer { diff --git a/src/PluginContext.hpp b/src/PluginContext.hpp index fa5c97d..8c2f02b 100644 --- a/src/PluginContext.hpp +++ b/src/PluginContext.hpp @@ -36,29 +36,14 @@ #ifndef HEADLESS # include "DistrhoUI.hpp" -#else -# include "Base.hpp" -START_NAMESPACE_DGL -class TopLevelWidget; -template class NanoBaseWidget; -typedef NanoBaseWidget NanoTopLevelWidget; -END_NAMESPACE_DGL #endif +#include "plugincontext.hpp" + START_NAMESPACE_DISTRHO // ----------------------------------------------------------------------------------------------------------- -static constexpr const uint kModuleParameterCount = 24; - -enum CardinalVariant { - kCardinalVariantMain, - kCardinalVariantMini, - kCardinalVariantFX, - kCardinalVariantNative, - kCardinalVariantSynth, -}; - enum CardinalParameters { kCardinalParameterCountAtModules = kModuleParameterCount, kCardinalParameterBypass = kCardinalParameterCountAtModules, @@ -126,82 +111,6 @@ static_assert(kCardinalParameterCountAtWindow == kModuleParameterCount + kWindow static_assert(DISTRHO_PLUGIN_NUM_INPUTS == kCardinalParameterCountAtMiniBuffers - kCardinalParameterStartMiniBuffers, "valid parameter indexes"); #endif -class UI; - -// ----------------------------------------------------------------------------------------------------------- - -struct CardinalPluginContext : rack::Context { - uint32_t bufferSize, processCounter; - double sampleRate; - float parameters[kModuleParameterCount]; - CardinalVariant variant; - bool bypassed, playing, reset, bbtValid; - int32_t bar, beat, beatsPerBar, beatType; - uint64_t frame; - double barStartTick, beatsPerMinute; - double tick, tickClock, ticksPerBeat, ticksPerClock, ticksPerFrame; - uintptr_t nativeWindowId; - const float* const* dataIns; - float** dataOuts; - const MidiEvent* midiEvents; - uint32_t midiEventCount; - Plugin* const plugin; - NanoTopLevelWidget* tlw; - UI* ui; - - CardinalPluginContext(Plugin* const p) - : bufferSize(p != nullptr ? p->getBufferSize() : 0), - processCounter(0), - sampleRate(p != nullptr ? p->getSampleRate() : 0.0), - #if CARDINAL_VARIANT_MAIN - variant(kCardinalVariantMain), - #elif CARDINAL_VARIANT_MINI - variant(kCardinalVariantMini), - #elif CARDINAL_VARIANT_FX - variant(kCardinalVariantFX), - #elif CARDINAL_VARIANT_NATIVE - variant(kCardinalVariantNative), - #elif CARDINAL_VARIANT_SYNTH - variant(kCardinalVariantSynth), - #else - #error cardinal variant not set - #endif - bypassed(false), - playing(false), - reset(false), - bbtValid(false), - bar(1), - beat(1), - beatsPerBar(4), - beatType(4), - frame(0), - barStartTick(0.0), - beatsPerMinute(120.0), - tick(0.0), - tickClock(0.0), - ticksPerBeat(0.0), - ticksPerClock(0.0), - ticksPerFrame(0.0), - nativeWindowId(0), - dataIns(nullptr), - dataOuts(nullptr), - midiEvents(nullptr), - midiEventCount(0), - plugin(p), - tlw(nullptr), - ui(nullptr) - { - std::memset(parameters, 0, sizeof(parameters)); - } - - void writeMidiMessage(const rack::midi::Message& message, uint8_t channel); - - #ifndef HEADLESS - bool addIdleCallback(IdleCallback* cb) const; - void removeIdleCallback(IdleCallback* cb) const; - #endif -}; - // ----------------------------------------------------------------------------------------------------------- #if DISTRHO_PLUGIN_WANT_DIRECT_ACCESS