Regen patches
Signed-off-by: falkTX <falktx@falktx.com>
This commit is contained in:
parent
476bae222f
commit
4ab933a073
12 changed files with 603 additions and 517 deletions
|
|
@ -1,6 +1,9 @@
|
|||
--- ../Rack/src/app/Scene.cpp 2022-09-21 20:25:53.591040280 +0100
|
||||
+++ Scene.cpp 2022-09-21 20:18:50.294557597 +0100
|
||||
@@ -1,3 +1,30 @@
|
||||
--- ../Rack/src/app/Scene.cpp 2022-09-21 19:49:12.199540706 +0100
|
||||
+++ Scene.cpp 2022-12-30 14:50:06.801891005 +0000
|
||||
@@ -1,12 +1,36 @@
|
||||
-#include <thread>
|
||||
-
|
||||
-#include <osdialog.h>
|
||||
+/*
|
||||
+ * DISTRHO Cardinal Plugin
|
||||
+ * Copyright (C) 2021-2022 Filipe Coelho <falktx@falktx.com>
|
||||
|
|
@ -27,11 +30,9 @@
|
|||
+ * published by the Free Software Foundation; either version 3 of
|
||||
+ * the License, or (at your option) any later version.
|
||||
+ */
|
||||
+
|
||||
#include <thread>
|
||||
|
||||
#include <osdialog.h>
|
||||
@@ -7,6 +34,7 @@
|
||||
#include <app/Scene.hpp>
|
||||
#include <app/Browser.hpp>
|
||||
#include <app/TipWindow.hpp>
|
||||
#include <app/MenuBar.hpp>
|
||||
#include <context.hpp>
|
||||
|
|
@ -39,7 +40,7 @@
|
|||
#include <system.hpp>
|
||||
#include <network.hpp>
|
||||
#include <history.hpp>
|
||||
@@ -14,6 +42,22 @@
|
||||
@@ -14,6 +38,13 @@
|
||||
#include <patch.hpp>
|
||||
#include <asset.hpp>
|
||||
|
||||
|
|
@ -47,22 +48,13 @@
|
|||
+# undef DEBUG
|
||||
+#endif
|
||||
+
|
||||
+#ifdef STATIC_BUILD
|
||||
+# undef HAVE_LIBLO
|
||||
+#endif
|
||||
+
|
||||
+#ifdef HAVE_LIBLO
|
||||
+# include <lo/lo.h>
|
||||
+#endif
|
||||
+
|
||||
+#include "../CardinalCommon.hpp"
|
||||
+#include "extra/Base64.hpp"
|
||||
+#include "DistrhoUtils.hpp"
|
||||
+#include "../CardinalRemote.hpp"
|
||||
+
|
||||
|
||||
namespace rack {
|
||||
namespace app {
|
||||
@@ -23,32 +67,94 @@
|
||||
@@ -23,32 +54,72 @@
|
||||
math::Vec size;
|
||||
|
||||
void draw(const DrawArgs& args) override {
|
||||
|
|
@ -140,34 +132,12 @@
|
|||
|
||||
bool heldArrowKeys[4] = {};
|
||||
+
|
||||
+#ifdef HAVE_LIBLO
|
||||
+ double lastSceneChangeTime = 0.0;
|
||||
+ int historyActionIndex = -1;
|
||||
+
|
||||
+ bool oscAutoDeploy = false;
|
||||
+ bool oscConnected = false;
|
||||
+ lo_server oscServer = nullptr;
|
||||
+
|
||||
+ static int osc_handler(const char* const path, const char* const types, lo_arg** argv, const int argc, lo_message, void* const self)
|
||||
+ {
|
||||
+ d_stdout("osc_handler(\"%s\", \"%s\", %p, %i)", path, types, argv, argc);
|
||||
+
|
||||
+ if (std::strcmp(path, "/resp") == 0 && argc == 2 && types[0] == 's' && types[1] == 's') {
|
||||
+ d_stdout("osc_handler(\"%s\", ...) - got resp | '%s' '%s'", path, &argv[0]->s, &argv[1]->s);
|
||||
+ if (std::strcmp(&argv[0]->s, "hello") == 0 && std::strcmp(&argv[1]->s, "ok") == 0)
|
||||
+ static_cast<Internal*>(self)->oscConnected = true;
|
||||
+ }
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ ~Internal() {
|
||||
+ lo_server_free(oscServer);
|
||||
+ }
|
||||
+#endif
|
||||
};
|
||||
|
||||
|
||||
@@ -67,13 +173,11 @@
|
||||
@@ -67,13 +138,11 @@
|
||||
browser->hide();
|
||||
addChild(browser);
|
||||
|
||||
|
|
@ -184,7 +154,7 @@
|
|||
addChild(internal->resizeHandle);
|
||||
}
|
||||
|
||||
@@ -99,22 +203,13 @@
|
||||
@@ -99,22 +168,13 @@
|
||||
rackScroll->box.pos.y = menuBar->box.size.y;
|
||||
}
|
||||
|
||||
|
|
@ -209,31 +179,37 @@
|
|||
// Scroll RackScrollWidget with arrow keys
|
||||
math::Vec arrowDelta;
|
||||
if (internal->heldArrowKeys[0]) {
|
||||
@@ -143,6 +238,23 @@
|
||||
@@ -143,6 +203,29 @@
|
||||
rackScroll->offset += arrowDelta * arrowSpeed;
|
||||
}
|
||||
|
||||
+#ifdef HAVE_LIBLO
|
||||
+ if (internal->oscServer != nullptr) {
|
||||
+ while (lo_server_recv_noblock(internal->oscServer, 0) != 0) {}
|
||||
+ if (remoteUtils::RemoteDetails* const remoteDetails = remoteUtils::getRemote()) {
|
||||
+ idleRemote(remoteDetails);
|
||||
+
|
||||
+ if (internal->oscAutoDeploy) {
|
||||
+ 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 == -1) {
|
||||
+ internal->historyActionIndex = actionIndex;
|
||||
+ internal->lastSceneChangeTime = time;
|
||||
+ } else if (internal->historyActionIndex != actionIndex && actionIndex > 0 && time - internal->lastSceneChangeTime >= 1.0) {
|
||||
+ const std::string& name(APP->history->actions[actionIndex - 1]->name);
|
||||
+ if (/*std::abs(internal->historyActionIndex = actionIndex) > 1 ||*/ name != "move knob") {
|
||||
+ printf("action '%s'\n", APP->history->actions[actionIndex - 1]->name.c_str());
|
||||
+ remoteUtils::sendFullPatchToRemote(remoteDetails);
|
||||
+ window::generateScreenshot();
|
||||
+ }
|
||||
+ internal->historyActionIndex = actionIndex;
|
||||
+ internal->lastSceneChangeTime = time;
|
||||
+ patchUtils::deployToRemote();
|
||||
+ window::generateScreenshot();
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+#endif
|
||||
+
|
||||
Widget::step();
|
||||
}
|
||||
|
||||
@@ -172,7 +284,7 @@
|
||||
@@ -172,7 +255,7 @@
|
||||
if (e.action == GLFW_PRESS || e.action == GLFW_REPEAT) {
|
||||
// DEBUG("key '%d '%c' scancode %d '%c' keyName '%s'", e.key, e.key, e.scancode, e.scancode, e.keyName.c_str());
|
||||
if (e.keyName == "n" && (e.mods & RACK_MOD_MASK) == RACK_MOD_CTRL) {
|
||||
|
|
@ -242,7 +218,7 @@
|
|||
e.consume(this);
|
||||
}
|
||||
if (e.keyName == "q" && (e.mods & RACK_MOD_MASK) == RACK_MOD_CTRL) {
|
||||
@@ -180,19 +292,22 @@
|
||||
@@ -180,19 +263,22 @@
|
||||
e.consume(this);
|
||||
}
|
||||
if (e.keyName == "o" && (e.mods & RACK_MOD_MASK) == RACK_MOD_CTRL) {
|
||||
|
|
@ -269,7 +245,7 @@
|
|||
e.consume(this);
|
||||
}
|
||||
if (e.keyName == "z" && (e.mods & RACK_MOD_MASK) == RACK_MOD_CTRL) {
|
||||
@@ -220,24 +335,37 @@
|
||||
@@ -220,24 +306,38 @@
|
||||
APP->scene->rackScroll->setZoom(std::pow(2.f, zoom));
|
||||
e.consume(this);
|
||||
}
|
||||
|
|
@ -292,7 +268,8 @@
|
|||
e.consume(this);
|
||||
}
|
||||
+ if (e.key == GLFW_KEY_F7 && (e.mods & RACK_MOD_MASK) == 0) {
|
||||
+ patchUtils::deployToRemote();
|
||||
+ if (remoteUtils::RemoteDetails* const remoteDetails = remoteUtils::getRemote())
|
||||
+ remoteUtils::sendFullPatchToRemote(remoteDetails);
|
||||
+ window::generateScreenshot();
|
||||
+ e.consume(this);
|
||||
+ }
|
||||
|
|
@ -311,7 +288,7 @@
|
|||
|
||||
// Module selections
|
||||
if (e.keyName == "a" && (e.mods & RACK_MOD_MASK) == RACK_MOD_CTRL) {
|
||||
@@ -326,13 +454,6 @@
|
||||
@@ -326,13 +426,6 @@
|
||||
|
||||
// Key commands that can be overridden by children
|
||||
if (e.action == GLFW_PRESS || e.action == GLFW_REPEAT) {
|
||||
|
|
@ -325,7 +302,7 @@
|
|||
if (e.keyName == "v" && (e.mods & RACK_MOD_MASK) == RACK_MOD_CTRL) {
|
||||
rack->pasteClipboardAction();
|
||||
e.consume(this);
|
||||
@@ -351,7 +472,7 @@
|
||||
@@ -351,7 +444,7 @@
|
||||
std::string extension = system::getExtension(path);
|
||||
|
||||
if (extension == ".vcv") {
|
||||
|
|
@ -334,98 +311,3 @@
|
|||
e.consume(this);
|
||||
return;
|
||||
}
|
||||
@@ -368,3 +489,94 @@
|
||||
|
||||
} // namespace app
|
||||
} // namespace rack
|
||||
+
|
||||
+
|
||||
+namespace patchUtils {
|
||||
+
|
||||
+
|
||||
+bool connectToRemote() {
|
||||
+#ifdef HAVE_LIBLO
|
||||
+ rack::app::Scene::Internal* const internal = APP->scene->internal;
|
||||
+
|
||||
+ if (internal->oscServer == nullptr) {
|
||||
+ const lo_server oscServer = lo_server_new_with_proto(nullptr, LO_UDP, nullptr);
|
||||
+ DISTRHO_SAFE_ASSERT_RETURN(oscServer != nullptr, false);
|
||||
+ lo_server_add_method(oscServer, "/resp", nullptr, rack::app::Scene::Internal::osc_handler, internal);
|
||||
+ internal->oscServer = oscServer;
|
||||
+ }
|
||||
+
|
||||
+ const lo_address addr = lo_address_new_with_proto(LO_UDP, REMOTE_HOST, REMOTE_HOST_PORT);
|
||||
+ DISTRHO_SAFE_ASSERT_RETURN(addr != nullptr, false);
|
||||
+ lo_send(addr, "/hello", "");
|
||||
+ lo_address_free(addr);
|
||||
+
|
||||
+ return true;
|
||||
+#else
|
||||
+ return false;
|
||||
+#endif
|
||||
+}
|
||||
+
|
||||
+
|
||||
+bool isRemoteConnected() {
|
||||
+#ifdef HAVE_LIBLO
|
||||
+ return APP->scene->internal->oscConnected;
|
||||
+#else
|
||||
+ return false;
|
||||
+#endif
|
||||
+}
|
||||
+
|
||||
+
|
||||
+bool isRemoteAutoDeployed() {
|
||||
+#ifdef HAVE_LIBLO
|
||||
+ return APP->scene->internal->oscAutoDeploy;
|
||||
+#else
|
||||
+ return false;
|
||||
+#endif
|
||||
+}
|
||||
+
|
||||
+
|
||||
+void setRemoteAutoDeploy(bool autoDeploy) {
|
||||
+#ifdef HAVE_LIBLO
|
||||
+ APP->scene->internal->oscAutoDeploy = autoDeploy;
|
||||
+#endif
|
||||
+}
|
||||
+
|
||||
+
|
||||
+void deployToRemote() {
|
||||
+#ifdef 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<uint8_t> 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);
|
||||
+ lo_blob_free(blob);
|
||||
+ }
|
||||
+
|
||||
+ lo_address_free(addr);
|
||||
+#endif
|
||||
+}
|
||||
+
|
||||
+
|
||||
+void sendScreenshotToRemote(const char* const screenshot) {
|
||||
+#ifdef HAVE_LIBLO
|
||||
+ const lo_address addr = lo_address_new_with_proto(LO_UDP, REMOTE_HOST, REMOTE_HOST_PORT);
|
||||
+ DISTRHO_SAFE_ASSERT_RETURN(addr != nullptr,);
|
||||
+
|
||||
+ std::vector<uint8_t> data(d_getChunkFromBase64String(screenshot));
|
||||
+
|
||||
+ if (const lo_blob blob = lo_blob_new(data.size(), data.data())) {
|
||||
+ lo_send(addr, "/screenshot", "b", blob);
|
||||
+ lo_blob_free(blob);
|
||||
+ }
|
||||
+
|
||||
+ lo_address_free(addr);
|
||||
+#endif
|
||||
+}
|
||||
+
|
||||
+
|
||||
+} // namespace patchUtils
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue