@@ -20,7 +20,9 @@ | |||
#include "CarlaStateUtils.hpp" | |||
#include "CarlaMIDI.h" | |||
#include <QtCore/QDir> | |||
#include <QtCore/QFile> | |||
#include <QtCore/QFileInfo> | |||
#include <QtCore/QTextStream> | |||
CARLA_BACKEND_START_NAMESPACE | |||
@@ -391,6 +393,40 @@ void doPluginRemove(CarlaEngineProtectedData* const kData, const bool unlock) | |||
kData->nextAction.mutex.unlock(); | |||
} | |||
const char* findDSSIGUI(const char* const filename, const char* const label) | |||
{ | |||
QString guiFilename; | |||
guiFilename.clear(); | |||
QString pluginDir(filename); | |||
pluginDir.resize(pluginDir.lastIndexOf(".")); | |||
QString shortName = QFileInfo(pluginDir).baseName(); | |||
QString checkLabel = QString(label); | |||
QString checkSName = shortName; | |||
if (! checkLabel.endsWith("_")) checkLabel += "_"; | |||
if (! checkSName.endsWith("_")) checkSName += "_"; | |||
QStringList guiFiles = QDir(pluginDir).entryList(); | |||
foreach (const QString& gui, guiFiles) | |||
{ | |||
if (gui.startsWith(checkLabel) || gui.startsWith(checkSName)) | |||
{ | |||
QFileInfo finalname(pluginDir + QDir::separator() + gui); | |||
guiFilename = finalname.absoluteFilePath(); | |||
break; | |||
} | |||
} | |||
if (guiFilename.isEmpty()) | |||
return nullptr; | |||
return carla_strdup(guiFilename.toUtf8().constData()); | |||
} | |||
// ----------------------------------------------------------------------- | |||
// Static values and calls | |||
@@ -993,8 +1029,13 @@ bool CarlaEngine::loadProject(const char* const filename) | |||
{ | |||
const SaveState& saveState = getSaveStateDictFromXML(node); | |||
const void* extraStuff = nullptr; | |||
if (std::strcmp(saveState.type, "DSSI") == 0) | |||
extraStuff = findDSSIGUI(saveState.binary, saveState.label); | |||
// TODO - proper find&load plugins | |||
if (addPlugin(getPluginTypeFromString(saveState.type), saveState.binary, saveState.name, saveState.label, nullptr)) | |||
if (addPlugin(getPluginTypeFromString(saveState.type), saveState.binary, saveState.name, saveState.label, extraStuff)) | |||
{ | |||
if (CarlaPlugin* plugin = getPlugin(kData->curPluginCount-1)) | |||
plugin->loadSaveState(saveState); | |||
@@ -597,7 +597,7 @@ void CarlaPlugin::loadSaveState(const SaveState& saveState) | |||
// Part 3 - set midi program | |||
if (saveState.currentMidiBank >= 0 && saveState.currentMidiProgram) | |||
setMidiProgramById(saveState.currentMidiBank, currentMidiProgram(), true, true, true); | |||
setMidiProgramById(saveState.currentMidiBank, saveState.currentMidiProgram, true, true, true); | |||
// --------------------------------------------------------------------- | |||
// Part 4a - get plugin parameter symbols | |||
@@ -1508,17 +1508,22 @@ void CarlaPlugin::updateOscData(const lo_address& source, const char* const url) | |||
osc_send_sample_rate(&kData->osc.data, kData->engine->getSampleRate()); | |||
#if 0 | |||
for (size_t i=0; i < kData->custom.count(); i++) | |||
for (size_t i=0, count=kData->custom.count(); i < count; i++) | |||
{ | |||
// TODO | |||
//if (m_type == PLUGIN_LV2) | |||
//osc_send_lv2_transfer_event(&osc.data, getCustomDataTypeString(custom[i].type), /*custom[i].key,*/ custom[i].value); | |||
//else | |||
if (custom[i].type == CUSTOM_DATA_STRING) | |||
osc_send_configure(&osc.data, custom[i].key, custom[i].value); | |||
} | |||
CustomData* const cData(kData->custom.getAt(i)); | |||
assert(cData->type != nullptr); | |||
assert(cData->key != nullptr); | |||
assert(cData->value != nullptr); | |||
#ifdef WANT_LV2 | |||
if (type() == PLUGIN_LV2) | |||
osc_send_lv2_transfer_event(&kData->osc.data, 0, cData->type, cData->value); | |||
else | |||
#endif | |||
if (std::strcmp(cData->type, CUSTOM_DATA_STRING) == 0) | |||
osc_send_configure(&kData->osc.data, cData->key, cData->value); | |||
} | |||
if (kData->prog.current >= 0) | |||
osc_send_program(&kData->osc.data, kData->prog.current); | |||
@@ -247,6 +247,7 @@ public: | |||
void setCustomData(const char* const type, const char* const key, const char* const value, const bool sendGui) | |||
{ | |||
carla_debug("DssiPlugin::setCustomData(%s, %s, %s, %s)", type, key, value, bool2str(sendGui)); | |||
CARLA_ASSERT(fDescriptor != nullptr); | |||
CARLA_ASSERT(fHandle != nullptr); | |||
CARLA_ASSERT(type != nullptr); | |||
@@ -101,39 +101,9 @@ void initSignalHandler() | |||
extern CarlaBackend::CarlaEngine* carla_get_standalone_engine(); | |||
const char* findDSSIGUI(const char* const filename, const char* const label) | |||
{ | |||
QString guiFilename; | |||
guiFilename.clear(); | |||
QString pluginDir(filename); | |||
pluginDir.resize(pluginDir.lastIndexOf(".")); | |||
QString shortName = QFileInfo(pluginDir).baseName(); | |||
QString checkLabel = QString(label); | |||
QString checkSName = shortName; | |||
if (! checkLabel.endsWith("_")) checkLabel += "_"; | |||
if (! checkSName.endsWith("_")) checkSName += "_"; | |||
QStringList guiFiles = QDir(pluginDir).entryList(); | |||
foreach (const QString& gui, guiFiles) | |||
{ | |||
if (gui.startsWith(checkLabel) || gui.startsWith(checkSName)) | |||
{ | |||
QFileInfo finalname(pluginDir + QDir::separator() + gui); | |||
guiFilename = finalname.absoluteFilePath(); | |||
break; | |||
} | |||
} | |||
if (guiFilename.isEmpty()) | |||
return nullptr; | |||
return carla_strdup(guiFilename.toUtf8().constData()); | |||
} | |||
CARLA_BACKEND_START_NAMESPACE | |||
extern const char* findDSSIGUI(const char* const filename, const char* const label); | |||
CARLA_BACKEND_END_NAMESPACE | |||
CARLA_BRIDGE_START_NAMESPACE | |||
@@ -537,7 +507,7 @@ int main(int argc, char* argv[]) | |||
const void* extraStuff = nullptr; | |||
if (itype == CarlaBackend::PLUGIN_DSSI) | |||
extraStuff = findDSSIGUI(filename, label); | |||
extraStuff = CarlaBackend::findDSSIGUI(filename, label); | |||
// Init plugin | |||
int ret; | |||