From f56945ec504277146b40266e92bdc5799031bb4c Mon Sep 17 00:00:00 2001 From: falkTX Date: Sat, 30 Mar 2013 12:11:51 +0000 Subject: [PATCH] NSM support --- source/backend/CarlaBackend.hpp | 15 +- source/backend/CarlaStandalone.hpp | 2 - source/backend/standalone/CarlaStandalone.cpp | 342 +++++------------- source/backend/standalone/Makefile | 2 +- source/carla.py | 89 +++-- source/carla_backend.py | 41 +-- source/carla_shared.py | 9 +- source/utils/CarlaBackendUtils.hpp | 6 +- 8 files changed, 174 insertions(+), 332 deletions(-) diff --git a/source/backend/CarlaBackend.hpp b/source/backend/CarlaBackend.hpp index 6e19b0d2d..501750b52 100644 --- a/source/backend/CarlaBackend.hpp +++ b/source/backend/CarlaBackend.hpp @@ -594,29 +594,24 @@ enum CallbackType { CALLBACK_NSM_ANNOUNCE = 28, /*! - * Non-Session-Manager Open message #1. + * Non-Session-Manager Open message. */ - CALLBACK_NSM_OPEN1 = 29, - - /*! - * Non-Session-Manager Open message #2. - */ - CALLBACK_NSM_OPEN2 = 30, + CALLBACK_NSM_OPEN = 29, /*! * Non-Session-Manager Save message. */ - CALLBACK_NSM_SAVE = 31, + CALLBACK_NSM_SAVE = 30, /*! * An error occurred, show \a valueStr as an error to user. */ - CALLBACK_ERROR = 32, + CALLBACK_ERROR = 31, /*! * The engine has crashed or malfunctioned and will no longer work. */ - CALLBACK_QUIT = 33 + CALLBACK_QUIT = 32 }; /*! diff --git a/source/backend/CarlaStandalone.hpp b/source/backend/CarlaStandalone.hpp index 3ccf825a9..ac17eab95 100644 --- a/source/backend/CarlaStandalone.hpp +++ b/source/backend/CarlaStandalone.hpp @@ -283,11 +283,9 @@ CARLA_EXPORT double carla_get_sample_rate(); CARLA_EXPORT const char* carla_get_last_error(); CARLA_EXPORT const char* carla_get_host_osc_url(); -#if 0 CARLA_EXPORT void carla_nsm_announce(const char* url, int pid); CARLA_EXPORT void carla_nsm_reply_open(); CARLA_EXPORT void carla_nsm_reply_save(); -#endif #ifdef BUILD_BRIDGE CARLA_EXPORT bool carla_engine_init_bridge(const char* audioBaseName, const char* controlBaseName, const char* clientName); diff --git a/source/backend/standalone/CarlaStandalone.cpp b/source/backend/standalone/CarlaStandalone.cpp index 3a97d4e2a..a83e411bc 100644 --- a/source/backend/standalone/CarlaStandalone.cpp +++ b/source/backend/standalone/CarlaStandalone.cpp @@ -18,6 +18,7 @@ #include "CarlaStandalone.hpp" #include "CarlaBackendUtils.hpp" +#include "CarlaOscUtils.hpp" #include "CarlaEngine.hpp" #include "CarlaPlugin.hpp" #include "CarlaMIDI.h" @@ -1756,177 +1757,199 @@ const char* carla_get_host_osc_url() return standalone.engine->getOscServerPathTCP(); } -#if 0 // ------------------------------------------------------------------------------------------------------------------- #define NSM_API_VERSION_MAJOR 1 -#define NSM_API_VERSION_MINOR 0 +#define NSM_API_VERSION_MINOR 2 class CarlaNSM { public: CarlaNSM() + : fServerThread(nullptr), + fReplyAddr(nullptr), + fIsOpened(false), + fIsSaved(false) { - m_controlAddr = nullptr; - m_serverThread = nullptr; - m_isOpened = false; - m_isSaved = false; } ~CarlaNSM() { - if (m_controlAddr) - lo_address_free(m_controlAddr); + if (fReplyAddr != nullptr) + lo_address_free(fReplyAddr); - if (m_serverThread) + if (fServerThread != nullptr) { - lo_server_thread_stop(m_serverThread); - lo_server_thread_del_method(m_serverThread, "/reply", "ssss"); - lo_server_thread_del_method(m_serverThread, "/nsm/client/open", "sss"); - lo_server_thread_del_method(m_serverThread, "/nsm/client/save", ""); - lo_server_thread_free(m_serverThread); + lo_server_thread_stop(fServerThread); + lo_server_thread_del_method(fServerThread, "/reply", "ssss"); + lo_server_thread_del_method(fServerThread, "/nsm/client/open", "sss"); + lo_server_thread_del_method(fServerThread, "/nsm/client/save", ""); + lo_server_thread_free(fServerThread); } } void announce(const char* const url, const int pid) { - lo_address addr = lo_address_new_from_url(url); - int proto = lo_address_get_protocol(addr); + lo_address const addr = lo_address_new_from_url(url); + + if (addr == nullptr) + return; + + const int proto = lo_address_get_protocol(addr); - if (! m_serverThread) + if (fServerThread == nullptr) { // create new OSC thread - m_serverThread = lo_server_thread_new_with_proto(nullptr, proto, error_handler); + fServerThread = lo_server_thread_new_with_proto(nullptr, proto, error_handler); // register message handlers and start OSC thread - lo_server_thread_add_method(m_serverThread, "/reply", "ssss", _reply_handler, this); - lo_server_thread_add_method(m_serverThread, "/nsm/client/open", "sss", _nsm_open_handler, this); - lo_server_thread_add_method(m_serverThread, "/nsm/client/save", "", _nsm_save_handler, this); - lo_server_thread_start(m_serverThread); + lo_server_thread_add_method(fServerThread, "/reply", "ssss", _reply_handler, this); + lo_server_thread_add_method(fServerThread, "/nsm/client/open", "sss", _open_handler, this); + lo_server_thread_add_method(fServerThread, "/nsm/client/save", "", _save_handler, this); + lo_server_thread_start(fServerThread); } - lo_send_from(addr, lo_server_thread_get_server(m_serverThread), LO_TT_IMMEDIATE, "/nsm/server/announce", "sssiii", - "Carla", ":switch:", "carla", NSM_API_VERSION_MAJOR, NSM_API_VERSION_MINOR, pid); + lo_send_from(addr, lo_server_thread_get_server(fServerThread), LO_TT_IMMEDIATE, "/nsm/server/announce", "sssiii", + "Carla", ":switch:", "carla", NSM_API_VERSION_MAJOR, NSM_API_VERSION_MINOR, pid); lo_address_free(addr); } void replyOpen() { - m_isOpened = true; + fIsOpened = true; } void replySave() { - m_isSaved = true; + fIsSaved = true; } protected: - int reply_handler(const char* const path, const char* const types, lo_arg** const argv, const int argc, const lo_message msg) + int handleReply(const char* const path, const char* const types, lo_arg** const argv, const int argc, const lo_message msg) { - carla_debug("CarlaNSM::reply_handler(%s, %i, %p, %s, %p)", path, argc, argv, types, msg); + carla_debug("CarlaNSM::handleReply(%s, %i, %p, %s, %p)", path, argc, argv, types, msg); - m_controlAddr = lo_address_new_from_url(lo_address_get_url(lo_message_get_source(msg))); + if (fReplyAddr != nullptr) + lo_address_free(fReplyAddr); + + fIsOpened = false; + fIsSaved = false; + + char* const url = lo_address_get_url(lo_message_get_source(msg)); + fReplyAddr = lo_address_new_from_url(url); + std::free(url); const char* const method = &argv[0]->s; + const char* const smName = &argv[2]->s; - if (std::strcmp(method, "/nsm/server/announce") == 0 && standalone.callback) - standalone.callback(nullptr, CarlaBackend::CALLBACK_NSM_ANNOUNCE, 0, 0, 0, 0.0, nullptr); // FIXME? + if (std::strcmp(method, "/nsm/server/announce") == 0 && standalone.callback != nullptr) + standalone.callback(standalone.callbackPtr, CarlaBackend::CALLBACK_NSM_ANNOUNCE, 0, 0, 0, 0.0f, smName); return 0; } - int nsm_open_handler(const char* const path, const char* const types, lo_arg** const argv, const int argc, const lo_message msg) + int handleOpen(const char* const path, const char* const types, lo_arg** const argv, const int argc, const lo_message msg) { - carla_debug("CarlaNSM::nsm_open_handler(\"%s\", \"%s\", %p, %i, %p)", path, types, argv, argc, msg); + carla_debug("CarlaNSM::handleOpen(\"%s\", \"%s\", %p, %i, %p)", path, types, argv, argc, msg); - if (! standalone.callback) + if (standalone.callback == nullptr) + return 1; + if (fServerThread == nullptr) + return 1; + if (fReplyAddr == nullptr) return 1; const char* const projectPath = &argv[0]->s; const char* const clientId = &argv[2]->s; - standalone.callback(nullptr, CarlaBackend::CALLBACK_NSM_OPEN1, 0, 0, 0, 0.0, clientId); - standalone.callback(nullptr, CarlaBackend::CALLBACK_NSM_OPEN2, 0, 0, 0, 0.0, projectPath); + char data[std::strlen(projectPath)+std::strlen(clientId)+2]; + std::strcpy(data, projectPath); + std::strcat(data, ":"); + std::strcat(data, clientId); - for (int i=0; i < 30 && ! m_isOpened; i++) + standalone.callback(nullptr, CarlaBackend::CALLBACK_NSM_OPEN, 0, 0, 0, 0.0f, data); + + for (int i=0; i < 30 && ! fIsOpened; i++) carla_msleep(100); - if (m_controlAddr) - lo_send_from(m_controlAddr, lo_server_thread_get_server(m_serverThread), LO_TT_IMMEDIATE, "/reply", "ss", "/nsm/client/open", "OK"); + if (fIsOpened) + lo_send_from(fReplyAddr, lo_server_thread_get_server(fServerThread), LO_TT_IMMEDIATE, "/reply", "ss", "/nsm/client/open", "OK"); return 0; } - int nsm_save_handler(const char* const path, const char* const types, lo_arg** const argv, const int argc, const lo_message msg) + int handleSave(const char* const path, const char* const types, lo_arg** const argv, const int argc, const lo_message msg) { - carla_debug("CarlaNSM::nsm_save_handler(\"%s\", \"%s\", %p, %i, %p)", path, types, argv, argc, msg); + carla_debug("CarlaNSM::handleSave(\"%s\", \"%s\", %p, %i, %p)", path, types, argv, argc, msg); - if (! standalone.callback) + if (standalone.callback == nullptr) + return 1; + if (fServerThread == nullptr) + return 1; + if (fReplyAddr == nullptr) return 1; - standalone.callback(nullptr, CarlaBackend::CALLBACK_NSM_SAVE, 0, 0, 0, 0.0, nullptr); + standalone.callback(nullptr, CarlaBackend::CALLBACK_NSM_SAVE, 0, 0, 0, 0.0f, nullptr); - for (int i=0; i < 30 && ! m_isSaved; i++) + for (int i=0; i < 30 && ! fIsSaved; i++) carla_msleep(100); - if (m_controlAddr) - lo_send_from(m_controlAddr, lo_server_thread_get_server(m_serverThread), LO_TT_IMMEDIATE, "/reply", "ss", "/nsm/client/save", "OK"); + if (fIsSaved) + lo_send_from(fReplyAddr, lo_server_thread_get_server(fServerThread), LO_TT_IMMEDIATE, "/reply", "ss", "/nsm/client/save", "OK"); return 0; } private: - lo_address m_controlAddr; - lo_server_thread m_serverThread; - bool m_isOpened, m_isSaved; + lo_server_thread fServerThread; + lo_address fReplyAddr; + + bool fIsOpened; + bool fIsSaved; - static int _reply_handler(const char* const path, const char* const types, lo_arg** const argv, const int argc, const lo_message msg, void* const data) + #define handlePtr ((CarlaNSM*)data) + + static int _reply_handler(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg, void* data) { - CARLA_ASSERT(data); - CarlaNSM* const _this_ = (CarlaNSM*)data; - return _this_->reply_handler(path, types, argv, argc, msg); + return handlePtr->handleReply(path, types, argv, argc, msg); } - static int _nsm_open_handler(const char* const path, const char* const types, lo_arg** const argv, const int argc, const lo_message msg, void* const data) + static int _open_handler(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg, void* data) { - CARLA_ASSERT(data); - CarlaNSM* const _this_ = (CarlaNSM*)data; - return _this_->nsm_open_handler(path, types, argv, argc, msg); + return handlePtr->handleOpen(path, types, argv, argc, msg); } - static int _nsm_save_handler(const char* const path, const char* const types, lo_arg** const argv, const int argc, const lo_message msg, void* const data) + static int _save_handler(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg, void* data) { - CARLA_ASSERT(data); - CarlaNSM* const _this_ = (CarlaNSM*)data; - return _this_->nsm_save_handler(path, types, argv, argc, msg); + return handlePtr->handleSave(path, types, argv, argc, msg); } - static void error_handler(const int num, const char* const msg, const char* const path) + #undef handlePtr + + static void error_handler(int num, const char* msg, const char* path) { carla_stderr2("CarlaNSM::error_handler(%i, \"%s\", \"%s\")", num, msg, path); } }; -static CarlaNSM carlaNSM; +static CarlaNSM gCarlaNSM; void carla_nsm_announce(const char* url, int pid) { - carlaNSM.announce(url, pid); + gCarlaNSM.announce(url, pid); } void carla_nsm_reply_open() { - carlaNSM.replyOpen(); + gCarlaNSM.replyOpen(); } void carla_nsm_reply_save() { - carlaNSM.replySave(); + gCarlaNSM.replySave(); } -#endif - // ------------------------------------------------------------------------------------------------------------------- #ifdef BUILD_BRIDGE @@ -1985,186 +2008,3 @@ CarlaEngine* carla_get_standalone_engine() return standalone.engine; } #endif - -// ------------------------------------------------------------------------------------------------------------------- - -#if 0 -//def QTCREATOR_TEST - -#include -#include - -QDialog* vstGui = nullptr; - -void main_callback(void* ptr, CarlaBackend::CallbackType action, unsigned int pluginId, int value1, int value2, double value3) -{ - switch (action) - { - case CarlaBackend::CALLBACK_SHOW_GUI: - if (vstGui && ! value1) - vstGui->close(); - break; - case CarlaBackend::CALLBACK_RESIZE_GUI: - vstGui->setFixedSize(value1, value2); - break; - default: - break; - } - - Q_UNUSED(ptr); - Q_UNUSED(pluginId); - Q_UNUSED(value3); -} - -void run_tests_standalone(short idMax) -{ - for (short id = 0; id <= idMax; id++) - { - carla_debug("------------------- TEST @%i: non-parameter calls --------------------", id); - get_plugin_info(id); - get_audio_port_count_info(id); - get_midi_port_count_info(id); - get_parameter_count_info(id); - get_gui_info(id); - get_chunk_data(id); - get_parameter_count(id); - get_program_count(id); - get_midi_program_count(id); - get_custom_data_count(id); - get_real_plugin_name(id); - get_current_program_index(id); - get_current_midi_program_index(id); - - carla_debug("------------------- TEST @%i: parameter calls [-1] --------------------", id); - get_parameter_info(id, -1); - get_parameter_scalepoint_info(id, -1, -1); - get_parameter_data(id, -1); - get_parameter_ranges(id, -1); - get_midi_program_data(id, -1); - get_custom_data(id, -1); - get_parameter_text(id, -1); - get_program_name(id, -1); - get_midi_program_name(id, -1); - get_default_parameter_value(id, -1); - get_current_parameter_value(id, -1); - get_input_peak_value(id, -1); - get_output_peak_value(id, -1); - - carla_debug("------------------- TEST @%i: parameter calls [0] --------------------", id); - get_parameter_info(id, 0); - get_parameter_scalepoint_info(id, 0, -1); - get_parameter_scalepoint_info(id, 0, 0); - get_parameter_data(id, 0); - get_parameter_ranges(id, 0); - get_midi_program_data(id, 0); - get_custom_data(id, 0); - get_parameter_text(id, 0); - get_program_name(id, 0); - get_midi_program_name(id, 0); - get_default_parameter_value(id, 0); - get_current_parameter_value(id, 0); - get_input_peak_value(id, 0); - get_input_peak_value(id, 1); - get_input_peak_value(id, 2); - get_output_peak_value(id, 0); - get_output_peak_value(id, 1); - get_output_peak_value(id, 2); - - carla_debug("------------------- TEST @%i: set extra data --------------------", id); - set_custom_data(id, CarlaBackend::CUSTOM_DATA_STRING, "", ""); - set_chunk_data(id, nullptr); - set_gui_container(id, (uintptr_t)1); - - carla_debug("------------------- TEST @%i: gui stuff --------------------", id); - show_gui(id, false); - show_gui(id, true); - show_gui(id, true); - - idle_guis(); - idle_guis(); - idle_guis(); - - carla_debug("------------------- TEST @%i: other --------------------", id); - send_midi_note(id, 15, 127, 127); - send_midi_note(id, 0, 0, 0); - - prepare_for_save(id); - prepare_for_save(id); - prepare_for_save(id); - } -} - -int main(int argc, char* argv[]) -{ - using namespace CarlaBackend; - - // Qt app - QApplication app(argc, argv); - - // Qt gui (for vst) - vstGui = new QDialog(nullptr); - - // set callback and options - set_callback_function(main_callback); - set_option(OPTION_PREFER_UI_BRIDGES, 0, nullptr); - //set_option(OPTION_PROCESS_MODE, PROCESS_MODE_CONTINUOUS_RACK, nullptr); - - // start engine - if (! engine_init("JACK", "carla_demo")) - { - carla_stderr2("failed to start backend engine, reason:\n%s", get_last_error()); - delete vstGui; - return 1; - } - - short id_ladspa = add_plugin(BINARY_NATIVE, PLUGIN_LADSPA, "/usr/lib/ladspa/LEET_eqbw2x2.so", "LADSPA plug name, test long name - " - "------- name ------------ name2 ----------- name3 ------------ name4 ------------ name5 ---------- name6", "leet_equalizer_bw2x2", nullptr); - - short id_dssi = add_plugin(BINARY_NATIVE, PLUGIN_DSSI, "/usr/lib/dssi/fluidsynth-dssi.so", "DSSI pname, short-utf8 _ \xAE", "FluidSynth-DSSI", (void*)"/usr/lib/dssi/fluidsynth-dssi/FluidSynth-DSSI_gtk"); - short id_native = add_plugin(BINARY_NATIVE, PLUGIN_INTERNAL, "", "ZynHere", "zynaddsubfx", nullptr); - - //short id_lv2 = add_plugin(BINARY_NATIVE, PLUGIN_LV2, "FILENAME", "HAHA name!!!", "http://studionumbersix.com/foo/lv2/yc20", nullptr); - - //short id_vst = add_plugin(BINARY_NATIVE, PLUGIN_LV2, "FILENAME", "HAHA name!!!", "http://studionumbersix.com/foo/lv2/yc20", nullptr); - - if (id_ladspa < 0 || id_dssi < 0 || id_native < 0) - { - carla_stderr2("failed to start load plugins, reason:\n%s", get_last_error()); - delete vstGui; - return 1; - } - - //const GuiInfo* const guiInfo = get_gui_info(id); - //if (guiInfo->type == CarlaBackend::GUI_INTERNAL_QT4 || guiInfo->type == CarlaBackend::GUI_INTERNAL_X11) - //{ - // set_gui_data(id, 0, (uintptr_t)gui); - //gui->show(); - //} - - // activate - set_active(id_ladspa, true); - set_active(id_dssi, true); - set_active(id_native, true); - - // start guis - show_gui(id_dssi, true); - carla_sleep(1); - - // do tests - run_tests_standalone(id_dssi+1); - - // lock - app.exec(); - - delete vstGui; - vstGui = nullptr; - - remove_plugin(id_ladspa); - remove_plugin(id_dssi); - remove_plugin(id_native); - engine_close(); - - return 0; -} - -#endif diff --git a/source/backend/standalone/Makefile b/source/backend/standalone/Makefile index 82ec872a9..01c06dfba 100644 --- a/source/backend/standalone/Makefile +++ b/source/backend/standalone/Makefile @@ -8,7 +8,7 @@ include ../Makefile.mk # -------------------------------------------------------------- -BUILD_CXX_FLAGS += $(shell pkg-config --cflags QtGui) +BUILD_CXX_FLAGS += $(shell pkg-config --cflags liblo QtGui) # -------------------------------------------------------------- # Common diff --git a/source/carla.py b/source/carla.py index 0294a54bf..e925e4fde 100755 --- a/source/carla.py +++ b/source/carla.py @@ -559,11 +559,7 @@ class CarlaMainW(QMainWindow): self.fLastLoadedPluginId = -1 self.fTransportWasPlaying = False - #self._nsmAnnounce2str = "" - #self._nsmOpen1str = "" - #self._nsmOpen2str = "" - #self.nsm_server = None - #self.nsm_url = None + self.fSessionManagerName = "LADISH" if os.getenv("LADISH_APP_NAME") else "" # ------------------------------------------------------------- # Set-up GUI stuff @@ -712,19 +708,47 @@ class CarlaMainW(QMainWindow): self.connect(self, SIGNAL("PatchbayConnectionRemovedCallback(int)"), SLOT("slot_handlePatchbayConnectionRemovedCallback(int)")) self.connect(self, SIGNAL("BufferSizeChangedCallback(int)"), SLOT("slot_handleBufferSizeChangedCallback(int)")) self.connect(self, SIGNAL("SampleRateChangedCallback(double)"), SLOT("slot_handleSampleRateChangedCallback(double)")) - #self.connect(self, SIGNAL("NSM_AnnounceCallback()"), SLOT("slot_handleNSM_AnnounceCallback()")) - #self.connect(self, SIGNAL("NSM_Open1Callback()"), SLOT("slot_handleNSM_Open1Callback()")) - #self.connect(self, SIGNAL("NSM_Open2Callback()"), SLOT("slot_handleNSM_Open2Callback()")) - #self.connect(self, SIGNAL("NSM_SaveCallback()"), SLOT("slot_handleNSM_SaveCallback()")) + self.connect(self, SIGNAL("NSM_AnnounceCallback(QString)"), SLOT("slot_handleNSM_AnnounceCallback(QString)")) + self.connect(self, SIGNAL("NSM_OpenCallback(QString)"), SLOT("slot_handleNSM_OpenCallback(QString)")) + self.connect(self, SIGNAL("NSM_SaveCallback()"), SLOT("slot_handleNSM_SaveCallback()")) self.connect(self, SIGNAL("ErrorCallback(QString)"), SLOT("slot_handleErrorCallback(QString)")) self.connect(self, SIGNAL("QuitCallback()"), SLOT("slot_handleQuitCallback()")) - #NSM_URL = os.getenv("NSM_URL") + self.setProperWindowTitle() - #if NSM_URL: - #Carla.host.nsm_announce(NSM_URL, os.getpid()) - #else: - QTimer.singleShot(0, self, SLOT("slot_engineStart()")) + NSM_URL = os.getenv("NSM_URL") + + if NSM_URL: + Carla.host.nsm_announce(NSM_URL, os.getpid()) + else: + QTimer.singleShot(0, self, SLOT("slot_engineStart()")) + + @pyqtSlot(str) + def slot_handleNSM_AnnounceCallback(self, smName): + self.fSessionManagerName = smName + self.ui.act_file_new.setEnabled(False) + self.ui.act_file_open.setEnabled(False) + self.ui.act_file_save_as.setEnabled(False) + + @pyqtSlot(str) + def slot_handleNSM_OpenCallback(self, data): + projectPath, clientId = data.rsplit(":", 1) + + # restart engine + if self.fEngineStarted: + self.stopEngine() + + self.startEngine(clientId) + + if self.fEngineStarted: + self.loadProject(projectPath) + + Carla.host.nsm_reply_open() + + @pyqtSlot() + def slot_handleNSM_SaveCallback(self): + self.saveProject(self.fProjectFilename) + Carla.host.nsm_reply_save() @pyqtSlot() def slot_toolbarShown(self): @@ -1042,9 +1066,19 @@ class CarlaMainW(QMainWindow): patchcanvas.clear() + def setProperWindowTitle(self): + title = "%s" % os.getenv("LADISH_APP_NAME", "Carla") + + if self.fProjectFilename: + title += " - %s" % os.path.basename(self.fProjectFilename) + if self.fSessionManagerName: + title += " (%s)" % self.fSessionManagerName + + self.setWindowTitle(title) + def loadProject(self, filename): self.fProjectFilename = filename - self.setWindowTitle("Carla - %s" % os.path.basename(filename)) + self.setProperWindowTitle() self.fProjectLoading = True Carla.host.load_project(filename) @@ -1052,12 +1086,12 @@ class CarlaMainW(QMainWindow): def loadProjectLater(self, filename): self.fProjectFilename = filename - self.setWindowTitle("Carla - %s" % os.path.basename(filename)) + self.setProperWindowTitle() QTimer.singleShot(0, self, SLOT("slot_loadProjectLater()")) def saveProject(self, filename): self.fProjectFilename = filename - self.setWindowTitle("Carla - %s" % os.path.basename(filename)) + self.setProperWindowTitle() Carla.host.save_project(filename) def addPlugin(self, btype, ptype, filename, name, label, extraStuff): @@ -1099,7 +1133,7 @@ class CarlaMainW(QMainWindow): self.removeAllPlugins() self.fProjectFilename = None self.fProjectLoading = False - self.setWindowTitle("Carla") + self.setProperWindowTitle() @pyqtSlot() def slot_fileOpen(self): @@ -1856,17 +1890,12 @@ def engineCallback(ptr, action, pluginId, value1, value2, value3, valueStr): Carla.gui.emit(SIGNAL("BufferSizeChangedCallback(int)"), value1) elif action == CALLBACK_SAMPLE_RATE_CHANGED: Carla.gui.emit(SIGNAL("SampleRateChangedCallback(double)"), value3) - #elif action == CALLBACK_NSM_ANNOUNCE: - #Carla.gui._nsmAnnounce2str = cString(Carla.host.get_last_error()) - #Carla.gui.emit(SIGNAL("NSM_AnnounceCallback()")) - #elif action == CALLBACK_NSM_OPEN1: - #Carla.gui._nsmOpen1str = cString(valueStr) - #Carla.gui.emit(SIGNAL("NSM_Open1Callback()")) - #elif action == CALLBACK_NSM_OPEN2: - #Carla.gui._nsmOpen2str = cString(valueStr) - #Carla.gui.emit(SIGNAL("NSM_Open2Callback()")) - #elif action == CALLBACK_NSM_SAVE: - #Carla.gui.emit(SIGNAL("NSM_SaveCallback()")) + elif action == CALLBACK_NSM_ANNOUNCE: + Carla.gui.emit(SIGNAL("NSM_AnnounceCallback(QString)"), cString(valueStr)) + elif action == CALLBACK_NSM_OPEN: + Carla.gui.emit(SIGNAL("NSM_OpenCallback(QString)"), cString(valueStr)) + elif action == CALLBACK_NSM_SAVE: + Carla.gui.emit(SIGNAL("NSM_SaveCallback()")) elif action == CALLBACK_ERROR: Carla.gui.emit(SIGNAL("ErrorCallback(QString)"), cString(valueStr)) elif action == CALLBACK_QUIT: @@ -1958,7 +1987,7 @@ if __name__ == '__main__': Carla.gui.show() # Load project file if set - if projectFilename: + if projectFilename and not os.getenv("NSM_URL"): Carla.gui.loadProjectLater(projectFilename) # App-Loop diff --git a/source/carla_backend.py b/source/carla_backend.py index c8106e3ea..3dc5711a8 100644 --- a/source/carla_backend.py +++ b/source/carla_backend.py @@ -386,14 +386,14 @@ class Host(object): self.lib.carla_get_host_osc_url.argtypes = None self.lib.carla_get_host_osc_url.restype = c_char_p - #self.lib.nsm_announce.argtypes = [c_char_p, c_int] - #self.lib.nsm_announce.restype = None + self.lib.carla_nsm_announce.argtypes = [c_char_p, c_int] + self.lib.carla_nsm_announce.restype = None - #self.lib.nsm_reply_open.argtypes = None - #self.lib.nsm_reply_open.restype = None + self.lib.carla_nsm_reply_open.argtypes = None + self.lib.carla_nsm_reply_open.restype = None - #self.lib.nsm_reply_save.argtypes = None - #self.lib.nsm_reply_save.restype = None + self.lib.carla_nsm_reply_save.argtypes = None + self.lib.carla_nsm_reply_save.restype = None def get_extended_license_text(self): return self.lib.carla_get_extended_license_text() @@ -624,28 +624,11 @@ class Host(object): def get_sample_rate(self): return self.lib.carla_get_sample_rate() - #def nsm_announce(self, url, pid): - #self.lib.nsm_announce(url.encode("utf-8"), pid) + def nsm_announce(self, url, pid): + self.lib.carla_nsm_announce(url.encode("utf-8"), pid) - #def nsm_reply_open(self): - #self.lib.nsm_reply_open() + def nsm_reply_open(self): + self.lib.carla_nsm_reply_open() - #def nsm_reply_save(self): - #self.lib.nsm_reply_save() - -#Carla.host = Host(None) - -## Test available drivers -#driverCount = Carla.host.get_engine_driver_count() -#driverList = [] -#for i in range(driverCount): - #driver = cString(Carla.host.get_engine_driver_name(i)) - #if driver: - #driverList.append(driver) - #print(i, driver) - -## Test available internal plugins -#pluginCount = Carla.host.get_internal_plugin_count() -#for i in range(pluginCount): - #plugin = Carla.host.get_internal_plugin_info(i) - #print(plugin) + def nsm_reply_save(self): + self.lib.carla_nsm_reply_save() diff --git a/source/carla_shared.py b/source/carla_shared.py index e18816f56..081248a66 100644 --- a/source/carla_shared.py +++ b/source/carla_shared.py @@ -308,11 +308,10 @@ CALLBACK_PATCHBAY_CONNECTION_REMOVED = 25 CALLBACK_BUFFER_SIZE_CHANGED = 26 CALLBACK_SAMPLE_RATE_CHANGED = 27 CALLBACK_NSM_ANNOUNCE = 28 -CALLBACK_NSM_OPEN1 = 29 -CALLBACK_NSM_OPEN2 = 30 -CALLBACK_NSM_SAVE = 31 -CALLBACK_ERROR = 32 -CALLBACK_QUIT = 33 +CALLBACK_NSM_OPEN = 29 +CALLBACK_NSM_SAVE = 30 +CALLBACK_ERROR = 31 +CALLBACK_QUIT = 32 # Process Mode PROCESS_MODE_SINGLE_CLIENT = 0 diff --git a/source/utils/CarlaBackendUtils.hpp b/source/utils/CarlaBackendUtils.hpp index 038661960..398394856 100644 --- a/source/utils/CarlaBackendUtils.hpp +++ b/source/utils/CarlaBackendUtils.hpp @@ -329,10 +329,8 @@ const char* CallbackType2Str(const CallbackType& type) return "CALLBACK_SAMPLE_RATE_CHANGED"; case CALLBACK_NSM_ANNOUNCE: return "CALLBACK_NSM_ANNOUNCE"; - case CALLBACK_NSM_OPEN1: - return "CALLBACK_NSM_OPEN1"; - case CALLBACK_NSM_OPEN2: - return "CALLBACK_NSM_OPEN2"; + case CALLBACK_NSM_OPEN: + return "CALLBACK_NSM_OPEN"; case CALLBACK_NSM_SAVE: return "CALLBACK_NSM_SAVE"; case CALLBACK_ERROR: