Browse Source

Save some engine settings in project file

tags/1.9.5
falkTX 10 years ago
parent
commit
0870864672
3 changed files with 48 additions and 30 deletions
  1. +36
    -12
      source/backend/engine/CarlaEngine.cpp
  2. +0
    -14
      source/utils/CarlaStateUtils.cpp
  3. +12
    -4
      source/utils/CarlaStateUtils.hpp

+ 36
- 12
source/backend/engine/CarlaEngine.cpp View File

@@ -1502,7 +1502,38 @@ void CarlaEngine::saveProjectInternal(juce::MemoryOutputStream& outStrm) const
outStrm << "<!DOCTYPE CARLA-PROJECT>\n"; outStrm << "<!DOCTYPE CARLA-PROJECT>\n";
outStrm << "<CARLA-PROJECT VERSION='2.0'>\n"; outStrm << "<CARLA-PROJECT VERSION='2.0'>\n";


bool firstPlugin = true;
const bool isPlugin(std::strcmp(getCurrentDriverName(), "Plugin") == 0);
const EngineOptions& options(pData->options);

// save appropriate engine settings
outStrm << " <EngineSettings>\n";

//processMode
//transportMode

outStrm << " <ForceStereo>" << bool2str(options.forceStereo) << "</ForceStereo>\n";
outStrm << " <PreferPluginBridges>" << bool2str(options.preferPluginBridges) << "</PreferPluginBridges>\n";
outStrm << " <PreferUiBridges>" << bool2str(options.preferUiBridges) << "</PreferUiBridges>\n";
outStrm << " <UIsAlwaysOnTop>" << bool2str(options.uisAlwaysOnTop) << "</UIsAlwaysOnTop>\n";

outStrm << " <MaxParameters>" << String(options.maxParameters) << "</MaxParameters>\n";
outStrm << " <UIBridgesTimeout>" << String(options.uiBridgesTimeout) << "</UIBridgesTimeout>\n";

if (isPlugin)
{
outStrm << " <LADSPA_PATH>" << xmlSafeString(options.pathLADSPA, true) << "</LADSPA_PATH>\n";
outStrm << " <DSSI_PATH>" << xmlSafeString(options.pathDSSI, true) << "</DSSI_PATH>\n";
outStrm << " <LV2_PATH>" << xmlSafeString(options.pathLV2, true) << "</LV2_PATH>\n";
outStrm << " <VST_PATH>" << xmlSafeString(options.pathVST, true) << "</VST_PATH>\n";
outStrm << " <VST3_PATH>" << xmlSafeString(options.pathVST3, true) << "</VST3_PATH>\n";
outStrm << " <AU_PATH>" << xmlSafeString(options.pathAU, true) << "</AU_PATH>\n";
outStrm << " <GIG_PATH>" << xmlSafeString(options.pathGIG, true) << "</GIG_PATH>\n";
outStrm << " <SF2_PATH>" << xmlSafeString(options.pathSF2, true) << "</SF2_PATH>\n";
outStrm << " <SFZ_PATH>" << xmlSafeString(options.pathSFZ, true) << "</_PATH>\n";
}

outStrm << " </EngineSettings>\n";

char strBuf[STR_MAX+1]; char strBuf[STR_MAX+1];


for (uint i=0; i < pData->curPluginCount; ++i) 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 (plugin != nullptr && plugin->isEnabled())
{ {
if (! firstPlugin)
outStrm << "\n";
outStrm << "\n";


strBuf[0] = '\0'; strBuf[0] = '\0';

plugin->getRealName(strBuf); plugin->getRealName(strBuf);


//if (strBuf[0] != '\0')
// out << QString(" <!-- %1 -->\n").arg(xmlSafeString(strBuf, true));
if (strBuf[0] != '\0')
outStrm << " <!-- " << xmlSafeString(strBuf, true) << " -->\n";


outStrm << " <Plugin>\n"; outStrm << " <Plugin>\n";
outStrm << plugin->getStateSave().toString(); outStrm << plugin->getStateSave().toString();
outStrm << " </Plugin>\n"; outStrm << " </Plugin>\n";

firstPlugin = false;
} }
} }


@@ -1552,10 +1579,7 @@ void CarlaEngine::saveProjectInternal(juce::MemoryOutputStream& outStrm) const
{ {
if (const char* const* const patchbayConns = getPatchbayConnections()) if (const char* const* const patchbayConns = getPatchbayConnections())
{ {
if (! firstPlugin)
outStrm << "\n";

outStrm << " <Patchbay>\n";
outStrm << "\n <Patchbay>\n";


for (int i=0; patchbayConns[i] != nullptr && patchbayConns[i+1] != nullptr; ++i, ++i ) for (int i=0; patchbayConns[i] != nullptr && patchbayConns[i+1] != nullptr; ++i, ++i )
{ {


+ 0
- 14
source/utils/CarlaStateUtils.cpp View File

@@ -21,7 +21,6 @@
#include "CarlaMathUtils.hpp" #include "CarlaMathUtils.hpp"
#include "CarlaMIDI.h" #include "CarlaMIDI.h"


#include "juce_core.h"
using juce::String; using juce::String;
using juce::XmlElement; using juce::XmlElement;


@@ -51,19 +50,6 @@ static String getNewLineSplittedString(const String& string)
return newString; return newString;
} }


// -----------------------------------------------------------------------
// xmlSafeString

static String xmlSafeString(const String& string, const bool toXml)
{
String newString(string);

if (toXml)
return newString.replace("&","&amp;").replace("<","&lt;").replace(">","&gt;").replace("'","&apos;").replace("\"","&quot;");
else
return newString.replace("&lt;","<").replace("&gt;",">").replace("&apos;","'").replace("&quot;","\"").replace("&amp;","&");
}

// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// xmlSafeStringCharDup // xmlSafeStringCharDup




+ 12
- 4
source/utils/CarlaStateUtils.hpp View File

@@ -21,10 +21,7 @@
#include "CarlaBackend.h" #include "CarlaBackend.h"
#include "LinkedList.hpp" #include "LinkedList.hpp"


namespace juce {
class String;
class XmlElement;
}
#include "juce_core.h"


CARLA_BACKEND_START_NAMESPACE CARLA_BACKEND_START_NAMESPACE


@@ -101,6 +98,17 @@ struct StateSave {
CARLA_DECLARE_NON_COPY_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("&","&amp;").replace("<","&lt;").replace(">","&gt;").replace("'","&apos;").replace("\"","&quot;");
else
return newString.replace("&lt;","<").replace("&gt;",">").replace("&apos;","'").replace("&quot;","\"").replace("&amp;","&");
}

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


CARLA_BACKEND_END_NAMESPACE CARLA_BACKEND_END_NAMESPACE


Loading…
Cancel
Save