From 087086467242754163a37021c9a2243c3616563e Mon Sep 17 00:00:00 2001 From: falkTX Date: Sun, 31 Aug 2014 07:16:49 +0100 Subject: [PATCH] Save some engine settings in project file --- source/backend/engine/CarlaEngine.cpp | 48 ++++++++++++++++++++------- source/utils/CarlaStateUtils.cpp | 14 -------- source/utils/CarlaStateUtils.hpp | 16 ++++++--- 3 files changed, 48 insertions(+), 30 deletions(-) diff --git a/source/backend/engine/CarlaEngine.cpp b/source/backend/engine/CarlaEngine.cpp index 5bb6dbc9b..adbb3a732 100644 --- a/source/backend/engine/CarlaEngine.cpp +++ b/source/backend/engine/CarlaEngine.cpp @@ -1502,7 +1502,38 @@ void CarlaEngine::saveProjectInternal(juce::MemoryOutputStream& outStrm) const outStrm << "\n"; outStrm << "\n"; - bool firstPlugin = true; + const bool isPlugin(std::strcmp(getCurrentDriverName(), "Plugin") == 0); + const EngineOptions& options(pData->options); + + // save appropriate engine settings + outStrm << " \n"; + + //processMode + //transportMode + + outStrm << " " << bool2str(options.forceStereo) << "\n"; + outStrm << " " << bool2str(options.preferPluginBridges) << "\n"; + outStrm << " " << bool2str(options.preferUiBridges) << "\n"; + outStrm << " " << bool2str(options.uisAlwaysOnTop) << "\n"; + + outStrm << " " << String(options.maxParameters) << "\n"; + outStrm << " " << String(options.uiBridgesTimeout) << "\n"; + + if (isPlugin) + { + outStrm << " " << xmlSafeString(options.pathLADSPA, true) << "\n"; + outStrm << " " << xmlSafeString(options.pathDSSI, true) << "\n"; + outStrm << " " << xmlSafeString(options.pathLV2, true) << "\n"; + outStrm << " " << xmlSafeString(options.pathVST, true) << "\n"; + outStrm << " " << xmlSafeString(options.pathVST3, true) << "\n"; + outStrm << " " << xmlSafeString(options.pathAU, true) << "\n"; + outStrm << " " << xmlSafeString(options.pathGIG, true) << "\n"; + outStrm << " " << xmlSafeString(options.pathSF2, true) << "\n"; + outStrm << " " << xmlSafeString(options.pathSFZ, true) << "\n"; + } + + outStrm << " \n"; + char strBuf[STR_MAX+1]; for (uint i=0; i < pData->curPluginCount; ++i) @@ -1511,21 +1542,17 @@ void CarlaEngine::saveProjectInternal(juce::MemoryOutputStream& outStrm) const if (plugin != nullptr && plugin->isEnabled()) { - if (! firstPlugin) - outStrm << "\n"; + outStrm << "\n"; strBuf[0] = '\0'; - plugin->getRealName(strBuf); - //if (strBuf[0] != '\0') - // out << QString(" \n").arg(xmlSafeString(strBuf, true)); + if (strBuf[0] != '\0') + outStrm << " \n"; outStrm << " \n"; outStrm << plugin->getStateSave().toString(); outStrm << " \n"; - - firstPlugin = false; } } @@ -1552,10 +1579,7 @@ void CarlaEngine::saveProjectInternal(juce::MemoryOutputStream& outStrm) const { if (const char* const* const patchbayConns = getPatchbayConnections()) { - if (! firstPlugin) - outStrm << "\n"; - - outStrm << " \n"; + outStrm << "\n \n"; for (int i=0; patchbayConns[i] != nullptr && patchbayConns[i+1] != nullptr; ++i, ++i ) { diff --git a/source/utils/CarlaStateUtils.cpp b/source/utils/CarlaStateUtils.cpp index 92d2eec69..640198f3d 100644 --- a/source/utils/CarlaStateUtils.cpp +++ b/source/utils/CarlaStateUtils.cpp @@ -21,7 +21,6 @@ #include "CarlaMathUtils.hpp" #include "CarlaMIDI.h" -#include "juce_core.h" using juce::String; using juce::XmlElement; @@ -51,19 +50,6 @@ static String getNewLineSplittedString(const String& string) return newString; } -// ----------------------------------------------------------------------- -// xmlSafeString - -static String xmlSafeString(const String& string, const bool toXml) -{ - String newString(string); - - if (toXml) - return newString.replace("&","&").replace("<","<").replace(">",">").replace("'","'").replace("\"","""); - else - return newString.replace("<","<").replace(">",">").replace("'","'").replace(""","\"").replace("&","&"); -} - // ----------------------------------------------------------------------- // xmlSafeStringCharDup diff --git a/source/utils/CarlaStateUtils.hpp b/source/utils/CarlaStateUtils.hpp index 6d2b7dc92..661553cf5 100644 --- a/source/utils/CarlaStateUtils.hpp +++ b/source/utils/CarlaStateUtils.hpp @@ -21,10 +21,7 @@ #include "CarlaBackend.h" #include "LinkedList.hpp" -namespace juce { -class String; -class XmlElement; -} +#include "juce_core.h" CARLA_BACKEND_START_NAMESPACE @@ -101,6 +98,17 @@ struct StateSave { CARLA_DECLARE_NON_COPY_STRUCT(StateSave) }; +static inline +juce::String xmlSafeString(const juce::String& string, const bool toXml) +{ + juce::String newString(string); + + if (toXml) + return newString.replace("&","&").replace("<","<").replace(">",">").replace("'","'").replace("\"","""); + else + return newString.replace("<","<").replace(">",">").replace("'","'").replace(""","\"").replace("&","&"); +} + // ----------------------------------------------------------------------- CARLA_BACKEND_END_NAMESPACE