diff --git a/resources/ui/carla_host.ui b/resources/ui/carla_host.ui index a7ae77b7d..e5f9b897d 100644 --- a/resources/ui/carla_host.ui +++ b/resources/ui/carla_host.ui @@ -6,7 +6,7 @@ 0 0 - 1057 + 1045 716 @@ -335,8 +335,8 @@ 0 0 - 1057 - 20 + 1045 + 31 @@ -358,6 +358,9 @@ + + + @@ -462,10 +465,10 @@ - - + + - + @@ -1051,21 +1054,6 @@ Ctrl+A - - - - :/16x16/list-add.svgz:/16x16/list-add.svgz - - - Add Plugin... - - - Add Plugin... - - - Add Plugin... - - @@ -1110,15 +1098,6 @@ Center Balance - - - - :/16x16/dialog-warning.svgz:/16x16/dialog-warning.svgz - - - Panic - - true @@ -1380,28 +1359,36 @@ Perform secret 5 - + :/16x16/list-add.svgz:/16x16/list-add.svgz - Add &JACK Application + Add &JACK Application... - - Add JACK Application... + + + + + :/16x16/configure.svgz:/16x16/configure.svgz - - Add JACK Application... + + &Configure driver... - + - :/16x16/list-add.svgz:/16x16/list-add.svgz + :/16x16/dialog-warning.svgz:/16x16/dialog-warning.svgz - Add &JACK Application... + Panic + + + + + Open custom driver panel... diff --git a/resources/ui/carla_settings_driver.ui b/resources/ui/carla_settings_driver.ui index 5d7c1b647..784d9c111 100644 --- a/resources/ui/carla_settings_driver.ui +++ b/resources/ui/carla_settings_driver.ui @@ -6,15 +6,15 @@ 0 0 - 320 - 205 + 403 + 264 Driver Settings - + Device: @@ -24,11 +24,11 @@ - - + + - - + + Qt::Horizontal @@ -37,72 +37,72 @@ - 40 + 1 1 - - + + - - + + + + + + + Triple buffer + + + + + Qt::Horizontal - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + 40 + 1 + - + - - + + - Buffer size: + Sample rate: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - + + - Sample rate: + Buffer size: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - + + Qt::Horizontal - - QSizePolicy::Fixed - - 1 - 1 + 40 + 20 - - - - Triple buffer - - - - + @@ -118,7 +118,7 @@ - + 22 @@ -140,7 +140,7 @@ - + Restart the engine to load the new settings @@ -161,6 +161,39 @@ + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 40 + 1 + + + + + + + + Show Driver Control Panel + + + diff --git a/source/backend/CarlaEngine.hpp b/source/backend/CarlaEngine.hpp index e53fc9327..143bf8ad6 100644 --- a/source/backend/CarlaEngine.hpp +++ b/source/backend/CarlaEngine.hpp @@ -732,6 +732,12 @@ public: */ static const EngineDriverDeviceInfo* getDriverDeviceInfo(const uint index, const char* const driverName); + /*! + * Show a device custom control panel. + * @see ENGINE_DRIVER_DEVICE_HAS_CONTROL_PANEL + */ + static bool showDriverDeviceControlPanel(const uint index, const char* const deviceName); + /*! * Create a new engine, using driver @a driverName. * Returned value must be deleted when no longer needed. @@ -831,6 +837,11 @@ public: */ virtual void clearXruns() const noexcept; + /*! + * Show the custom control panel for the current engine device. + */ + virtual bool showDeviceControlPanel() const noexcept; + // ------------------------------------------------------------------- // Plugin management @@ -949,12 +960,6 @@ public: // ------------------------------------------------------------------- // Information (base) - /*! - * Get the current engine driver hints. - * @see EngineDriverHints - */ - uint getHints() const noexcept; - /*! * Get the current buffer size. */ @@ -1290,6 +1295,7 @@ public: static const char* getJuceApiName(const uint index); static const char* const* getJuceApiDeviceNames(const uint index); static const EngineDriverDeviceInfo* getJuceDeviceInfo(const uint index, const char* const deviceName); + static bool showJuceDeviceControlPanel(const uint index, const char* const deviceName); # else // RtAudio static CarlaEngine* newRtAudio(const AudioApi api); diff --git a/source/backend/CarlaHost.h b/source/backend/CarlaHost.h index 9748f8153..fd6cb52c3 100644 --- a/source/backend/CarlaHost.h +++ b/source/backend/CarlaHost.h @@ -290,6 +290,45 @@ typedef struct _CarlaRuntimeEngineInfo { } CarlaRuntimeEngineInfo; +/*! + * Runtime engine driver device information. + */ +typedef struct { + /*! + * Name of the driver device. + */ + const char* name; + + /*! + * This driver device hints. + * @see EngineDriverHints + */ + uint hints; + + /*! + * Current buffer size. + */ + uint bufferSize; + + /*! + * Available buffer sizes. + * Terminated with 0. + */ + const uint32_t* bufferSizes; + + /*! + * Current sample rate. + */ + double sampleRate; + + /*! + * Available sample rates. + * Terminated with 0.0. + */ + const double* sampleRates; + +} CarlaRuntimeEngineDriverDeviceInfo; + /*! * Image data for LV2 inline display API. * raw image pixmap format is ARGB32, @@ -328,6 +367,14 @@ CARLA_EXPORT const char* const* carla_get_engine_driver_device_names(uint index) */ CARLA_EXPORT const EngineDriverDeviceInfo* carla_get_engine_driver_device_info(uint index, const char* name); +/*! + * Show a device custom control panel. + * @see ENGINE_DRIVER_DEVICE_HAS_CONTROL_PANEL + * @param index Driver index + * @param name Device name + */ +CARLA_EXPORT bool carla_show_engine_driver_device_control_panel(uint index, const char* name); + #ifdef __cplusplus /*! * Get the currently used engine, may be NULL. @@ -375,6 +422,16 @@ CARLA_EXPORT bool carla_is_engine_running(); */ CARLA_EXPORT const CarlaRuntimeEngineInfo* carla_get_runtime_engine_info(); +/*! + * Get information about the currently running engine driver device. + */ +CARLA_EXPORT const CarlaRuntimeEngineDriverDeviceInfo* carla_get_runtime_engine_driver_device_info(); + +/*! + * Show the custom control panel for the current engine device. + */ +CARLA_EXPORT bool carla_show_engine_device_control_panel(); + /*! * Clear the xrun count on the engine, so that the next time carla_get_runtime_engine_info() is called, it returns 0. */ diff --git a/source/backend/CarlaStandalone.cpp b/source/backend/CarlaStandalone.cpp index bb75c454b..4ee276e5b 100644 --- a/source/backend/CarlaStandalone.cpp +++ b/source/backend/CarlaStandalone.cpp @@ -163,6 +163,11 @@ const EngineDriverDeviceInfo* carla_get_engine_driver_device_info(uint index, co return &retDevInfo; } +bool carla_show_engine_driver_device_control_panel(uint index, const char* name) +{ + return CarlaEngine::showDriverDeviceControlPanel(index, name); +} + // -------------------------------------------------------------------------------------------------------------------- CarlaEngine* carla_get_engine() @@ -493,6 +498,57 @@ const CarlaRuntimeEngineInfo* carla_get_runtime_engine_info() return &retInfo; } +const CarlaRuntimeEngineDriverDeviceInfo* carla_get_runtime_engine_driver_device_info() +{ + static CarlaRuntimeEngineDriverDeviceInfo retInfo; + + // reset + retInfo.name = gNullCharPtr; + retInfo.hints = 0x0; + retInfo.bufferSize = 0; + retInfo.bufferSizes = nullptr; + retInfo.sampleRate = 0.0; + retInfo.sampleRates = nullptr; + + CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr, &retInfo); + const char* const audioDriver = gStandalone.engine->getCurrentDriverName(); + + uint index = 0; + uint count = CarlaEngine::getDriverCount(); + for (; indexgetOptions()); + const char* const audioDevice = options.audioDevice; + + const EngineDriverDeviceInfo* const devInfo = CarlaEngine::getDriverDeviceInfo(index, audioDevice); + CARLA_SAFE_ASSERT_RETURN(devInfo != nullptr, &retInfo); + + retInfo.name = audioDevice; + retInfo.hints = devInfo->hints; + retInfo.bufferSize = gStandalone.engine->getBufferSize(); + retInfo.bufferSizes = devInfo->bufferSizes; + retInfo.sampleRate = gStandalone.engine->getSampleRate(); + retInfo.sampleRates = devInfo->sampleRates; + + return &retInfo; +} + +bool carla_show_engine_device_control_panel() +{ + CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr, false); + carla_debug("carla_show_engine_device_control_panel()"); + + return gStandalone.engine->showDeviceControlPanel(); +} + void carla_clear_engine_xruns() { if (gStandalone.engine != nullptr) diff --git a/source/backend/engine/CarlaEngine.cpp b/source/backend/engine/CarlaEngine.cpp index 0a8468b1a..79efa21f0 100644 --- a/source/backend/engine/CarlaEngine.cpp +++ b/source/backend/engine/CarlaEngine.cpp @@ -193,6 +193,38 @@ const EngineDriverDeviceInfo* CarlaEngine::getDriverDeviceInfo(const uint index2 return nullptr; } +bool CarlaEngine::showDriverDeviceControlPanel(const uint index2, const char* const deviceName) +{ + carla_debug("CarlaEngine::showDriverDeviceControlPanel(%i, \"%s\")", index2, deviceName); + + uint index = index2; + + if (jackbridge_is_ok() && index-- == 0) + { + return false; + } + +#ifndef BUILD_BRIDGE +# ifdef USING_JUCE + if (const uint count = getJuceApiCount()) + { + if (index < count) + return showJuceDeviceControlPanel(index, deviceName); + index -= count; + } +# else + if (const uint count = getRtAudioApiCount()) + { + if (index < count) + return false; + } +# endif +#endif + + carla_stderr("CarlaEngine::showDriverDeviceControlPanel(%i, \"%s\") - invalid index", index2, deviceName); + return false; +} + CarlaEngine* CarlaEngine::newDriverByName(const char* const driverName) { CARLA_SAFE_ASSERT_RETURN(driverName != nullptr && driverName[0] != '\0', nullptr); @@ -373,6 +405,11 @@ void CarlaEngine::clearXruns() const noexcept #endif } +bool CarlaEngine::showDeviceControlPanel() const noexcept +{ + return false; +} + // ----------------------------------------------------------------------- // Plugin management @@ -1203,11 +1240,6 @@ void CarlaEngine::clearCurrentProjectFilename() noexcept // ----------------------------------------------------------------------- // Information (base) -uint CarlaEngine::getHints() const noexcept -{ - return pData->hints; -} - uint32_t CarlaEngine::getBufferSize() const noexcept { return pData->bufferSize; diff --git a/source/backend/engine/CarlaEngineInternal.cpp b/source/backend/engine/CarlaEngineInternal.cpp index e4c8aeae3..777f09d3f 100644 --- a/source/backend/engine/CarlaEngineInternal.cpp +++ b/source/backend/engine/CarlaEngineInternal.cpp @@ -379,7 +379,6 @@ CarlaEngine::ProtectedData::ProtectedData(CarlaEngine* const engine) noexcept loadingProject(false), currentProjectFilename(), #endif - hints(0x0), bufferSize(0), sampleRate(0.0), aboutToClose(false), diff --git a/source/backend/engine/CarlaEngineInternal.hpp b/source/backend/engine/CarlaEngineInternal.hpp index fbc6435b5..d9ce9a101 100644 --- a/source/backend/engine/CarlaEngineInternal.hpp +++ b/source/backend/engine/CarlaEngineInternal.hpp @@ -231,7 +231,6 @@ struct CarlaEngine::ProtectedData { CarlaString currentProjectFilename; #endif - uint hints; uint32_t bufferSize; double sampleRate; diff --git a/source/backend/engine/CarlaEngineJuce.cpp b/source/backend/engine/CarlaEngineJuce.cpp index f78bd8782..5299afcb2 100644 --- a/source/backend/engine/CarlaEngineJuce.cpp +++ b/source/backend/engine/CarlaEngineJuce.cpp @@ -352,6 +352,13 @@ public: pData->xruns = xruns > 0 ? static_cast(xruns) : 0; } + bool showDeviceControlPanel() const noexcept override + { + try { + return fDevice->showControlPanel(); + } CARLA_SAFE_EXCEPTION_RETURN("showDeviceControlPanel", false); + } + // ------------------------------------------------------------------- // Patchbay @@ -1010,6 +1017,23 @@ const EngineDriverDeviceInfo* CarlaEngine::getJuceDeviceInfo(const uint uindex, return &devInfo; } +bool CarlaEngine::showJuceDeviceControlPanel(const uint uindex, const char* const deviceName) +{ + const int index(static_cast(uindex)); + + CARLA_SAFE_ASSERT_RETURN(index < gDeviceTypes.size(), false); + + juce::AudioIODeviceType* const deviceType(gDeviceTypes[index]); + CARLA_SAFE_ASSERT_RETURN(deviceType != nullptr, false); + + deviceType->scanForDevices(); + + ScopedPointer device(deviceType->createDevice(deviceName, deviceName)); + CARLA_SAFE_ASSERT_RETURN(device != nullptr, false); + + return device->showControlPanel(); +} + // ----------------------------------------- CARLA_BACKEND_END_NAMESPACE diff --git a/source/frontend/carla_backend.py b/source/frontend/carla_backend.py index 1547b3b74..8ff16d45b 100644 --- a/source/frontend/carla_backend.py +++ b/source/frontend/carla_backend.py @@ -1291,6 +1291,31 @@ class CarlaRuntimeEngineInfo(Structure): ("xruns", c_uint32) ] +# Runtime engine driver device information. +class CarlaRuntimeEngineDriverDeviceInfo(Structure): + _fields_ = [ + # Name of the driver device. + ("name", c_char_p), + + # This driver device hints. + # @see EngineDriverHints + ("hints", c_uint), + + # Current buffer size. + ("bufferSize", c_uint32), + + # Available buffer sizes. + # Terminated with 0. + ("bufferSizes", POINTER(c_uint32)), + + # Current sample rate. + ("sampleRate", c_double), + + # Available sample rates. + # Terminated with 0.0. + ("sampleRates", POINTER(c_double)) + ] + # Image data for LV2 inline display API. # raw image pixmap format is ARGB32, class CarlaInlineDisplayImageSurface(Structure): @@ -1342,18 +1367,28 @@ PyCarlaScalePointInfo = { # @see CarlaTransportInfo PyCarlaTransportInfo = { - "playing": False, - "frame": 0, - "bar": 0, - "beat": 0, - "tick": 0, - "bpm": 0.0 + 'playing': False, + 'frame': 0, + 'bar': 0, + 'beat': 0, + 'tick': 0, + 'bpm': 0.0 } # @see CarlaRuntimeEngineInfo PyCarlaRuntimeEngineInfo = { - "load": 0.0, - "xruns": 0 + 'load': 0.0, + 'xruns': 0 +} + +# @see CarlaRuntimeEngineDriverDeviceInfo +PyCarlaRuntimeEngineDriverDeviceInfo = { + 'name': "", + 'hints': 0x0, + 'bufferSize': 0, + 'bufferSizes': [], + 'sampleRate': 0.0, + 'sampleRates': [] } # ------------------------------------------------------------------------------------------------------------ @@ -1429,6 +1464,14 @@ class CarlaHostMeta(object): def get_engine_driver_device_info(self, index, name): raise NotImplementedError + # Show a device custom control panel. + # @see ENGINE_DRIVER_DEVICE_HAS_CONTROL_PANEL + # @param index Driver index + # @param name Device name + @abstractmethod + def show_engine_driver_device_control_panel(self, index, name): + raise NotImplementedError + # Initialize the engine. # Make sure to call carla_engine_idle() at regular intervals afterwards. # @param driverName Driver to use @@ -1460,6 +1503,15 @@ class CarlaHostMeta(object): def get_runtime_engine_info(self): raise NotImplementedError + # Get information about the currently running engine driver device. + @abstractmethod + def get_runtime_engine_driver_device_info(self): + raise NotImplementedError + + # Show the custom control panel for the current engine device. + def show_engine_device_control_panel(self): + raise NotImplementedError + # Clear the xrun count on the engine, so that the next time carla_get_runtime_engine_info() is called, it returns 0. @abstractmethod def clear_engine_xruns(self): @@ -2083,6 +2135,9 @@ class CarlaHostNull(CarlaHostMeta): def get_engine_driver_device_info(self, index, name): return PyEngineDriverDeviceInfo + def show_engine_driver_device_control_panel(self, index, name): + return False + def engine_init(self, driverName, clientName): self.fEngineRunning = True if self.fEngineCallback is not None: @@ -2110,6 +2165,12 @@ class CarlaHostNull(CarlaHostMeta): def get_runtime_engine_info(self): return PyCarlaRuntimeEngineInfo + def get_runtime_engine_driver_device_info(self): + return PyCarlaRuntimeEngineDriverDeviceInfo + + def show_engine_device_control_panel(self): + return False + def clear_engine_xruns(self): return @@ -2395,6 +2456,9 @@ class CarlaHostDLL(CarlaHostMeta): self.lib.carla_get_engine_driver_device_info.argtypes = [c_uint, c_char_p] self.lib.carla_get_engine_driver_device_info.restype = POINTER(EngineDriverDeviceInfo) + self.lib.carla_show_engine_driver_device_control_panel.argtypes = [c_uint, c_char_p] + self.lib.carla_show_engine_driver_device_control_panel.restype = c_bool + self.lib.carla_engine_init.argtypes = [c_char_p, c_char_p] self.lib.carla_engine_init.restype = c_bool @@ -2410,6 +2474,12 @@ class CarlaHostDLL(CarlaHostMeta): self.lib.carla_get_runtime_engine_info.argtypes = None self.lib.carla_get_runtime_engine_info.restype = POINTER(CarlaRuntimeEngineInfo) + self.lib.carla_get_runtime_engine_driver_device_info.argtypes = None + self.lib.carla_get_runtime_engine_driver_device_info.restype = POINTER(CarlaRuntimeEngineDriverDeviceInfo) + + self.lib.carla_show_engine_device_control_panel.argtypes = None + self.lib.carla_show_engine_device_control_panel.restype = c_bool + self.lib.carla_clear_engine_xruns.argtypes = None self.lib.carla_clear_engine_xruns.restype = None @@ -2685,6 +2755,9 @@ class CarlaHostDLL(CarlaHostMeta): def get_engine_driver_device_info(self, index, name): return structToDict(self.lib.carla_get_engine_driver_device_info(index, name.encode("utf-8")).contents) + def show_engine_driver_device_control_panel(self, index, name): + return bool(self.lib.carla_show_engine_driver_device_control_panel(index, name.encode("utf-8"))) + def engine_init(self, driverName, clientName): return bool(self.lib.carla_engine_init(driverName.encode("utf-8"), clientName.encode("utf-8"))) @@ -2700,11 +2773,17 @@ class CarlaHostDLL(CarlaHostMeta): def get_runtime_engine_info(self): return structToDict(self.lib.carla_get_runtime_engine_info().contents) + def get_runtime_engine_driver_device_info(self): + return structToDict(self.lib.carla_get_runtime_engine_driver_device_info().contents) + + def show_engine_device_control_panel(self): + return bool(self.lib.carla_show_engine_device_control_panel()) + def clear_engine_xruns(self): - return self.lib.carla_clear_engine_xruns() + self.lib.carla_clear_engine_xruns() def cancel_engine_action(self): - return self.lib.carla_cancel_engine_action() + self.lib.carla_cancel_engine_action() def set_engine_about_to_close(self): return bool(self.lib.carla_set_engine_about_to_close()) @@ -3078,9 +3157,18 @@ class CarlaHostPlugin(CarlaHostMeta): def get_engine_driver_device_info(self, index, name): return PyEngineDriverDeviceInfo + def show_engine_driver_device_control_panel(self, index, name): + return False + def get_runtime_engine_info(self): return self.fRuntimeEngineInfo + def get_runtime_engine_driver_device_info(self): + return PyCarlaRuntimeEngineDriverDeviceInfo + + def show_engine_device_control_panel(self): + return False + def clear_engine_xruns(self): self.sendMsg(["clear_engine_xruns"]) diff --git a/source/frontend/carla_host.py b/source/frontend/carla_host.py index 8f5d1a803..ccf1df6d5 100644 --- a/source/frontend/carla_host.py +++ b/source/frontend/carla_host.py @@ -423,13 +423,12 @@ class HostWindow(QMainWindow): self.ui.act_engine_start.triggered.connect(self.slot_engineStart) self.ui.act_engine_stop.triggered.connect(self.slot_engineStop) + self.ui.act_engine_panic.triggered.connect(self.slot_pluginsDisable) + self.ui.act_engine_config.triggered.connect(self.slot_engineConfig) self.ui.act_plugin_add.triggered.connect(self.slot_pluginAdd) - self.ui.act_plugin_add2.triggered.connect(self.slot_pluginAdd) - self.ui.act_plugin_remove_all.triggered.connect(self.slot_confirmRemoveAll) - - self.ui.act_add_jack.triggered.connect(self.slot_jackAppAdd) self.ui.act_plugin_add_jack.triggered.connect(self.slot_jackAppAdd) + self.ui.act_plugin_remove_all.triggered.connect(self.slot_confirmRemoveAll) self.ui.act_plugins_enable.triggered.connect(self.slot_pluginsEnable) self.ui.act_plugins_disable.triggered.connect(self.slot_pluginsDisable) @@ -440,7 +439,6 @@ class HostWindow(QMainWindow): self.ui.act_plugins_center.triggered.connect(self.slot_pluginsCenter) self.ui.act_plugins_compact.triggered.connect(self.slot_pluginsCompact) self.ui.act_plugins_expand.triggered.connect(self.slot_pluginsExpand) - self.ui.act_plugins_panic.triggered.connect(self.slot_pluginsDisable) self.ui.act_settings_show_toolbar.toggled.connect(self.slot_showToolbar) self.ui.act_settings_show_meters.toggled.connect(self.slot_showCanvasMeters) @@ -868,6 +866,17 @@ class HostWindow(QMainWindow): return self.slot_engineStopTryAgain() + @pyqtSlot() + def slot_engineConfig(self): + dialog = RuntimeDriverSettingsW(self.fParentOrSelf, self.host) + + if not dialog.exec_(): + return + + if not self.host.is_engine_running(): + QMessageBox.warning(self, self.tr("Warning"), self.tr("Engine was stopped while configuring settings, all changes have been ignored")) + return + @pyqtSlot() def slot_engineStopTryAgain(self): if self.host.is_engine_running() and not self.host.set_engine_about_to_close(): @@ -1746,10 +1755,8 @@ class HostWindow(QMainWindow): if self.host.experimental: visible = settings2.value(CARLA_KEY_EXPERIMENTAL_JACK_APPS, CARLA_DEFAULT_EXPERIMENTAL_JACK_APPS, type=bool) - self.ui.act_add_jack.setVisible(visible) self.ui.act_plugin_add_jack.setVisible(visible) else: - self.ui.act_add_jack.setVisible(False) self.ui.act_plugin_add_jack.setVisible(False) self.fMiniCanvasUpdateTimeout = 1000 if self.fSavedSettings[CARLA_KEY_CANVAS_FANCY_EYE_CANDY] else 0 diff --git a/source/frontend/carla_settings.py b/source/frontend/carla_settings.py index 6850d47ff..f48c4831c 100755 --- a/source/frontend/carla_settings.py +++ b/source/frontend/carla_settings.py @@ -82,6 +82,7 @@ class DriverSettingsW(QDialog): # Set-up connections self.accepted.connect(self.slot_saveSettings) + self.ui.b_panel.clicked.connect(self.slot_showDevicePanel) self.ui.cb_device.currentIndexChanged.connect(self.slot_updateDeviceInfo) # ---------------------------------------------------------------------------------------------------- @@ -139,6 +140,10 @@ class DriverSettingsW(QDialog): # -------------------------------------------------------------------------------------------------------- + @pyqtSlot() + def slot_showDevicePanel(self): + self.host.show_engine_driver_device_control_panel(self.fDriverIndex, self.ui.cb_device.currentText()) + @pyqtSlot() def slot_updateDeviceInfo(self): deviceName = self.ui.cb_device.currentText() @@ -159,6 +164,11 @@ class DriverSettingsW(QDialog): else: self.ui.cb_triple_buffer.setEnabled(False) + if driverDeviceHints & ENGINE_DRIVER_DEVICE_HAS_CONTROL_PANEL: + self.ui.b_panel.setEnabled(True) + else: + self.ui.b_panel.setEnabled(False) + if len(self.fBufferSizes) > 0: for bsize in self.fBufferSizes: sbsize = str(bsize) @@ -189,6 +199,107 @@ class DriverSettingsW(QDialog): QDialog.done(self, r) self.close() +# ------------------------------------------------------------------------------------------------------------ +# Runtime Driver Settings + +class RuntimeDriverSettingsW(QDialog): + def __init__(self, parent, host): + QDialog.__init__(self, parent) + self.host = host + self.ui = ui_carla_settings_driver.Ui_DriverSettingsW() + self.ui.setupUi(self) + + if False: + # kdevelop likes this :) + host = CarlaHostNull() + self.host = host + + driverDeviceInfo = host.get_runtime_engine_driver_device_info() + + # ---------------------------------------------------------------------------------------------------- + # Set-up GUI + + self.ui.cb_device.setEnabled(False) + self.ui.cb_device.clear() + self.ui.cb_buffersize.clear() + self.ui.cb_samplerate.clear() + self.ui.cb_triple_buffer.hide() + self.ui.ico_restart.hide() + self.ui.label_restart.hide() + + self.adjustSize() + self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) + #self.setFixedSize(self.size()) + + # ---------------------------------------------------------------------------------------------------- + # Load runtime settings + + self.ui.cb_device.addItem(driverDeviceInfo['name']) + self.ui.cb_device.setCurrentIndex(0) + + if len(driverDeviceInfo['bufferSizes']) > 0: + for bsize in driverDeviceInfo['bufferSizes']: + sbsize = str(bsize) + self.ui.cb_buffersize.addItem(sbsize) + + if driverDeviceInfo['bufferSize'] == bsize: + self.ui.cb_buffersize.setCurrentIndex(self.ui.cb_buffersize.count()-1) + + else: + self.ui.cb_buffersize.addItem(DriverSettingsW.AUTOMATIC_OPTION) + self.ui.cb_buffersize.setCurrentIndex(0) + + if (driverDeviceInfo['hints'] & ENGINE_DRIVER_DEVICE_VARIABLE_BUFFER_SIZE) == 0x0: + self.ui.cb_buffersize.setEnabled(False) + + if len(driverDeviceInfo['sampleRates']) > 0: + for srate in driverDeviceInfo['sampleRates']: + ssrate = str(int(srate)) + self.ui.cb_samplerate.addItem(ssrate) + + if driverDeviceInfo['sampleRate'] == srate: + self.ui.cb_samplerate.setCurrentIndex(self.ui.cb_samplerate.count()-1) + + else: + self.ui.cb_samplerate.addItem(DriverSettingsW.AUTOMATIC_OPTION) + self.ui.cb_samplerate.setCurrentIndex(0) + + if (driverDeviceInfo['hints'] & ENGINE_DRIVER_DEVICE_VARIABLE_SAMPLE_RATE) == 0x0: + self.ui.cb_samplerate.setEnabled(False) + + if (driverDeviceInfo['hints'] & ENGINE_DRIVER_DEVICE_HAS_CONTROL_PANEL) == 0x0: + self.ui.b_panel.setEnabled(False) + + # ---------------------------------------------------------------------------------------------------- + # Set-up connections + + self.ui.b_panel.clicked.connect(self.slot_showDevicePanel) + + # -------------------------------------------------------------------------------------------------------- + + def getValues(self): + bufferSize = self.ui.cb_buffersize.currentText() + sampleRate = self.ui.cb_samplerate.currentText() + + if bufferSize == self.AUTOMATIC_OPTION: + bufferSize = "0" + if sampleRate == self.AUTOMATIC_OPTION: + sampleRate = "0" + + return (int(bufferSize), int(sampleRate)) + + # -------------------------------------------------------------------------------------------------------- + + @pyqtSlot() + def slot_showDevicePanel(self): + self.host.show_engine_device_control_panel() + + # -------------------------------------------------------------------------------------------------------- + + def done(self, r): + QDialog.done(self, r) + self.close() + # ------------------------------------------------------------------------------------------------------------ # Settings Dialog