@@ -845,10 +845,8 @@ protected: | |||||
void uiServerCallback(const EngineCallbackOpcode action, const uint pluginId, const int value1, const int value2, const float value3, const char* const valueStr) | void uiServerCallback(const EngineCallbackOpcode action, const uint pluginId, const int value1, const int value2, const float value3, const char* const valueStr) | ||||
{ | { | ||||
if (! fIsRunning) | |||||
return; | |||||
if (! fUiServer.isOk()) | |||||
return; | |||||
CARLA_SAFE_ASSERT_RETURN(fIsRunning,); | |||||
CARLA_SAFE_ASSERT_RETURN(fUiServer.isOk(),); | |||||
CarlaPlugin* plugin; | CarlaPlugin* plugin; | ||||
@@ -921,6 +919,65 @@ protected: | |||||
fUiServer.writeAndFixMsg(valueStr); | fUiServer.writeAndFixMsg(valueStr); | ||||
} | } | ||||
void uiServerOptions() | |||||
{ | |||||
CARLA_SAFE_ASSERT_RETURN(fIsRunning,); | |||||
CARLA_SAFE_ASSERT_RETURN(fUiServer.isOk(),); | |||||
const EngineOptions& options(getOptions()); | |||||
const CarlaMutexLocker cml(fUiServer.getWriteLock()); | |||||
std::sprintf(fTmpBuf, "ENGINE_OPTION_%i\n", ENGINE_OPTION_PROCESS_MODE); | |||||
fUiServer.writeMsg(fTmpBuf); | |||||
std::sprintf(fTmpBuf, "%i\n", options.processMode); | |||||
fUiServer.writeMsg(fTmpBuf); | |||||
std::sprintf(fTmpBuf, "ENGINE_OPTION_%i\n", ENGINE_OPTION_TRANSPORT_MODE); | |||||
fUiServer.writeMsg(fTmpBuf); | |||||
std::sprintf(fTmpBuf, "%i\n", options.transportMode); | |||||
fUiServer.writeMsg(fTmpBuf); | |||||
std::sprintf(fTmpBuf, "ENGINE_OPTION_%i\n", ENGINE_OPTION_FORCE_STEREO); | |||||
fUiServer.writeMsg(fTmpBuf); | |||||
std::sprintf(fTmpBuf, "%s\n", bool2str(options.forceStereo)); | |||||
fUiServer.writeMsg(fTmpBuf); | |||||
std::sprintf(fTmpBuf, "ENGINE_OPTION_%i\n", ENGINE_OPTION_PREFER_PLUGIN_BRIDGES); | |||||
fUiServer.writeMsg(fTmpBuf); | |||||
std::sprintf(fTmpBuf, "%s\n", bool2str(options.preferPluginBridges)); | |||||
fUiServer.writeMsg(fTmpBuf); | |||||
std::sprintf(fTmpBuf, "ENGINE_OPTION_%i\n", ENGINE_OPTION_PREFER_UI_BRIDGES); | |||||
fUiServer.writeMsg(fTmpBuf); | |||||
std::sprintf(fTmpBuf, "%s\n", bool2str(options.preferUiBridges)); | |||||
fUiServer.writeMsg(fTmpBuf); | |||||
std::sprintf(fTmpBuf, "ENGINE_OPTION_%i\n", ENGINE_OPTION_UIS_ALWAYS_ON_TOP); | |||||
fUiServer.writeMsg(fTmpBuf); | |||||
std::sprintf(fTmpBuf, "%s\n", bool2str(options.uisAlwaysOnTop)); | |||||
fUiServer.writeMsg(fTmpBuf); | |||||
std::sprintf(fTmpBuf, "ENGINE_OPTION_%i\n", ENGINE_OPTION_MAX_PARAMETERS); | |||||
fUiServer.writeMsg(fTmpBuf); | |||||
std::sprintf(fTmpBuf, "%i\n", options.maxParameters); | |||||
fUiServer.writeMsg(fTmpBuf); | |||||
std::sprintf(fTmpBuf, "ENGINE_OPTION_%i\n", ENGINE_OPTION_UI_BRIDGES_TIMEOUT); | |||||
fUiServer.writeMsg(fTmpBuf); | |||||
std::sprintf(fTmpBuf, "%i\n", options.uiBridgesTimeout); | |||||
fUiServer.writeMsg(fTmpBuf); | |||||
std::sprintf(fTmpBuf, "ENGINE_OPTION_%i\n", ENGINE_OPTION_PATH_BINARIES); | |||||
fUiServer.writeMsg(fTmpBuf); | |||||
std::sprintf(fTmpBuf, "%s\n", options.binaryDir); | |||||
fUiServer.writeMsg(fTmpBuf); | |||||
std::sprintf(fTmpBuf, "ENGINE_OPTION_%i\n", ENGINE_OPTION_PATH_RESOURCES); | |||||
fUiServer.writeMsg(fTmpBuf); | |||||
std::sprintf(fTmpBuf, "%s\n", options.resourceDir); | |||||
fUiServer.writeMsg(fTmpBuf); | |||||
} | |||||
// ------------------------------------------------------------------- | // ------------------------------------------------------------------- | ||||
// Plugin parameter calls | // Plugin parameter calls | ||||
@@ -1262,6 +1319,8 @@ protected: | |||||
fUiServer.setData(path, pData->sampleRate, pHost->uiName); | fUiServer.setData(path, pData->sampleRate, pHost->uiName); | ||||
fUiServer.start(); | fUiServer.start(); | ||||
uiServerOptions(); | |||||
for (uint i=0; i < pData->curPluginCount; ++i) | for (uint i=0; i < pData->curPluginCount; ++i) | ||||
{ | { | ||||
CarlaPlugin* const plugin(pData->plugins[i].plugin); | CarlaPlugin* const plugin(pData->plugins[i].plugin); | ||||
@@ -1306,7 +1365,7 @@ protected: | |||||
for (uint32_t j=0, count=plugin->getParameterCount(); j < count; ++j) | for (uint32_t j=0, count=plugin->getParameterCount(); j < count; ++j) | ||||
{ | { | ||||
if (plugin->isParameterOutput(j)) | |||||
if (! plugin->isParameterOutput(j)) | |||||
continue; | continue; | ||||
const CarlaMutexLocker cml(fUiServer.getWriteLock()); | const CarlaMutexLocker cml(fUiServer.getWriteLock()); | ||||
@@ -1050,9 +1050,6 @@ def engineCallback(host, action, pluginId, value1, value2, value3, valueStr): | |||||
# kdevelop likes this :) | # kdevelop likes this :) | ||||
if False: host = CarlaHostMeta() | if False: host = CarlaHostMeta() | ||||
# FIXME | |||||
if host is None: host = gCarla.gui.host | |||||
if action == ENGINE_CALLBACK_ENGINE_STARTED: | if action == ENGINE_CALLBACK_ENGINE_STARTED: | ||||
host.processMode = value1 | host.processMode = value1 | ||||
host.transportMode = value2 | host.transportMode = value2 | ||||
@@ -1301,9 +1298,9 @@ def loadHostSettings(host): | |||||
host.preferPluginBridges = CARLA_DEFAULT_PREFER_PLUGIN_BRIDGES | host.preferPluginBridges = CARLA_DEFAULT_PREFER_PLUGIN_BRIDGES | ||||
try: | try: | ||||
host.preferUiBridges = settings.value(CARLA_KEY_ENGINE_PREFER_UI_BRIDGES, CARLA_DEFAULT_PREFER_UI_BRIDGES, type=bool) | |||||
host.preferUIBridges = settings.value(CARLA_KEY_ENGINE_PREFER_UI_BRIDGES, CARLA_DEFAULT_PREFER_UI_BRIDGES, type=bool) | |||||
except: | except: | ||||
host.preferUiBridges = CARLA_DEFAULT_PREFER_UI_BRIDGES | |||||
host.preferUIBridges = CARLA_DEFAULT_PREFER_UI_BRIDGES | |||||
try: | try: | ||||
host.uisAlwaysOnTop = settings.value(CARLA_KEY_ENGINE_UIS_ALWAYS_ON_TOP, CARLA_DEFAULT_UIS_ALWAYS_ON_TOP, type=bool) | host.uisAlwaysOnTop = settings.value(CARLA_KEY_ENGINE_UIS_ALWAYS_ON_TOP, CARLA_DEFAULT_UIS_ALWAYS_ON_TOP, type=bool) | ||||
@@ -54,11 +54,13 @@ class ExternalUI(object): | |||||
self.fPipeRecv = None | self.fPipeRecv = None | ||||
self.fPipeSend = None | self.fPipeSend = None | ||||
# send empty line (just newline char) | |||||
self.send([""]) | |||||
def showUiIfTesting(self): | |||||
if self.fPipeRecv is None: | |||||
def ready(self): | |||||
if self.fPipeRecv is not None: | |||||
# send empty line (just newline char) | |||||
self.send([""]) | |||||
else: | |||||
# testing, show UI only | |||||
self.d_uiShow() | self.d_uiShow() | ||||
# ------------------------------------------------------------------- | # ------------------------------------------------------------------- | ||||
@@ -44,7 +44,7 @@ class DistrhoUIBigMeter(ExternalUI, DigitalPeakMeter): | |||||
self.fIdleTimer = self.startTimer(30) | self.fIdleTimer = self.startTimer(30) | ||||
self.showUiIfTesting() | |||||
self.ready() | |||||
# ------------------------------------------------------------------- | # ------------------------------------------------------------------- | ||||
# DSP Callbacks | # DSP Callbacks | ||||
@@ -29,30 +29,44 @@ class PluginHost(CarlaHostPlugin): | |||||
def __init__(self): | def __init__(self): | ||||
CarlaHostPlugin.__init__(self) | CarlaHostPlugin.__init__(self) | ||||
if False: | |||||
# kdevelop likes this :) | |||||
self.fExternalUI = ExternalUI() | |||||
# --------------------------------------------------------------- | |||||
self.fExternalUI = None | |||||
self.fIsRunning = True | self.fIsRunning = True | ||||
self.fSampleRate = float(sys.argv[1]) if len(sys.argv) > 1 else 44100.0 | self.fSampleRate = float(sys.argv[1]) if len(sys.argv) > 1 else 44100.0 | ||||
# ------------------------------------------------------------------- | # ------------------------------------------------------------------- | ||||
def setExternalUI(self, extUI): | |||||
self.fExternalUI = extUI | |||||
def sendMsg(self, lines): | def sendMsg(self, lines): | ||||
# FIXME | |||||
gCarla.gui.send(lines) | |||||
if self.fExternalUI is None: | |||||
return False | |||||
self.fExternalUI.send(lines) | |||||
return True | return True | ||||
# ------------------------------------------------------------------- | # ------------------------------------------------------------------- | ||||
def engine_init(self, driverName, clientName): | def engine_init(self, driverName, clientName): | ||||
self.fIsRunning = True | |||||
return True | return True | ||||
def engine_close(self): | def engine_close(self): | ||||
self.fIsRunning = False | |||||
return True | return True | ||||
def engine_idle(self): | def engine_idle(self): | ||||
if gCarla.gui.idleExternalUI(): | |||||
if self.fExternalUI.idleExternalUI(): | |||||
return | return | ||||
self.fIsRunning = False | self.fIsRunning = False | ||||
gCarla.gui.d_uiQuit() | |||||
self.fExternalUI.d_uiQuit() | |||||
def is_engine_running(self): | def is_engine_running(self): | ||||
return self.fIsRunning | return self.fIsRunning | ||||
@@ -65,19 +79,17 @@ class PluginHost(CarlaHostPlugin): | |||||
class CarlaMiniW(ExternalUI, HostWindow): | class CarlaMiniW(ExternalUI, HostWindow): | ||||
def __init__(self, host, parent=None): | def __init__(self, host, parent=None): | ||||
# need to init this first | |||||
gCarla.gui = self | |||||
# now the regular stuff | |||||
ExternalUI.__init__(self) | ExternalUI.__init__(self) | ||||
HostWindow.__init__(self, host, parent) | HostWindow.__init__(self, host, parent) | ||||
self.host = host | self.host = host | ||||
if False: | if False: | ||||
# kdevelop likes this :) | # kdevelop likes this :) | ||||
host = CarlaHostPlugin() | |||||
host = PluginHost() | |||||
self.host = host | self.host = host | ||||
host.setExternalUI(self) | |||||
if sys.argv[0].lower().endswith("/carla-plugin-patchbay"): | if sys.argv[0].lower().endswith("/carla-plugin-patchbay"): | ||||
from carla_patchbay import CarlaPatchbayW | from carla_patchbay import CarlaPatchbayW | ||||
self.fContainer = CarlaPatchbayW(self, host) | self.fContainer = CarlaPatchbayW(self, host) | ||||
@@ -88,7 +100,7 @@ class CarlaMiniW(ExternalUI, HostWindow): | |||||
self.setupContainer(False) | self.setupContainer(False) | ||||
self.setWindowTitle(self.fUiName) | self.setWindowTitle(self.fUiName) | ||||
self.showUiIfTesting() | |||||
self.ready() | |||||
# ------------------------------------------------------------------- | # ------------------------------------------------------------------- | ||||
# ExternalUI Callbacks | # ExternalUI Callbacks | ||||
@@ -167,7 +179,32 @@ class CarlaMiniW(ExternalUI, HostWindow): | |||||
elif action == ENGINE_CALLBACK_MIDI_PROGRAM_CHANGED: | elif action == ENGINE_CALLBACK_MIDI_PROGRAM_CHANGED: | ||||
self.host._set_currentMidiProgram(pluginId, value1) | self.host._set_currentMidiProgram(pluginId, value1) | ||||
engineCallback(None, action, pluginId, value1, value2, value3, valueStr) | |||||
engineCallback(self.host, action, pluginId, value1, value2, value3, valueStr) | |||||
elif msg.startswith("ENGINE_OPTION_"): | |||||
option = int(msg.replace("ENGINE_OPTION_", "")) | |||||
value = self.readlineblock() | |||||
if option == ENGINE_OPTION_PROCESS_MODE: | |||||
self.host.processMode = int(value) | |||||
elif option == ENGINE_OPTION_TRANSPORT_MODE: | |||||
self.host.transportMode = int(value) | |||||
elif option == ENGINE_OPTION_FORCE_STEREO: | |||||
self.host.forceStereo = bool(value == "true") | |||||
elif option == ENGINE_OPTION_PREFER_PLUGIN_BRIDGES: | |||||
self.host.preferPluginBridges = bool(value == "true") | |||||
elif option == ENGINE_OPTION_PREFER_UI_BRIDGES: | |||||
self.host.preferUIBridges = bool(value == "true") | |||||
elif option == ENGINE_OPTION_UIS_ALWAYS_ON_TOP: | |||||
self.host.uisAlwaysOnTop = bool(value == "true") | |||||
elif option == ENGINE_OPTION_MAX_PARAMETERS: | |||||
self.host.maxParameters = int(value) | |||||
elif option == ENGINE_OPTION_UI_BRIDGES_TIMEOUT: | |||||
self.host.uiBridgesTimeout = int(value) | |||||
elif option == ENGINE_OPTION_PATH_BINARIES: | |||||
self.host.pathBinaries = value | |||||
elif option == ENGINE_OPTION_PATH_RESOURCES: | |||||
self.host.pathResources = value | |||||
elif msg.startswith("PLUGIN_INFO_"): | elif msg.startswith("PLUGIN_INFO_"): | ||||
pluginId = int(msg.replace("PLUGIN_INFO_", "")) | pluginId = int(msg.replace("PLUGIN_INFO_", "")) | ||||
@@ -273,7 +310,7 @@ class CarlaMiniW(ExternalUI, HostWindow): | |||||
elif msg == "error": | elif msg == "error": | ||||
error = self.readlineblock().replace("\r", "\n") | error = self.readlineblock().replace("\r", "\n") | ||||
engineCallback(None, ENGINE_CALLBACK_ERROR, 0, 0, 0, 0.0, error) | |||||
engineCallback(self.host, ENGINE_CALLBACK_ERROR, 0, 0, 0, 0.0, error) | |||||
elif msg == "show": | elif msg == "show": | ||||
self.d_uiShow() | self.d_uiShow() | ||||
@@ -90,7 +90,7 @@ class DistrhoUINotes(ExternalUI, QWidget): | |||||
self.fIdleTimer = self.startTimer(50) | self.fIdleTimer = self.startTimer(50) | ||||
self.showUiIfTesting() | |||||
self.ready() | |||||
def saveCurrentTextState(self): | def saveCurrentTextState(self): | ||||
pageKey = "pageText #%i" % self.fCurPage | pageKey = "pageText #%i" % self.fCurPage | ||||