From 345352c1f5e0f024019ff7065edede62d83c8d28 Mon Sep 17 00:00:00 2001 From: falkTX Date: Tue, 2 Sep 2014 14:37:19 +0100 Subject: [PATCH] Continue previous work, more or less working; Still needs more --- source/carla | 78 +- source/carla_backend.py | 55 +- source/carla_host.py | 933 ++++++++---------- source/carla_patchbay.py | 52 +- source/carla_rack.py | 33 +- .../native-plugins/resources/carla-plugin | 103 +- 6 files changed, 594 insertions(+), 660 deletions(-) diff --git a/source/carla b/source/carla index 25d136feb..3ecfdc540 100755 --- a/source/carla +++ b/source/carla @@ -45,6 +45,13 @@ class CarlaMultiW(QTabWidget): def __init__(self, parent, host): QTabWidget.__init__(self, parent) + if False: + # kdevelop likes this :) + host = CarlaHostMeta() + self.host = host + + # ------------------------------------------------------------- + self.fRack = CarlaRackW(parent, host, False) self.fPatchbay = CarlaPatchbayW(parent, host, False, False) self.fParent = parent @@ -84,36 +91,36 @@ class CarlaMultiW(QTabWidget): parent.ui.act_settings_configure.triggered.connect(self.fPatchbay.slot_configureCarla) - parent.ParameterValueChangedCallback.connect(self.fRack.slot_handleParameterValueChangedCallback) - parent.ParameterValueChangedCallback.connect(self.fPatchbay.slot_handleParameterValueChangedCallback) - parent.ParameterDefaultChangedCallback.connect(self.fRack.slot_handleParameterDefaultChangedCallback) - parent.ParameterMidiChannelChangedCallback.connect(self.fRack.slot_handleParameterMidiChannelChangedCallback) - parent.ParameterMidiCcChangedCallback.connect(self.fRack.slot_handleParameterMidiCcChangedCallback) - parent.ProgramChangedCallback.connect(self.fRack.slot_handleProgramChangedCallback) - parent.MidiProgramChangedCallback.connect(self.fRack.slot_handleMidiProgramChangedCallback) - parent.OptionChangedCallback.connect(self.fRack.slot_handleOptionChangedCallback) - parent.UiStateChangedCallback.connect(self.fRack.slot_handleUiStateChangedCallback) - parent.NoteOnCallback.connect(self.fRack.slot_handleNoteOnCallback) - parent.NoteOnCallback.connect(self.fPatchbay.slot_handleNoteOnCallback) - parent.NoteOffCallback.connect(self.fRack.slot_handleNoteOffCallback) - parent.NoteOffCallback.connect(self.fPatchbay.slot_handleNoteOffCallback) - parent.UpdateCallback.connect(self.fRack.slot_handleUpdateCallback) - parent.ReloadInfoCallback.connect(self.fRack.slot_handleReloadInfoCallback) - parent.ReloadParametersCallback.connect(self.fRack.slot_handleReloadParametersCallback) - parent.ReloadParametersCallback.connect(self.fPatchbay.slot_handleReloadParametersCallback) - parent.ReloadProgramsCallback.connect(self.fRack.slot_handleReloadProgramsCallback) - parent.ReloadAllCallback.connect(self.fRack.slot_handleReloadAllCallback) - parent.ReloadAllCallback.connect(self.fPatchbay.slot_handleReloadAllCallback) - - parent.PatchbayClientAddedCallback.connect(self.fPatchbay.slot_handlePatchbayClientAddedCallback) - parent.PatchbayClientRemovedCallback.connect(self.fPatchbay.slot_handlePatchbayClientRemovedCallback) - parent.PatchbayClientRenamedCallback.connect(self.fPatchbay.slot_handlePatchbayClientRenamedCallback) - parent.PatchbayClientDataChangedCallback.connect(self.fPatchbay.slot_handlePatchbayClientDataChangedCallback) - parent.PatchbayPortAddedCallback.connect(self.fPatchbay.slot_handlePatchbayPortAddedCallback) - parent.PatchbayPortRemovedCallback.connect(self.fPatchbay.slot_handlePatchbayPortRemovedCallback) - parent.PatchbayPortRenamedCallback.connect(self.fPatchbay.slot_handlePatchbayPortRenamedCallback) - parent.PatchbayConnectionAddedCallback.connect(self.fPatchbay.slot_handlePatchbayConnectionAddedCallback) - parent.PatchbayConnectionRemovedCallback.connect(self.fPatchbay.slot_handlePatchbayConnectionRemovedCallback) + host.ParameterValueChangedCallback.connect(self.fRack.slot_handleParameterValueChangedCallback) + host.ParameterValueChangedCallback.connect(self.fPatchbay.slot_handleParameterValueChangedCallback) + host.ParameterDefaultChangedCallback.connect(self.fRack.slot_handleParameterDefaultChangedCallback) + host.ParameterMidiChannelChangedCallback.connect(self.fRack.slot_handleParameterMidiChannelChangedCallback) + host.ParameterMidiCcChangedCallback.connect(self.fRack.slot_handleParameterMidiCcChangedCallback) + host.ProgramChangedCallback.connect(self.fRack.slot_handleProgramChangedCallback) + host.MidiProgramChangedCallback.connect(self.fRack.slot_handleMidiProgramChangedCallback) + host.OptionChangedCallback.connect(self.fRack.slot_handleOptionChangedCallback) + host.UiStateChangedCallback.connect(self.fRack.slot_handleUiStateChangedCallback) + host.NoteOnCallback.connect(self.fRack.slot_handleNoteOnCallback) + host.NoteOnCallback.connect(self.fPatchbay.slot_handleNoteOnCallback) + host.NoteOffCallback.connect(self.fRack.slot_handleNoteOffCallback) + host.NoteOffCallback.connect(self.fPatchbay.slot_handleNoteOffCallback) + host.UpdateCallback.connect(self.fRack.slot_handleUpdateCallback) + host.ReloadInfoCallback.connect(self.fRack.slot_handleReloadInfoCallback) + host.ReloadParametersCallback.connect(self.fRack.slot_handleReloadParametersCallback) + host.ReloadParametersCallback.connect(self.fPatchbay.slot_handleReloadParametersCallback) + host.ReloadProgramsCallback.connect(self.fRack.slot_handleReloadProgramsCallback) + host.ReloadAllCallback.connect(self.fRack.slot_handleReloadAllCallback) + host.ReloadAllCallback.connect(self.fPatchbay.slot_handleReloadAllCallback) + + host.PatchbayClientAddedCallback.connect(self.fPatchbay.slot_handlePatchbayClientAddedCallback) + host.PatchbayClientRemovedCallback.connect(self.fPatchbay.slot_handlePatchbayClientRemovedCallback) + host.PatchbayClientRenamedCallback.connect(self.fPatchbay.slot_handlePatchbayClientRenamedCallback) + host.PatchbayClientDataChangedCallback.connect(self.fPatchbay.slot_handlePatchbayClientDataChangedCallback) + host.PatchbayPortAddedCallback.connect(self.fPatchbay.slot_handlePatchbayPortAddedCallback) + host.PatchbayPortRemovedCallback.connect(self.fPatchbay.slot_handlePatchbayPortRemovedCallback) + host.PatchbayPortRenamedCallback.connect(self.fPatchbay.slot_handlePatchbayPortRenamedCallback) + host.PatchbayConnectionAddedCallback.connect(self.fPatchbay.slot_handlePatchbayConnectionAddedCallback) + host.PatchbayConnectionRemovedCallback.connect(self.fPatchbay.slot_handlePatchbayConnectionRemovedCallback) # ----------------------------------------------------------------- @@ -143,18 +150,15 @@ class CarlaMultiW(QTabWidget): # ----------------------------------------------------------------- def engineStarted(self): + pass #self.fRack.engineStarted() #self.fPatchbay.engineStarted() - self.fParent.engineChanged() def engineStopped(self): #self.fRack.engineStopped() self.fPatchbay.engineStopped() self.fParent.engineStopped() - def engineChanged(self): - self.fParent.engineChanged() - # ----------------------------------------------------------------- def idleFast(self): @@ -257,9 +261,9 @@ class CarlaHostW(HostWindow): self.fInfoText = "" self.fInfoLabel.setText("Engine stopped") - def engineChanged(self): - self.fInfoText = "Engine running | SampleRate: %g | BufferSize: %i" % (gCarla.sampleRate, gCarla.bufferSize) - self.fInfoLabel.setText("%s | %s" % (self.fInfoText, self.fTextTransport)) + #def engineChanged(self): + #self.fInfoText = "Engine running | SampleRate: %g | BufferSize: %i" % (gCarla.sampleRate, gCarla.bufferSize) + #self.fInfoLabel.setText("%s | %s" % (self.fInfoText, self.fTextTransport)) # ----------------------------------------------------------------- diff --git a/source/carla_backend.py b/source/carla_backend.py index 32889bfd9..a7f4bad64 100644 --- a/source/carla_backend.py +++ b/source/carla_backend.py @@ -16,6 +16,11 @@ # # For a full copy of the GNU General Public License see the doc/GPL.txt file. +# ------------------------------------------------------------------------------------------------------------ +# Imports (Config) + +from carla_config import * + # ------------------------------------------------------------------------------------------------------------ # Imports (Global) @@ -25,6 +30,11 @@ from os import environ from platform import architecture from sys import platform, maxsize +if config_UseQt5: + from PyQt5.QtCore import pyqtSignal, QObject +else: + from PyQt4.QtCore import pyqtSignal, QObject + # ------------------------------------------------------------------------------------------------------------ # 64bit check @@ -1237,9 +1247,50 @@ else: # ------------------------------------------------------------------------------------------------------------ # Carla Host object (Meta) -class CarlaHostMeta(object): -#class CarlaHostMeta(metaclass=ABCMeta): +class CarlaHostMeta(QObject): +#class CarlaHostMeta(QObject, metaclass=ABCMeta): + # signals + DebugCallback = pyqtSignal(int, int, int, float, str) + PluginAddedCallback = pyqtSignal(int, str) + PluginRemovedCallback = pyqtSignal(int) + PluginRenamedCallback = pyqtSignal(int, str) + PluginUnavailableCallback = pyqtSignal(int, str) + ParameterValueChangedCallback = pyqtSignal(int, int, float) + ParameterDefaultChangedCallback = pyqtSignal(int, int, float) + ParameterMidiCcChangedCallback = pyqtSignal(int, int, int) + ParameterMidiChannelChangedCallback = pyqtSignal(int, int, int) + ProgramChangedCallback = pyqtSignal(int, int) + MidiProgramChangedCallback = pyqtSignal(int, int) + OptionChangedCallback = pyqtSignal(int, int, bool) + UiStateChangedCallback = pyqtSignal(int, int) + NoteOnCallback = pyqtSignal(int, int, int, int) + NoteOffCallback = pyqtSignal(int, int, int) + UpdateCallback = pyqtSignal(int) + ReloadInfoCallback = pyqtSignal(int) + ReloadParametersCallback = pyqtSignal(int) + ReloadProgramsCallback = pyqtSignal(int) + ReloadAllCallback = pyqtSignal(int) + PatchbayClientAddedCallback = pyqtSignal(int, int, int, str) + PatchbayClientRemovedCallback = pyqtSignal(int) + PatchbayClientRenamedCallback = pyqtSignal(int, str) + PatchbayClientDataChangedCallback = pyqtSignal(int, int, int) + PatchbayPortAddedCallback = pyqtSignal(int, int, int, str) + PatchbayPortRemovedCallback = pyqtSignal(int, int) + PatchbayPortRenamedCallback = pyqtSignal(int, int, str) + PatchbayConnectionAddedCallback = pyqtSignal(int, int, int, int, int) + PatchbayConnectionRemovedCallback = pyqtSignal(int, int, int) + EngineStartedCallback = pyqtSignal(int, int, str) + EngineStoppedCallback = pyqtSignal() + ProcessModeChangedCallback = pyqtSignal(int) + TransportModeChangedCallback = pyqtSignal(int) + BufferSizeChangedCallback = pyqtSignal(int) + SampleRateChangedCallback = pyqtSignal(float) + InfoCallback = pyqtSignal(str) + ErrorCallback = pyqtSignal(str) + QuitCallback = pyqtSignal() + def __init__(self): + QObject.__init__(self) # info about this host object self.isControl = False diff --git a/source/carla_host.py b/source/carla_host.py index aa942074a..a2358b73e 100644 --- a/source/carla_host.py +++ b/source/carla_host.py @@ -57,113 +57,63 @@ NSM_URL = os.getenv("NSM_URL") # ------------------------------------------------------------------------------------------------------------ # Dummy widget -class CarlaDummyW(object): - def __init__(self, parent): - object.__init__(self) +class HostWidgetMeta(object): +#class HostWidgetMeta(metaclass=ABCMeta): - # ----------------------------------------------------------------- + # -------------------------------------------------------------------------------------------------------- def getPluginCount(self): - return 0 - - # ----------------------------------------------------------------- + raise NotImplementedError def addPlugin(self, pluginId, isProjectLoading): - pass + raise NotImplementedError def removePlugin(self, pluginId): - pass + raise NotImplementedError def renamePlugin(self, pluginId, newName): - pass + raise NotImplementedError def disablePlugin(self, pluginId, errorMsg): - pass + raise NotImplementedError def removeAllPlugins(self): - pass - - # ----------------------------------------------------------------- + raise NotImplementedError def engineStarted(self): - pass + raise NotImplementedError def engineStopped(self): - pass - - def engineChanged(self): - pass - - # ----------------------------------------------------------------- + raise NotImplementedError def idleFast(self): - pass + raise NotImplementedError def idleSlow(self): - pass - - # ----------------------------------------------------------------- + raise NotImplementedError def projectLoadingStarted(self): - pass + raise NotImplementedError def projectLoadingFinished(self): - pass - - # ----------------------------------------------------------------- + raise NotImplementedError def saveSettings(self, settings): - pass + raise NotImplementedError def showEditDialog(self, pluginId): - pass + raise NotImplementedError # ------------------------------------------------------------------------------------------------------------ # Host Window class HostWindow(QMainWindow): # signals - DebugCallback = pyqtSignal(int, int, int, float, str) - PluginAddedCallback = pyqtSignal(int, str) - PluginRemovedCallback = pyqtSignal(int) - PluginRenamedCallback = pyqtSignal(int, str) - PluginUnavailableCallback = pyqtSignal(int, str) - ParameterValueChangedCallback = pyqtSignal(int, int, float) - ParameterDefaultChangedCallback = pyqtSignal(int, int, float) - ParameterMidiCcChangedCallback = pyqtSignal(int, int, int) - ParameterMidiChannelChangedCallback = pyqtSignal(int, int, int) - ProgramChangedCallback = pyqtSignal(int, int) - MidiProgramChangedCallback = pyqtSignal(int, int) - OptionChangedCallback = pyqtSignal(int, int, bool) - UiStateChangedCallback = pyqtSignal(int, int) - NoteOnCallback = pyqtSignal(int, int, int, int) - NoteOffCallback = pyqtSignal(int, int, int) - UpdateCallback = pyqtSignal(int) - ReloadInfoCallback = pyqtSignal(int) - ReloadParametersCallback = pyqtSignal(int) - ReloadProgramsCallback = pyqtSignal(int) - ReloadAllCallback = pyqtSignal(int) - PatchbayClientAddedCallback = pyqtSignal(int, int, int, str) - PatchbayClientRemovedCallback = pyqtSignal(int) - PatchbayClientRenamedCallback = pyqtSignal(int, str) - PatchbayClientDataChangedCallback = pyqtSignal(int, int, int) - PatchbayPortAddedCallback = pyqtSignal(int, int, int, str) - PatchbayPortRemovedCallback = pyqtSignal(int, int) - PatchbayPortRenamedCallback = pyqtSignal(int, int, str) - PatchbayConnectionAddedCallback = pyqtSignal(int, int, int, int, int) - PatchbayConnectionRemovedCallback = pyqtSignal(int, int, int) - EngineStartedCallback = pyqtSignal(int, int, str) - EngineStoppedCallback = pyqtSignal() - ProcessModeChangedCallback = pyqtSignal(int) - TransportModeChangedCallback = pyqtSignal(int) - BufferSizeChangedCallback = pyqtSignal(int) - SampleRateChangedCallback = pyqtSignal(float) - InfoCallback = pyqtSignal(str) - ErrorCallback = pyqtSignal(str) - QuitCallback = pyqtSignal() SIGTERM = pyqtSignal() SIGUSR1 = pyqtSignal() + # -------------------------------------------------------------------------------------------------------- + def __init__(self, host): QMainWindow.__init__(self) self.host = host @@ -173,28 +123,18 @@ class HostWindow(QMainWindow): if False: # kdevelop likes this :) host = CarlaHostMeta() - self.host = CarlaHostMeta() + self.host = host + self.fContainer = HostWidgetMeta(self, host) gCarla.gui = self - self.fContainer = CarlaDummyW(self) - - if MACOS and config_UseQt5: - self.ui.act_file_quit.setMenuRole(QAction.QuitRole) - self.ui.act_settings_configure.setMenuRole(QAction.PreferencesRole) - self.ui.act_help_about.setMenuRole(QAction.AboutRole) - self.ui.act_help_about_juce.setMenuRole(QAction.AboutRole) - self.ui.act_help_about_qt.setMenuRole(QAction.AboutQtRole) - self.ui.menu_Settings.setTitle("Panels") - #self.ui.menu_Help.hide() - # ------------------------------------------------------------- + # ---------------------------------------------------------------------------------------------------- # Internal stuff + self.fSampleRate = 0.0 + self.fIdleTimerFast = 0 self.fIdleTimerSlow = 0 - self.fIsProjectLoading = False - self.fProjectFilename = "" - self.fLadspaRdfNeedsUpdate = True self.fLadspaRdfList = [] @@ -202,15 +142,16 @@ class HostWindow(QMainWindow): self.fLastTransportState = False self.fTransportText = "" - # when true, call engineChanged() asap - self.fEngineChanged = False + self.fProjectFilename = "" + self.fIsProjectLoading = False # first attempt of auto-start engine doesn't show an error self.fFirstEngineInit = True + # to be filled with key-value pairs of current settings self.fSavedSettings = {} - if self.host.isPlugin: + if host.isPlugin: self.fClientName = "Carla-Plugin" self.fSessionManagerName = "Plugin" elif LADISH_APP_NAME: @@ -223,12 +164,7 @@ class HostWindow(QMainWindow): self.fClientName = "Carla" self.fSessionManagerName = "" - # ------------------------------------------------------------- - # Load Settings - - self.loadSettings(True) - - # ------------------------------------------------------------- + # ---------------------------------------------------------------------------------------------------- # Set up GUI (engine stopped) if self.host.isPlugin: @@ -246,10 +182,6 @@ class HostWindow(QMainWindow): self.ui.act_engine_stop.setEnabled(False) self.ui.act_plugin_remove_all.setEnabled(False) - #if gCarla.externalPatchbay: - #self.ui.act_canvas_show_internal.setChecked(False) - #self.ui.act_canvas_show_external.setChecked(True) - #else: self.ui.act_canvas_show_internal.setChecked(True) self.ui.act_canvas_show_external.setChecked(False) @@ -261,7 +193,7 @@ class HostWindow(QMainWindow): self.setTransportMenuEnabled(False) - # ------------------------------------------------------------- + # ---------------------------------------------------------------------------------------------------- # Set up GUI (disk) self.fDirModel = QFileSystemModel(self) @@ -275,21 +207,24 @@ class HostWindow(QMainWindow): self.ui.fileTreeView.setColumnHidden(3, True) self.ui.fileTreeView.setHeaderHidden(True) - # ------------------------------------------------------------- - # Set up GUI (disk) + # ---------------------------------------------------------------------------------------------------- + # Set up GUI (special stuff for Mac OS) - #self.item1 = QListWidgetItem(self.ui.lw_plugins) - #self.item1.setFlags(Qt.ItemIsSelectable|Qt.ItemIsEnabled|Qt.ItemIsDragEnabled) - #self.item1.setIcon(QIcon(":/bitmaps/thumbs/zita-rev1.png")) - #self.item1.setText("zita-rev1") - #item1.setTextAlignment(Qt.ali) - #self.ui.lw_plugins.() + if MACOS and config_UseQt5: + self.ui.act_file_quit.setMenuRole(QAction.QuitRole) + self.ui.act_settings_configure.setMenuRole(QAction.PreferencesRole) + self.ui.act_help_about.setMenuRole(QAction.AboutRole) + self.ui.act_help_about_juce.setMenuRole(QAction.AboutRole) + self.ui.act_help_about_qt.setMenuRole(QAction.AboutQtRole) + self.ui.menu_Settings.setTitle("Panels") + #self.ui.menu_Help.hide() - # ------------------------------------------------------------- + # ---------------------------------------------------------------------------------------------------- + # Load Settings - self.setProperWindowTitle() + self.loadSettings(True) - # ------------------------------------------------------------- + # ---------------------------------------------------------------------------------------------------- # Connect actions to functions self.ui.act_file_new.triggered.connect(self.slot_fileNew) @@ -318,12 +253,15 @@ class HostWindow(QMainWindow): self.ui.b_disk_remove.clicked.connect(self.slot_diskFolderRemove) self.ui.fileTreeView.doubleClicked.connect(self.slot_fileTreeDoubleClicked) - self.DebugCallback.connect(self.slot_handleDebugCallback) + self.SIGUSR1.connect(self.slot_handleSIGUSR1) + self.SIGTERM.connect(self.slot_handleSIGTERM) - self.PluginAddedCallback.connect(self.slot_handlePluginAddedCallback) - self.PluginRemovedCallback.connect(self.slot_handlePluginRemovedCallback) - self.PluginRenamedCallback.connect(self.slot_handlePluginRenamedCallback) - self.PluginUnavailableCallback.connect(self.slot_handlePluginUnavailableCallback) + host.DebugCallback.connect(self.slot_handleDebugCallback) + + host.PluginAddedCallback.connect(self.slot_handlePluginAddedCallback) + host.PluginRemovedCallback.connect(self.slot_handlePluginRemovedCallback) + host.PluginRenamedCallback.connect(self.slot_handlePluginRenamedCallback) + host.PluginUnavailableCallback.connect(self.slot_handlePluginUnavailableCallback) # parameter (rack, patchbay) # program, midi-program, ui-state (rack, patchbay) @@ -331,28 +269,34 @@ class HostWindow(QMainWindow): # update, reload (rack, patchbay) # patchbay - self.EngineStartedCallback.connect(self.slot_handleEngineStartedCallback) - self.EngineStoppedCallback.connect(self.slot_handleEngineStoppedCallback) - - self.ProcessModeChangedCallback.connect(self.slot_handleProcessModeChangedCallback) - self.TransportModeChangedCallback.connect(self.slot_handleTransportModeChangedCallback) + host.EngineStartedCallback.connect(self.slot_handleEngineStartedCallback) + host.EngineStoppedCallback.connect(self.slot_handleEngineStoppedCallback) - self.BufferSizeChangedCallback.connect(self.slot_handleBufferSizeChangedCallback) - self.SampleRateChangedCallback.connect(self.slot_handleSampleRateChangedCallback) + host.SampleRateChangedCallback.connect(self.slot_handleSampleRateChangedCallback) - self.InfoCallback.connect(self.slot_handleInfoCallback) - self.ErrorCallback.connect(self.slot_handleErrorCallback) - self.QuitCallback.connect(self.slot_handleQuitCallback) + host.InfoCallback.connect(self.slot_handleInfoCallback) + host.ErrorCallback.connect(self.slot_handleErrorCallback) + host.QuitCallback.connect(self.slot_handleQuitCallback) - self.SIGUSR1.connect(self.slot_handleSIGUSR1) - self.SIGTERM.connect(self.slot_handleSIGTERM) - - # ------------------------------------------------------------- + # ---------------------------------------------------------------------------------------------------- # Final setup + self.setProperWindowTitle() QTimer.singleShot(0, self.slot_engineStart) - # ----------------------------------------------------------------- + # -------------------------------------------------------------------------------------------------------- + + def setProperWindowTitle(self): + title = self.fClientName + + if self.fProjectFilename: + title += " - %s" % os.path.basename(self.fProjectFilename) + if self.fSessionManagerName: + title += " (%s)" % self.fSessionManagerName + + self.setWindowTitle(title) + + # -------------------------------------------------------------------------------------------------------- # Called by containers def openSettingsWindow(self, hasCanvas, hasCanvasGL): @@ -390,7 +334,7 @@ class HostWindow(QMainWindow): self.ui.miniCanvasPreview.setViewTheme(canvasBg, canvasBrush, canvasPen) self.ui.miniCanvasPreview.init(self.fContainer.scene, canvasWidth, canvasHeight, self.fSavedSettings[CARLA_KEY_CUSTOM_PAINTING]) - # ----------------------------------------------------------------- + # -------------------------------------------------------------------------------------------------------- # Internal stuff (files) def loadProjectNow(self): @@ -405,10 +349,6 @@ class HostWindow(QMainWindow): self.fIsProjectLoading = False self.fContainer.projectLoadingFinished() - @pyqtSlot() - def slot_loadProjectNow(self): - self.loadProjectNow() - def loadProjectLater(self, filename): self.fProjectFilename = QFileInfo(filename).absoluteFilePath() self.setProperWindowTitle() @@ -420,143 +360,95 @@ class HostWindow(QMainWindow): self.host.save_project(self.fProjectFilename) - # ----------------------------------------------------------------- - # Internal stuff (engine) - - def setEngineSettings(self, settings = None): - if settings is None: settings = QSettings() - - # ------------------------------------------------------------- - # read settings (engine base) - - # bool values - try: - forceStereo = settings.value(CARLA_KEY_ENGINE_FORCE_STEREO, CARLA_DEFAULT_FORCE_STEREO, type=bool) - except: - forceStereo = CARLA_DEFAULT_FORCE_STEREO - - try: - preferPluginBridges = settings.value(CARLA_KEY_ENGINE_PREFER_PLUGIN_BRIDGES, CARLA_DEFAULT_PREFER_PLUGIN_BRIDGES, type=bool) - except: - preferPluginBridges = CARLA_DEFAULT_PREFER_PLUGIN_BRIDGES - - try: - preferUiBridges = settings.value(CARLA_KEY_ENGINE_PREFER_UI_BRIDGES, CARLA_DEFAULT_PREFER_UI_BRIDGES, type=bool) - except: - preferUiBridges = CARLA_DEFAULT_PREFER_UI_BRIDGES - - try: - uisAlwaysOnTop = settings.value(CARLA_KEY_ENGINE_UIS_ALWAYS_ON_TOP, CARLA_DEFAULT_UIS_ALWAYS_ON_TOP, type=bool) - except: - uisAlwaysOnTop = CARLA_DEFAULT_UIS_ALWAYS_ON_TOP - - # int values - try: - maxParameters = settings.value(CARLA_KEY_ENGINE_MAX_PARAMETERS, CARLA_DEFAULT_MAX_PARAMETERS, type=int) - except: - maxParameters = CARLA_DEFAULT_MAX_PARAMETERS - - try: - uiBridgesTimeout = settings.value(CARLA_KEY_ENGINE_UI_BRIDGES_TIMEOUT, CARLA_DEFAULT_UI_BRIDGES_TIMEOUT, type=int) - except: - uiBridgesTimeout = CARLA_DEFAULT_UI_BRIDGES_TIMEOUT - - # ------------------------------------------------------------- - # read settings (plugin paths) + # -------------------------------------------------------------------------------------------------------- - LADSPA_PATH = toList(settings.value(CARLA_KEY_PATHS_LADSPA, CARLA_DEFAULT_LADSPA_PATH)) - DSSI_PATH = toList(settings.value(CARLA_KEY_PATHS_DSSI, CARLA_DEFAULT_DSSI_PATH)) - LV2_PATH = toList(settings.value(CARLA_KEY_PATHS_LV2, CARLA_DEFAULT_LV2_PATH)) - VST_PATH = toList(settings.value(CARLA_KEY_PATHS_VST, CARLA_DEFAULT_VST_PATH)) - VST3_PATH = toList(settings.value(CARLA_KEY_PATHS_VST3, CARLA_DEFAULT_VST3_PATH)) - AU_PATH = toList(settings.value(CARLA_KEY_PATHS_AU, CARLA_DEFAULT_AU_PATH)) - GIG_PATH = toList(settings.value(CARLA_KEY_PATHS_GIG, CARLA_DEFAULT_GIG_PATH)) - SF2_PATH = toList(settings.value(CARLA_KEY_PATHS_SF2, CARLA_DEFAULT_SF2_PATH)) - SFZ_PATH = toList(settings.value(CARLA_KEY_PATHS_SFZ, CARLA_DEFAULT_SFZ_PATH)) + @pyqtSlot() + def slot_fileNew(self): + self.fContainer.removeAllPlugins() + self.fProjectFilename = "" + self.setProperWindowTitle() - # ------------------------------------------------------------- - # read settings (other) + @pyqtSlot() + def slot_fileOpen(self): + fileFilter = self.tr("Carla Project File (*.carxp)") + filename = QFileDialog.getOpenFileName(self, self.tr("Open Carla Project File"), self.fSavedSettings[CARLA_KEY_MAIN_PROJECT_FOLDER], filter=fileFilter) - # int values - try: - useCustomSkins = settings.value(CARLA_KEY_MAIN_USE_CUSTOM_SKINS, CARLA_DEFAULT_MAIN_USE_CUSTOM_SKINS, type=bool) - except: - useCustomSkins = CARLA_DEFAULT_MAIN_USE_CUSTOM_SKINS + if config_UseQt5: + filename = filename[0] + if not filename: + return - # ------------------------------------------------------------- - # read settings (engine advanced) + newFile = True - if self.host.isPlugin: - audioDriver = "Plugin" + if self.fContainer.getPluginCount() > 0: + ask = QMessageBox.question(self, self.tr("Question"), self.tr("There are some plugins loaded, do you want to remove them now?"), + QMessageBox.Yes | QMessageBox.No, QMessageBox.No) + newFile = (ask == QMessageBox.Yes) + if newFile: + self.fContainer.removeAllPlugins() + self.fProjectFilename = filename + self.setProperWindowTitle() + self.loadProjectNow() else: - # enums - try: - processMode = settings.value(CARLA_KEY_ENGINE_PROCESS_MODE, CARLA_DEFAULT_PROCESS_MODE, type=int) - except: - processMode = CARLA_DEFAULT_PROCESS_MODE + filenameOld = self.fProjectFilename + self.fProjectFilename = filename + self.loadProjectNow() + self.fProjectFilename = filenameOld - try: - transportMode = settings.value(CARLA_KEY_ENGINE_TRANSPORT_MODE, CARLA_DEFAULT_TRANSPORT_MODE, type=int) - except: - transportMode = CARLA_DEFAULT_TRANSPORT_MODE + @pyqtSlot() + def slot_fileSave(self, saveAs=False): + if self.fProjectFilename and not saveAs: + return self.saveProjectNow() - # driver name - try: - audioDriver = settings.value(CARLA_KEY_ENGINE_AUDIO_DRIVER, CARLA_DEFAULT_AUDIO_DRIVER, type=str) - except: - audioDriver = CARLA_DEFAULT_AUDIO_DRIVER + fileFilter = self.tr("Carla Project File (*.carxp)") + filename = QFileDialog.getSaveFileName(self, self.tr("Save Carla Project File"), self.fSavedSettings[CARLA_KEY_MAIN_PROJECT_FOLDER], filter=fileFilter) - # driver options - try: - audioDevice = settings.value("%s%s/Device" % (CARLA_KEY_ENGINE_DRIVER_PREFIX, audioDriver), "", type=str) - except: - audioDevice = "" + if config_UseQt5: + filename = filename[0] + if not filename: + return - try: - audioNumPeriods = settings.value("%s%s/NumPeriods" % (CARLA_KEY_ENGINE_DRIVER_PREFIX, audioDriver), CARLA_DEFAULT_AUDIO_NUM_PERIODS, type=int) - except: - audioNumPeriods = CARLA_DEFAULT_AUDIO_NUM_PERIODS + if not filename.lower().endswith(".carxp"): + filename += ".carxp" - try: - audioBufferSize = settings.value("%s%s/BufferSize" % (CARLA_KEY_ENGINE_DRIVER_PREFIX, audioDriver), CARLA_DEFAULT_AUDIO_BUFFER_SIZE, type=int) - except: - audioBufferSize = CARLA_DEFAULT_AUDIO_BUFFER_SIZE + if self.fProjectFilename != filename: + self.fProjectFilename = filename + self.setProperWindowTitle() - try: - audioSampleRate = settings.value("%s%s/SampleRate" % (CARLA_KEY_ENGINE_DRIVER_PREFIX, audioDriver), CARLA_DEFAULT_AUDIO_SAMPLE_RATE, type=int) - except: - audioSampleRate = CARLA_DEFAULT_AUDIO_SAMPLE_RATE + self.saveProjectNow() - # ------------------------------------------------------------- - # fix things if needed + @pyqtSlot() + def slot_fileSaveAs(self): + self.slot_fileSave(True) - if processMode == ENGINE_PROCESS_MODE_CONTINUOUS_RACK: - forceStereo = True - elif processMode == ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS and LADISH_APP_NAME: - print("LADISH detected but using multiple clients (not allowed), forcing single client now") - processMode = ENGINE_PROCESS_MODE_SINGLE_CLIENT + @pyqtSlot() + def slot_loadProjectNow(self): + self.loadProjectNow() - if audioDriver != "JACK" and transportMode == ENGINE_TRANSPORT_MODE_JACK: - transportMode = ENGINE_TRANSPORT_MODE_INTERNAL + # -------------------------------------------------------------------------------------------------------- + # Internal stuff (engine) - if self.host.isPlugin: - processMode = self.host.processMode + def setEngineSettings(self): + settings = QSettings("falkTX", "Carla2") - # ------------------------------------------------------------- - # save this for later + # ---------------------------------------------------------------------------------------------------- + # main settings - self.host.maxParameters = maxParameters + setHostSettings(self.host) - # ------------------------------------------------------------- - # apply settings + # ---------------------------------------------------------------------------------------------------- + # plugin paths - self.host.set_engine_option(ENGINE_OPTION_FORCE_STEREO, forceStereo, "") - self.host.set_engine_option(ENGINE_OPTION_PREFER_PLUGIN_BRIDGES, preferPluginBridges, "") - self.host.set_engine_option(ENGINE_OPTION_PREFER_UI_BRIDGES, preferUiBridges, "") - self.host.set_engine_option(ENGINE_OPTION_UIS_ALWAYS_ON_TOP, uisAlwaysOnTop, "") - self.host.set_engine_option(ENGINE_OPTION_MAX_PARAMETERS, maxParameters, "") - self.host.set_engine_option(ENGINE_OPTION_UI_BRIDGES_TIMEOUT, uiBridgesTimeout, "") + LADSPA_PATH = toList(settings.value(CARLA_KEY_PATHS_LADSPA, CARLA_DEFAULT_LADSPA_PATH)) + DSSI_PATH = toList(settings.value(CARLA_KEY_PATHS_DSSI, CARLA_DEFAULT_DSSI_PATH)) + LV2_PATH = toList(settings.value(CARLA_KEY_PATHS_LV2, CARLA_DEFAULT_LV2_PATH)) + VST_PATH = toList(settings.value(CARLA_KEY_PATHS_VST, CARLA_DEFAULT_VST_PATH)) + VST3_PATH = toList(settings.value(CARLA_KEY_PATHS_VST3, CARLA_DEFAULT_VST3_PATH)) + AU_PATH = toList(settings.value(CARLA_KEY_PATHS_AU, CARLA_DEFAULT_AU_PATH)) + GIG_PATH = toList(settings.value(CARLA_KEY_PATHS_GIG, CARLA_DEFAULT_GIG_PATH)) + SF2_PATH = toList(settings.value(CARLA_KEY_PATHS_SF2, CARLA_DEFAULT_SF2_PATH)) + SFZ_PATH = toList(settings.value(CARLA_KEY_PATHS_SFZ, CARLA_DEFAULT_SFZ_PATH)) self.host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_LADSPA, splitter.join(LADSPA_PATH)) self.host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_DSSI, splitter.join(DSSI_PATH)) @@ -568,20 +460,60 @@ class HostWindow(QMainWindow): self.host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_SF2, splitter.join(SF2_PATH)) self.host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_SFZ, splitter.join(SFZ_PATH)) - if not self.host.isPlugin: - self.host.set_engine_option(ENGINE_OPTION_PROCESS_MODE, processMode, "") - self.host.set_engine_option(ENGINE_OPTION_TRANSPORT_MODE, transportMode, "") + # ---------------------------------------------------------------------------------------------------- + # don't continue if plugin + + if self.host.isPlugin: + return "Plugin" + + # ---------------------------------------------------------------------------------------------------- + # driver and device settings + + # driver name + try: + audioDriver = settings.value(CARLA_KEY_ENGINE_AUDIO_DRIVER, CARLA_DEFAULT_AUDIO_DRIVER, type=str) + except: + audioDriver = CARLA_DEFAULT_AUDIO_DRIVER + + # driver options + try: + audioDevice = settings.value("%s%s/Device" % (CARLA_KEY_ENGINE_DRIVER_PREFIX, audioDriver), "", type=str) + except: + audioDevice = "" + + try: + audioNumPeriods = settings.value("%s%s/NumPeriods" % (CARLA_KEY_ENGINE_DRIVER_PREFIX, audioDriver), CARLA_DEFAULT_AUDIO_NUM_PERIODS, type=int) + except: + audioNumPeriods = CARLA_DEFAULT_AUDIO_NUM_PERIODS + + try: + audioBufferSize = settings.value("%s%s/BufferSize" % (CARLA_KEY_ENGINE_DRIVER_PREFIX, audioDriver), CARLA_DEFAULT_AUDIO_BUFFER_SIZE, type=int) + except: + audioBufferSize = CARLA_DEFAULT_AUDIO_BUFFER_SIZE - self.host.set_engine_option(ENGINE_OPTION_AUDIO_NUM_PERIODS, audioNumPeriods, "") - self.host.set_engine_option(ENGINE_OPTION_AUDIO_BUFFER_SIZE, audioBufferSize, "") - self.host.set_engine_option(ENGINE_OPTION_AUDIO_SAMPLE_RATE, audioSampleRate, "") - self.host.set_engine_option(ENGINE_OPTION_AUDIO_DEVICE, 0, audioDevice) + try: + audioSampleRate = settings.value("%s%s/SampleRate" % (CARLA_KEY_ENGINE_DRIVER_PREFIX, audioDriver), CARLA_DEFAULT_AUDIO_SAMPLE_RATE, type=int) + except: + audioSampleRate = CARLA_DEFAULT_AUDIO_SAMPLE_RATE + + self.host.set_engine_option(ENGINE_OPTION_AUDIO_DEVICE, 0, audioDevice) + self.host.set_engine_option(ENGINE_OPTION_AUDIO_NUM_PERIODS, audioNumPeriods, "") + self.host.set_engine_option(ENGINE_OPTION_AUDIO_BUFFER_SIZE, audioBufferSize, "") + self.host.set_engine_option(ENGINE_OPTION_AUDIO_SAMPLE_RATE, audioSampleRate, "") + + # ---------------------------------------------------------------------------------------------------- + # fix things if needed - # ------------------------------------------------------------- + if audioDriver != "JACK" and self.host.transportMode == ENGINE_TRANSPORT_MODE_JACK: + self.host.set_engine_option(ENGINE_OPTION_TRANSPORT_MODE, ENGINE_TRANSPORT_MODE_INTERNAL, "") + + # ---------------------------------------------------------------------------------------------------- # return selected driver name return audioDriver + # -------------------------------------------------------------------------------------------------------- + def startEngine(self): audioDriver = self.setEngineSettings() @@ -614,6 +546,109 @@ class HostWindow(QMainWindow): if self.host.is_engine_running() and not self.host.engine_close(): print(self.host.get_last_error()) + # -------------------------------------------------------------------------------------------------------- + + def handleEngineStarted(self): + check = self.host.is_engine_running() + self.ui.menu_PluginMacros.setEnabled(check) + self.ui.menu_Canvas.setEnabled(check) + + if not self.host.isPlugin: + self.ui.act_engine_start.setEnabled(not check) + self.ui.act_engine_stop.setEnabled(check) + + if not self.fSessionManagerName: + self.ui.act_file_open.setEnabled(check) + self.ui.act_file_save.setEnabled(check) + self.ui.act_file_save_as.setEnabled(check) + + self.setTransportMenuEnabled(check) + + if check: + if not self.host.isPlugin: + self.refreshTransport(True) + + self.fContainer.engineStarted() + + def handleEngineStopped(self): + # FIXME? + if self.fContainer.getPluginCount() > 0: + self.ui.act_plugin_remove_all.setEnabled(False) + self.fContainer.removeAllPlugins() + + check = self.host.is_engine_running() + self.ui.menu_PluginMacros.setEnabled(check) + self.ui.menu_Canvas.setEnabled(check) + + if not self.host.isPlugin: + self.ui.act_engine_start.setEnabled(not check) + self.ui.act_engine_stop.setEnabled(check) + + if not self.fSessionManagerName: + self.ui.act_file_open.setEnabled(check) + self.ui.act_file_save.setEnabled(check) + self.ui.act_file_save_as.setEnabled(check) + + self.setTransportMenuEnabled(check) + + if not check: + self.fTextTransport = "" + self.fContainer.engineStopped() + + # -------------------------------------------------------------------------------------------------------- + + @pyqtSlot() + def slot_engineStart(self): + self.startEngine() + #self.handleEngineStarted() + + @pyqtSlot() + def slot_engineStop(self): + self.stopEngine() + #self.handleEngineStopped() + + # -------------------------------------------------------------------------------------------------------- + + @pyqtSlot(str) + def slot_handleEngineStartedCallback(self, processMode, transportMode, driverName): + self.fSampleRate = self.host.get_sample_rate() + self.handleEngineStarted() + self.startTimers() + + @pyqtSlot() + def slot_handleEngineStoppedCallback(self): + self.killTimers() + self.handleEngineStopped() + self.fSampleRate = 0.0 + + # -------------------------------------------------------------------------------------------------------- + # Internal stuff (timers) + + def startTimers(self): + if self.fIdleTimerFast == 0: + self.fIdleTimerFast = self.startTimer(self.fSavedSettings[CARLA_KEY_MAIN_REFRESH_INTERVAL]) + + if self.fIdleTimerSlow == 0: + self.fIdleTimerSlow = self.startTimer(self.fSavedSettings[CARLA_KEY_MAIN_REFRESH_INTERVAL]*4) + + def restartTimersIfNeeded(self): + if self.fIdleTimerFast != 0: + self.killTimer(self.fIdleTimerFast) + self.fIdleTimerFast = self.startTimer(self.fSavedSettings[CARLA_KEY_MAIN_REFRESH_INTERVAL]) + + if self.fIdleTimerSlow != 0: + self.killTimer(self.fIdleTimerSlow) + self.fIdleTimerSlow = self.startTimer(self.fSavedSettings[CARLA_KEY_MAIN_REFRESH_INTERVAL]*4) + + def killTimers(self): + if self.fIdleTimerFast != 0: + self.killTimer(self.fIdleTimerFast) + self.fIdleTimerFast = 0 + + if self.fIdleTimerSlow != 0: + self.killTimer(self.fIdleTimerSlow) + self.fIdleTimerSlow = 0 + # ----------------------------------------------------------------- # Internal stuff (plugins) @@ -665,7 +700,7 @@ class HostWindow(QMainWindow): # Internal stuff (transport) def refreshTransport(self, forced = False): - if gCarla.sampleRate == 0.0 or not self.host.is_engine_running(): + if self.fSampleRate == 0.0 or not self.host.is_engine_running(): return timeInfo = self.host.get_transport_info() @@ -687,7 +722,7 @@ class HostWindow(QMainWindow): self.fLastTransportState = playing if frame != self.fLastTransportFrame or forced: - time = frame / gCarla.sampleRate + time = frame / self.fSampleRate secs = time % 60 mins = (time / 60) % 60 hrs = (time / 3600) % 60 @@ -736,7 +771,7 @@ class HostWindow(QMainWindow): if not self.host.isPlugin: # engine - self.setEngineSettings(settings) + self.setEngineSettings() # --------------------------------------------- @@ -745,6 +780,7 @@ class HostWindow(QMainWindow): self.fSavedSettings = { CARLA_KEY_MAIN_PROJECT_FOLDER: settings.value(CARLA_KEY_MAIN_PROJECT_FOLDER, CARLA_DEFAULT_MAIN_PROJECT_FOLDER, type=str), CARLA_KEY_MAIN_REFRESH_INTERVAL: settings.value(CARLA_KEY_MAIN_REFRESH_INTERVAL, CARLA_DEFAULT_MAIN_REFRESH_INTERVAL, type=int), + CARLA_KEY_MAIN_USE_CUSTOM_SKINS: settings.value(CARLA_KEY_MAIN_USE_CUSTOM_SKINS, CARLA_DEFAULT_MAIN_USE_CUSTOM_SKINS, type=bool), CARLA_KEY_CANVAS_THEME: settings.value(CARLA_KEY_CANVAS_THEME, CARLA_DEFAULT_CANVAS_THEME, type=str), CARLA_KEY_CANVAS_SIZE: settings.value(CARLA_KEY_CANVAS_SIZE, CARLA_DEFAULT_CANVAS_SIZE, type=str), CARLA_KEY_CANVAS_AUTO_HIDE_GROUPS: settings.value(CARLA_KEY_CANVAS_AUTO_HIDE_GROUPS, CARLA_DEFAULT_CANVAS_AUTO_HIDE_GROUPS, type=bool), @@ -759,13 +795,9 @@ class HostWindow(QMainWindow): # --------------------------------------------- - if self.fIdleTimerFast != 0: - self.killTimer(self.fIdleTimerFast) - self.fIdleTimerFast = self.startTimer(self.fSavedSettings[CARLA_KEY_MAIN_REFRESH_INTERVAL]) + self.restartTimersIfNeeded() - if self.fIdleTimerSlow != 0: - self.killTimer(self.fIdleTimerSlow) - self.fIdleTimerSlow = self.startTimer(self.fSavedSettings[CARLA_KEY_MAIN_REFRESH_INTERVAL]*4) + # --------------------------------------------- def saveSettings(self): settings = QSettings() @@ -786,144 +818,6 @@ class HostWindow(QMainWindow): # ----------------------------------------------------------------- # Internal stuff (gui) - def killTimers(self): - if self.fIdleTimerFast != 0: - self.killTimer(self.fIdleTimerFast) - self.fIdleTimerFast = 0 - - if self.fIdleTimerSlow != 0: - self.killTimer(self.fIdleTimerSlow) - self.fIdleTimerSlow = 0 - - def setProperWindowTitle(self): - title = self.fClientName - - if self.fProjectFilename: - title += " - %s" % os.path.basename(self.fProjectFilename) - if self.fSessionManagerName: - title += " (%s)" % self.fSessionManagerName - - self.setWindowTitle(title) - - # ----------------------------------------------------------------- - - @pyqtSlot() - def slot_fileNew(self): - self.fContainer.removeAllPlugins() - self.fProjectFilename = "" - self.setProperWindowTitle() - - @pyqtSlot() - def slot_fileOpen(self): - fileFilter = self.tr("Carla Project File (*.carxp)") - filename = QFileDialog.getOpenFileName(self, self.tr("Open Carla Project File"), self.fSavedSettings[CARLA_KEY_MAIN_PROJECT_FOLDER], filter=fileFilter) - - if config_UseQt5: - filename = filename[0] - if not filename: - return - - newFile = True - - if self.fContainer.getPluginCount() > 0: - ask = QMessageBox.question(self, self.tr("Question"), self.tr("There are some plugins loaded, do you want to remove them now?"), - QMessageBox.Yes | QMessageBox.No, QMessageBox.No) - newFile = (ask == QMessageBox.Yes) - - if newFile: - self.fContainer.removeAllPlugins() - self.fProjectFilename = filename - self.setProperWindowTitle() - self.loadProjectNow() - else: - filenameOld = self.fProjectFilename - self.fProjectFilename = filename - self.loadProjectNow() - self.fProjectFilename = filenameOld - - @pyqtSlot() - def slot_fileSave(self, saveAs=False): - if self.fProjectFilename and not saveAs: - return self.saveProjectNow() - - fileFilter = self.tr("Carla Project File (*.carxp)") - filename = QFileDialog.getSaveFileName(self, self.tr("Save Carla Project File"), self.fSavedSettings[CARLA_KEY_MAIN_PROJECT_FOLDER], filter=fileFilter) - - if config_UseQt5: - filename = filename[0] - if not filename: - return - - if not filename.lower().endswith(".carxp"): - filename += ".carxp" - - if self.fProjectFilename != filename: - self.fProjectFilename = filename - self.setProperWindowTitle() - - self.saveProjectNow() - - @pyqtSlot() - def slot_fileSaveAs(self): - self.slot_fileSave(True) - - # ----------------------------------------------------------------- - - @pyqtSlot() - def slot_engineStart(self, doStart = True): - if doStart: self.startEngine() - - check = self.host.is_engine_running() - self.ui.menu_PluginMacros.setEnabled(check) - self.ui.menu_Canvas.setEnabled(check) - - if not self.host.isPlugin: - self.ui.act_engine_start.setEnabled(not check) - self.ui.act_engine_stop.setEnabled(check) - - if not self.fSessionManagerName: - self.ui.act_file_open.setEnabled(check) - self.ui.act_file_save.setEnabled(check) - self.ui.act_file_save_as.setEnabled(check) - - self.setTransportMenuEnabled(check) - - if check: - if not self.host.isPlugin: - self.refreshTransport(True) - - self.fContainer.engineStarted() - - @pyqtSlot() - def slot_engineStop(self, doStop = True): - if doStop: self.stopEngine() - - # FIXME? - if self.fContainer.getPluginCount() > 0: - self.ui.act_plugin_remove_all.setEnabled(False) - self.fContainer.removeAllPlugins() - - check = self.host.is_engine_running() - self.ui.menu_PluginMacros.setEnabled(check) - self.ui.menu_Canvas.setEnabled(check) - - if not self.host.isPlugin: - self.ui.act_engine_start.setEnabled(not check) - self.ui.act_engine_stop.setEnabled(check) - - if not self.fSessionManagerName: - self.ui.act_file_open.setEnabled(check) - self.ui.act_file_save.setEnabled(check) - self.ui.act_file_save_as.setEnabled(check) - - self.setTransportMenuEnabled(check) - - if not check: - self.fTextTransport = "" - self.fContainer.engineStopped() - - # ----------------------------------------------------------------- - @pyqtSlot() def slot_pluginAdd(self, pluginToReplace = -1): dialog = PluginDatabaseW(self, self.host) @@ -1115,47 +1009,10 @@ class HostWindow(QMainWindow): # ----------------------------------------------------------------- - @pyqtSlot(str) - def slot_handleEngineStartedCallback(self, processMode, transportMode, driverName): - self.host.processMode = processMode - self.host.transportMode = transportMode - gCarla.bufferSize = self.host.get_buffer_size() - gCarla.sampleRate = self.host.get_sample_rate() - - self.slot_engineStart(False) - - if self.fIdleTimerFast == 0: - self.fIdleTimerFast = self.startTimer(self.fSavedSettings[CARLA_KEY_MAIN_REFRESH_INTERVAL]) - if self.fIdleTimerSlow == 0: - self.fIdleTimerSlow = self.startTimer(self.fSavedSettings[CARLA_KEY_MAIN_REFRESH_INTERVAL]*4) - - @pyqtSlot() - def slot_handleEngineStoppedCallback(self): - self.killTimers() - self.slot_engineStop(False) - - gCarla.bufferSize = 0 - gCarla.sampleRate = 0.0 - - # ----------------------------------------------------------------- - - @pyqtSlot(int) - def slot_handleProcessModeChangedCallback(self, newProcessMode): - self.fEngineChanged = True - - @pyqtSlot(int) - def slot_handleTransportModeChangedCallback(self, newTransportMode): - self.fEngineChanged = True - - # ----------------------------------------------------------------- - - @pyqtSlot(int) - def slot_handleBufferSizeChangedCallback(self, newBufferSize): - self.fEngineChanged = True - @pyqtSlot(float) def slot_handleSampleRateChangedCallback(self, newSampleRate): - self.fEngineChanged = True + self.fSampleRate = newSampleRate + self.refreshTransport(True) # ----------------------------------------------------------------- @@ -1192,19 +1049,22 @@ class HostWindow(QMainWindow): winIdStr = "%x" % self.winId() self.host.set_engine_option(ENGINE_OPTION_FRONTEND_WIN_ID, 0, winIdStr) + def hideEvent(self, event): + # disable parent + self.host.set_engine_option(ENGINE_OPTION_FRONTEND_WIN_ID, 0, "0") + + QMainWindow.hideEvent(self, event) + + # ----------------------------------------------------------------- + def timerEvent(self, event): if event.timerId() == self.fIdleTimerFast: - #if not gCarla.isPlugin: - self.host.engine_idle() - self.refreshTransport() - + #if not self.host.isPlugin: self.fContainer.idleFast() + self.refreshTransport() + self.host.engine_idle() elif event.timerId() == self.fIdleTimerSlow: - if self.fEngineChanged: - self.fContainer.engineChanged() - self.fEngineChanged = False - self.fContainer.idleSlow() QMainWindow.timerEvent(self, event) @@ -1243,118 +1103,111 @@ class HostWindow(QMainWindow): # ------------------------------------------------------------------------------------------------------------ # Engine callback -def engineCallback(ptr, action, pluginId, value1, value2, value3, valueStr): - if action == ENGINE_CALLBACK_PROCESS_MODE_CHANGED: - gCarla.processMode = value1 - if gCarla.gui is not None: - gCarla.gui.ProcessModeChangedCallback.emit(value1) - return - - if action == ENGINE_CALLBACK_TRANSPORT_MODE_CHANGED: - gCarla.transportMode = value1 - if gCarla.gui is not None: - gCarla.gui.TransportModeChangedCallback.emit(value1) - return - - if action == ENGINE_CALLBACK_BUFFER_SIZE_CHANGED: - gCarla.bufferSize = value1 - if gCarla.gui is not None: - gCarla.gui.BufferSizeChangedCallback.emit(value1) - return +def engineCallback(host, action, pluginId, value1, value2, value3, valueStr): + # kdevelop likes this :) + if False: host = CarlaHostMeta() - if action == ENGINE_CALLBACK_SAMPLE_RATE_CHANGED: - gCarla.sampleRate = value1 - if gCarla.gui is not None: - gCarla.gui.SampleRateChangedCallback.emit(value3) - return + # FIXME + if host is None: host = gCarla.gui.host - if gCarla.gui is None: - print("WARNING: Got engine callback but UI is not ready : ", pluginId, value1, value2, value3, valueStr) - return + if action in (ENGINE_CALLBACK_ENGINE_STARTED, + ENGINE_CALLBACK_PROCESS_MODE_CHANGED, + ENGINE_CALLBACK_TRANSPORT_MODE_CHANGED): + if action == ENGINE_CALLBACK_ENGINE_STARTED: + host.processMode = value1 + host.transportMode = value2 + elif action == ENGINE_CALLBACK_PROCESS_MODE_CHANGED: + host.processMode = value1 + elif action == ENGINE_CALLBACK_TRANSPORT_MODE_CHANGED: + host.transportMode = value1 valueStr = charPtrToString(valueStr) if action == ENGINE_CALLBACK_DEBUG: - gCarla.gui.DebugCallback.emit(pluginId, value1, value2, value3, valueStr) + host.DebugCallback.emit(pluginId, value1, value2, value3, valueStr) elif action == ENGINE_CALLBACK_PLUGIN_ADDED: - gCarla.gui.PluginAddedCallback.emit(pluginId, valueStr) + host.PluginAddedCallback.emit(pluginId, valueStr) elif action == ENGINE_CALLBACK_PLUGIN_REMOVED: - gCarla.gui.PluginRemovedCallback.emit(pluginId) + host.PluginRemovedCallback.emit(pluginId) elif action == ENGINE_CALLBACK_PLUGIN_RENAMED: - gCarla.gui.PluginRenamedCallback.emit(pluginId, valueStr) + host.PluginRenamedCallback.emit(pluginId, valueStr) elif action == ENGINE_CALLBACK_PLUGIN_UNAVAILABLE: - gCarla.gui.PluginUnavailableCallback.emit(pluginId, valueStr) + host.PluginUnavailableCallback.emit(pluginId, valueStr) elif action == ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED: - gCarla.gui.ParameterValueChangedCallback.emit(pluginId, value1, value3) + host.ParameterValueChangedCallback.emit(pluginId, value1, value3) elif action == ENGINE_CALLBACK_PARAMETER_DEFAULT_CHANGED: - gCarla.gui.ParameterDefaultChangedCallback.emit(pluginId, value1, value3) + host.ParameterDefaultChangedCallback.emit(pluginId, value1, value3) elif action == ENGINE_CALLBACK_PARAMETER_MIDI_CC_CHANGED: - gCarla.gui.ParameterMidiCcChangedCallback.emit(pluginId, value1, value2) + host.ParameterMidiCcChangedCallback.emit(pluginId, value1, value2) elif action == ENGINE_CALLBACK_PARAMETER_MIDI_CHANNEL_CHANGED: - gCarla.gui.ParameterMidiChannelChangedCallback.emit(pluginId, value1, value2) + host.ParameterMidiChannelChangedCallback.emit(pluginId, value1, value2) elif action == ENGINE_CALLBACK_PROGRAM_CHANGED: - gCarla.gui.ProgramChangedCallback.emit(pluginId, value1) + host.ProgramChangedCallback.emit(pluginId, value1) elif action == ENGINE_CALLBACK_MIDI_PROGRAM_CHANGED: - gCarla.gui.MidiProgramChangedCallback.emit(pluginId, value1) + host.MidiProgramChangedCallback.emit(pluginId, value1) elif action == ENGINE_CALLBACK_OPTION_CHANGED: - gCarla.gui.OptionChangedCallback.emit(pluginId, value1, bool(value2)) + host.OptionChangedCallback.emit(pluginId, value1, bool(value2)) elif action == ENGINE_CALLBACK_UI_STATE_CHANGED: - gCarla.gui.UiStateChangedCallback.emit(pluginId, value1) + host.UiStateChangedCallback.emit(pluginId, value1) elif action == ENGINE_CALLBACK_NOTE_ON: - gCarla.gui.NoteOnCallback.emit(pluginId, value1, value2, int(value3)) + host.NoteOnCallback.emit(pluginId, value1, value2, int(value3)) elif action == ENGINE_CALLBACK_NOTE_OFF: - gCarla.gui.NoteOffCallback.emit(pluginId, value1, value2) + host.NoteOffCallback.emit(pluginId, value1, value2) elif action == ENGINE_CALLBACK_UPDATE: - gCarla.gui.UpdateCallback.emit(pluginId) + host.UpdateCallback.emit(pluginId) elif action == ENGINE_CALLBACK_RELOAD_INFO: - gCarla.gui.ReloadInfoCallback.emit(pluginId) + host.ReloadInfoCallback.emit(pluginId) elif action == ENGINE_CALLBACK_RELOAD_PARAMETERS: - gCarla.gui.ReloadParametersCallback.emit(pluginId) + host.ReloadParametersCallback.emit(pluginId) elif action == ENGINE_CALLBACK_RELOAD_PROGRAMS: - gCarla.gui.ReloadProgramsCallback.emit(pluginId) + host.ReloadProgramsCallback.emit(pluginId) elif action == ENGINE_CALLBACK_RELOAD_ALL: - gCarla.gui.ReloadAllCallback.emit(pluginId) + host.ReloadAllCallback.emit(pluginId) elif action == ENGINE_CALLBACK_PATCHBAY_CLIENT_ADDED: - gCarla.gui.PatchbayClientAddedCallback.emit(pluginId, value1, value2, valueStr) + host.PatchbayClientAddedCallback.emit(pluginId, value1, value2, valueStr) elif action == ENGINE_CALLBACK_PATCHBAY_CLIENT_REMOVED: - gCarla.gui.PatchbayClientRemovedCallback.emit(pluginId) + host.PatchbayClientRemovedCallback.emit(pluginId) elif action == ENGINE_CALLBACK_PATCHBAY_CLIENT_RENAMED: - gCarla.gui.PatchbayClientRenamedCallback.emit(pluginId, valueStr) + host.PatchbayClientRenamedCallback.emit(pluginId, valueStr) elif action == ENGINE_CALLBACK_PATCHBAY_CLIENT_DATA_CHANGED: - gCarla.gui.PatchbayClientDataChangedCallback.emit(pluginId, value1, value2) + host.PatchbayClientDataChangedCallback.emit(pluginId, value1, value2) elif action == ENGINE_CALLBACK_PATCHBAY_PORT_ADDED: - gCarla.gui.PatchbayPortAddedCallback.emit(pluginId, value1, value2, valueStr) + host.PatchbayPortAddedCallback.emit(pluginId, value1, value2, valueStr) elif action == ENGINE_CALLBACK_PATCHBAY_PORT_REMOVED: - gCarla.gui.PatchbayPortRemovedCallback.emit(pluginId, value1) + host.PatchbayPortRemovedCallback.emit(pluginId, value1) elif action == ENGINE_CALLBACK_PATCHBAY_PORT_RENAMED: - gCarla.gui.PatchbayPortRenamedCallback.emit(pluginId, value1, valueStr) + host.PatchbayPortRenamedCallback.emit(pluginId, value1, valueStr) elif action == ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED: - gOut, pOut, gIn, pIn = [int(i) for i in valueStr.split(":")] - gCarla.gui.PatchbayConnectionAddedCallback.emit(pluginId, gOut, pOut, gIn, pIn) + gOut, pOut, gIn, pIn = [int(i) for i in valueStr.split(":")] # FIXME + host.PatchbayConnectionAddedCallback.emit(pluginId, gOut, pOut, gIn, pIn) elif action == ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED: - gCarla.gui.PatchbayConnectionRemovedCallback.emit(pluginId, value1, value2) + host.PatchbayConnectionRemovedCallback.emit(pluginId, value1, value2) elif action == ENGINE_CALLBACK_ENGINE_STARTED: - gCarla.gui.EngineStartedCallback.emit(value1, value2, valueStr) + host.EngineStartedCallback.emit(value1, value2, valueStr) elif action == ENGINE_CALLBACK_ENGINE_STOPPED: - gCarla.gui.killTimers() - gCarla.gui.EngineStoppedCallback.emit() + host.EngineStoppedCallback.emit() + elif action == ENGINE_CALLBACK_PROCESS_MODE_CHANGED: + host.ProcessModeChangedCallback.emit(value1) + elif action == ENGINE_CALLBACK_TRANSPORT_MODE_CHANGED: + host.TransportModeChangedCallback.emit(value1) + elif action == ENGINE_CALLBACK_BUFFER_SIZE_CHANGED: + host.BufferSizeChangedCallback.emit(value1) + elif action == ENGINE_CALLBACK_SAMPLE_RATE_CHANGED: + host.SampleRateChangedCallback.emit(value3) elif action == ENGINE_CALLBACK_IDLE: QApplication.instance().processEvents() elif action == ENGINE_CALLBACK_INFO: - gCarla.gui.InfoCallback.emit(valueStr) + host.InfoCallback.emit(valueStr) elif action == ENGINE_CALLBACK_ERROR: - gCarla.gui.ErrorCallback.emit(valueStr) + host.ErrorCallback.emit(valueStr) elif action == ENGINE_CALLBACK_QUIT: - gCarla.gui.QuitCallback.emit() + host.QuitCallback.emit() # ------------------------------------------------------------------------------------------------------------ # File callback def fileCallback(ptr, action, isDir, title, filter): - if gCarla.gui is None: - return None - - ret = "" + ret = ("", "") if config_UseQt5 else "" if action == FILE_CALLBACK_DEBUG: pass @@ -1368,14 +1221,22 @@ def fileCallback(ptr, action, isDir, title, filter): if not ret: return None - gCarla.gui._fileRet = c_char_p(ret.encode("utf-8")) - retval = cast(byref(gCarla.gui._fileRet), POINTER(c_uintptr)) + global fileRet + fileRet = c_char_p(ret.encode("utf-8")) + retval = cast(byref(fileRet), POINTER(c_uintptr)) return retval.contents.value # ------------------------------------------------------------------------------------------------------------ # Init host -def initHost(initName, libPrefix, isControl, isPlugin, failError): +def initHost(initName, libPrefixOrPluginClass, isControl, isPlugin, failError): + if isPlugin: + PluginClass = libPrefixOrPluginClass + libPrefix = None + else: + PluginClass = None + libPrefix = libPrefixOrPluginClass + # -------------------------------------------------------------------------------------------------------- # Set Carla library name @@ -1454,17 +1315,17 @@ def initHost(initName, libPrefix, isControl, isPlugin, failError): if failError: # no try - host = CarlaHostPlugin() if isPlugin else CarlaHostDLL(os.path.join(pathBinaries, libname)) + host = PluginClass() if isPlugin else CarlaHostDLL(os.path.join(pathBinaries, libname)) else: try: - host = CarlaHostPlugin() if isPlugin else CarlaHostDLL(os.path.join(pathBinaries, libname)) + host = PluginClass() if isPlugin else CarlaHostDLL(os.path.join(pathBinaries, libname)) except: host = CarlaHostNull() host.isControl = isControl host.isPlugin = isPlugin - host.set_engine_callback(engineCallback) + host.set_engine_callback(lambda h,a,p,v1,v2,v3,vs: engineCallback(host,a,p,v1,v2,v3,vs)) host.set_file_callback(fileCallback) # If it's a plugin the paths are already set @@ -1480,7 +1341,7 @@ def initHost(initName, libPrefix, isControl, isPlugin, failError): return host # ------------------------------------------------------------------------------------------------------------ -# Load host settings (fills host vars with common host settings) +# Load host settings def loadHostSettings(host): # kdevelop likes this :) @@ -1542,3 +1403,25 @@ def loadHostSettings(host): host.processMode = ENGINE_PROCESS_MODE_SINGLE_CLIENT # ------------------------------------------------------------------------------------------------------------ +# Set host settings + +def setHostSettings(host): + # kdevelop likes this :) + if False: host = CarlaHostMeta() + + host.set_engine_option(ENGINE_OPTION_FORCE_STEREO, host.forceStereo, "") + host.set_engine_option(ENGINE_OPTION_PREFER_PLUGIN_BRIDGES, host.preferPluginBridges, "") + host.set_engine_option(ENGINE_OPTION_PREFER_UI_BRIDGES, host.preferUIBridges, "") + host.set_engine_option(ENGINE_OPTION_UIS_ALWAYS_ON_TOP, host.uisAlwaysOnTop, "") + host.set_engine_option(ENGINE_OPTION_MAX_PARAMETERS, host.maxParameters, "") + host.set_engine_option(ENGINE_OPTION_UI_BRIDGES_TIMEOUT, host.uiBridgesTimeout, "") + + if host.isPlugin: + return + + host.set_engine_option(ENGINE_OPTION_TRANSPORT_MODE, host.transportMode, "") + + if not host.processModeForced: + host.set_engine_option(ENGINE_OPTION_PROCESS_MODE, host.processMode, "") + +# ------------------------------------------------------------------------------------------------------------ diff --git a/source/carla_patchbay.py b/source/carla_patchbay.py index 1eb2ab8e0..6a1338080 100644 --- a/source/carla_patchbay.py +++ b/source/carla_patchbay.py @@ -102,7 +102,8 @@ class CarlaPatchbayW(QFrame, PluginEditParentMeta): if False: # kdevelop likes this :) - self.host = host = CarlaHostMeta() + host = CarlaHostMeta() + self.host = host # ------------------------------------------------------------- @@ -230,29 +231,29 @@ class CarlaPatchbayW(QFrame, PluginEditParentMeta): parent.ui.act_settings_configure.triggered.connect(self.slot_configureCarla) - parent.ParameterValueChangedCallback.connect(self.slot_handleParameterValueChangedCallback) - parent.ParameterDefaultChangedCallback.connect(self.slot_handleParameterDefaultChangedCallback) - parent.ParameterMidiChannelChangedCallback.connect(self.slot_handleParameterMidiChannelChangedCallback) - parent.ParameterMidiCcChangedCallback.connect(self.slot_handleParameterMidiCcChangedCallback) - parent.ProgramChangedCallback.connect(self.slot_handleProgramChangedCallback) - parent.MidiProgramChangedCallback.connect(self.slot_handleMidiProgramChangedCallback) - parent.OptionChangedCallback.connect(self.slot_handleOptionChangedCallback) - parent.NoteOnCallback.connect(self.slot_handleNoteOnCallback) - parent.NoteOffCallback.connect(self.slot_handleNoteOffCallback) - parent.UpdateCallback.connect(self.slot_handleUpdateCallback) - parent.ReloadInfoCallback.connect(self.slot_handleReloadInfoCallback) - parent.ReloadParametersCallback.connect(self.slot_handleReloadParametersCallback) - parent.ReloadProgramsCallback.connect(self.slot_handleReloadProgramsCallback) - parent.ReloadAllCallback.connect(self.slot_handleReloadAllCallback) - parent.PatchbayClientAddedCallback.connect(self.slot_handlePatchbayClientAddedCallback) - parent.PatchbayClientRemovedCallback.connect(self.slot_handlePatchbayClientRemovedCallback) - parent.PatchbayClientRenamedCallback.connect(self.slot_handlePatchbayClientRenamedCallback) - parent.PatchbayClientDataChangedCallback.connect(self.slot_handlePatchbayClientDataChangedCallback) - parent.PatchbayPortAddedCallback.connect(self.slot_handlePatchbayPortAddedCallback) - parent.PatchbayPortRemovedCallback.connect(self.slot_handlePatchbayPortRemovedCallback) - parent.PatchbayPortRenamedCallback.connect(self.slot_handlePatchbayPortRenamedCallback) - parent.PatchbayConnectionAddedCallback.connect(self.slot_handlePatchbayConnectionAddedCallback) - parent.PatchbayConnectionRemovedCallback.connect(self.slot_handlePatchbayConnectionRemovedCallback) + host.ParameterValueChangedCallback.connect(self.slot_handleParameterValueChangedCallback) + host.ParameterDefaultChangedCallback.connect(self.slot_handleParameterDefaultChangedCallback) + host.ParameterMidiChannelChangedCallback.connect(self.slot_handleParameterMidiChannelChangedCallback) + host.ParameterMidiCcChangedCallback.connect(self.slot_handleParameterMidiCcChangedCallback) + host.ProgramChangedCallback.connect(self.slot_handleProgramChangedCallback) + host.MidiProgramChangedCallback.connect(self.slot_handleMidiProgramChangedCallback) + host.OptionChangedCallback.connect(self.slot_handleOptionChangedCallback) + host.NoteOnCallback.connect(self.slot_handleNoteOnCallback) + host.NoteOffCallback.connect(self.slot_handleNoteOffCallback) + host.UpdateCallback.connect(self.slot_handleUpdateCallback) + host.ReloadInfoCallback.connect(self.slot_handleReloadInfoCallback) + host.ReloadParametersCallback.connect(self.slot_handleReloadParametersCallback) + host.ReloadProgramsCallback.connect(self.slot_handleReloadProgramsCallback) + host.ReloadAllCallback.connect(self.slot_handleReloadAllCallback) + host.PatchbayClientAddedCallback.connect(self.slot_handlePatchbayClientAddedCallback) + host.PatchbayClientRemovedCallback.connect(self.slot_handlePatchbayClientRemovedCallback) + host.PatchbayClientRenamedCallback.connect(self.slot_handlePatchbayClientRenamedCallback) + host.PatchbayClientDataChangedCallback.connect(self.slot_handlePatchbayClientDataChangedCallback) + host.PatchbayPortAddedCallback.connect(self.slot_handlePatchbayPortAddedCallback) + host.PatchbayPortRemovedCallback.connect(self.slot_handlePatchbayPortRemovedCallback) + host.PatchbayPortRenamedCallback.connect(self.slot_handlePatchbayPortRenamedCallback) + host.PatchbayConnectionAddedCallback.connect(self.slot_handlePatchbayConnectionAddedCallback) + host.PatchbayConnectionRemovedCallback.connect(self.slot_handlePatchbayConnectionRemovedCallback) # ----------------------------------------------------------------- @@ -337,9 +338,6 @@ class CarlaPatchbayW(QFrame, PluginEditParentMeta): def engineStopped(self): patchcanvas.clear() - def engineChanged(self): - pass - # ----------------------------------------------------------------- def idleFast(self): diff --git a/source/carla_rack.py b/source/carla_rack.py index 25c0cf510..2e3fc62b4 100644 --- a/source/carla_rack.py +++ b/source/carla_rack.py @@ -305,21 +305,21 @@ class CarlaRackW(QFrame): parent.ui.act_settings_configure.triggered.connect(self.slot_configureCarla) - parent.ParameterValueChangedCallback.connect(self.slot_handleParameterValueChangedCallback) - parent.ParameterDefaultChangedCallback.connect(self.slot_handleParameterDefaultChangedCallback) - parent.ParameterMidiChannelChangedCallback.connect(self.slot_handleParameterMidiChannelChangedCallback) - parent.ParameterMidiCcChangedCallback.connect(self.slot_handleParameterMidiCcChangedCallback) - parent.ProgramChangedCallback.connect(self.slot_handleProgramChangedCallback) - parent.MidiProgramChangedCallback.connect(self.slot_handleMidiProgramChangedCallback) - parent.OptionChangedCallback.connect(self.slot_handleOptionChangedCallback) - parent.UiStateChangedCallback.connect(self.slot_handleUiStateChangedCallback) - parent.NoteOnCallback.connect(self.slot_handleNoteOnCallback) - parent.NoteOffCallback.connect(self.slot_handleNoteOffCallback) - parent.UpdateCallback.connect(self.slot_handleUpdateCallback) - parent.ReloadInfoCallback.connect(self.slot_handleReloadInfoCallback) - parent.ReloadParametersCallback.connect(self.slot_handleReloadParametersCallback) - parent.ReloadProgramsCallback.connect(self.slot_handleReloadProgramsCallback) - parent.ReloadAllCallback.connect(self.slot_handleReloadAllCallback) + host.ParameterValueChangedCallback.connect(self.slot_handleParameterValueChangedCallback) + host.ParameterDefaultChangedCallback.connect(self.slot_handleParameterDefaultChangedCallback) + host.ParameterMidiChannelChangedCallback.connect(self.slot_handleParameterMidiChannelChangedCallback) + host.ParameterMidiCcChangedCallback.connect(self.slot_handleParameterMidiCcChangedCallback) + host.ProgramChangedCallback.connect(self.slot_handleProgramChangedCallback) + host.MidiProgramChangedCallback.connect(self.slot_handleMidiProgramChangedCallback) + host.OptionChangedCallback.connect(self.slot_handleOptionChangedCallback) + host.UiStateChangedCallback.connect(self.slot_handleUiStateChangedCallback) + host.NoteOnCallback.connect(self.slot_handleNoteOnCallback) + host.NoteOffCallback.connect(self.slot_handleNoteOffCallback) + host.UpdateCallback.connect(self.slot_handleUpdateCallback) + host.ReloadInfoCallback.connect(self.slot_handleReloadInfoCallback) + host.ReloadParametersCallback.connect(self.slot_handleReloadParametersCallback) + host.ReloadProgramsCallback.connect(self.slot_handleReloadProgramsCallback) + host.ReloadAllCallback.connect(self.slot_handleReloadAllCallback) # ----------------------------------------------------------------- @@ -400,9 +400,6 @@ class CarlaRackW(QFrame): def engineStopped(self): pass - def engineChanged(self): - pass - # ----------------------------------------------------------------- def idleFast(self): diff --git a/source/modules/native-plugins/resources/carla-plugin b/source/modules/native-plugins/resources/carla-plugin index 2bc531707..3983fcf1a 100755 --- a/source/modules/native-plugins/resources/carla-plugin +++ b/source/modules/native-plugins/resources/carla-plugin @@ -26,11 +26,11 @@ from externalui import ExternalUI # Host Plugin object class PluginHost(CarlaHostPlugin): - def __init__(self, sampleRate): + def __init__(self): CarlaHostPlugin.__init__(self) self.fIsRunning = True - self.fSampleRate = sampleRate + self.fSampleRate = float(sys.argv[1]) if len(sys.argv) > 1 else 44100.0 # ------------------------------------------------------------------- @@ -64,17 +64,27 @@ class PluginHost(CarlaHostPlugin): # Main Window class CarlaMiniW(ExternalUI, HostWindow): - def __init__(self): + def __init__(self, host): + # need to init this first + gCarla.gui = self + + # now the regular stuff ExternalUI.__init__(self) - HostWindow.__init__(self, None) + HostWindow.__init__(self, host) + self.host = host + + if False: + # kdevelop likes this :) + host = CarlaHostPlugin() + self.host = host if sys.argv[0].lower().endswith("/carla-plugin-patchbay"): from carla_patchbay import CarlaPatchbayW - self.fContainer = CarlaPatchbayW(self) + self.fContainer = CarlaPatchbayW(self, host) self.setupContainer(True, self.fContainer.themeData) else: from carla_rack import CarlaRackW - self.fContainer = CarlaRackW(self) + self.fContainer = CarlaRackW(self, host) self.setupContainer(False) self.setWindowTitle(self.fUiName) @@ -122,12 +132,12 @@ class CarlaMiniW(ExternalUI, HostWindow): elif msg.startswith("PEAKS_"): pluginId = int(msg.replace("PEAKS_", "")) in1, in2, out1, out2 = [float(i) for i in self.readlineblock().split(":")] - gCarla.host._set_peaks(pluginId, in1, in2, out1, out2) + self.host._set_peaks(pluginId, in1, in2, out1, out2) elif msg.startswith("PARAMVAL_"): pluginId, paramId = [int(i) for i in msg.replace("PARAMVAL_", "").split(":")] paramValue = float(self.readlineblock()) - gCarla.host._set_parameterValue(pluginId, paramId, paramValue) + self.host._set_parameterValue(pluginId, paramId, paramValue) elif msg.startswith("ENGINE_CALLBACK_"): action = int(msg.replace("ENGINE_CALLBACK_", "")) @@ -138,28 +148,28 @@ class CarlaMiniW(ExternalUI, HostWindow): valueStr = self.readlineblock().replace("\r", "\n") if action == ENGINE_CALLBACK_PLUGIN_RENAMED: - gCarla.host._set_pluginName(pluginId, valueStr) + self.host._set_pluginName(pluginId, valueStr) elif action == ENGINE_CALLBACK_PARAMETER_VALUE_CHANGED: if value1 < 0: - gCarla.host._set_internalValue(pluginId, value1, value3) + self.host._set_internalValue(pluginId, value1, value3) else: - gCarla.host._set_parameterValue(pluginId, value1, value3) + self.host._set_parameterValue(pluginId, value1, value3) elif action == ENGINE_CALLBACK_PARAMETER_DEFAULT_CHANGED: - gCarla.host._set_parameterDefault(pluginId, value1, value3) + self.host._set_parameterDefault(pluginId, value1, value3) elif action == ENGINE_CALLBACK_PARAMETER_MIDI_CC_CHANGED: - gCarla.host._set_parameterMidiCC(pluginId, value1, value2) + self.host._set_parameterMidiCC(pluginId, value1, value2) elif action == ENGINE_CALLBACK_PARAMETER_MIDI_CHANNEL_CHANGED: - gCarla.host._set_parameterMidiChannel(pluginId, value1, value2) + self.host._set_parameterMidiChannel(pluginId, value1, value2) elif action == ENGINE_CALLBACK_PROGRAM_CHANGED: - gCarla.host._set_currentProgram(pluginId, value1) + self.host._set_currentProgram(pluginId, value1) elif action == ENGINE_CALLBACK_MIDI_PROGRAM_CHANGED: - gCarla.host._set_currentMidiProgram(pluginId, value1) + self.host._set_currentMidiProgram(pluginId, value1) engineCallback(None, action, pluginId, value1, value2, value3, valueStr) elif msg.startswith("PLUGIN_INFO_"): pluginId = int(msg.replace("PLUGIN_INFO_", "")) - gCarla.host._add(pluginId) + self.host._add(pluginId) type_, category, hints, uniqueId, optsAvail, optsEnabled = [int(i) for i in self.readlineblock().split(":")] filename = self.readlineblock().replace("\r", "\n") @@ -185,20 +195,20 @@ class CarlaMiniW(ExternalUI, HostWindow): 'patchbayClientId': 0, 'uniqueId': uniqueId } - gCarla.host._set_pluginInfo(pluginId, pinfo) - gCarla.host._set_pluginRealName(pluginId, realName) + self.host._set_pluginInfo(pluginId, pinfo) + self.host._set_pluginRealName(pluginId, realName) elif msg.startswith("AUDIO_COUNT_"): pluginId, ins, outs = [int(i) for i in msg.replace("AUDIO_COUNT_", "").split(":")] - gCarla.host._set_audioCountInfo(pluginId, {'ins': ins, 'outs': outs}) + self.host._set_audioCountInfo(pluginId, {'ins': ins, 'outs': outs}) elif msg.startswith("MIDI_COUNT_"): pluginId, ins, outs = [int(i) for i in msg.replace("MIDI_COUNT_", "").split(":")] - gCarla.host._set_midiCountInfo(pluginId, {'ins': ins, 'outs': outs}) + self.host._set_midiCountInfo(pluginId, {'ins': ins, 'outs': outs}) elif msg.startswith("PARAMETER_COUNT_"): pluginId, ins, outs, count = [int(i) for i in msg.replace("PARAMETER_COUNT_", "").split(":")] - gCarla.host._set_parameterCountInfo(pluginId, count, {'ins': ins, 'outs': outs}) + self.host._set_parameterCountInfo(pluginId, count, {'ins': ins, 'outs': outs}) elif msg.startswith("PARAMETER_DATA_"): pluginId, paramId = [int(i) for i in msg.replace("PARAMETER_DATA_", "").split(":")] @@ -212,7 +222,7 @@ class CarlaMiniW(ExternalUI, HostWindow): 'unit': paramUnit, 'scalePointCount': 0, } - gCarla.host._set_parameterInfo(pluginId, paramId, paramInfo) + self.host._set_parameterInfo(pluginId, paramId, paramInfo) paramData = { 'type': paramType, @@ -222,7 +232,7 @@ class CarlaMiniW(ExternalUI, HostWindow): 'midiCC': midiCC, 'midiChannel': midiChannel } - gCarla.host._set_parameterData(pluginId, paramId, paramData) + self.host._set_parameterData(pluginId, paramId, paramData) elif msg.startswith("PARAMETER_RANGES_"): pluginId, paramId = [int(i) for i in msg.replace("PARAMETER_RANGES_", "").split(":")] @@ -236,28 +246,28 @@ class CarlaMiniW(ExternalUI, HostWindow): 'stepSmall': stepSmall, 'stepLarge': stepLarge } - gCarla.host._set_parameterRanges(pluginId, paramId, paramRanges) + self.host._set_parameterRanges(pluginId, paramId, paramRanges) elif msg.startswith("PROGRAM_COUNT_"): pluginId, count, current = [int(i) for i in msg.replace("PROGRAM_COUNT_", "").split(":")] - gCarla.host._set_programCount(pluginId, count) - gCarla.host._set_currentProgram(pluginId, current) + self.host._set_programCount(pluginId, count) + self.host._set_currentProgram(pluginId, current) elif msg.startswith("PROGRAM_NAME_"): pluginId, progId = [int(i) for i in msg.replace("PROGRAM_NAME_", "").split(":")] progName = self.readlineblock().replace("\r", "\n") - gCarla.host._set_programName(pluginId, progId, progName) + self.host._set_programName(pluginId, progId, progName) elif msg.startswith("MIDI_PROGRAM_COUNT_"): pluginId, count, current = [int(i) for i in msg.replace("MIDI_PROGRAM_COUNT_", "").split(":")] - gCarla.host._set_midiProgramCount(pluginId, count) - gCarla.host._set_currentMidiProgram(pluginId, current) + self.host._set_midiProgramCount(pluginId, count) + self.host._set_currentMidiProgram(pluginId, current) elif msg.startswith("MIDI_PROGRAM_DATA_"): pluginId, midiProgId = [int(i) for i in msg.replace("MIDI_PROGRAM_DATA_", "").split(":")] bank, program = [int(i) for i in self.readlineblock().split(":")] name = self.readlineblock().replace("\r", "\n") - gCarla.host._set_midiProgramData(pluginId, midiProgId, {'bank': bank, 'program': program, 'name': name}) + self.host._set_midiProgramData(pluginId, midiProgId, {'bank': bank, 'program': program, 'name': name}) elif msg == "error": error = self.readlineblock().replace("\r", "\n") @@ -297,34 +307,25 @@ if __name__ == '__main__': setUpSignals() # ------------------------------------------------------------- - # Init plugin host data + # Init host backend - gCarla.isControl = False - gCarla.isLocal = True - gCarla.isPlugin = True - gCarla.processMode = ENGINE_PROCESS_MODE_CONTINUOUS_RACK + host = initHost("Carla-Plugin", PluginHost, False, True, True) + host.processMode = ENGINE_PROCESS_MODE_PATCHBAY if sys.argv[0].lower().endswith("/carla-plugin-patchbay") else ENGINE_PROCESS_MODE_CONTINUOUS_RACK - # ------------------------------------------------------------- - # Create GUI first - - gCarla.gui = CarlaMiniW() + # FIXME + loadHostSettings(host) # ------------------------------------------------------------- - # Init plugin host now + # Create GUI - gCarla.host = PluginHost(gCarla.gui.d_getSampleRate()) + gCarla.gui = CarlaMiniW(host) - initHost("Carla-Plugin") + # ------------------------------------------------------------- + # simulate an engire started callback FIXME - # simulate an engire started callback - engineCallback(None, ENGINE_CALLBACK_ENGINE_STARTED, 0, ENGINE_PROCESS_MODE_CONTINUOUS_RACK, ENGINE_TRANSPORT_MODE_PLUGIN, 0.0, "Plugin") + engineCallback(host, ENGINE_CALLBACK_ENGINE_STARTED, 0, host.processMode, ENGINE_TRANSPORT_MODE_PLUGIN, 0.0, "Plugin") # ------------------------------------------------------------- # App-Loop - ret = app.exec_() - - # disable parenting - gCarla.host.set_engine_option(ENGINE_OPTION_FRONTEND_WIN_ID, 0, "0") - - sys.exit(ret) + app.exit_exec()