From a5dcf3cb803eadc5640e25d7f0a5f040985ceb77 Mon Sep 17 00:00:00 2001 From: falkTX Date: Sun, 10 Feb 2013 11:42:38 +0000 Subject: [PATCH] More work --- source/carla.py | 102 +++++++--------- source/carla_control.py | 264 ++++++++++++++++++++++------------------ source/carla_shared.py | 12 +- 3 files changed, 202 insertions(+), 176 deletions(-) diff --git a/source/carla.py b/source/carla.py index 3804489bb..a6e124445 100755 --- a/source/carla.py +++ b/source/carla.py @@ -20,16 +20,14 @@ # Imports (Global) from PyQt4.QtCore import QSize -from PyQt4.QtGui import QApplication, QListWidgetItem, QMainWindow +from PyQt4.QtGui import QApplication, QMainWindow # ------------------------------------------------------------------------------------------------------------ # Imports (Custom Stuff) import ui_carla -from carla_backend import * from carla_shared import * -# FIXME, remove later -#from shared_settings import * +from carla_backend import * # FIXME, remove later # ------------------------------------------------------------------------------------------------------------ # Main Window @@ -179,7 +177,7 @@ class CarlaMainW(QMainWindow): Carla.host.set_option(OPTION_PREFERRED_SAMPLE_RATE, preferredSampleRate, "") # --------------------------------------------- - # start + # Start audioDriver = settings.value("Engine/AudioDriver", "JACK", type=str) @@ -188,9 +186,6 @@ class CarlaMainW(QMainWindow): self.fFirstEngineInit = False return - #self.ui.act_engine_start.setEnabled(True) - #self.ui.act_engine_stop.setEnabled(False) - audioError = cString(Carla.host.get_last_error()) if audioError: @@ -241,18 +236,22 @@ class CarlaMainW(QMainWindow): self.killTimer(self.fIdleTimerSlow) def loadProject(self, filename): - self.fProjectLoading = True self.fProjectFilename = filename + self.setWindowTitle("Carla - %s" % os.path.basename(filename)) + + self.fProjectLoading = True Carla.host.load_project(filename) + self.fProjectLoading = False def loadProjectLater(self, filename): - self.fProjectLoading = True self.fProjectFilename = filename self.setWindowTitle("Carla - %s" % os.path.basename(filename)) QTimer.singleShot(0, self, SLOT("slot_loadProjectLater()")) - def saveProject(self): - Carla.host.save_project(self.fProjectFilename) + def saveProject(self, filename): + self.fProjectFilename = filename + self.setWindowTitle("Carla - %s" % os.path.basename(filename)) + Carla.host.save_project(filename) def addPlugin(self, btype, ptype, filename, name, label, extraStuff): if not self.fEngineStarted: @@ -300,12 +299,11 @@ class CarlaMainW(QMainWindow): # FIXME - show dialog to user self.removeAllPlugins() self.loadProject(filenameTry) - self.setWindowTitle("Carla - %s" % os.path.basename(filenameTry)) @pyqtSlot() def slot_fileSave(self, saveAs=False): if self.fProjectFilename and not saveAs: - return self.saveProject() + return self.saveProject(self.fProjectFilename) fileFilter = self.tr("Carla Project File (*.carxp)") filenameTry = QFileDialog.getSaveFileName(self, self.tr("Save Carla Project File"), self.fSavedSettings["Main/DefaultProjectFolder"], filter=fileFilter) @@ -314,9 +312,7 @@ class CarlaMainW(QMainWindow): if not filenameTry.endswith(".carxp"): filenameTry += ".carxp" - self.fProjectFilename = filenameTry - self.saveProject() - self.setWindowTitle("Carla - %s" % os.path.basename(filenameTry)) + self.saveProject(filenameTry) @pyqtSlot() def slot_fileSaveAs(self): @@ -324,7 +320,9 @@ class CarlaMainW(QMainWindow): @pyqtSlot() def slot_loadProjectLater(self): + self.fProjectLoading = True Carla.host.load_project(self.fProjectFilename) + self.fProjectLoading = False @pyqtSlot() def slot_engineStart(self): @@ -380,7 +378,7 @@ class CarlaMainW(QMainWindow): print("DEBUG :: %i, %i, %i, %f, \"%s\")" % (pluginId, value1, value2, value3, valueStr)) @pyqtSlot(int) - def slot_handlePluginAddedCallback(self, pluginId, pluginName="todo"): + def slot_handlePluginAddedCallback(self, pluginId): pwidget = PluginWidget(self, pluginId) pwidget.setRefreshRate(self.fSavedSettings["Main/RefreshInterval"]) @@ -389,12 +387,12 @@ class CarlaMainW(QMainWindow): self.fPluginCount += 1 self.fPluginList[pluginId] = pwidget - if self.fPluginCount == 1: - self.ui.act_plugin_remove_all.setEnabled(True) - if not self.fProjectLoading: pwidget.setActive(True, True, True) + if self.fPluginCount == 1: + self.ui.act_plugin_remove_all.setEnabled(True) + @pyqtSlot(int) def slot_handlePluginRemovedCallback(self, pluginId): pwidget = self.fPluginList[pluginId] @@ -412,10 +410,7 @@ class CarlaMainW(QMainWindow): del pwidget # push all plugins 1 slot back - for i in range(self.fPluginCount): - if i < pluginId: - continue - + for i in range(pluginId, self.fPluginCount): self.fPluginList[i] = self.fPluginList[i+1] self.fPluginList[i].setId(i) @@ -428,7 +423,7 @@ class CarlaMainW(QMainWindow): if pwidget is None: return - pwidget.setParameterValue(value, True, False) + pwidget.setParameterValue(parameterId, value) @pyqtSlot(int, int, float) def slot_handleParameterDefaultChangedCallback(self, pluginId, parameterId, value): @@ -436,7 +431,7 @@ class CarlaMainW(QMainWindow): if pwidget is None: return - pwidget.setParameterDefault(value, True, False) + pwidget.setParameterDefault(parameterId, value) @pyqtSlot(int, int, int) def slot_handleParameterMidiChannelChangedCallback(self, pluginId, parameterId, channel): @@ -444,7 +439,7 @@ class CarlaMainW(QMainWindow): if pwidget is None: return - pwidget.setParameterMidiChannel(parameterId, channel, True) + pwidget.setParameterMidiChannel(parameterId, channel) @pyqtSlot(int, int, int) def slot_handleParameterMidiCcChangedCallback(self, pluginId, parameterId, cc): @@ -452,7 +447,7 @@ class CarlaMainW(QMainWindow): if pwidget is None: return - pwidget.setParameterMidiControl(parameterId, cc, True) + pwidget.setParameterMidiControl(parameterId, cc) @pyqtSlot(int, int) def slot_handleProgramChangedCallback(self, pluginId, programId): @@ -476,7 +471,7 @@ class CarlaMainW(QMainWindow): if pwidget is None: return - pwidget.ui.edit_dialog.keyboard.sendNoteOn(note, False) + pwidget.sendNoteOn(note) @pyqtSlot(int, int, int) def slot_handleNoteOffCallback(self, pluginId, channel, note): @@ -484,7 +479,7 @@ class CarlaMainW(QMainWindow): if pwidget is None: return - pwidget.ui.edit_dialog.keyboard.sendNoteOff(note, False) + pwidget.sendNoteOff(note) @pyqtSlot(int, int) def slot_handleShowGuiCallback(self, pluginId, show): @@ -673,57 +668,54 @@ def callbackFunction(ptr, action, pluginId, value1, value2, value3, valueStr): return if action == CALLBACK_DEBUG: - return Carla.gui.emit(SIGNAL("DebugCallback(int, int, int, double, QString)"), pluginId, value1, value2, value3, cString(valueStr)) + Carla.gui.emit(SIGNAL("DebugCallback(int, int, int, double, QString)"), pluginId, value1, value2, value3, cString(valueStr)) elif action == CALLBACK_PLUGIN_ADDED: - return Carla.gui.emit(SIGNAL("PluginAddedCallback(int)"), pluginId) + Carla.gui.emit(SIGNAL("PluginAddedCallback(int)"), pluginId) elif action == CALLBACK_PLUGIN_REMOVED: - return Carla.gui.emit(SIGNAL("PluginRemovedCallback(int)"), pluginId) + Carla.gui.emit(SIGNAL("PluginRemovedCallback(int)"), pluginId) elif action == CALLBACK_PARAMETER_VALUE_CHANGED: - return Carla.gui.emit(SIGNAL("ParameterValueChangedCallback(int, int, double)"), pluginId, value1, value3) + Carla.gui.emit(SIGNAL("ParameterValueChangedCallback(int, int, double)"), pluginId, value1, value3) elif action == CALLBACK_PARAMETER_DEFAULT_CHANGED: - return Carla.gui.emit(SIGNAL("ParameterDefaultChangedCallback(int, int, double)"), pluginId, value1, value3) + Carla.gui.emit(SIGNAL("ParameterDefaultChangedCallback(int, int, double)"), pluginId, value1, value3) elif action == CALLBACK_PARAMETER_MIDI_CHANNEL_CHANGED: - return Carla.gui.emit(SIGNAL("ParameterMidiChannelChangedCallback(int, int, int)"), pluginId, value1, value2) + Carla.gui.emit(SIGNAL("ParameterMidiChannelChangedCallback(int, int, int)"), pluginId, value1, value2) elif action == CALLBACK_PARAMETER_MIDI_CC_CHANGED: - return Carla.gui.emit(SIGNAL("ParameterMidiCcChangedCallback(int, int, int)"), pluginId, value1, value2) + Carla.gui.emit(SIGNAL("ParameterMidiCcChangedCallback(int, int, int)"), pluginId, value1, value2) elif action == CALLBACK_PROGRAM_CHANGED: - return Carla.gui.emit(SIGNAL("ProgramChangedCallback(int, int)"), pluginId, value1) + Carla.gui.emit(SIGNAL("ProgramChangedCallback(int, int)"), pluginId, value1) elif action == CALLBACK_MIDI_PROGRAM_CHANGED: - return Carla.gui.emit(SIGNAL("MidiProgramChangedCallback(int, int)"), pluginId, value1) + Carla.gui.emit(SIGNAL("MidiProgramChangedCallback(int, int)"), pluginId, value1) elif action == CALLBACK_NOTE_ON: - return Carla.gui.emit(SIGNAL("NoteOnCallback(int, int, int, int)"), pluginId, value1, value2, value3) + Carla.gui.emit(SIGNAL("NoteOnCallback(int, int, int, int)"), pluginId, value1, value2, value3) elif action == CALLBACK_NOTE_OFF: - return Carla.gui.emit(SIGNAL("NoteOffCallback(int, int, int)"), pluginId, value1, value2) + Carla.gui.emit(SIGNAL("NoteOffCallback(int, int, int)"), pluginId, value1, value2) elif action == CALLBACK_SHOW_GUI: - return Carla.gui.emit(SIGNAL("ShowGuiCallback(int, int)"), pluginId, value1) + Carla.gui.emit(SIGNAL("ShowGuiCallback(int, int)"), pluginId, value1) elif action == CALLBACK_UPDATE: - return Carla.gui.emit(SIGNAL("UpdateCallback(int)"), pluginId) + Carla.gui.emit(SIGNAL("UpdateCallback(int)"), pluginId) elif action == CALLBACK_RELOAD_INFO: - return Carla.gui.emit(SIGNAL("ReloadInfoCallback(int)"), pluginId) + Carla.gui.emit(SIGNAL("ReloadInfoCallback(int)"), pluginId) elif action == CALLBACK_RELOAD_PARAMETERS: - return Carla.gui.emit(SIGNAL("ReloadParametersCallback(int)"), pluginId) + Carla.gui.emit(SIGNAL("ReloadParametersCallback(int)"), pluginId) elif action == CALLBACK_RELOAD_PROGRAMS: - return Carla.gui.emit(SIGNAL("ReloadProgramsCallback(int)"), pluginId) + Carla.gui.emit(SIGNAL("ReloadProgramsCallback(int)"), pluginId) elif action == CALLBACK_RELOAD_ALL: - return Carla.gui.emit(SIGNAL("ReloadAllCallback(int)"), pluginId) + Carla.gui.emit(SIGNAL("ReloadAllCallback(int)"), pluginId) #elif action == CALLBACK_NSM_ANNOUNCE: #Carla.gui._nsmAnnounce2str = cString(Carla.host.get_last_error()) #Carla.gui.emit(SIGNAL("NSM_AnnounceCallback()")) - #return #elif action == CALLBACK_NSM_OPEN1: #Carla.gui._nsmOpen1str = cString(valueStr) #Carla.gui.emit(SIGNAL("NSM_Open1Callback()")) - #return #elif action == CALLBACK_NSM_OPEN2: #Carla.gui._nsmOpen2str = cString(valueStr) #Carla.gui.emit(SIGNAL("NSM_Open2Callback()")) - #return #elif action == CALLBACK_NSM_SAVE: - #return Carla.gui.emit(SIGNAL("NSM_SaveCallback()")) + #Carla.gui.emit(SIGNAL("NSM_SaveCallback()")) elif action == CALLBACK_ERROR: - return Carla.gui.emit(SIGNAL("ErrorCallback(QString)"), valueStr) + Carla.gui.emit(SIGNAL("ErrorCallback(QString)"), valueStr) elif action == CALLBACK_QUIT: - return Carla.gui.emit(SIGNAL("QuitCallback()")) + Carla.gui.emit(SIGNAL("QuitCallback()")) #--------------- main ------------------ if __name__ == '__main__': @@ -805,7 +797,7 @@ if __name__ == '__main__': Carla.gui = CarlaMainW() # Set-up custom signal handling - setUpSignals(Carla.gui) + setUpSignals() # Show GUI Carla.gui.show() diff --git a/source/carla_control.py b/source/carla_control.py index cdc7c61ad..c5d096c42 100755 --- a/source/carla_control.py +++ b/source/carla_control.py @@ -1,28 +1,32 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -# Carla Backend code -# Copyright (C) 2011-2012 Filipe Coelho +# Carla OSC controller +# Copyright (C) 2011-2013 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 2 of the License, or -# any later version. +# 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 2 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 +# 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 COPYING file +# For a full copy of the GNU General Public License see the GPL.txt file +# ------------------------------------------------------------------------------------------------------------ # Imports (Global) -from PyQt4.QtGui import QApplication, QMainWindow + +from PyQt4.QtGui import QApplication, QInputDialog, QMainWindow from liblo import make_method, Address, ServerError, ServerThread from liblo import send as lo_send from liblo import TCP as LO_TCP +# ------------------------------------------------------------------------------------------------------------ # Imports (Custom) + import ui_carla_control from carla_shared import * @@ -32,7 +36,9 @@ lo_targetName = "" Carla.isControl = True +# ------------------------------------------------------------------------------------------------------------ # Python Object dicts compatible to carla-backend struct ctypes + MidiProgramData = { 'bank': 0, 'program': 0, @@ -114,17 +120,15 @@ class ControlPluginInfo(object): 'outPeak' ] +# ------------------------------------------------------------------------------------------------------------ # Python Object class compatible to 'Host' on the Carla Backend code + class Host(object): def __init__(self): object.__init__(self) self.pluginInfo = [] - for i in range(MAX_DEFAULT_PLUGINS): - self.pluginInfo.append(ControlPluginInfo()) - self._clear(i) - def _clear(self, index): self.pluginInfo[index].pluginInfo = PluginInfo self.pluginInfo[index].pluginRealName = None @@ -258,9 +262,6 @@ class Host(object): def get_parameter_scalepoint_info(self, plugin_id, parameter_id, scalepoint_id): return ScalePointInfo - def get_gui_info(self, plugin_id): - return GuiInfo - def get_parameter_data(self, plugin_id, parameter_id): return self.pluginInfo[plugin_id].parameterDataS[parameter_id] @@ -377,7 +378,9 @@ class Host(object): lo_path = "/%s/%i/note_off" % (lo_targetName, plugin_id) lo_send(lo_target, lo_path, channel, note) +# ------------------------------------------------------------------------------------------------------------ # OSC Control server + class ControlServer(ServerThread): def __init__(self, parent): ServerThread.__init__(self, 8087, LO_TCP) @@ -500,16 +503,18 @@ class ControlServer(ServerThread): def fallback(self, path, args): print("ControlServer::fallback(\"%s\") - unknown message, args =" % path, args) +# ------------------------------------------------------------------------------------------------------------ # Main Window -class CarlaControlW(QMainWindow, ui_carla_control.Ui_CarlaControlW): + +class CarlaControlW(QMainWindow): def __init__(self, parent=None): QMainWindow.__init__(self, parent) - self.setupUi(self) + self.ui = ui_carla_control.Ui_CarlaControlW + self.ui.setupUi(self) # ------------------------------------------------------------- # Load Settings - self.settings = QSettings("Cadence", "Carla-Control") self.loadSettings() self.setStyleSheet(""" @@ -529,26 +534,29 @@ class CarlaControlW(QMainWindow, ui_carla_control.Ui_CarlaControlW): self.lo_address = "" self.lo_server = None - self.m_lastPluginName = None + self.fLastPluginName = "" + + self.fPluginCount = 0 + self.fPluginList = [] - self.m_plugin_list = [] - for x in range(MAX_DEFAULT_PLUGINS): - self.m_plugin_list.append(None) + self.fIdleTimerFast = 0 + self.fIdleTimerSlow = 0 # ------------------------------------------------------------- # Set-up GUI stuff - self.act_file_refresh.setEnabled(False) + self.ui.act_file_refresh.setEnabled(False) + self.resize(self.width(), 0) # ------------------------------------------------------------- # Connect actions to functions - self.connect(self.act_file_connect, SIGNAL("triggered()"), SLOT("slot_doConnect()")) - self.connect(self.act_file_refresh, SIGNAL("triggered()"), SLOT("slot_doRefresh()")) + self.connect(self.ui.act_file_connect, SIGNAL("triggered()"), SLOT("slot_fileConnect()")) + self.connect(self.ui.act_file_refresh, SIGNAL("triggered()"), SLOT("slot_fileRefresh()")) - self.connect(self.act_help_about, SIGNAL("triggered()"), SLOT("slot_aboutCarlaControl()")) - self.connect(self.act_help_about_qt, SIGNAL("triggered()"), app, SLOT("aboutQt()")) + self.connect(self.ui.act_help_about, SIGNAL("triggered()"), SLOT("slot_aboutCarlaControl()")) + self.connect(self.ui.act_help_about_qt, SIGNAL("triggered()"), app, SLOT("aboutQt()")) self.connect(self, SIGNAL("AddPluginStart(int, QString)"), SLOT("slot_handleAddPluginStart(int, QString)")) self.connect(self, SIGNAL("AddPluginEnd(int)"), SLOT("slot_handleAddPluginEnd(int)")) @@ -573,16 +581,17 @@ class CarlaControlW(QMainWindow, ui_carla_control.Ui_CarlaControlW): self.connect(self, SIGNAL("NoteOff(int, int, int)"), SLOT("slot_handleNoteOff(int, int, int)")) self.connect(self, SIGNAL("Exit()"), SLOT("slot_handleExit()")) - self.TIMER_GUI_STUFF = self.startTimer(50) # Peaks - self.TIMER_GUI_STUFF2 = self.startTimer(50 * 2) # LEDs and edit dialog + # Peaks + self.fIdleTimerFast = self.startTimer(50) + # LEDs and edit dialog parameters + self.fIdleTimerSlow = self.startTimer(50*2) - def remove_all(self): - for i in range(MAX_DEFAULT_PLUGINS): - if self.m_plugin_list[i]: - self.slot_handleRemovePlugin(i) + def removeAll(self): + for i in range(self.fPluginCount): + self.slot_handleRemovePlugin(i) @pyqtSlot() - def slot_doConnect(self): + def slot_fileConnect(self): global lo_target, lo_targetName if lo_target and self.lo_server: @@ -611,14 +620,14 @@ class CarlaControlW(QMainWindow, ui_carla_control.Ui_CarlaControlW): if self.lo_server: self.lo_server.start() - self.act_file_refresh.setEnabled(True) + self.ui.act_file_refresh.setEnabled(True) lo_send(lo_target, "/register", self.lo_server.getFullURL()) @pyqtSlot() - def slot_doRefresh(self): + def slot_fileRefresh(self): global lo_target if lo_target and self.lo_server: - self.remove_all() + self.removeAll() lo_send(lo_target, "/unregister") lo_send(lo_target, "/register", self.lo_server.getFullURL()) @@ -633,18 +642,35 @@ class CarlaControlW(QMainWindow, ui_carla_control.Ui_CarlaControlW): @pyqtSlot(int) def slot_handleAddPluginEnd(self, pluginId): pwidget = PluginWidget(self, pluginId) - self.w_plugins.layout().addWidget(pwidget) - self.m_plugin_list[pluginId] = pwidget + pwidget.setRefreshRate(50) + + self.ui.w_plugins.layout().addWidget(pwidget) + + self.fPluginCount += 1 + self.fPluginList.append(pwidget) @pyqtSlot(int) def slot_handleRemovePlugin(self, pluginId): - pwidget = self.m_plugin_list[pluginId] - if pwidget: - pwidget.edit_dialog.close() - pwidget.close() - pwidget.deleteLater() - self.w_plugins.layout().removeWidget(pwidget) - self.m_plugin_list[pluginId] = None + pwidget = self.fPluginList[pluginId] + if pwidget is None: + return + + self.fPluginList[pluginId] = None + self.fPluginCount -= 1 + + self.ui.w_plugins.layout().removeWidget(pwidget) + + pwidget.ui.edit_dialog.close() + pwidget.close() + pwidget.deleteLater() + del pwidget + + # push all plugins 1 slot back + for i in range(pluginId, self.fPluginCount): + self.fPluginList[i] = self.fPluginList[i+1] + self.fPluginList[i].setId(i) + + # TODO - move Carla.host.* stuff too @pyqtSlot(int, int, int, int, str, str, str, str, int) def slot_handleSetPluginData(self, pluginId, type_, category, hints, realName, label, maker, copyright, uniqueId): @@ -713,67 +739,56 @@ class CarlaControlW(QMainWindow, ui_carla_control.Ui_CarlaControlW): Carla.host._set_parameterRangeS(pluginId, index, ranges) - @pyqtSlot(int, int, int) - def slot_handleSetParameterMidiCC(self, pluginId, index, cc): - Carla.host._set_parameterMidiCC(pluginId, index, cc) - - pwidget = self.m_plugin_list[pluginId] - if pwidget: - pwidget.edit_dialog.set_parameter_midi_cc(index, cc, True) - - @pyqtSlot(int, int, int) - def slot_handleSetParameterMidiChannel(self, pluginId, index, channel): - Carla.host._set_parameterMidiChannel(pluginId, index, channel) - - pwidget = self.m_plugin_list[pluginId] - if pwidget: - pwidget.edit_dialog.set_parameter_midi_channel(index, channel, True) - @pyqtSlot(int, int, float) def slot_handleSetParameterValue(self, pluginId, parameterId, value): if parameterId >= 0: Carla.host._set_parameterValueS(pluginId, parameterId, value) - pwidget = self.m_plugin_list[pluginId] - if pwidget: - if parameterId < PARAMETER_NULL: - pwidget.m_parameterIconTimer = ICON_STATE_ON - else: - for param in pwidget.edit_dialog.m_parameterList: - if param[1] == parameterId: - if param[0] == PARAMETER_INPUT: - pwidget.m_parameterIconTimer = ICON_STATE_ON - break - - if parameterId == PARAMETER_ACTIVE: - pwidget.set_active((value > 0.0), True, False) - elif parameterId == PARAMETER_DRYWET: - pwidget.set_drywet(value * 1000, True, False) - elif parameterId == PARAMETER_VOLUME: - pwidget.set_volume(value * 1000, True, False) - elif parameterId == PARAMETER_BALANCE_LEFT: - pwidget.set_balance_left(value * 1000, True, False) - elif parameterId == PARAMETER_BALANCE_RIGHT: - pwidget.set_balance_right(value * 1000, True, False) - elif parameterId >= 0: - pwidget.edit_dialog.set_parameter_to_update(parameterId) + pwidget = self.fPluginList[pluginId] + if pwidget is None: + return + + pwidget.setParameterValue(parameterId, value) @pyqtSlot(int, int, float) def slot_handleSetDefaultValue(self, pluginId, parameterId, value): Carla.host._set_parameterDefaultValue(pluginId, parameterId, value) - #pwidget = self.m_plugin_list[pluginId] - #if pwidget: - #pwidget.edit_dialog.set_parameter_default_value(parameterId, value) + pwidget = self.fPluginList[pluginId] + if pwidget is None: + return + + pwidget.setParameterDefault(parameterId, value) + + @pyqtSlot(int, int, int) + def slot_handleSetParameterMidiCC(self, pluginId, index, cc): + Carla.host._set_parameterMidiCC(pluginId, index, cc) + + pwidget = self.fPluginList[pluginId] + if pwidget is None: + return + + pwidget.setParameterMidiControl(index, cc) + + @pyqtSlot(int, int, int) + def slot_handleSetParameterMidiChannel(self, pluginId, index, channel): + Carla.host._set_parameterMidiChannel(pluginId, index, channel) + + pwidget = self.fPluginList[pluginId] + if pwidget is None: + return + + pwidget.setParameterMidiChannel(index, channel) @pyqtSlot(int, int) def slot_handleSetProgram(self, pluginId, index): Carla.host._set_currentProgram(pluginId, index) - pwidget = self.m_plugin_list[pluginId] - if pwidget: - pwidget.edit_dialog.set_program(index) - pwidget.m_parameterIconTimer = ICON_STATE_ON + pwidget = self.fPluginList[pluginId] + if pwidget is None: + return + + pwidget.setProgram(index) @pyqtSlot(int, int) def slot_handleSetProgramCount(self, pluginId, count): @@ -787,10 +802,11 @@ class CarlaControlW(QMainWindow, ui_carla_control.Ui_CarlaControlW): def slot_handleSetMidiProgram(self, pluginId, index): Carla.host._set_currentMidiProgram(pluginId, index) - pwidget = self.m_plugin_list[pluginId] - if pwidget: - pwidget.edit_dialog.set_midi_program(index) - pwidget.m_parameterIconTimer = ICON_STATE_ON + pwidget = self.fPluginList[pluginId] + if pwidget is None: + return + + pwidget.setMidiProgram(index) @pyqtSlot(int, int) def slot_handleSetMidiProgramCount(self, pluginId, count): @@ -814,24 +830,28 @@ class CarlaControlW(QMainWindow, ui_carla_control.Ui_CarlaControlW): @pyqtSlot(int, int, int, int) def slot_handleNoteOn(self, pluginId, channel, note, velo): - pwidget = self.m_plugin_list[pluginId] - if pwidget: - pwidget.edit_dialog.keyboard.sendNoteOn(note, False) + pwidget = self.fPluginList[pluginId] + if pwidget is None: + return + + pwidget.sendNoteOn(note) @pyqtSlot(int, int, int) def slot_handleNoteOff(self, pluginId, channel, note): - pwidget = self.m_plugin_list[pluginId] - if pwidget: - pwidget.edit_dialog.keyboard.sendNoteOff(note, False) + pwidget = self.fPluginList[pluginId] + if pwidget is None: + return + + pwidget.sendNoteOff(note) @pyqtSlot() def slot_handleExit(self): - self.remove_all() + self.removeAll() if self.lo_server: self.lo_server.stop() self.lo_server = None - self.act_file_refresh.setEnabled(False) + self.ui.act_file_refresh.setEnabled(False) global lo_target, lo_targetName lo_target = None @@ -839,23 +859,31 @@ class CarlaControlW(QMainWindow, ui_carla_control.Ui_CarlaControlW): self.lo_address = "" def saveSettings(self): - self.settings.setValue("Geometry", self.saveGeometry()) - #self.settings.setValue("ShowToolbar", self.toolBar.isVisible()) + settings = QSettings() + settings.setValue("Geometry", self.saveGeometry()) + #settings.setValue("ShowToolbar", self.ui.toolBar.isVisible()) def loadSettings(self): - self.restoreGeometry(self.settings.value("Geometry", "")) + settings = QSettings() + self.restoreGeometry(settings.value("Geometry", "")) - #show_toolbar = self.settings.value("ShowToolbar", True, type=bool) - #self.act_settings_show_toolbar.setChecked(show_toolbar) - #self.toolBar.setVisible(show_toolbar) + #showToolbar = settings.value("ShowToolbar", True, type=bool) + #self.ui.act_settings_show_toolbar.setChecked(showToolbar) + #self.ui.toolBar.setVisible(showToolbar) def timerEvent(self, event): - if event.timerId() == self.TIMER_GUI_STUFF: - for pwidget in self.m_plugin_list: - if pwidget: pwidget.check_gui_stuff() - elif event.timerId() == self.TIMER_GUI_STUFF2: - for pwidget in self.m_plugin_list: - if pwidget: pwidget.check_gui_stuff2() + if event.timerId() == self.fIdleTimerFast: + for pwidget in self.fPluginList: + if pwidget is None: + break + pwidget.idleFast() + + elif event.timerId() == self.fIdleTimerSlow: + for pwidget in self.fPluginList: + if pwidget is None: + break + pwidget.idleSlow() + QMainWindow.timerEvent(self, event) def closeEvent(self, event): @@ -883,7 +911,7 @@ if __name__ == '__main__': Carla.gui = CarlaControlW() # Set-up custom signal handling - #setUpSignals(Carla.gui) + setUpSignals() # Show GUI Carla.gui.show() diff --git a/source/carla_shared.py b/source/carla_shared.py index 1f340532e..c96fe6bc5 100644 --- a/source/carla_shared.py +++ b/source/carla_shared.py @@ -759,7 +759,7 @@ def getIcon(icon, size=16): # ------------------------------------------------------------------------------------------------------------ # Signal handler -def setUpSignals(self_): +def setUpSignals(): if not haveSignal: return @@ -2176,14 +2176,20 @@ class PluginWidget(QFrame): def setParameterMidiChannel(self, parameterId, channel): self.ui.edit_dialog.setParameterMidiChannel(parameterId, channel) - def setProgram(self, parameterId, index): + def setProgram(self, index): self.fParameterIconTimer = ICON_STATE_ON self.ui.edit_dialog.setProgram(index) - def setMidiProgram(self, parameterId, index): + def setMidiProgram(self, index): self.fParameterIconTimer = ICON_STATE_ON self.ui.edit_dialog.setMidiProgram(index) + def sendNoteOn(self, note): + self.ui.edit_dialog.ui.keyboard.sendNoteOn(note, False) + + def sendNoteOff(self, note): + self.ui.edit_dialog.ui.keyboard.sendNoteOff(note, False) + def setId(self, idx): self.fPluginId = idx self.ui.edit_dialog.fPluginId = idx