diff --git a/source/backend/CarlaEngine.hpp b/source/backend/CarlaEngine.hpp index dc9a6045a..a5c0d964a 100644 --- a/source/backend/CarlaEngine.hpp +++ b/source/backend/CarlaEngine.hpp @@ -780,13 +780,17 @@ public: * Add new plugin. * @see ENGINE_CALLBACK_PLUGIN_ADDED */ - bool addPlugin(const BinaryType btype, const PluginType ptype, const char* const filename, const char* const name, const char* const label, const int64_t uniqueId, const void* const extra); + bool addPlugin(const BinaryType btype, const PluginType ptype, + const char* const filename, const char* const name, const char* const label, const int64_t uniqueId, + const void* const extra, const uint options); /*! - * Add new plugin, using native binary type. + * Add new plugin, using native binary type and default options. * @see ENGINE_CALLBACK_PLUGIN_ADDED */ - bool addPlugin(const PluginType ptype, const char* const filename, const char* const name, const char* const label, const int64_t uniqueId, const void* const extra); + bool addPlugin(const PluginType ptype, + const char* const filename, const char* const name, const char* const label, const int64_t uniqueId, + const void* const extra); /*! * Remove plugin with id @a id. diff --git a/source/backend/CarlaHost.h b/source/backend/CarlaHost.h index 989ffa169..83f65486b 100644 --- a/source/backend/CarlaHost.h +++ b/source/backend/CarlaHost.h @@ -458,8 +458,11 @@ CARLA_EXPORT uint32_t carla_get_max_plugin_number(); * @param label Plugin label, if applicable * @param uniqueId Plugin unique Id, if applicable * @param extraPtr Extra pointer, defined per plugin type + * @param options Initial plugin options */ -CARLA_EXPORT bool carla_add_plugin(BinaryType btype, PluginType ptype, const char* filename, const char* name, const char* label, int64_t uniqueId, const void* extraPtr); +CARLA_EXPORT bool carla_add_plugin(BinaryType btype, PluginType ptype, + const char* filename, const char* name, const char* label, int64_t uniqueId, + const void* extraPtr, uint options); /*! * Remove one plugin. diff --git a/source/backend/CarlaPlugin.hpp b/source/backend/CarlaPlugin.hpp index d7aaed900..7462fe3b9 100644 --- a/source/backend/CarlaPlugin.hpp +++ b/source/backend/CarlaPlugin.hpp @@ -883,6 +883,7 @@ public: const char* const name; const char* const label; const int64_t uniqueId; + const uint options; // see PluginOptions }; static CarlaPlugin* newNative(const Initializer& init); diff --git a/source/backend/CarlaStandalone.cpp b/source/backend/CarlaStandalone.cpp index 17009a75c..a053dd021 100644 --- a/source/backend/CarlaStandalone.cpp +++ b/source/backend/CarlaStandalone.cpp @@ -1068,13 +1068,13 @@ uint32_t carla_get_max_plugin_number() // ------------------------------------------------------------------------------------------------------------------- -bool carla_add_plugin(BinaryType btype, PluginType ptype, const char* filename, const char* name, const char* label, int64_t uniqueId, const void* extraPtr) +bool carla_add_plugin(BinaryType btype, PluginType ptype, const char* filename, const char* name, const char* label, int64_t uniqueId, const void* extraPtr, uint options) { CARLA_SAFE_ASSERT_RETURN(label != nullptr /*&& label[0] != '\0'*/, false); - carla_debug("carla_add_plugin(%i:%s, %i:%s, \"%s\", \"%s\", \"%s\", " P_INT64 ", %p)", btype, CB::BinaryType2Str(btype), ptype, CB::PluginType2Str(ptype), filename, name, label, uniqueId, extraPtr); + carla_debug("carla_add_plugin(%i:%s, %i:%s, \"%s\", \"%s\", \"%s\", " P_INT64 ", %p, %u)", btype, CB::BinaryType2Str(btype), ptype, CB::PluginType2Str(ptype), filename, name, label, uniqueId, extraPtr, options); if (gStandalone.engine != nullptr) - return gStandalone.engine->addPlugin(btype, ptype, filename, name, label, uniqueId, extraPtr); + return gStandalone.engine->addPlugin(btype, ptype, filename, name, label, uniqueId, extraPtr, options); carla_stderr2("Engine is not running"); gStandalone.lastError = "Engine is not running"; diff --git a/source/backend/engine/CarlaEngine.cpp b/source/backend/engine/CarlaEngine.cpp index 5cf9ca0cc..74b57026b 100644 --- a/source/backend/engine/CarlaEngine.cpp +++ b/source/backend/engine/CarlaEngine.cpp @@ -30,6 +30,7 @@ #include "CarlaBinaryUtils.hpp" #include "CarlaEngineUtils.hpp" #include "CarlaMathUtils.hpp" +#include "CarlaPipeUtils.hpp" #include "CarlaStateUtils.hpp" #include "CarlaMIDI.h" @@ -316,7 +317,9 @@ CarlaEngineClient* CarlaEngine::addClient(CarlaPlugin* const) // ----------------------------------------------------------------------- // Plugin management -bool CarlaEngine::addPlugin(const BinaryType btype, const PluginType ptype, const char* const filename, const char* const name, const char* const label, const int64_t uniqueId, const void* const extra) +bool CarlaEngine::addPlugin(const BinaryType btype, const PluginType ptype, + const char* const filename, const char* const name, const char* const label, const int64_t uniqueId, + const void* const extra, const uint options) { CARLA_SAFE_ASSERT_RETURN_ERR(pData->isIdling == 0, "An operation is still being processed, please wait for it to finish"); CARLA_SAFE_ASSERT_RETURN_ERR(pData->plugins != nullptr, "Invalid engine internal data"); @@ -325,7 +328,7 @@ bool CarlaEngine::addPlugin(const BinaryType btype, const PluginType ptype, cons CARLA_SAFE_ASSERT_RETURN_ERR(btype != BINARY_NONE, "Invalid plugin binary mode"); CARLA_SAFE_ASSERT_RETURN_ERR(ptype != PLUGIN_NONE, "Invalid plugin type"); CARLA_SAFE_ASSERT_RETURN_ERR((filename != nullptr && filename[0] != '\0') || (label != nullptr && label[0] != '\0'), "Invalid plugin filename and label"); - carla_debug("CarlaEngine::addPlugin(%i:%s, %i:%s, \"%s\", \"%s\", \"%s\", " P_INT64 ", %p)", btype, BinaryType2Str(btype), ptype, PluginType2Str(ptype), filename, name, label, uniqueId, extra); + carla_debug("CarlaEngine::addPlugin(%i:%s, %i:%s, \"%s\", \"%s\", \"%s\", " P_INT64 ", %p, %u)", btype, BinaryType2Str(btype), ptype, PluginType2Str(ptype), filename, name, label, uniqueId, extra, options); uint id; @@ -361,7 +364,8 @@ bool CarlaEngine::addPlugin(const BinaryType btype, const PluginType ptype, cons filename, name, label, - uniqueId + uniqueId, + options }; CarlaPlugin* plugin = nullptr; @@ -427,16 +431,13 @@ bool CarlaEngine::addPlugin(const BinaryType btype, const PluginType ptype, cons "/usr/lib/dssi/dssi-vst.so", name, label2, - uniqueId + uniqueId, + options }; - char* const oldVstPath(std::getenv("VST_PATH")); - carla_setenv("VST_PATH", file.getParentDirectory().getFullPathName().toRawUTF8()); + ScopedEnvVar sev("VST_PATH", file.getParentDirectory().getFullPathName().toRawUTF8()); plugin = CarlaPlugin::newDSSI(init2); - - if (oldVstPath != nullptr) - carla_setenv("VST_PATH", oldVstPath); } # endif else @@ -578,7 +579,7 @@ bool CarlaEngine::addPlugin(const BinaryType btype, const PluginType ptype, cons bool CarlaEngine::addPlugin(const PluginType ptype, const char* const filename, const char* const name, const char* const label, const int64_t uniqueId, const void* const extra) { - return addPlugin(BINARY_NATIVE, ptype, filename, name, label, uniqueId, extra); + return addPlugin(BINARY_NATIVE, ptype, filename, name, label, uniqueId, extra, 0x0); } bool CarlaEngine::removePlugin(const uint id) @@ -726,7 +727,9 @@ bool CarlaEngine::clonePlugin(const uint id) const uint pluginCountBefore(pData->curPluginCount); - if (! addPlugin(plugin->getBinaryType(), plugin->getType(), plugin->getFilename(), plugin->getName(), label, plugin->getUniqueId(), plugin->getExtraStuff())) + if (! addPlugin(plugin->getBinaryType(), plugin->getType(), + plugin->getFilename(), plugin->getName(), label, plugin->getUniqueId(), + plugin->getExtraStuff(), plugin->getOptionsEnabled())) return false; CARLA_SAFE_ASSERT_RETURN_ERR(pluginCountBefore+1 == pData->curPluginCount, "No new plugin found"); @@ -977,7 +980,7 @@ bool CarlaEngine::loadFile(const char* const filename) if (extension == "xmz" || extension == "xiz") { -#ifdef WANT_ZYNADDSUBFX +#ifdef HAVE_ZYN_DEPS if (addPlugin(PLUGIN_INTERNAL, nullptr, baseName, "zynaddsubfx", 0, nullptr)) { if (CarlaPlugin* const plugin = getPlugin(pData->curPluginCount-1)) @@ -1844,7 +1847,7 @@ bool CarlaEngine::loadProjectInternal(juce::XmlDocument& xmlDoc) // TODO - proper find&load plugins - if (addPlugin(btype, ptype, stateSave.binary, stateSave.name, stateSave.label, stateSave.uniqueId, extraStuff)) + if (addPlugin(btype, ptype, stateSave.binary, stateSave.name, stateSave.label, stateSave.uniqueId, extraStuff, stateSave.options)) { if (CarlaPlugin* const plugin = getPlugin(pData->curPluginCount-1)) { diff --git a/source/backend/engine/CarlaEngineNative.cpp b/source/backend/engine/CarlaEngineNative.cpp index 046a2ab69..e7629bb18 100644 --- a/source/backend/engine/CarlaEngineNative.cpp +++ b/source/backend/engine/CarlaEngineNative.cpp @@ -187,6 +187,7 @@ protected: const char* name; const char* label; int64_t uniqueId; + uint options; CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(btype), true); CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(ptype), true); @@ -194,6 +195,7 @@ protected: CARLA_SAFE_ASSERT_RETURN(readNextLineAsString(name), true); CARLA_SAFE_ASSERT_RETURN(readNextLineAsString(label), true); CARLA_SAFE_ASSERT_RETURN(readNextLineAsLong(uniqueId), true); + CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(options), true); if (filename != nullptr && std::strcmp(filename, "(null)") == 0) { @@ -207,7 +209,8 @@ protected: name = nullptr; } - ok = fEngine->addPlugin(static_cast(btype), static_cast(ptype), filename, name, label, uniqueId, nullptr); + ok = fEngine->addPlugin(static_cast(btype), static_cast(ptype), + filename, name, label, uniqueId, nullptr, options); if (filename != nullptr) delete[] filename; diff --git a/source/backend/plugin/CarlaPluginLADSPA.cpp b/source/backend/plugin/CarlaPluginLADSPA.cpp index ac8055a0d..150b1a3dc 100644 --- a/source/backend/plugin/CarlaPluginLADSPA.cpp +++ b/source/backend/plugin/CarlaPluginLADSPA.cpp @@ -1551,7 +1551,8 @@ public: // ------------------------------------------------------------------- - bool init(const char* const filename, const char* const name, const char* const label, const LADSPA_RDF_Descriptor* const rdfDescriptor) + bool init(const char* const filename, const char* const name, const char* const label, const uint options, + const LADSPA_RDF_Descriptor* const rdfDescriptor) { CARLA_SAFE_ASSERT_RETURN(pData->engine != nullptr, false); @@ -1703,10 +1704,14 @@ public: pData->options = 0x0; - if (fLatencyIndex >= 0 || fIsDssiVst) + /**/ if (fLatencyIndex >= 0 || fIsDssiVst) + pData->options |= PLUGIN_OPTION_FIXED_BUFFERS; + else if (options & PLUGIN_OPTION_FIXED_BUFFERS) pData->options |= PLUGIN_OPTION_FIXED_BUFFERS; - if (pData->engine->getOptions().forceStereo) + /**/ if (pData->engine->getOptions().forceStereo) + pData->options |= PLUGIN_OPTION_FORCE_STEREO; + else if (options & PLUGIN_OPTION_FORCE_STEREO) pData->options |= PLUGIN_OPTION_FORCE_STEREO; return true; @@ -1827,11 +1832,11 @@ private: CarlaPlugin* CarlaPlugin::newLADSPA(const Initializer& init, const LADSPA_RDF_Descriptor* const rdfDescriptor) { - carla_debug("CarlaPlugin::newLADSPA({%p, \"%s\", \"%s\", \"%s\", " P_INT64 "}, %p)", init.engine, init.filename, init.name, init.label, init.uniqueId, rdfDescriptor); + carla_debug("CarlaPlugin::newLADSPA({%p, \"%s\", \"%s\", \"%s\", " P_INT64 ", %x}, %p)", init.engine, init.filename, init.name, init.label, init.uniqueId, init.options, rdfDescriptor); CarlaPluginLADSPA* const plugin(new CarlaPluginLADSPA(init.engine, init.id)); - if (! plugin->init(init.filename, init.name, init.label, rdfDescriptor)) + if (! plugin->init(init.filename, init.name, init.label, init.options, rdfDescriptor)) { delete plugin; return nullptr; diff --git a/source/bridges-plugin/CarlaBridgePlugin.cpp b/source/bridges-plugin/CarlaBridgePlugin.cpp index f4ba8d866..d3268a8e1 100644 --- a/source/bridges-plugin/CarlaBridgePlugin.cpp +++ b/source/bridges-plugin/CarlaBridgePlugin.cpp @@ -409,7 +409,7 @@ int main(int argc, char* argv[]) int ret; - if (carla_add_plugin(CarlaBackend::BINARY_NATIVE, itype, filename, name, label, uniqueId, extraStuff)) + if (carla_add_plugin(CarlaBackend::BINARY_NATIVE, itype, filename, name, label, uniqueId, extraStuff, 0x0)) { ret = 0; diff --git a/source/carla_backend.py b/source/carla_backend.py index a49fa60cd..a3f8863c4 100644 --- a/source/carla_backend.py +++ b/source/carla_backend.py @@ -1380,8 +1380,9 @@ class CarlaHostMeta(object): # @param label Plugin label, if applicable # @param uniqueId Plugin unique Id, if applicable # @param extraPtr Extra pointer, defined per plugin type + # @param options Initial plugin options @abstractmethod - def add_plugin(self, btype, ptype, filename, name, label, uniqueId, extraPtr): + def add_plugin(self, btype, ptype, filename, name, label, uniqueId, extraPtr, options): raise NotImplementedError # Remove a plugin. @@ -1892,7 +1893,7 @@ class CarlaHostNull(CarlaHostMeta): def get_max_plugin_number(self): return 0 - def add_plugin(self, btype, ptype, filename, name, label, uniqueId, extraPtr): + def add_plugin(self, btype, ptype, filename, name, label, uniqueId, extraPtr, options): return False def remove_plugin(self, pluginId): @@ -2163,7 +2164,7 @@ class CarlaHostDLL(CarlaHostMeta): self.lib.carla_get_max_plugin_number.argtypes = None self.lib.carla_get_max_plugin_number.restype = c_uint32 - self.lib.carla_add_plugin.argtypes = [c_enum, c_enum, c_char_p, c_char_p, c_char_p, c_int64, c_void_p] + self.lib.carla_add_plugin.argtypes = [c_enum, c_enum, c_char_p, c_char_p, c_char_p, c_int64, c_void_p, c_uint] self.lib.carla_add_plugin.restype = c_bool self.lib.carla_remove_plugin.argtypes = [c_uint] @@ -2422,11 +2423,11 @@ class CarlaHostDLL(CarlaHostMeta): def get_max_plugin_number(self): return int(self.lib.carla_get_max_plugin_number()) - def add_plugin(self, btype, ptype, filename, name, label, uniqueId, extraPtr): + def add_plugin(self, btype, ptype, filename, name, label, uniqueId, extraPtr, options): cfilename = filename.encode("utf-8") if filename else None cname = name.encode("utf-8") if name else None clabel = label.encode("utf-8") if label else None - return bool(self.lib.carla_add_plugin(btype, ptype, cfilename, cname, clabel, uniqueId, cast(extraPtr, c_void_p))) + return bool(self.lib.carla_add_plugin(btype, ptype, cfilename, cname, clabel, uniqueId, cast(extraPtr, c_void_p)), options) def remove_plugin(self, pluginId): return bool(self.lib.carla_remove_plugin(pluginId)) @@ -2741,8 +2742,8 @@ class CarlaHostPlugin(CarlaHostMeta): def get_max_plugin_number(self): return self.fMaxPluginNumber - def add_plugin(self, btype, ptype, filename, name, label, uniqueId, extraPtr): - return self.sendMsgAndSetError(["add_plugin", btype, ptype, filename, name, label, uniqueId]) + def add_plugin(self, btype, ptype, filename, name, label, uniqueId, extraPtr, options): + return self.sendMsgAndSetError(["add_plugin", btype, ptype, filename, name, label, uniqueId, options]) def remove_plugin(self, pluginId): return self.sendMsgAndSetError(["remove_plugin", pluginId]) diff --git a/source/carla_host.py b/source/carla_host.py index 517f5f29e..5e8fc2d83 100644 --- a/source/carla_host.py +++ b/source/carla_host.py @@ -681,7 +681,7 @@ class HostWindow(QMainWindow): CustomMessageBox(self, QMessageBox.Critical, self.tr("Error"), self.tr("Failed to replace plugin"), self.host.get_last_error(), QMessageBox.Ok, QMessageBox.Ok) return - ok = self.host.add_plugin(btype, ptype, filename, None, label, uniqueId, extraPtr) + ok = self.host.add_plugin(btype, ptype, filename, None, label, uniqueId, extraPtr, 0x0) if pluginToReplace >= 0: self.host.replace_plugin(self.host.get_max_plugin_number()) diff --git a/source/carla_skin.py b/source/carla_skin.py index 400bc5932..4d5d44005 100644 --- a/source/carla_skin.py +++ b/source/carla_skin.py @@ -1874,10 +1874,10 @@ if __name__ == '__main__': loadHostSettings(host) host.engine_init("JACK", "Carla-Widgets") - host.add_plugin(BINARY_NATIVE, PLUGIN_INTERNAL, "", "", "zynreverb", 0, None) - #host.add_plugin(BINARY_NATIVE, PLUGIN_DSSI, "/usr/lib/dssi/karplong.so", "karplong", "karplong", 0, None) - #host.add_plugin(BINARY_NATIVE, PLUGIN_LV2, "", "", "http://www.openavproductions.com/sorcer", 0, None) - #host.add_plugin(BINARY_NATIVE, PLUGIN_LV2, "", "", "http://calf.sourceforge.net/plugins/Compressor", 0, None) + host.add_plugin(BINARY_NATIVE, PLUGIN_INTERNAL, "", "", "zynreverb", 0, None, 0x0) + #host.add_plugin(BINARY_NATIVE, PLUGIN_DSSI, "/usr/lib/dssi/karplong.so", "karplong", "karplong", 0, None, 0x0) + #host.add_plugin(BINARY_NATIVE, PLUGIN_LV2, "", "", "http://www.openavproductions.com/sorcer", 0, None, 0x0) + #host.add_plugin(BINARY_NATIVE, PLUGIN_LV2, "", "", "http://calf.sourceforge.net/plugins/Compressor", 0, None, 0x0) host.set_active(0, True) gui = createPluginSlot(None, host, 0, True) diff --git a/source/carla_widgets.py b/source/carla_widgets.py index 4061bf6bc..2f0bf5bcf 100755 --- a/source/carla_widgets.py +++ b/source/carla_widgets.py @@ -1542,7 +1542,7 @@ if __name__ == '__main__': loadHostSettings(host) host.engine_init("JACK", "Carla-Widgets") - host.add_plugin(BINARY_NATIVE, PLUGIN_DSSI, "/usr/lib/dssi/karplong.so", "karplong", "karplong", 0, None) + host.add_plugin(BINARY_NATIVE, PLUGIN_DSSI, "/usr/lib/dssi/karplong.so", "karplong", "karplong", 0, None, 0x0) host.set_active(0, True) gui1 = CarlaAboutW(None, host) diff --git a/source/utils/CarlaStateUtils.cpp b/source/utils/CarlaStateUtils.cpp index 1d16897fe..cbedf1dfc 100644 --- a/source/utils/CarlaStateUtils.cpp +++ b/source/utils/CarlaStateUtils.cpp @@ -186,6 +186,7 @@ CarlaStateSave::CarlaStateSave() noexcept label(nullptr), binary(nullptr), uniqueId(0), + options(0x0), #ifndef BUILD_BRIDGE active(false), dryWet(1.0f), @@ -194,7 +195,6 @@ CarlaStateSave::CarlaStateSave() noexcept balanceRight(1.0f), panning(0.0f), ctrlChannel(-1), - options(0x0), #endif currentProgramIndex(-1), currentProgramName(nullptr), @@ -243,6 +243,8 @@ void CarlaStateSave::clear() noexcept } uniqueId = 0; + options = 0x0; + #ifndef BUILD_BRIDGE active = false; dryWet = 1.0f; @@ -251,8 +253,8 @@ void CarlaStateSave::clear() noexcept balanceRight = 1.0f; panning = 0.0f; ctrlChannel = -1; - options = 0x0; #endif + currentProgramIndex = -1; currentMidiBank = -1; currentMidiProgram = -1; diff --git a/source/utils/CarlaStateUtils.hpp b/source/utils/CarlaStateUtils.hpp index 1d58065ce..c07908c19 100644 --- a/source/utils/CarlaStateUtils.hpp +++ b/source/utils/CarlaStateUtils.hpp @@ -68,6 +68,7 @@ struct CarlaStateSave { const char* label; const char* binary; int64_t uniqueId; + uint options; #ifndef BUILD_BRIDGE bool active; @@ -77,7 +78,6 @@ struct CarlaStateSave { float balanceRight; float panning; int8_t ctrlChannel; - uint options; #endif int32_t currentProgramIndex;