Browse Source

Introduce CARLA_PLUGIN_ONLY_BRIDGE build macro

Signed-off-by: falkTX <falktx@falktx.com>
pull/1775/head
falkTX 2 years ago
parent
commit
9c00a93cb8
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
5 changed files with 122 additions and 100 deletions
  1. +7
    -2
      source/backend/CarlaPlugin.hpp
  2. +65
    -48
      source/backend/engine/CarlaEngine.cpp
  3. +16
    -14
      source/backend/plugin/CarlaPlugin.cpp
  4. +29
    -31
      source/utils/CarlaStateUtils.cpp
  5. +5
    -5
      source/utils/CarlaStateUtils.hpp

+ 7
- 2
source/backend/CarlaPlugin.hpp View File

@@ -1,6 +1,6 @@
/* /*
* Carla Plugin Host * Carla Plugin Host
* Copyright (C) 2011-2022 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2011-2023 Filipe Coelho <falktx@falktx.com>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
@@ -451,10 +451,12 @@ public:
*/ */
bool loadStateFromFile(const char* filename); bool loadStateFromFile(const char* filename);


#ifndef CARLA_PLUGIN_ONLY_BRIDGE
/*! /*!
* Export this plugin as its own LV2 plugin, using a carla wrapper around it for the LV2 functionality. * Export this plugin as its own LV2 plugin, using a carla wrapper around it for the LV2 functionality.
*/ */
bool exportAsLV2(const char* lv2path); bool exportAsLV2(const char* lv2path);
#endif


// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Set data (internal stuff) // Set data (internal stuff)
@@ -967,11 +969,13 @@ public:
const uint options; // see PluginOptions const uint options; // see PluginOptions
}; };


static CarlaPluginPtr newNative(const Initializer& init);
static CarlaPluginPtr newBridge(const Initializer& init, static CarlaPluginPtr newBridge(const Initializer& init,
BinaryType btype, PluginType ptype, BinaryType btype, PluginType ptype,
const char* binaryArchName, const char* bridgeBinary); const char* binaryArchName, const char* bridgeBinary);


#ifndef CARLA_PLUGIN_ONLY_BRIDGE
static CarlaPluginPtr newNative(const Initializer& init);

static CarlaPluginPtr newLADSPA(const Initializer& init, const LADSPA_RDF_Descriptor* rdfDescriptor); static CarlaPluginPtr newLADSPA(const Initializer& init, const LADSPA_RDF_Descriptor* rdfDescriptor);
static CarlaPluginPtr newDSSI(const Initializer& init); static CarlaPluginPtr newDSSI(const Initializer& init);
static CarlaPluginPtr newLV2(const Initializer& init); static CarlaPluginPtr newLV2(const Initializer& init);
@@ -986,6 +990,7 @@ public:
static CarlaPluginPtr newSFZero(const Initializer& init); static CarlaPluginPtr newSFZero(const Initializer& init);


static CarlaPluginPtr newJackApp(const Initializer& init); static CarlaPluginPtr newJackApp(const Initializer& init);
#endif
#endif #endif


// ------------------------------------------------------------------- // -------------------------------------------------------------------


+ 65
- 48
source/backend/engine/CarlaEngine.cpp View File

@@ -1,6 +1,6 @@
/* /*
* Carla Plugin Host * Carla Plugin Host
* Copyright (C) 2011-2022 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2011-2023 Filipe Coelho <falktx@falktx.com>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
@@ -319,7 +319,7 @@ CarlaEngine* CarlaEngine::newDriverByName(const char* const driverName)
return newJack(); return newJack();
#endif #endif


#if !(defined(BUILD_BRIDGE_ALTERNATIVE_ARCH) || defined(CARLA_OS_WASM))
#if !(defined(BUILD_BRIDGE_ALTERNATIVE_ARCH) || defined(CARLA_OS_WASM) || defined(STATIC_PLUGIN_TARGET))
if (std::strcmp(driverName, "Dummy") == 0) if (std::strcmp(driverName, "Dummy") == 0)
return newDummy(); return newDummy();
#endif #endif
@@ -574,7 +574,7 @@ bool CarlaEngine::addPlugin(const BinaryType btype,


uint id; uint id;


#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
CarlaPluginPtr oldPlugin; CarlaPluginPtr oldPlugin;


if (pData->nextPluginId < pData->curPluginCount) if (pData->nextPluginId < pData->curPluginCount)
@@ -587,7 +587,7 @@ bool CarlaEngine::addPlugin(const BinaryType btype,
CARLA_SAFE_ASSERT_RETURN_ERR(oldPlugin.get() != nullptr, "Invalid replace plugin Id"); CARLA_SAFE_ASSERT_RETURN_ERR(oldPlugin.get() != nullptr, "Invalid replace plugin Id");
} }
else else
#endif
#endif
{ {
id = pData->curPluginCount; id = pData->curPluginCount;


@@ -597,9 +597,9 @@ bool CarlaEngine::addPlugin(const BinaryType btype,
return false; return false;
} }


#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
CARLA_SAFE_ASSERT_RETURN_ERR(pData->plugins[id].plugin.get() == nullptr, "Invalid engine internal data"); CARLA_SAFE_ASSERT_RETURN_ERR(pData->plugins[id].plugin.get() == nullptr, "Invalid engine internal data");
#endif
#endif
} }


CarlaPlugin::Initializer initializer = { CarlaPlugin::Initializer initializer = {
@@ -617,13 +617,13 @@ bool CarlaEngine::addPlugin(const BinaryType btype,


if (bridgeBinary.isNotEmpty()) if (bridgeBinary.isNotEmpty())
{ {
#ifndef CARLA_OS_WIN
#ifndef CARLA_OS_WIN
if (btype == BINARY_NATIVE) if (btype == BINARY_NATIVE)
{ {
bridgeBinary += CARLA_OS_SEP_STR "carla-bridge-native"; bridgeBinary += CARLA_OS_SEP_STR "carla-bridge-native";
} }
else else
#endif
#endif
{ {
switch (btype) switch (btype)
{ {
@@ -634,18 +634,18 @@ bool CarlaEngine::addPlugin(const BinaryType btype,
bridgeBinary += CARLA_OS_SEP_STR "carla-bridge-posix64"; bridgeBinary += CARLA_OS_SEP_STR "carla-bridge-posix64";
break; break;
case BINARY_WIN32: case BINARY_WIN32:
#if defined(CARLA_OS_WIN) && !defined(CARLA_OS_64BIT)
#if defined(CARLA_OS_WIN) && !defined(CARLA_OS_64BIT)
bridgeBinary += CARLA_OS_SEP_STR "carla-bridge-native.exe"; bridgeBinary += CARLA_OS_SEP_STR "carla-bridge-native.exe";
#else
#else
bridgeBinary += CARLA_OS_SEP_STR "carla-bridge-win32.exe"; bridgeBinary += CARLA_OS_SEP_STR "carla-bridge-win32.exe";
#endif
#endif
break; break;
case BINARY_WIN64: case BINARY_WIN64:
#if defined(CARLA_OS_WIN) && defined(CARLA_OS_64BIT)
#if defined(CARLA_OS_WIN) && defined(CARLA_OS_64BIT)
bridgeBinary += CARLA_OS_SEP_STR "carla-bridge-native.exe"; bridgeBinary += CARLA_OS_SEP_STR "carla-bridge-native.exe";
#else
#else
bridgeBinary += CARLA_OS_SEP_STR "carla-bridge-win64.exe"; bridgeBinary += CARLA_OS_SEP_STR "carla-bridge-win64.exe";
#endif
#endif
break; break;
default: default:
bridgeBinary.clear(); bridgeBinary.clear();
@@ -669,16 +669,16 @@ bool CarlaEngine::addPlugin(const BinaryType btype,
bool preferBridges = pData->options.preferPluginBridges; bool preferBridges = pData->options.preferPluginBridges;
const char* needsArchBridge = nullptr; const char* needsArchBridge = nullptr;


#ifdef CARLA_OS_MAC
#ifdef CARLA_OS_MAC
// Plugin might be in quarentine due to Apple stupid notarization rules, let's remove that if possible // Plugin might be in quarentine due to Apple stupid notarization rules, let's remove that if possible
if (canBeBridged && ptype != PLUGIN_LV2 && ptype != PLUGIN_AU) if (canBeBridged && ptype != PLUGIN_LV2 && ptype != PLUGIN_AU)
removeFileFromQuarantine(filename); removeFileFromQuarantine(filename);
#endif
#endif


#ifndef BUILD_BRIDGE
#ifndef BUILD_BRIDGE
if (canBeBridged && ! preferBridges) if (canBeBridged && ! preferBridges)
{ {
# if 0
/*
if (ptype == PLUGIN_LV2 && label != nullptr) if (ptype == PLUGIN_LV2 && label != nullptr)
{ {
if (std::strncmp(label, "http://calf.sourceforge.net/plugins/", 36) == 0 || if (std::strncmp(label, "http://calf.sourceforge.net/plugins/", 36) == 0 ||
@@ -688,8 +688,8 @@ bool CarlaEngine::addPlugin(const BinaryType btype,
preferBridges = true; preferBridges = true;
} }
} }
# endif
# ifdef ADAPT_FOR_APPLE_SILLICON
*/
#ifdef ADAPT_FOR_APPLE_SILLICON
// see if this binary needs bridging // see if this binary needs bridging
if (ptype == PLUGIN_VST2 || ptype == PLUGIN_VST3) if (ptype == PLUGIN_VST2 || ptype == PLUGIN_VST3)
{ {
@@ -699,13 +699,13 @@ bool CarlaEngine::addPlugin(const BinaryType btype,
if (const char* const output = magic.getFileDescription(vst2Binary)) if (const char* const output = magic.getFileDescription(vst2Binary))
{ {
carla_stdout("VST binary magic output is '%s'", output); carla_stdout("VST binary magic output is '%s'", output);
# ifdef __aarch64__
#ifdef __aarch64__
if (std::strstr(output, "arm64") == nullptr && std::strstr(output, "x86_64") != nullptr) if (std::strstr(output, "arm64") == nullptr && std::strstr(output, "x86_64") != nullptr)
needsArchBridge = "x86_64"; needsArchBridge = "x86_64";
# else
#else
if (std::strstr(output, "x86_64") == nullptr && std::strstr(output, "arm64") != nullptr) if (std::strstr(output, "x86_64") == nullptr && std::strstr(output, "arm64") != nullptr)
needsArchBridge = "arm64"; needsArchBridge = "arm64";
# endif
#endif
} }
else else
{ {
@@ -717,11 +717,21 @@ bool CarlaEngine::addPlugin(const BinaryType btype,
carla_stdout("Search for binary in VST bundle failed"); carla_stdout("Search for binary in VST bundle failed");
} }
} }
# endif
#endif // ADAPT_FOR_APPLE_SILLICON
} }
#endif // ! BUILD_BRIDGE
#endif // ! BUILD_BRIDGE


#ifndef CARLA_OS_WASM
#if defined(CARLA_PLUGIN_ONLY_BRIDGE)
if (bridgeBinary.isNotEmpty())
{
plugin = CarlaPlugin::newBridge(initializer, btype, ptype, needsArchBridge, bridgeBinary);
}
else
{
setLastError("Cannot load plugin, the required plugin bridge is not available");
return false;
}
#elif !defined(CARLA_OS_WASM)
if (canBeBridged && (needsArchBridge || btype != BINARY_NATIVE || (preferBridges && bridgeBinary.isNotEmpty()))) if (canBeBridged && (needsArchBridge || btype != BINARY_NATIVE || (preferBridges && bridgeBinary.isNotEmpty())))
{ {
if (bridgeBinary.isNotEmpty()) if (bridgeBinary.isNotEmpty())
@@ -735,11 +745,12 @@ bool CarlaEngine::addPlugin(const BinaryType btype,
} }
} }
else else
#endif
#endif
#ifndef CARLA_PLUGIN_ONLY_BRIDGE
{ {
#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
bool use16Outs; bool use16Outs;
#endif
#endif
setLastError("Invalid or unsupported plugin type"); setLastError("Invalid or unsupported plugin type");


// Some stupid plugins mess up with global signals, err!! // Some stupid plugins mess up with global signals, err!!
@@ -779,7 +790,7 @@ bool CarlaEngine::addPlugin(const BinaryType btype,
plugin = CarlaPlugin::newCLAP(initializer); plugin = CarlaPlugin::newCLAP(initializer);
break; break;


#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
case PLUGIN_INTERNAL: case PLUGIN_INTERNAL:
plugin = CarlaPlugin::newNative(initializer); plugin = CarlaPlugin::newNative(initializer);
break; break;
@@ -792,7 +803,7 @@ bool CarlaEngine::addPlugin(const BinaryType btype,
break; break;


case PLUGIN_SFZ: case PLUGIN_SFZ:
# ifdef SFZ_FILES_USING_SFIZZ
#ifdef SFZ_FILES_USING_SFIZZ
{ {
CarlaPlugin::Initializer sfizzInitializer = { CarlaPlugin::Initializer sfizzInitializer = {
this, this,
@@ -806,9 +817,9 @@ bool CarlaEngine::addPlugin(const BinaryType btype,


plugin = CarlaPlugin::newLV2(sfizzInitializer); plugin = CarlaPlugin::newLV2(sfizzInitializer);
} }
# else
#else
plugin = CarlaPlugin::newSFZero(initializer); plugin = CarlaPlugin::newSFZero(initializer);
# endif
#endif
break; break;


case PLUGIN_JSFX: case PLUGIN_JSFX:
@@ -816,13 +827,13 @@ bool CarlaEngine::addPlugin(const BinaryType btype,
break; break;


case PLUGIN_JACK: case PLUGIN_JACK:
# ifdef HAVE_JACK
#ifdef HAVE_JACK
plugin = CarlaPlugin::newJackApp(initializer); plugin = CarlaPlugin::newJackApp(initializer);
# else
#else
setLastError("JACK plugin target is not available"); setLastError("JACK plugin target is not available");
# endif
#endif
break; break;
#else
#else
case PLUGIN_INTERNAL: case PLUGIN_INTERNAL:
case PLUGIN_DLS: case PLUGIN_DLS:
case PLUGIN_GIG: case PLUGIN_GIG:
@@ -832,16 +843,17 @@ bool CarlaEngine::addPlugin(const BinaryType btype,
case PLUGIN_JSFX: case PLUGIN_JSFX:
setLastError("Plugin bridges cannot handle this binary"); setLastError("Plugin bridges cannot handle this binary");
break; break;
#endif
#endif // BUILD_BRIDGE_ALTERNATIVE_ARCH
} }
} }
#endif // CARLA_PLUGIN_ONLY_BRIDGE


if (plugin.get() == nullptr) if (plugin.get() == nullptr)
return false; return false;


plugin->reload(); plugin->reload();


#ifdef SFZ_FILES_USING_SFIZZ
#ifdef SFZ_FILES_USING_SFIZZ
if (ptype == PLUGIN_SFZ && plugin->getType() == PLUGIN_LV2) if (ptype == PLUGIN_SFZ && plugin->getType() == PLUGIN_LV2)
{ {
plugin->setCustomData(LV2_ATOM__Path, plugin->setCustomData(LV2_ATOM__Path,
@@ -851,7 +863,7 @@ bool CarlaEngine::addPlugin(const BinaryType btype,


plugin->restoreLV2State(true); plugin->restoreLV2State(true);
} }
#endif
#endif


bool canRun = true; bool canRun = true;


@@ -873,7 +885,7 @@ bool CarlaEngine::addPlugin(const BinaryType btype,
pluginData.plugin = plugin; pluginData.plugin = plugin;
carla_zeroFloats(pluginData.peaks, 4); carla_zeroFloats(pluginData.peaks, 4);


#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
if (oldPlugin.get() != nullptr) if (oldPlugin.get() != nullptr)
{ {
CARLA_SAFE_ASSERT(! pData->loadingProject); CARLA_SAFE_ASSERT(! pData->loadingProject);
@@ -905,7 +917,7 @@ bool CarlaEngine::addPlugin(const BinaryType btype,
callback(true, true, ENGINE_CALLBACK_RELOAD_ALL, id, 0, 0, 0, 0.0f, nullptr); callback(true, true, ENGINE_CALLBACK_RELOAD_ALL, id, 0, 0, 0, 0.0f, nullptr);
} }
else if (! pData->loadingProject) else if (! pData->loadingProject)
#endif
#endif
{ {
plugin->setEnabled(true); plugin->setEnabled(true);


@@ -915,13 +927,18 @@ bool CarlaEngine::addPlugin(const BinaryType btype,
if (getType() != kEngineTypeBridge) if (getType() != kEngineTypeBridge)
plugin->setActive(true, true, true); plugin->setActive(true, true, true);


#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
if (pData->options.processMode == ENGINE_PROCESS_MODE_PATCHBAY) if (pData->options.processMode == ENGINE_PROCESS_MODE_PATCHBAY)
pData->graph.addPlugin(plugin); pData->graph.addPlugin(plugin);
#endif
#endif
} }


return true; return true;

#if defined(BUILD_BRIDGE_ALTERNATIVE_ARCH) || defined(CARLA_PLUGIN_ONLY_BRIDGE)
// unused
(void)extra;
#endif
} }


bool CarlaEngine::addPlugin(const PluginType ptype, bool CarlaEngine::addPlugin(const PluginType ptype,
@@ -2947,7 +2964,7 @@ bool CarlaEngine::loadProjectInternal(water::XmlDocument& xmlDoc, const bool alw


CARLA_SAFE_ASSERT_CONTINUE(stateSave.type != nullptr); CARLA_SAFE_ASSERT_CONTINUE(stateSave.type != nullptr);


#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
#if !(defined(BUILD_BRIDGE_ALTERNATIVE_ARCH) || defined(CARLA_PLUGIN_ONLY_BRIDGE))
// compatibility code to load projects with GIG files // compatibility code to load projects with GIG files
// FIXME Remove on 2.1 release // FIXME Remove on 2.1 release
if (std::strcmp(stateSave.type, "GIG") == 0) if (std::strcmp(stateSave.type, "GIG") == 0)
@@ -3008,7 +3025,7 @@ bool CarlaEngine::loadProjectInternal(water::XmlDocument& xmlDoc, const bool alw
callback(true, true, ENGINE_CALLBACK_IDLE, 0, 0, 0, 0, 0.0f, nullptr); callback(true, true, ENGINE_CALLBACK_IDLE, 0, 0, 0, 0, 0.0f, nullptr);
continue; continue;
} }
# ifdef SFZ_FILES_USING_SFIZZ
#ifdef SFZ_FILES_USING_SFIZZ
if (std::strcmp(stateSave.type, "SFZ") == 0) if (std::strcmp(stateSave.type, "SFZ") == 0)
{ {
if (addPlugin(PLUGIN_LV2, "", stateSave.name, "http://sfztools.github.io/sfizz", 0, nullptr)) if (addPlugin(PLUGIN_LV2, "", stateSave.name, "http://sfztools.github.io/sfizz", 0, nullptr))
@@ -3063,8 +3080,8 @@ bool CarlaEngine::loadProjectInternal(water::XmlDocument& xmlDoc, const bool alw
callback(true, true, ENGINE_CALLBACK_IDLE, 0, 0, 0, 0, 0.0f, nullptr); callback(true, true, ENGINE_CALLBACK_IDLE, 0, 0, 0, 0, 0.0f, nullptr);
continue; continue;
} }
# endif
#endif
#endif
#endif


const void* extraStuff = nullptr; const void* extraStuff = nullptr;
static const char kTrue[] = "true"; static const char kTrue[] = "true";


+ 16
- 14
source/backend/plugin/CarlaPlugin.cpp View File

@@ -1,6 +1,6 @@
/* /*
* Carla Plugin * Carla Plugin
* Copyright (C) 2011-2022 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2011-2023 Filipe Coelho <falktx@falktx.com>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
@@ -536,14 +536,14 @@ const CarlaStateSave& CarlaPlugin::getStateSave(const bool callPrepareForSave)
pData->stateSave.name = carla_strdup(pData->name); pData->stateSave.name = carla_strdup(pData->name);
pData->stateSave.label = carla_strdup(strBuf); pData->stateSave.label = carla_strdup(strBuf);
pData->stateSave.uniqueId = getUniqueId(); pData->stateSave.uniqueId = getUniqueId();
#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
// #ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
pData->stateSave.options = pData->options; pData->stateSave.options = pData->options;
#endif
// #endif


if (pData->filename != nullptr) if (pData->filename != nullptr)
pData->stateSave.binary = carla_strdup(pData->filename); pData->stateSave.binary = carla_strdup(pData->filename);


#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
#if !(defined(BUILD_BRIDGE_ALTERNATIVE_ARCH) || defined(CARLA_PLUGIN_ONLY_BRIDGE))
// --------------------------------------------------------------- // ---------------------------------------------------------------
// Internals // Internals


@@ -554,7 +554,7 @@ const CarlaStateSave& CarlaPlugin::getStateSave(const bool callPrepareForSave)
pData->stateSave.balanceRight = pData->postProc.balanceRight; pData->stateSave.balanceRight = pData->postProc.balanceRight;
pData->stateSave.panning = pData->postProc.panning; pData->stateSave.panning = pData->postProc.panning;
pData->stateSave.ctrlChannel = pData->ctrlChannel; pData->stateSave.ctrlChannel = pData->ctrlChannel;
#endif
#endif


if (pData->hints & PLUGIN_IS_BRIDGE) if (pData->hints & PLUGIN_IS_BRIDGE)
waitForBridgeSaveSignal(); waitForBridgeSaveSignal();
@@ -621,7 +621,7 @@ const CarlaStateSave& CarlaPlugin::getStateSave(const bool callPrepareForSave)


stateParameter->dummy = dummy; stateParameter->dummy = dummy;
stateParameter->index = paramData.index; stateParameter->index = paramData.index;
#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
#if !(defined(BUILD_BRIDGE_ALTERNATIVE_ARCH) || defined(CARLA_PLUGIN_ONLY_BRIDGE))
if (paramData.mappedControlIndex != CONTROL_INDEX_MIDI_LEARN) if (paramData.mappedControlIndex != CONTROL_INDEX_MIDI_LEARN)
{ {
stateParameter->mappedControlIndex = paramData.mappedControlIndex; stateParameter->mappedControlIndex = paramData.mappedControlIndex;
@@ -640,7 +640,7 @@ const CarlaStateSave& CarlaPlugin::getStateSave(const bool callPrepareForSave)
} }
} }
} }
#endif
#endif


if (! getParameterName(i, strBuf)) if (! getParameterName(i, strBuf))
strBuf[0] = '\0'; strBuf[0] = '\0';
@@ -859,7 +859,7 @@ void CarlaPlugin::loadStateSave(const CarlaStateSave& stateSave)
setParameterValue(static_cast<uint32_t>(index), stateParameter->value, true, true, true); setParameterValue(static_cast<uint32_t>(index), stateParameter->value, true, true, true);
} }


#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
#if !(defined(BUILD_BRIDGE_ALTERNATIVE_ARCH) || defined(CARLA_PLUGIN_ONLY_BRIDGE))
if (stateParameter->mappedRangeValid) if (stateParameter->mappedRangeValid)
{ {
if (pData->param.data[index].hints & PARAMETER_USES_SAMPLERATE) if (pData->param.data[index].hints & PARAMETER_USES_SAMPLERATE)
@@ -876,7 +876,7 @@ void CarlaPlugin::loadStateSave(const CarlaStateSave& stateSave)
setParameterMappedControlIndex(static_cast<uint32_t>(index), setParameterMappedControlIndex(static_cast<uint32_t>(index),
stateParameter->mappedControlIndex, true, true, false); stateParameter->mappedControlIndex, true, true, false);
setParameterMidiChannel(static_cast<uint32_t>(index), stateParameter->midiChannel, true, true); setParameterMidiChannel(static_cast<uint32_t>(index), stateParameter->midiChannel, true, true);
#endif
#endif
} }
else else
carla_stderr("Could not set parameter '%s' value for '%s'", carla_stderr("Could not set parameter '%s' value for '%s'",
@@ -939,14 +939,14 @@ void CarlaPlugin::loadStateSave(const CarlaStateSave& stateSave)
if (stateSave.chunk != nullptr && (pData->options & PLUGIN_OPTION_USE_CHUNKS) != 0) if (stateSave.chunk != nullptr && (pData->options & PLUGIN_OPTION_USE_CHUNKS) != 0)
{ {
std::vector<uint8_t> chunk(carla_getChunkFromBase64String(stateSave.chunk)); std::vector<uint8_t> chunk(carla_getChunkFromBase64String(stateSave.chunk));
#ifdef CARLA_PROPER_CPP11_SUPPORT
#ifdef CARLA_PROPER_CPP11_SUPPORT
setChunkData(chunk.data(), chunk.size()); setChunkData(chunk.data(), chunk.size());
#else
#else
setChunkData(&chunk.front(), chunk.size()); setChunkData(&chunk.front(), chunk.size());
#endif
#endif
} }


#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
#if !(defined(BUILD_BRIDGE_ALTERNATIVE_ARCH) || defined(CARLA_PLUGIN_ONLY_BRIDGE))
// --------------------------------------------------------------- // ---------------------------------------------------------------
// Part 6 - set internal stuff // Part 6 - set internal stuff


@@ -970,7 +970,7 @@ void CarlaPlugin::loadStateSave(const CarlaStateSave& stateSave)


if (! pData->engine->isLoadingProject()) if (! pData->engine->isLoadingProject())
pData->engine->callback(true, true, ENGINE_CALLBACK_UPDATE, pData->id, 0, 0, 0, 0.0f, nullptr); pData->engine->callback(true, true, ENGINE_CALLBACK_UPDATE, pData->id, 0, 0, 0, 0.0f, nullptr);
#endif
#endif
} }


bool CarlaPlugin::saveStateToFile(const char* const filename) bool CarlaPlugin::saveStateToFile(const char* const filename)
@@ -1026,6 +1026,7 @@ bool CarlaPlugin::loadStateFromFile(const char* const filename)
return false; return false;
} }


#ifndef CARLA_PLUGIN_ONLY_BRIDGE
bool CarlaPlugin::exportAsLV2(const char* const lv2path) bool CarlaPlugin::exportAsLV2(const char* const lv2path)
{ {
CARLA_SAFE_ASSERT_RETURN(lv2path != nullptr && lv2path[0] != '\0', false); CARLA_SAFE_ASSERT_RETURN(lv2path != nullptr && lv2path[0] != '\0', false);
@@ -1343,6 +1344,7 @@ bool CarlaPlugin::exportAsLV2(const char* const lv2path)


return true; return true;
} }
#endif


// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Set data (internal stuff) // Set data (internal stuff)


+ 29
- 31
source/utils/CarlaStateUtils.cpp View File

@@ -1,6 +1,6 @@
/* /*
* Carla State utils * Carla State utils
* Copyright (C) 2012-2022 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2012-2023 Filipe Coelho <falktx@falktx.com>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
@@ -122,16 +122,16 @@ CarlaStateSave::Parameter::Parameter() noexcept
index(-1), index(-1),
name(nullptr), name(nullptr),
symbol(nullptr), symbol(nullptr),
#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
#if !(defined(BUILD_BRIDGE_ALTERNATIVE_ARCH) || defined(CARLA_PLUGIN_ONLY_BRIDGE))
value(0.0f), value(0.0f),
mappedControlIndex(CONTROL_INDEX_NONE), mappedControlIndex(CONTROL_INDEX_NONE),
midiChannel(0), midiChannel(0),
mappedRangeValid(false), mappedRangeValid(false),
mappedMinimum(0.0f), mappedMinimum(0.0f),
mappedMaximum(1.0f) {} mappedMaximum(1.0f) {}
#else
#else
value(0.0f) {} value(0.0f) {}
#endif
#endif


CarlaStateSave::Parameter::~Parameter() noexcept CarlaStateSave::Parameter::~Parameter() noexcept
{ {
@@ -191,9 +191,9 @@ CarlaStateSave::CarlaStateSave() noexcept
label(nullptr), label(nullptr),
binary(nullptr), binary(nullptr),
uniqueId(0), uniqueId(0),
options(0x0),
options(PLUGIN_OPTIONS_NULL),
temporary(false), temporary(false),
#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
#if !(defined(BUILD_BRIDGE_ALTERNATIVE_ARCH) || defined(CARLA_PLUGIN_ONLY_BRIDGE))
active(false), active(false),
dryWet(1.0f), dryWet(1.0f),
volume(1.0f), volume(1.0f),
@@ -201,7 +201,7 @@ CarlaStateSave::CarlaStateSave() noexcept
balanceRight(1.0f), balanceRight(1.0f),
panning(0.0f), panning(0.0f),
ctrlChannel(-1), ctrlChannel(-1),
#endif
#endif
currentProgramIndex(-1), currentProgramIndex(-1),
currentProgramName(nullptr), currentProgramName(nullptr),
currentMidiBank(-1), currentMidiBank(-1),
@@ -249,9 +249,9 @@ void CarlaStateSave::clear() noexcept
} }


uniqueId = 0; uniqueId = 0;
options = 0x0;
options = PLUGIN_OPTIONS_NULL;


#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
#if !(defined(BUILD_BRIDGE_ALTERNATIVE_ARCH) || defined(CARLA_PLUGIN_ONLY_BRIDGE))
active = false; active = false;
dryWet = 1.0f; dryWet = 1.0f;
volume = 1.0f; volume = 1.0f;
@@ -259,7 +259,7 @@ void CarlaStateSave::clear() noexcept
balanceRight = 1.0f; balanceRight = 1.0f;
panning = 0.0f; panning = 0.0f;
ctrlChannel = -1; ctrlChannel = -1;
#endif
#endif


currentProgramIndex = -1; currentProgramIndex = -1;
currentMidiBank = -1; currentMidiBank = -1;
@@ -327,11 +327,17 @@ bool CarlaStateSave::fillFromXmlElement(const XmlElement* const xmlElement)
const String& tag(xmlData->getTagName()); const String& tag(xmlData->getTagName());
const String text(xmlData->getAllSubText().trim()); const String text(xmlData->getAllSubText().trim());


#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
// ------------------------------------------------------- // -------------------------------------------------------
// Internal Data // Internal Data


/**/ if (tag == "Active")
/**/ if (tag == "Options")
{
const int value(text.getHexValue32());
if (value > 0)
options = static_cast<uint>(value);
}
#if !(defined(BUILD_BRIDGE_ALTERNATIVE_ARCH) || defined(CARLA_PLUGIN_ONLY_BRIDGE))
else if (tag == "Active")
{ {
active = (text == "Yes"); active = (text == "Yes");
} }
@@ -364,15 +370,7 @@ bool CarlaStateSave::fillFromXmlElement(const XmlElement* const xmlElement)
ctrlChannel = static_cast<int8_t>(value-1); ctrlChannel = static_cast<int8_t>(value-1);
} }
} }
else if (tag == "Options")
{
const int value(text.getHexValue32());
if (value > 0)
options = static_cast<uint>(value);
}
#else
if (false) {}
#endif
#endif


// ------------------------------------------------------- // -------------------------------------------------------
// Program (current) // Program (current)
@@ -410,9 +408,9 @@ bool CarlaStateSave::fillFromXmlElement(const XmlElement* const xmlElement)
else if (tag == "Parameter") else if (tag == "Parameter")
{ {
Parameter* const stateParameter(new Parameter()); Parameter* const stateParameter(new Parameter());
#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
#if !(defined(BUILD_BRIDGE_ALTERNATIVE_ARCH) || defined(CARLA_PLUGIN_ONLY_BRIDGE))
bool hasMappedMinimum = false, hasMappedMaximum = false; bool hasMappedMinimum = false, hasMappedMaximum = false;
#endif
#endif


for (XmlElement* xmlSubData = xmlData->getFirstChildElement(); xmlSubData != nullptr; xmlSubData = xmlSubData->getNextElement()) for (XmlElement* xmlSubData = xmlData->getFirstChildElement(); xmlSubData != nullptr; xmlSubData = xmlSubData->getNextElement())
{ {
@@ -438,7 +436,7 @@ bool CarlaStateSave::fillFromXmlElement(const XmlElement* const xmlElement)
stateParameter->dummy = false; stateParameter->dummy = false;
stateParameter->value = pText.getFloatValue(); stateParameter->value = pText.getFloatValue();
} }
#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
#if !(defined(BUILD_BRIDGE_ALTERNATIVE_ARCH) || defined(CARLA_PLUGIN_ONLY_BRIDGE))
else if (pTag == "MidiChannel") else if (pTag == "MidiChannel")
{ {
const int channel(pText.getIntValue()); const int channel(pText.getIntValue());
@@ -468,13 +466,13 @@ bool CarlaStateSave::fillFromXmlElement(const XmlElement* const xmlElement)
hasMappedMaximum = true; hasMappedMaximum = true;
stateParameter->mappedMaximum = pText.getFloatValue(); stateParameter->mappedMaximum = pText.getFloatValue();
} }
#endif
#endif
} }


#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
#if !(defined(BUILD_BRIDGE_ALTERNATIVE_ARCH) || defined(CARLA_PLUGIN_ONLY_BRIDGE))
if (hasMappedMinimum && hasMappedMaximum) if (hasMappedMinimum && hasMappedMaximum)
stateParameter->mappedRangeValid = true; stateParameter->mappedRangeValid = true;
#endif
#endif


parameters.append(stateParameter); parameters.append(stateParameter);
} }
@@ -627,7 +625,7 @@ void CarlaStateSave::dumpToMemoryStream(MemoryOutputStream& content) const


content << " <Data>\n"; content << " <Data>\n";


#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
#if !(defined(BUILD_BRIDGE_ALTERNATIVE_ARCH) || defined(CARLA_PLUGIN_ONLY_BRIDGE))
{ {
MemoryOutputStream dataXml; MemoryOutputStream dataXml;


@@ -653,7 +651,7 @@ void CarlaStateSave::dumpToMemoryStream(MemoryOutputStream& content) const


content << dataXml; content << dataXml;
} }
#endif
#endif


for (ParameterItenerator it = parameters.begin2(); it.valid(); it.next()) for (ParameterItenerator it = parameters.begin2(); it.valid(); it.next())
{ {
@@ -675,7 +673,7 @@ void CarlaStateSave::dumpToMemoryStream(MemoryOutputStream& content) const
parameterXml << " <Symbol>" << xmlSafeString(stateParameter->symbol, true) << "</Symbol>\n"; parameterXml << " <Symbol>" << xmlSafeString(stateParameter->symbol, true) << "</Symbol>\n";
} }


#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
#if !(defined(BUILD_BRIDGE_ALTERNATIVE_ARCH) || defined(CARLA_PLUGIN_ONLY_BRIDGE))
if (stateParameter->mappedControlIndex > CONTROL_INDEX_NONE && stateParameter->mappedControlIndex <= CONTROL_INDEX_MAX_ALLOWED) if (stateParameter->mappedControlIndex > CONTROL_INDEX_NONE && stateParameter->mappedControlIndex <= CONTROL_INDEX_MAX_ALLOWED)
{ {
parameterXml << " <MidiChannel>" << stateParameter->midiChannel+1 << "</MidiChannel>\n"; parameterXml << " <MidiChannel>" << stateParameter->midiChannel+1 << "</MidiChannel>\n";
@@ -691,7 +689,7 @@ void CarlaStateSave::dumpToMemoryStream(MemoryOutputStream& content) const
if (stateParameter->mappedControlIndex > 0 && stateParameter->mappedControlIndex < MAX_MIDI_CONTROL) if (stateParameter->mappedControlIndex > 0 && stateParameter->mappedControlIndex < MAX_MIDI_CONTROL)
parameterXml << " <MidiCC>" << stateParameter->mappedControlIndex << "</MidiCC>\n"; parameterXml << " <MidiCC>" << stateParameter->mappedControlIndex << "</MidiCC>\n";
} }
#endif
#endif


if (! stateParameter->dummy) if (! stateParameter->dummy)
parameterXml << " <Value>" << String(stateParameter->value, 15) << "</Value>\n"; parameterXml << " <Value>" << String(stateParameter->value, 15) << "</Value>\n";


+ 5
- 5
source/utils/CarlaStateUtils.hpp View File

@@ -1,6 +1,6 @@
/* /*
* Carla State utils * Carla State utils
* Copyright (C) 2012-2022 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2012-2023 Filipe Coelho <falktx@falktx.com>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
@@ -34,13 +34,13 @@ struct CarlaStateSave {
const char* name; const char* name;
const char* symbol; const char* symbol;
float value; float value;
#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
#if !(defined(BUILD_BRIDGE_ALTERNATIVE_ARCH) || defined(CARLA_PLUGIN_ONLY_BRIDGE))
int16_t mappedControlIndex; int16_t mappedControlIndex;
uint8_t midiChannel; uint8_t midiChannel;
bool mappedRangeValid; bool mappedRangeValid;
float mappedMinimum; float mappedMinimum;
float mappedMaximum; float mappedMaximum;
#endif
#endif


Parameter() noexcept; Parameter() noexcept;
~Parameter() noexcept; ~Parameter() noexcept;
@@ -76,7 +76,7 @@ struct CarlaStateSave {
// saved during clone, rename or similar // saved during clone, rename or similar
bool temporary; bool temporary;


#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
#if !(defined(BUILD_BRIDGE_ALTERNATIVE_ARCH) || defined(CARLA_PLUGIN_ONLY_BRIDGE))
bool active; bool active;
float dryWet; float dryWet;
float volume; float volume;
@@ -84,7 +84,7 @@ struct CarlaStateSave {
float balanceRight; float balanceRight;
float panning; float panning;
int8_t ctrlChannel; int8_t ctrlChannel;
#endif
#endif


int32_t currentProgramIndex; int32_t currentProgramIndex;
const char* currentProgramName; const char* currentProgramName;


Loading…
Cancel
Save