From 579a103821cf943f7ecba57b2a25ac1503c77daa Mon Sep 17 00:00:00 2001 From: falkTX Date: Wed, 21 Nov 2012 21:29:51 +0000 Subject: [PATCH] Catia: Enable ALSA-MIDI via GUI (EXPERIMENTAL); Carla misc changes --- c++/carla-native/zynaddsubfx.cpp | 2 + c++/carla-plugin/ladspa.cpp | 41 +++++++++------- c++/carla-utils/carla_utils.hpp | 6 ++- doc/TODO | 3 -- resources/ui/catia.ui | 83 ++++++++++++++++++-------------- src/catia.py | 26 ++++++++-- 6 files changed, 97 insertions(+), 64 deletions(-) diff --git a/c++/carla-native/zynaddsubfx.cpp b/c++/carla-native/zynaddsubfx.cpp index 2f3a7e6..2737a19 100644 --- a/c++/carla-native/zynaddsubfx.cpp +++ b/c++/carla-native/zynaddsubfx.cpp @@ -71,6 +71,8 @@ public: qDebug("ZynAddSubFxPlugin::~ZynAddSubFxPlugin(), s_instanceCount=%i", s_instanceCount); m_programs.clear(); + + delete m_master; } protected: diff --git a/c++/carla-plugin/ladspa.cpp b/c++/carla-plugin/ladspa.cpp index 478cc5e..610ee41 100644 --- a/c++/carla-plugin/ladspa.cpp +++ b/c++/carla-plugin/ladspa.cpp @@ -412,11 +412,12 @@ public: paramBuffers = new float[params]; } - const int portNameSize = x_engine->maxPortNameSize() - 2; - char portName[portNameSize]; bool needsCtrlIn = false; bool needsCtrlOut = false; + const int portNameSize = x_engine->maxPortNameSize() - 3; + CarlaString portName; + for (unsigned long i=0; i < portCount; i++) { const LADSPA_PortDescriptor portType = descriptor->PortDescriptors[i]; @@ -425,16 +426,18 @@ public: if (LADSPA_IS_PORT_AUDIO(portType)) { + portName.clear(); + #ifndef BUILD_BRIDGE if (x_engine->processMode() == PROCESS_MODE_SINGLE_CLIENT) { - strcpy(portName, m_name); - strcat(portName, ":"); - strncat(portName, descriptor->PortNames[i], portNameSize/2); + portName = m_name; + portName += ":"; } - else #endif - strncpy(portName, descriptor->PortNames[i], portNameSize); + + portName += descriptor->PortNames[i]; + portName.truncate(portNameSize); if (LADSPA_IS_PORT_INPUT(portType)) { @@ -444,7 +447,7 @@ public: if (forcedStereoIn) { - strcat(portName, "_"); + portName += "_2"; aIn.ports[1] = (CarlaEngineAudioPort*)x_client->addPort(CarlaEnginePortTypeAudio, portName, true); aIn.rindexes[1] = i; } @@ -458,7 +461,7 @@ public: if (forcedStereoOut) { - strcat(portName, "_"); + portName += "_2"; aOut.ports[1] = (CarlaEngineAudioPort*)x_client->addPort(CarlaEnginePortTypeAudio, portName, false); aOut.rindexes[1] = i; } @@ -618,30 +621,34 @@ public: if (needsCtrlIn) { + portName.clear(); + #ifndef BUILD_BRIDGE if (x_engine->processMode() == PROCESS_MODE_SINGLE_CLIENT) { - strcpy(portName, m_name); - strcat(portName, ":control-in"); + portName = m_name; + portName += ":"; } - else #endif - strcpy(portName, "control-in"); + portName += "control-in"; + portName.truncate(portNameSize); param.portCin = (CarlaEngineControlPort*)x_client->addPort(CarlaEnginePortTypeControl, portName, true); } if (needsCtrlOut) { + portName.clear(); + #ifndef BUILD_BRIDGE if (x_engine->processMode() == PROCESS_MODE_SINGLE_CLIENT) { - strcpy(portName, m_name); - strcat(portName, ":control-out"); + portName = m_name; + portName += ":"; } - else #endif - strcpy(portName, "control-out"); + portName += "control-out"; + portName.truncate(portNameSize); param.portCout = (CarlaEngineControlPort*)x_client->addPort(CarlaEnginePortTypeControl, portName, false); } diff --git a/c++/carla-utils/carla_utils.hpp b/c++/carla-utils/carla_utils.hpp index 194f43b..34ffb37 100644 --- a/c++/carla-utils/carla_utils.hpp +++ b/c++/carla-utils/carla_utils.hpp @@ -269,8 +269,10 @@ public: void clear() { - for (size_t i=0, len = ::strlen(buffer); i < len; i++) - buffer[i] = 0; + if (::strcmp(buffer, "") == 0) + return; + + buffer = ::strdup(""); } void replace(char before, char after) diff --git a/doc/TODO b/doc/TODO index ca9d42a..25f9fa4 100644 --- a/doc/TODO +++ b/doc/TODO @@ -12,9 +12,6 @@ GUI: ------------------- - APPS - -Catia: - - Add ALSA-MIDI option via settings, label it experimental - Claudia: - Cleanup DB - Auto-recover crashes diff --git a/resources/ui/catia.ui b/resources/ui/catia.ui index 5da3674..37fd30b 100644 --- a/resources/ui/catia.ui +++ b/resources/ui/catia.ui @@ -45,7 +45,7 @@ - + :/16x16/media-playback-start.png:/16x16/media-playback-start.png @@ -68,7 +68,7 @@ - + :/16x16/media-playback-stop.png:/16x16/media-playback-stop.png @@ -88,7 +88,7 @@ - + :/16x16/media-seek-backward.png:/16x16/media-seek-backward.png @@ -111,7 +111,7 @@ - + :/16x16/media-seek-forward.png:/16x16/media-seek-forward.png @@ -197,7 +197,7 @@ - + :/16x16/zoom-fit-best.png:/16x16/zoom-fit-best.png @@ -217,7 +217,7 @@ - + :/16x16/zoom-in.png:/16x16/zoom-in.png @@ -237,7 +237,7 @@ - + :/16x16/zoom-out.png:/16x16/zoom-out.png @@ -257,7 +257,7 @@ - + :/16x16/zoom-original.png:/16x16/zoom-original.png @@ -286,7 +286,7 @@ - + :/16x16/edit-clear.png:/16x16/edit-clear.png @@ -306,7 +306,7 @@ - + :/16x16/configure.png:/16x16/configure.png @@ -326,7 +326,7 @@ - + :/16x16/media-record.png:/16x16/media-record.png @@ -553,6 +553,7 @@ S&ettings + @@ -567,7 +568,7 @@ - + :/16x16/application-exit.png:/16x16/application-exit.png @@ -579,7 +580,7 @@ - + :/16x16/document-new.png:/16x16/document-new.png @@ -591,7 +592,7 @@ - + :/16x16/document-open.png:/16x16/document-open.png @@ -603,7 +604,7 @@ - + :/16x16/document-save.png:/16x16/document-save.png @@ -615,7 +616,7 @@ - + :/16x16/document-save-as.png:/16x16/document-save-as.png @@ -640,7 +641,7 @@ true - + :/16x16/media-playback-start.png:/16x16/media-playback-start.png @@ -652,7 +653,7 @@ - + :/16x16/media-playback-stop.png:/16x16/media-playback-stop.png @@ -664,7 +665,7 @@ - + :/16x16/media-seek-backward.png:/16x16/media-seek-backward.png @@ -676,7 +677,7 @@ - + :/16x16/media-seek-forward.png:/16x16/media-seek-forward.png @@ -688,7 +689,7 @@ - + :/16x16/view-refresh.png:/16x16/view-refresh.png @@ -700,7 +701,7 @@ - + :/16x16/view-sort-ascending.png:/16x16/view-sort-ascending.png @@ -712,7 +713,7 @@ - + :/16x16/zoom-fit-best.png:/16x16/zoom-fit-best.png @@ -721,7 +722,7 @@ - + :/16x16/zoom-in.png:/16x16/zoom-in.png @@ -733,7 +734,7 @@ - + :/16x16/zoom-out.png:/16x16/zoom-out.png @@ -745,7 +746,7 @@ - + :/16x16/zoom-original.png:/16x16/zoom-original.png @@ -757,7 +758,7 @@ - + :/16x16/edit-clear.png:/16x16/edit-clear.png @@ -766,7 +767,7 @@ - + :/16x16/configure.png:/16x16/configure.png @@ -796,7 +797,7 @@ - + :/16x16/configure.png:/16x16/configure.png @@ -808,7 +809,7 @@ - + :/16x16/media-playback-start.png:/16x16/media-playback-start.png @@ -820,7 +821,7 @@ - + :/16x16/media-playback-stop.png:/16x16/media-playback-stop.png @@ -904,7 +905,7 @@ - + :/16x16/media-playback-start.png:/16x16/media-playback-start.png @@ -916,7 +917,7 @@ - + :/16x16/media-playback-stop.png:/16x16/media-playback-stop.png @@ -938,7 +939,7 @@ - + :/16x16/document-print.png:/16x16/document-print.png @@ -975,7 +976,7 @@ - + :/16x16/configure.png:/16x16/configure.png @@ -997,7 +998,7 @@ - + :/16x16/media-record.png:/16x16/media-record.png @@ -1017,9 +1018,17 @@ 16 + + + true + + + Show ALSA-MIDI (EXPERIMENTAL) + + - + diff --git a/src/catia.py b/src/catia.py index 03d0d7b..b782152 100755 --- a/src/catia.py +++ b/src/catia.py @@ -40,12 +40,13 @@ except: haveDBus = False # Disabled for Beta -if LINUX and False: +if LINUX: for iPATH in PATH: if os.path.exists(os.path.join(iPATH, "aconnect")): from subprocess import getoutput haveALSA = True - print("Using experimental ALSA-MIDI support") + if DEBUG: + print("Using experimental ALSA-MIDI support") break else: haveALSA = False @@ -86,6 +87,9 @@ class CatiaMainW(QMainWindow, ui_catia.Ui_CatiaMainW): self.act_quit.setIcon(getIcon("application-exit")) self.act_configure.setIcon(getIcon("configure")) + if not haveALSA: + self.act_settings_show_alsa.setEnabled(False) + self.m_group_list = [] self.m_group_split_list = [] self.m_port_list = [] @@ -189,6 +193,7 @@ class CatiaMainW(QMainWindow, ui_catia.Ui_CatiaMainW): self.connect(self.act_tools_a2j_stop, SIGNAL("triggered()"), SLOT("slot_A2JBridgeStop()")) self.connect(self.act_tools_a2j_export_hw, SIGNAL("triggered()"), SLOT("slot_A2JBridgeExportHW()")) + self.connect(self.act_settings_show_alsa, SIGNAL("triggered(bool)"), SLOT("slot_showAlsaMIDI(bool)")) self.connect(self.act_configure, SIGNAL("triggered()"), SLOT("slot_configureCatia()")) self.connect(self.act_help_about, SIGNAL("triggered()"), SLOT("slot_aboutCatia()")) @@ -506,7 +511,7 @@ class CatiaMainW(QMainWindow, ui_catia.Ui_CatiaMainW): self.canvas_connect_ports_by_name(port_name, port_con_name) def init_alsa_ports(self): - if not haveALSA: + if not (haveALSA and self.act_settings_show_alsa.isChecked()): return # Get ALSA MIDI ports (outputs) @@ -1040,6 +1045,12 @@ class CatiaMainW(QMainWindow, ui_catia.Ui_CatiaMainW): self.emit(SIGNAL("ShutdownCallback()")) return 0 + @pyqtSlot(bool) + def slot_showAlsaMIDI(self, yesNo): + # refresh canvas (remove jack ports) + patchcanvas.clear() + self.init_ports() + @pyqtSlot() def slot_JackServerStart(self): if DBus.jack: @@ -1239,6 +1250,7 @@ class CatiaMainW(QMainWindow, ui_catia.Ui_CatiaMainW): def saveSettings(self): self.settings.setValue("Geometry", self.saveGeometry()) + self.settings.setValue("ShowAlsaMIDI", self.act_settings_show_alsa.isChecked()) self.settings.setValue("ShowToolbar", self.frame_toolbar.isVisible()) self.settings.setValue("ShowStatusbar", self.frame_statusbar.isVisible()) self.settings.setValue("TransportView", self.m_selected_transport_view) @@ -1247,6 +1259,9 @@ class CatiaMainW(QMainWindow, ui_catia.Ui_CatiaMainW): if geometry: self.restoreGeometry(self.settings.value("Geometry", "")) + show_alsamidi = self.settings.value("ShowAlsaMIDI", False, type=bool) + self.act_settings_show_alsa.setChecked(show_alsamidi) + show_toolbar = self.settings.value("ShowToolbar", True, type=bool) self.act_settings_show_toolbar.setChecked(show_toolbar) self.frame_toolbar.setVisible(show_toolbar) @@ -1312,7 +1327,7 @@ if __name__ == '__main__': DBus.a2j = None a2j_client_name = None - if DBus.jack or DBus.a2j: + if DEBUG and (DBus.jack or DBus.a2j): string = "Using DBus for " if DBus.jack: string += "JACK" @@ -1326,7 +1341,8 @@ if __name__ == '__main__': DBus.jack = None DBus.a2j = None a2j_client_name = None - print("Not using DBus") + if DEBUG: + print("Not using DBus") # Show GUI gui = CatiaMainW()