From 91cac905cc6be763ce1946237250f3959a3781f9 Mon Sep 17 00:00:00 2001 From: falkTX Date: Thu, 29 Dec 2022 15:33:16 +0000 Subject: [PATCH] More details for mini version, make menubar variant specific Signed-off-by: falkTX --- plugins/Makefile | 43 ++++++- plugins/plugins-mini.cpp | 228 ++++++++++++++++++++++++++++++--- plugins/plugins.cpp | 2 +- src/Cardinal/MenuBar.cpp | 1 + src/CardinalFX/MenuBar.cpp | 1 + src/CardinalMini/MenuBar.cpp | 1 + src/CardinalNative/MenuBar.cpp | 1 + src/CardinalRemote.cpp | 40 ++++-- src/CardinalRemote/MenuBar.cpp | 1 + src/CardinalSynth/MenuBar.cpp | 1 + src/CardinalUI.cpp | 49 +++---- src/Makefile | 1 - src/Makefile.cardinal.mk | 2 + src/PluginContext.hpp | 5 +- src/override/Engine.cpp | 13 +- src/override/MenuBar.cpp | 11 +- src/override/Scene.cpp | 10 +- 17 files changed, 331 insertions(+), 79 deletions(-) create mode 120000 src/Cardinal/MenuBar.cpp create mode 120000 src/CardinalFX/MenuBar.cpp create mode 120000 src/CardinalMini/MenuBar.cpp create mode 120000 src/CardinalNative/MenuBar.cpp create mode 120000 src/CardinalRemote/MenuBar.cpp create mode 120000 src/CardinalSynth/MenuBar.cpp diff --git a/plugins/Makefile b/plugins/Makefile index 3f59508..5d95dfa 100644 --- a/plugins/Makefile +++ b/plugins/Makefile @@ -311,9 +311,11 @@ endif PLUGIN_FILES += $(filter-out Fundamental/src/plugin.cpp,$(wildcard Fundamental/src/*.cpp)) PLUGIN_FILES += Fundamental/src/dr_wav.c -MINIPLUGIN_FILES += Fundamental/src/ADSR.cpp MINIPLUGIN_FILES += Fundamental/src/LFO.cpp +MINIPLUGIN_FILES += Fundamental/src/Noise.cpp +MINIPLUGIN_FILES += Fundamental/src/Random.cpp MINIPLUGIN_FILES += Fundamental/src/VCF.cpp +MINIPLUGIN_FILES += Fundamental/src/VCMixer.cpp MINIPLUGIN_FILES += Fundamental/src/VCO.cpp # modules/types which are present in other plugins @@ -524,6 +526,16 @@ PLUGIN_FILES += AudibleInstruments/eurorack/streams/svf.cc PLUGIN_FILES += AudibleInstruments/eurorack/streams/vactrol.cc PLUGIN_FILES += AudibleInstruments/eurorack/streams/compressor.cc +MINIPLUGIN_FILES += AudibleInstruments/src/Plaits.cpp +MINIPLUGIN_FILES += $(wildcard AudibleInstruments/eurorack/plaits/dsp/*.cc) +MINIPLUGIN_FILES += $(wildcard AudibleInstruments/eurorack/plaits/dsp/engine/*.cc) +MINIPLUGIN_FILES += $(wildcard AudibleInstruments/eurorack/plaits/dsp/speech/*.cc) +MINIPLUGIN_FILES += $(wildcard AudibleInstruments/eurorack/plaits/dsp/physical_modelling/*.cc) +MINIPLUGIN_FILES += AudibleInstruments/eurorack/plaits/resources.cc +MINIPLUGIN_FILES += AudibleInstruments/eurorack/stmlib/dsp/atan.cc +MINIPLUGIN_FILES += AudibleInstruments/eurorack/stmlib/dsp/units.cc +MINIPLUGIN_FILES += AudibleInstruments/eurorack/stmlib/utils/random.cc + # -------------------------------------------------------------- # Autinn @@ -575,6 +587,29 @@ PLUGIN_FILES += $(filter-out BogaudioModules/src/bogaudio.cpp,$(wildcard Bogaudi PLUGIN_FILES += $(wildcard BogaudioModules/src/dsp/*.cpp) PLUGIN_FILES += $(wildcard BogaudioModules/src/dsp/filters/*.cpp) +MINIPLUGIN_FILES += BogaudioModules/src/LFO.cpp +MINIPLUGIN_FILES += BogaudioModules/src/Noise.cpp +MINIPLUGIN_FILES += BogaudioModules/src/VCA.cpp +MINIPLUGIN_FILES += BogaudioModules/src/VCF.cpp +MINIPLUGIN_FILES += BogaudioModules/src/VCO.cpp +MINIPLUGIN_FILES += BogaudioModules/src/lfo_base.cpp +MINIPLUGIN_FILES += BogaudioModules/src/menu.cpp +MINIPLUGIN_FILES += BogaudioModules/src/module.cpp +MINIPLUGIN_FILES += BogaudioModules/src/param_quantities.cpp +MINIPLUGIN_FILES += BogaudioModules/src/poly_channels.cpp +MINIPLUGIN_FILES += BogaudioModules/src/skins.cpp +MINIPLUGIN_FILES += BogaudioModules/src/utils.cpp +MINIPLUGIN_FILES += BogaudioModules/src/vco_base.cpp +MINIPLUGIN_FILES += BogaudioModules/src/widgets.cpp +MINIPLUGIN_FILES += BogaudioModules/src/dsp/analyzer.cpp +MINIPLUGIN_FILES += BogaudioModules/src/dsp/math.cpp +MINIPLUGIN_FILES += BogaudioModules/src/dsp/noise.cpp +MINIPLUGIN_FILES += BogaudioModules/src/dsp/oscillator.cpp +MINIPLUGIN_FILES += BogaudioModules/src/dsp/signal.cpp +MINIPLUGIN_FILES += BogaudioModules/src/dsp/table.cpp +MINIPLUGIN_FILES += BogaudioModules/src/dsp/filters/multimode.cpp +MINIPLUGIN_FILES += BogaudioModules/src/dsp/filters/resample.cpp + # modules/types which are present in other plugins BOGAUDIO_CUSTOM = ADSR BlueNoiseGenerator LFO Noise VCA VCO VCF BOGAUDIO_CUSTOM_PER_FILE = ARQuantity AttackMenuItem ReleaseMenuItem @@ -1384,8 +1419,10 @@ endif RESOURCE_FILES += Cardinal/res/Miku/Miku.png -MINIPLUGIN_LIST = Cardinal Fundamental -MINIRESOURCE_FILES = $(wildcard Cardinal/res/*.svg) +MINIPLUGIN_LIST = AudibleInstruments BogaudioModules Cardinal Fundamental +MINIRESOURCE_FILES = $(wildcard AudibleInstruments/res/*.svg) +MINIRESOURCE_FILES += $(wildcard BogaudioModules/res/*.svg) +MINIRESOURCE_FILES += $(wildcard Cardinal/res/*.svg) MINIRESOURCE_FILES += $(wildcard Fundamental/res/*.svg) MINIRESOURCE_FILES += $(wildcard Fundamental/res/components/*.svg) MINIRESOURCE_FILES += Fundamental/presets diff --git a/plugins/plugins-mini.cpp b/plugins/plugins-mini.cpp index e0fa9d2..9770704 100644 --- a/plugins/plugins-mini.cpp +++ b/plugins/plugins-mini.cpp @@ -26,12 +26,34 @@ // Fundamental #include "Fundamental/src/plugin.hpp" +// AudibleInstruments +#include "AudibleInstruments/src/plugin.hpp" + +// BogaudioModules - integrate theme/skin support +#include +#include +#include +#include +#include +#define private public +#include "BogaudioModules/src/skins.hpp" +#undef private + +// BogaudioModules +extern Model* modelBogaudioLFO; +extern Model* modelBogaudioNoise; +extern Model* modelBogaudioVCA; +extern Model* modelBogaudioVCF; +extern Model* modelBogaudioVCO; + // known terminal modules std::vector hostTerminalModels; // plugin instances Plugin* pluginInstance__Cardinal; Plugin* pluginInstance__Fundamental; +Plugin* pluginInstance__AudibleInstruments; +Plugin* pluginInstance__BogaudioModules; namespace rack { @@ -187,32 +209,192 @@ static void initStatic__Fundamental() const StaticPluginLoader spl(p, "Fundamental"); if (spl.ok()) { - p->addModel(modelADSR); p->addModel(modelLFO); + p->addModel(modelNoise); + p->addModel(modelRandom); p->addModel(modelVCF); - p->addModel(modelVCO); - spl.removeModule("VCO2"); - spl.removeModule("VCA-1"); - spl.removeModule("VCA"); - spl.removeModule("LFO2"); - spl.removeModule("Delay"); - spl.removeModule("Mixer"); - spl.removeModule("VCMixer"); + p->addModel(modelVCMixer); spl.removeModule("8vert"); + spl.removeModule("ADSR"); + spl.removeModule("Delay"); + spl.removeModule("LFO2"); + spl.removeModule("Merge"); + spl.removeModule("MidSide"); + spl.removeModule("Mixer"); spl.removeModule("Mutes"); + spl.removeModule("Octave"); spl.removeModule("Pulses"); - spl.removeModule("Scope"); + spl.removeModule("Quantizer"); spl.removeModule("SEQ3"); + spl.removeModule("Scope"); spl.removeModule("SequentialSwitch1"); spl.removeModule("SequentialSwitch2"); - spl.removeModule("Octave"); - spl.removeModule("Quantizer"); spl.removeModule("Split"); - spl.removeModule("Merge"); spl.removeModule("Sum"); - spl.removeModule("MidSide"); - spl.removeModule("Noise"); - spl.removeModule("Random"); + spl.removeModule("VCA"); + spl.removeModule("VCA-1"); + spl.removeModule("VCO"); + spl.removeModule("VCO2"); + } +} + +static void initStatic__AudibleInstruments() +{ + Plugin* const p = new Plugin; + pluginInstance__AudibleInstruments = p; + + const StaticPluginLoader spl(p, "AudibleInstruments"); + if (spl.ok()) + { + p->addModel(modelPlaits); + + spl.removeModule("Blinds"); + spl.removeModule("Braids"); + spl.removeModule("Branches"); + spl.removeModule("Clouds"); + spl.removeModule("Elements"); + spl.removeModule("Frames"); + spl.removeModule("Kinks"); + spl.removeModule("Links"); + spl.removeModule("Marbles"); + spl.removeModule("Rings"); + spl.removeModule("Ripples"); + spl.removeModule("Shades"); + spl.removeModule("Shelves"); + spl.removeModule("Stages"); + spl.removeModule("Streams"); + spl.removeModule("Tides"); + spl.removeModule("Tides2"); + spl.removeModule("Veils"); + spl.removeModule("Warps"); + } +} + +static void initStatic__BogaudioModules() +{ + Plugin* const p = new Plugin; + pluginInstance__BogaudioModules = p; + + const StaticPluginLoader spl(p, "BogaudioModules"); + if (spl.ok()) + { + // Make sure to use match Cardinal theme + Skins& skins(Skins::skins()); + skins._default = settings::darkMode ? "dark" : "light"; + + p->addModel(modelBogaudioLFO); + p->addModel(modelBogaudioNoise); + p->addModel(modelBogaudioVCA); + p->addModel(modelBogaudioVCF); + p->addModel(modelBogaudioVCO); + + // cat plugins/BogaudioModules/plugin.json | jq -r .modules[].slug - | sort + spl.removeModule("Bogaudio-AD"); + spl.removeModule("Bogaudio-Additator"); + spl.removeModule("Bogaudio-AddrSeq"); + spl.removeModule("Bogaudio-AddrSeqX"); + spl.removeModule("Bogaudio-ADSR"); + spl.removeModule("Bogaudio-AMRM"); + spl.removeModule("Bogaudio-Analyzer"); + spl.removeModule("Bogaudio-AnalyzerXL"); + spl.removeModule("Bogaudio-Arp"); + spl.removeModule("Bogaudio-ASR"); + spl.removeModule("Bogaudio-Assign"); + spl.removeModule("Bogaudio-Blank3"); + spl.removeModule("Bogaudio-Blank6"); + spl.removeModule("Bogaudio-Bool"); + spl.removeModule("Bogaudio-Chirp"); + spl.removeModule("Bogaudio-Clpr"); + spl.removeModule("Bogaudio-Cmp"); + spl.removeModule("Bogaudio-CmpDist"); + spl.removeModule("Bogaudio-CVD"); + spl.removeModule("Bogaudio-DADSRH"); + spl.removeModule("Bogaudio-DADSRHPlus"); + spl.removeModule("Bogaudio-Detune"); + spl.removeModule("Bogaudio-DGate"); + spl.removeModule("Bogaudio-Edge"); + spl.removeModule("Bogaudio-EightFO"); + spl.removeModule("Bogaudio-EightOne"); + spl.removeModule("Bogaudio-EQ"); + spl.removeModule("Bogaudio-EQS"); + spl.removeModule("Bogaudio-FFB"); + spl.removeModule("Bogaudio-FlipFlop"); + spl.removeModule("Bogaudio-FMOp"); + spl.removeModule("Bogaudio-Follow"); + spl.removeModule("Bogaudio-FourFO"); + spl.removeModule("Bogaudio-FourMan"); + spl.removeModule("Bogaudio-Inv"); + spl.removeModule("Bogaudio-Lgsw"); + spl.removeModule("Bogaudio-LLFO"); + spl.removeModule("Bogaudio-LLPG"); + spl.removeModule("Bogaudio-Lmtr"); + spl.removeModule("Bogaudio-LPG"); + spl.removeModule("Bogaudio-LVCF"); + spl.removeModule("Bogaudio-LVCO"); + spl.removeModule("Bogaudio-Manual"); + spl.removeModule("Bogaudio-Matrix18"); + spl.removeModule("Bogaudio-Matrix44"); + spl.removeModule("Bogaudio-Matrix44Cvm"); + spl.removeModule("Bogaudio-Matrix81"); + spl.removeModule("Bogaudio-Matrix88"); + spl.removeModule("Bogaudio-Matrix88Cv"); + spl.removeModule("Bogaudio-Matrix88M"); + spl.removeModule("Bogaudio-MegaGate"); + spl.removeModule("Bogaudio-Mix1"); + spl.removeModule("Bogaudio-Mix2"); + spl.removeModule("Bogaudio-Mix4"); + spl.removeModule("Bogaudio-Mix4x"); + spl.removeModule("Bogaudio-Mix8"); + spl.removeModule("Bogaudio-Mix8x"); + spl.removeModule("Bogaudio-Mono"); + spl.removeModule("Bogaudio-Mult"); + spl.removeModule("Bogaudio-Mumix"); + spl.removeModule("Bogaudio-Mute8"); + spl.removeModule("Bogaudio-Nsgt"); + spl.removeModule("Bogaudio-Offset"); + spl.removeModule("Bogaudio-OneEight"); + spl.removeModule("Bogaudio-Pan"); + spl.removeModule("Bogaudio-PEQ"); + spl.removeModule("Bogaudio-PEQ14"); + spl.removeModule("Bogaudio-PEQ14XF"); + spl.removeModule("Bogaudio-PEQ6"); + spl.removeModule("Bogaudio-PEQ6XF"); + spl.removeModule("Bogaudio-Pgmr"); + spl.removeModule("Bogaudio-PgmrX"); + spl.removeModule("Bogaudio-PolyCon"); + spl.removeModule("Bogaudio-PolyCon8"); + spl.removeModule("Bogaudio-PolyMult"); + spl.removeModule("Bogaudio-PolyOff16"); + spl.removeModule("Bogaudio-PolyOff8"); + spl.removeModule("Bogaudio-Pressor"); + spl.removeModule("Bogaudio-Pulse"); + spl.removeModule("Bogaudio-Ranalyzer"); + spl.removeModule("Bogaudio-Reftone"); + spl.removeModule("Bogaudio-RGate"); + spl.removeModule("Bogaudio-SampleHold"); + spl.removeModule("Bogaudio-Shaper"); + spl.removeModule("Bogaudio-ShaperPlus"); + spl.removeModule("Bogaudio-Sine"); + spl.removeModule("Bogaudio-Slew"); + spl.removeModule("Bogaudio-Stack"); + spl.removeModule("Bogaudio-Sums"); + spl.removeModule("Bogaudio-Switch"); + spl.removeModule("Bogaudio-Switch1616"); + spl.removeModule("Bogaudio-Switch18"); + spl.removeModule("Bogaudio-Switch44"); + spl.removeModule("Bogaudio-Switch81"); + spl.removeModule("Bogaudio-Switch88"); + spl.removeModule("Bogaudio-UMix"); + spl.removeModule("Bogaudio-Unison"); + spl.removeModule("Bogaudio-VCAmp"); + spl.removeModule("Bogaudio-VCM"); + spl.removeModule("Bogaudio-Velo"); + spl.removeModule("Bogaudio-Vish"); + spl.removeModule("Bogaudio-VU"); + spl.removeModule("Bogaudio-Walk"); + spl.removeModule("Bogaudio-Walk2"); + spl.removeModule("Bogaudio-XCO"); + spl.removeModule("Bogaudio-XFade"); } } @@ -220,6 +402,8 @@ void initStaticPlugins() { initStatic__Cardinal(); initStatic__Fundamental(); + initStatic__AudibleInstruments(); + initStatic__BogaudioModules(); } void destroyStaticPlugins() @@ -231,7 +415,17 @@ void destroyStaticPlugins() void updateStaticPluginsDarkMode() { - d_stdout("TODO"); + const bool darkMode = settings::darkMode; + // bogaudio + { + Skins& skins(Skins::skins()); + skins._default = darkMode ? "dark" : "light"; + + std::lock_guard lock(skins._defaultSkinListenersLock); + for (auto listener : skins._defaultSkinListeners) { + listener->defaultSkinChanged(skins._default); + } + } } } diff --git a/plugins/plugins.cpp b/plugins/plugins.cpp index b19046a..e6e5db2 100644 --- a/plugins/plugins.cpp +++ b/plugins/plugins.cpp @@ -156,7 +156,7 @@ extern Model* modelChord; // Bidoo #include "Bidoo/src/plugin.hpp" -// BogaudioModules - force dark skin as default +// BogaudioModules - integrate theme/skin support #include #include #include diff --git a/src/Cardinal/MenuBar.cpp b/src/Cardinal/MenuBar.cpp new file mode 120000 index 0000000..8d1a35a --- /dev/null +++ b/src/Cardinal/MenuBar.cpp @@ -0,0 +1 @@ +../override/MenuBar.cpp \ No newline at end of file diff --git a/src/CardinalFX/MenuBar.cpp b/src/CardinalFX/MenuBar.cpp new file mode 120000 index 0000000..8d1a35a --- /dev/null +++ b/src/CardinalFX/MenuBar.cpp @@ -0,0 +1 @@ +../override/MenuBar.cpp \ No newline at end of file diff --git a/src/CardinalMini/MenuBar.cpp b/src/CardinalMini/MenuBar.cpp new file mode 120000 index 0000000..8d1a35a --- /dev/null +++ b/src/CardinalMini/MenuBar.cpp @@ -0,0 +1 @@ +../override/MenuBar.cpp \ No newline at end of file diff --git a/src/CardinalNative/MenuBar.cpp b/src/CardinalNative/MenuBar.cpp new file mode 120000 index 0000000..8d1a35a --- /dev/null +++ b/src/CardinalNative/MenuBar.cpp @@ -0,0 +1 @@ +../override/MenuBar.cpp \ No newline at end of file diff --git a/src/CardinalRemote.cpp b/src/CardinalRemote.cpp index 5aabed0..6f451cf 100644 --- a/src/CardinalRemote.cpp +++ b/src/CardinalRemote.cpp @@ -76,13 +76,21 @@ bool connectToRemote() RemoteDetails* remoteDetails = ui->remoteDetails; -#ifdef HAVE_LIBLO +#if CARDINAL_VARIANT_MINI + if (remoteDetails == nullptr) + { + ui->remoteDetails = remoteDetails = new RemoteDetails; + remoteDetails->handle = ui; + remoteDetails->connected = true; + remoteDetails->autoDeploy = true; + } +#elif defined(HAVE_LIBLO) if (remoteDetails == nullptr) { const lo_server oscServer = lo_server_new_with_proto(nullptr, LO_UDP, nullptr); DISTRHO_SAFE_ASSERT_RETURN(oscServer != nullptr, false); - remoteDetails = new RemoteDetails; + ui->remoteDetails = remoteDetails = new RemoteDetails; remoteDetails->handle = oscServer; remoteDetails->connected = false; remoteDetails->autoDeploy = false; @@ -106,13 +114,14 @@ void disconnectFromRemote(RemoteDetails* const remote) { #ifdef HAVE_LIBLO lo_server_free(static_cast(remote->handle)); - delete remote; #endif + delete remote; } } void idleRemote(RemoteDetails* const remote) { + DISTRHO_SAFE_ASSERT_RETURN(remote != nullptr,); #ifdef HAVE_LIBLO while (lo_server_recv_noblock(static_cast(remote->handle), 0) != 0) {} #endif @@ -120,15 +129,26 @@ void idleRemote(RemoteDetails* const remote) void deployToRemote(RemoteDetails* const remote) { -#ifdef HAVE_LIBLO + CardinalPluginContext* const context = static_cast(APP); + DISTRHO_SAFE_ASSERT_RETURN(context != nullptr,); + + context->engine->prepareSave(); + context->patch->saveAutosave(); + context->patch->cleanAutosave(); + std::vector data(rack::system::archiveDirectory(context->patch->autosavePath, 1)); + + DISTRHO_SAFE_ASSERT_RETURN(data.size() >= 4,); + +#if CARDINAL_VARIANT_MINI + if (char* const patch = String::asBase64(data.data(), data.size()).getAndReleaseBuffer()) + { + static_cast(remote->handle)->setState("patch", patch); + std::free(patch); + } +#elif defined(HAVE_LIBLO) const lo_address addr = lo_address_new_with_proto(LO_UDP, REMOTE_HOST, REMOTE_HOST_PORT); DISTRHO_SAFE_ASSERT_RETURN(addr != nullptr,); - APP->engine->prepareSave(); - APP->patch->saveAutosave(); - APP->patch->cleanAutosave(); - std::vector data(rack::system::archiveDirectory(APP->patch->autosavePath, 1)); - if (const lo_blob blob = lo_blob_new(data.size(), data.data())) { lo_send(addr, "/load", "b", blob); @@ -139,7 +159,7 @@ void deployToRemote(RemoteDetails* const remote) #endif } -void sendScreenshotToRemote(RemoteDetails* const remote, const char* const screenshot) +void sendScreenshotToRemote(RemoteDetails*, const char* const screenshot) { #ifdef HAVE_LIBLO const lo_address addr = lo_address_new_with_proto(LO_UDP, REMOTE_HOST, REMOTE_HOST_PORT); diff --git a/src/CardinalRemote/MenuBar.cpp b/src/CardinalRemote/MenuBar.cpp new file mode 120000 index 0000000..8d1a35a --- /dev/null +++ b/src/CardinalRemote/MenuBar.cpp @@ -0,0 +1 @@ +../override/MenuBar.cpp \ No newline at end of file diff --git a/src/CardinalSynth/MenuBar.cpp b/src/CardinalSynth/MenuBar.cpp new file mode 120000 index 0000000..8d1a35a --- /dev/null +++ b/src/CardinalSynth/MenuBar.cpp @@ -0,0 +1 @@ +../override/MenuBar.cpp \ No newline at end of file diff --git a/src/CardinalUI.cpp b/src/CardinalUI.cpp index b664736..0664a76 100644 --- a/src/CardinalUI.cpp +++ b/src/CardinalUI.cpp @@ -62,9 +62,6 @@ #endif namespace rack { -namespace app { - widget::Widget* createMenuBar(bool isStandalone); -} namespace engine { void Engine_setAboutToClose(Engine*); } @@ -87,7 +84,7 @@ bool Plugin::writeMidiEvent(const MidiEvent&) noexcept { return false; } // -------------------------------------------------------------------------------------------------------------------- -#ifdef DISTRHO_OS_WASM +#if defined(DISTRHO_OS_WASM) && ! CARDINAL_VARIANT_MINI struct WasmWelcomeDialog : rack::widget::OpaqueWidget { static const constexpr float margin = 10; @@ -346,7 +343,10 @@ public: { rack::contextSet(context); - #if ! DISTRHO_PLUGIN_WANT_DIRECT_ACCESS + #if CARDINAL_VARIANT_MINI + DISTRHO_SAFE_ASSERT_RETURN(remoteUtils::connectToRemote(),); + DISTRHO_SAFE_ASSERT_RETURN(remoteDetails != nullptr,); + // create unique temporary path for this instance try { char uidBuf[24]; @@ -369,7 +369,7 @@ public: const float sampleRate = getSampleRate(); rack::settings::sampleRate = sampleRate; - context->bufferSize = 128; + context->bufferSize = 1; context->sampleRate = sampleRate; context->engine = new rack::engine::Engine; @@ -403,15 +403,6 @@ public: rack::window::WindowSetPluginUI(context->window, this); - if (rack::widget::Widget* const menuBar = context->scene->menuBar) - { - context->scene->removeChild(menuBar); - delete menuBar; - } - - context->scene->menuBar = rack::app::createMenuBar(getApp().isStandalone()); - context->scene->addChildBelow(context->scene->menuBar, context->scene->rackScroll); - // hide "Browse VCV Library" button rack::widget::Widget* const browser = context->scene->browser->children.back(); rack::widget::Widget* const headerLayout = browser->children.front(); @@ -444,7 +435,7 @@ public: } } - #ifdef DISTRHO_OS_WASM + #if defined(DISTRHO_OS_WASM) && ! CARDINAL_VARIANT_MINI if (rack::patchStorageSlug != nullptr) { psDialog = new WasmRemotePatchLoadingDialog(true); @@ -477,26 +468,18 @@ public: context->nativeWindowId = 0; - if (rack::widget::Widget* const menuBar = context->scene->menuBar) - { - context->scene->removeChild(menuBar); - delete menuBar; - } - - context->scene->menuBar = rack::app::createMenuBar(); - context->scene->addChildBelow(context->scene->menuBar, context->scene->rackScroll); - rack::window::WindowSetPluginUI(context->window, nullptr); - #if ! DISTRHO_PLUGIN_WANT_DIRECT_ACCESS + context->tlw = nullptr; + context->ui = nullptr; + + #if CARDINAL_VARIANT_MINI { const ScopedContext sc(this); context->patch->clear(); // do a little dance to prevent context scene deletion from saving to temp dir - #ifndef HEADLESS const ScopedValueSetter svs(rack::settings::headless, true); - #endif Engine_setAboutToClose(context->engine); delete context; } @@ -620,6 +603,10 @@ public: filebrowserhandle = nullptr; } + #if CARDINAL_VARIANT_MINI + context->engine->stepBlock(1); + #endif + if (windowParameters.rateLimit != 0 && ++rateLimitStep % (windowParameters.rateLimit * 2)) return; @@ -804,7 +791,7 @@ protected: void stateChanged(const char* const key, const char* const value) override { - #if ! DISTRHO_PLUGIN_WANT_DIRECT_ACCESS + #if CARDINAL_VARIANT_MINI if (std::strcmp(key, "patch") == 0) { if (fAutosavePath.empty()) @@ -952,9 +939,9 @@ protected: #endif rack::math::Vec scrollDelta = rack::math::Vec(ev.delta.getX(), ev.delta.getY()); -#ifndef DISTRHO_OS_MAC + #ifndef DISTRHO_OS_MAC scrollDelta = scrollDelta.mult(50.0); -#endif + #endif const int mods = glfwMods(ev.mod); const ScopedContext sc(this, mods); diff --git a/src/Makefile b/src/Makefile index ea787fe..7d73a0f 100644 --- a/src/Makefile +++ b/src/Makefile @@ -165,7 +165,6 @@ RACK_FILES += override/context.cpp RACK_FILES += override/minblep.cpp RACK_FILES += override/plugin.cpp RACK_FILES += override/Engine.cpp -RACK_FILES += override/MenuBar.cpp RACK_FILES += override/Model.cpp RACK_FILES += override/ModuleWidget.cpp RACK_FILES += override/OpenGlWidget.cpp diff --git a/src/Makefile.cardinal.mk b/src/Makefile.cardinal.mk index 2226e34..3336da0 100644 --- a/src/Makefile.cardinal.mk +++ b/src/Makefile.cardinal.mk @@ -108,6 +108,7 @@ FILES_DSP += RemoteWindow.cpp else FILES_UI = CardinalUI.cpp FILES_UI += glfw.cpp +FILES_UI += MenuBar.cpp FILES_UI += Window.cpp endif @@ -255,6 +256,7 @@ FILES_UI += CardinalCommon-UI.cpp FILES_UI += CardinalRemote.cpp FILES_UI += common.cpp FILES_UI += glfw.cpp +FILES_UI += MenuBar.cpp FILES_UI += Window.cpp EXTRA_UI_DEPENDENCIES = $(subst -headless,,$(EXTRA_DSP_DEPENDENCIES)) EXTRA_UI_LIBS += $(subst -headless,,$(EXTRA_DSP_LIBS)) diff --git a/src/PluginContext.hpp b/src/PluginContext.hpp index 94d696f..264934f 100644 --- a/src/PluginContext.hpp +++ b/src/PluginContext.hpp @@ -182,13 +182,10 @@ public: ~CardinalBaseUI() override { - disconnectFromRemote(remoteDetails); + remoteUtils::disconnectFromRemote(remoteDetails); if (filebrowserhandle != nullptr) fileBrowserClose(filebrowserhandle); - - context->tlw = nullptr; - context->ui = nullptr; } }; #endif diff --git a/src/override/Engine.cpp b/src/override/Engine.cpp index 927f561..2eed5e0 100644 --- a/src/override/Engine.cpp +++ b/src/override/Engine.cpp @@ -209,10 +209,15 @@ static void Engine_stepFrame(Engine* that) { float smoothValue = internal->smoothValue; Param* smoothParam = &smoothModule->params[smoothParamId]; float value = smoothParam->value; - // Use decay rate of roughly 1 graphics frame - const float smoothLambda = 60.f; - float newValue = value + (smoothValue - value) * smoothLambda * internal->sampleTime; - if (value == newValue) { + float newValue; + if (internal->blockFrames != 1) { + // Use decay rate of roughly 1 graphics frame + const float smoothLambda = 60.f; + newValue = value + (smoothValue - value) * smoothLambda * internal->sampleTime; + } else { + newValue = value; + } + if (d_isEqual(value, newValue)) { // Snap to actual smooth value if the value doesn't change enough (due to the granularity of floats) smoothParam->setValue(smoothValue); internal->smoothModule = NULL; diff --git a/src/override/MenuBar.cpp b/src/override/MenuBar.cpp index d75d8cc..ffb5fb4 100644 --- a/src/override/MenuBar.cpp +++ b/src/override/MenuBar.cpp @@ -53,6 +53,7 @@ #include "../CardinalCommon.hpp" #include "../CardinalRemote.hpp" +#include "DistrhoPlugin.hpp" #include "DistrhoStandaloneUtils.hpp" #ifdef HAVE_LIBLO @@ -98,14 +99,14 @@ struct MenuButton : ui::Button { struct FileButton : MenuButton { const bool isStandalone; -#if !(defined(DISTRHO_OS_WASM) && defined(STATIC_BUILD)) +#if ! CARDINAL_VARIANT_MINI std::vector demoPatches; #endif FileButton(const bool standalone) : MenuButton(), isStandalone(standalone) { -#if !(defined(DISTRHO_OS_WASM) && defined(STATIC_BUILD)) +#if ! CARDINAL_VARIANT_MINI const std::string patchesDir = asset::patchesPath() + DISTRHO_OS_SEP_STR "examples"; if (system::isDirectory(patchesDir)) @@ -167,7 +168,7 @@ struct FileButton : MenuButton { patchUtils::revertDialog(); }, APP->patch->path.empty())); -#ifdef HAVE_LIBLO +// #if defined(HAVE_LIBLO) && ! CARDINAL_VARIANT_MINI menu->addChild(new ui::MenuSeparator); remoteUtils::RemoteDetails* const remoteDetails = remoteUtils::getRemote(); @@ -186,7 +187,7 @@ struct FileButton : MenuButton { remoteUtils::connectToRemote(); })); } -#endif +// #endif #ifndef DISTRHO_OS_WASM menu->addChild(new ui::MenuSeparator); @@ -201,7 +202,7 @@ struct FileButton : MenuButton { })); #endif -#if !(defined(DISTRHO_OS_WASM) && defined(STATIC_BUILD)) +#if ! CARDINAL_VARIANT_MINI if (!demoPatches.empty()) { menu->addChild(new ui::MenuSeparator); diff --git a/src/override/Scene.cpp b/src/override/Scene.cpp index 032d4c2..e3af71f 100644 --- a/src/override/Scene.cpp +++ b/src/override/Scene.cpp @@ -50,6 +50,9 @@ namespace rack { namespace app { +widget::Widget* createMenuBar(bool isStandalone); + + struct ResizeHandle : widget::OpaqueWidget { math::Vec size; @@ -131,7 +134,7 @@ Scene::Scene() { rack = rackScroll->rackWidget; - menuBar = createMenuBar(); + menuBar = createMenuBar(isStandalone()); addChild(menuBar); browser = browserCreate(); @@ -209,7 +212,7 @@ void Scene::step() { if (remoteDetails->autoDeploy) { const int actionIndex = APP->history->actionIndex; const double time = system::getTime(); - if (internal->historyActionIndex != actionIndex && time - internal->lastSceneChangeTime >= 5.0) { + if (internal->historyActionIndex != actionIndex && time - internal->lastSceneChangeTime >= 1.0) { internal->historyActionIndex = actionIndex; internal->lastSceneChangeTime = time; remoteUtils::deployToRemote(remoteDetails); @@ -315,7 +318,8 @@ void Scene::onHoverKey(const HoverKeyEvent& e) { e.consume(this); } if (e.key == GLFW_KEY_F7 && (e.mods & RACK_MOD_MASK) == 0) { - remoteUtils::deployToRemote(remoteUtils::getRemote()); + if (remoteUtils::RemoteDetails* const remoteDetails = remoteUtils::getRemote()) + remoteUtils::deployToRemote(remoteDetails); window::generateScreenshot(); e.consume(this); }