Browse Source

Pass initial engine options to plugin UI; Cleanup

tags/1.9.5
falkTX 10 years ago
parent
commit
613302ffb9
6 changed files with 123 additions and 28 deletions
  1. +64
    -5
      source/backend/engine/CarlaEngineNative.cpp
  2. +2
    -5
      source/carla_host.py
  3. +6
    -4
      source/externalui.py
  4. +1
    -1
      source/modules/native-plugins/resources/bigmeter-ui
  5. +49
    -12
      source/modules/native-plugins/resources/carla-plugin
  6. +1
    -1
      source/modules/native-plugins/resources/notes-ui

+ 64
- 5
source/backend/engine/CarlaEngineNative.cpp View File

@@ -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)
{
if (! fIsRunning)
return;
if (! fUiServer.isOk())
return;
CARLA_SAFE_ASSERT_RETURN(fIsRunning,);
CARLA_SAFE_ASSERT_RETURN(fUiServer.isOk(),);

CarlaPlugin* plugin;

@@ -921,6 +919,65 @@ protected:
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

@@ -1262,6 +1319,8 @@ protected:
fUiServer.setData(path, pData->sampleRate, pHost->uiName);
fUiServer.start();

uiServerOptions();

for (uint i=0; i < pData->curPluginCount; ++i)
{
CarlaPlugin* const plugin(pData->plugins[i].plugin);
@@ -1306,7 +1365,7 @@ protected:

for (uint32_t j=0, count=plugin->getParameterCount(); j < count; ++j)
{
if (plugin->isParameterOutput(j))
if (! plugin->isParameterOutput(j))
continue;

const CarlaMutexLocker cml(fUiServer.getWriteLock());


+ 2
- 5
source/carla_host.py View File

@@ -1050,9 +1050,6 @@ def engineCallback(host, action, pluginId, value1, value2, value3, valueStr):
# kdevelop likes this :)
if False: host = CarlaHostMeta()

# FIXME
if host is None: host = gCarla.gui.host

if action == ENGINE_CALLBACK_ENGINE_STARTED:
host.processMode = value1
host.transportMode = value2
@@ -1301,9 +1298,9 @@ def loadHostSettings(host):
host.preferPluginBridges = CARLA_DEFAULT_PREFER_PLUGIN_BRIDGES

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:
host.preferUiBridges = CARLA_DEFAULT_PREFER_UI_BRIDGES
host.preferUIBridges = CARLA_DEFAULT_PREFER_UI_BRIDGES

try:
host.uisAlwaysOnTop = settings.value(CARLA_KEY_ENGINE_UIS_ALWAYS_ON_TOP, CARLA_DEFAULT_UIS_ALWAYS_ON_TOP, type=bool)


+ 6
- 4
source/externalui.py View File

@@ -54,11 +54,13 @@ class ExternalUI(object):
self.fPipeRecv = 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()

# -------------------------------------------------------------------


+ 1
- 1
source/modules/native-plugins/resources/bigmeter-ui View File

@@ -44,7 +44,7 @@ class DistrhoUIBigMeter(ExternalUI, DigitalPeakMeter):

self.fIdleTimer = self.startTimer(30)

self.showUiIfTesting()
self.ready()

# -------------------------------------------------------------------
# DSP Callbacks


+ 49
- 12
source/modules/native-plugins/resources/carla-plugin View File

@@ -29,30 +29,44 @@ class PluginHost(CarlaHostPlugin):
def __init__(self):
CarlaHostPlugin.__init__(self)

if False:
# kdevelop likes this :)
self.fExternalUI = ExternalUI()

# ---------------------------------------------------------------

self.fExternalUI = None
self.fIsRunning = True
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):
# FIXME
gCarla.gui.send(lines)
if self.fExternalUI is None:
return False

self.fExternalUI.send(lines)
return True

# -------------------------------------------------------------------

def engine_init(self, driverName, clientName):
self.fIsRunning = True
return True

def engine_close(self):
self.fIsRunning = False
return True

def engine_idle(self):
if gCarla.gui.idleExternalUI():
if self.fExternalUI.idleExternalUI():
return

self.fIsRunning = False
gCarla.gui.d_uiQuit()
self.fExternalUI.d_uiQuit()

def is_engine_running(self):
return self.fIsRunning
@@ -65,19 +79,17 @@ class PluginHost(CarlaHostPlugin):

class CarlaMiniW(ExternalUI, HostWindow):
def __init__(self, host, parent=None):
# need to init this first
gCarla.gui = self

# now the regular stuff
ExternalUI.__init__(self)
HostWindow.__init__(self, host, parent)
self.host = host

if False:
# kdevelop likes this :)
host = CarlaHostPlugin()
host = PluginHost()
self.host = host

host.setExternalUI(self)

if sys.argv[0].lower().endswith("/carla-plugin-patchbay"):
from carla_patchbay import CarlaPatchbayW
self.fContainer = CarlaPatchbayW(self, host)
@@ -88,7 +100,7 @@ class CarlaMiniW(ExternalUI, HostWindow):
self.setupContainer(False)

self.setWindowTitle(self.fUiName)
self.showUiIfTesting()
self.ready()

# -------------------------------------------------------------------
# ExternalUI Callbacks
@@ -167,7 +179,32 @@ class CarlaMiniW(ExternalUI, HostWindow):
elif action == ENGINE_CALLBACK_MIDI_PROGRAM_CHANGED:
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_"):
pluginId = int(msg.replace("PLUGIN_INFO_", ""))
@@ -273,7 +310,7 @@ class CarlaMiniW(ExternalUI, HostWindow):

elif msg == "error":
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":
self.d_uiShow()


+ 1
- 1
source/modules/native-plugins/resources/notes-ui View File

@@ -90,7 +90,7 @@ class DistrhoUINotes(ExternalUI, QWidget):

self.fIdleTimer = self.startTimer(50)

self.showUiIfTesting()
self.ready()

def saveCurrentTextState(self):
pageKey = "pageText #%i" % self.fCurPage


Loading…
Cancel
Save