Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

705 lines
24KB

  1. /*
  2. * Carla State utils
  3. * Copyright (C) 2012-2018 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation; either version 2 of
  8. * the License, or any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * For a full copy of the GNU General Public License see the doc/GPL.txt file.
  16. */
  17. #include "CarlaStateUtils.hpp"
  18. #include "CarlaBackendUtils.hpp"
  19. #include "CarlaMathUtils.hpp"
  20. #include "CarlaMIDI.h"
  21. #include "water/streams/MemoryOutputStream.h"
  22. #include "water/xml/XmlElement.h"
  23. #include <string>
  24. using water::MemoryOutputStream;
  25. using water::String;
  26. using water::XmlElement;
  27. CARLA_BACKEND_START_NAMESPACE
  28. // -----------------------------------------------------------------------
  29. // getNewLineSplittedString
  30. static void getNewLineSplittedString(MemoryOutputStream& stream, const String& string)
  31. {
  32. static const int kLineWidth = 120;
  33. int i = 0;
  34. const int length = string.length();
  35. const char* const raw = string.toUTF8();
  36. stream.preallocate(static_cast<std::size_t>(length + length/kLineWidth + 3));
  37. for (; i+kLineWidth < length; i += kLineWidth)
  38. {
  39. stream.write(raw+i, kLineWidth);
  40. stream.writeByte('\n');
  41. }
  42. stream << (raw+i);
  43. }
  44. // -----------------------------------------------------------------------
  45. // xmlSafeStringFast
  46. /* Based on some code by James Kanze from stackoverflow
  47. * https://stackoverflow.com/questions/7724011/in-c-whats-the-fastest-way-to-replace-all-occurrences-of-a-substring-within */
  48. static std::string replaceStdString(const std::string& original, const std::string& before, const std::string& after)
  49. {
  50. std::string::const_iterator current = original.begin(), end = original.end(), next;
  51. std::string retval;
  52. for (; (next = std::search(current, end, before.begin(), before.end())) != end;)
  53. {
  54. retval.append(current, next);
  55. retval.append(after);
  56. current = next + static_cast<ssize_t>(before.size());
  57. }
  58. retval.append(current, next);
  59. return retval;
  60. }
  61. static std::string xmlSafeStringFast(const char* const cstring, const bool toXml)
  62. {
  63. std::string string(cstring);
  64. if (toXml)
  65. {
  66. string = replaceStdString(string, "&","&amp;");
  67. string = replaceStdString(string, "<","&lt;");
  68. string = replaceStdString(string, ">","&gt;");
  69. string = replaceStdString(string, "'","&apos;");
  70. string = replaceStdString(string, "\"","&quot;");
  71. }
  72. else
  73. {
  74. string = replaceStdString(string, "&lt;","<");
  75. string = replaceStdString(string, "&gt;",">");
  76. string = replaceStdString(string, "&apos;","'");
  77. string = replaceStdString(string, "&quot;","\"");
  78. string = replaceStdString(string, "&amp;","&");
  79. }
  80. return string;
  81. }
  82. // -----------------------------------------------------------------------
  83. // xmlSafeStringCharDup
  84. /*
  85. static const char* xmlSafeStringCharDup(const char* const cstring, const bool toXml)
  86. {
  87. return carla_strdup(xmlSafeString(cstring, toXml).toRawUTF8());
  88. }
  89. */
  90. static const char* xmlSafeStringCharDup(const String& string, const bool toXml)
  91. {
  92. return carla_strdup(xmlSafeString(string, toXml).toRawUTF8());
  93. }
  94. // -----------------------------------------------------------------------
  95. // StateParameter
  96. CarlaStateSave::Parameter::Parameter() noexcept
  97. : dummy(true),
  98. index(-1),
  99. name(nullptr),
  100. symbol(nullptr),
  101. #ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
  102. value(0.0f),
  103. mappedControlIndex(CONTROL_INDEX_NONE),
  104. midiChannel(0) {}
  105. #else
  106. value(0.0f) {}
  107. #endif
  108. CarlaStateSave::Parameter::~Parameter() noexcept
  109. {
  110. if (name != nullptr)
  111. {
  112. delete[] name;
  113. name = nullptr;
  114. }
  115. if (symbol != nullptr)
  116. {
  117. delete[] symbol;
  118. symbol = nullptr;
  119. }
  120. }
  121. // -----------------------------------------------------------------------
  122. // StateCustomData
  123. CarlaStateSave::CustomData::CustomData() noexcept
  124. : type(nullptr),
  125. key(nullptr),
  126. value(nullptr) {}
  127. CarlaStateSave::CustomData::~CustomData() noexcept
  128. {
  129. if (type != nullptr)
  130. {
  131. delete[] type;
  132. type = nullptr;
  133. }
  134. if (key != nullptr)
  135. {
  136. delete[] key;
  137. key = nullptr;
  138. }
  139. if (value != nullptr)
  140. {
  141. delete[] value;
  142. value = nullptr;
  143. }
  144. }
  145. bool CarlaStateSave::CustomData::isValid() const noexcept
  146. {
  147. if (type == nullptr || type[0] == '\0') return false;
  148. if (key == nullptr || key [0] == '\0') return false;
  149. if (value == nullptr) return false;
  150. return true;
  151. }
  152. // -----------------------------------------------------------------------
  153. // StateSave
  154. CarlaStateSave::CarlaStateSave() noexcept
  155. : type(nullptr),
  156. name(nullptr),
  157. label(nullptr),
  158. binary(nullptr),
  159. uniqueId(0),
  160. options(0x0),
  161. #ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
  162. active(false),
  163. dryWet(1.0f),
  164. volume(1.0f),
  165. balanceLeft(-1.0f),
  166. balanceRight(1.0f),
  167. panning(0.0f),
  168. ctrlChannel(-1),
  169. #endif
  170. currentProgramIndex(-1),
  171. currentProgramName(nullptr),
  172. currentMidiBank(-1),
  173. currentMidiProgram(-1),
  174. chunk(nullptr),
  175. parameters(),
  176. customData() {}
  177. CarlaStateSave::~CarlaStateSave() noexcept
  178. {
  179. clear();
  180. }
  181. void CarlaStateSave::clear() noexcept
  182. {
  183. if (type != nullptr)
  184. {
  185. delete[] type;
  186. type = nullptr;
  187. }
  188. if (name != nullptr)
  189. {
  190. delete[] name;
  191. name = nullptr;
  192. }
  193. if (label != nullptr)
  194. {
  195. delete[] label;
  196. label = nullptr;
  197. }
  198. if (binary != nullptr)
  199. {
  200. delete[] binary;
  201. binary = nullptr;
  202. }
  203. if (currentProgramName != nullptr)
  204. {
  205. delete[] currentProgramName;
  206. currentProgramName = nullptr;
  207. }
  208. if (chunk != nullptr)
  209. {
  210. delete[] chunk;
  211. chunk = nullptr;
  212. }
  213. uniqueId = 0;
  214. options = 0x0;
  215. #ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
  216. active = false;
  217. dryWet = 1.0f;
  218. volume = 1.0f;
  219. balanceLeft = -1.0f;
  220. balanceRight = 1.0f;
  221. panning = 0.0f;
  222. ctrlChannel = -1;
  223. #endif
  224. currentProgramIndex = -1;
  225. currentMidiBank = -1;
  226. currentMidiProgram = -1;
  227. for (ParameterItenerator it = parameters.begin2(); it.valid(); it.next())
  228. {
  229. Parameter* const stateParameter(it.getValue(nullptr));
  230. delete stateParameter;
  231. }
  232. for (CustomDataItenerator it = customData.begin2(); it.valid(); it.next())
  233. {
  234. CustomData* const stateCustomData(it.getValue(nullptr));
  235. delete stateCustomData;
  236. }
  237. parameters.clear();
  238. customData.clear();
  239. }
  240. // -----------------------------------------------------------------------
  241. // fillFromXmlElement
  242. bool CarlaStateSave::fillFromXmlElement(const XmlElement* const xmlElement)
  243. {
  244. CARLA_SAFE_ASSERT_RETURN(xmlElement != nullptr, false);
  245. clear();
  246. for (XmlElement* elem = xmlElement->getFirstChildElement(); elem != nullptr; elem = elem->getNextElement())
  247. {
  248. const String& tagName(elem->getTagName());
  249. // ---------------------------------------------------------------
  250. // Info
  251. if (tagName == "Info")
  252. {
  253. for (XmlElement* xmlInfo = elem->getFirstChildElement(); xmlInfo != nullptr; xmlInfo = xmlInfo->getNextElement())
  254. {
  255. const String& tag(xmlInfo->getTagName());
  256. const String text(xmlInfo->getAllSubText().trim());
  257. /**/ if (tag == "Type")
  258. type = xmlSafeStringCharDup(text, false);
  259. else if (tag == "Name")
  260. name = xmlSafeStringCharDup(text, false);
  261. else if (tag == "Label" || tag == "URI" || tag == "Identifier" || tag == "Setup")
  262. label = xmlSafeStringCharDup(text, false);
  263. else if (tag == "Binary" || tag == "Filename")
  264. binary = xmlSafeStringCharDup(text, false);
  265. else if (tag == "UniqueID")
  266. uniqueId = text.getLargeIntValue();
  267. }
  268. }
  269. // ---------------------------------------------------------------
  270. // Data
  271. else if (tagName == "Data")
  272. {
  273. for (XmlElement* xmlData = elem->getFirstChildElement(); xmlData != nullptr; xmlData = xmlData->getNextElement())
  274. {
  275. const String& tag(xmlData->getTagName());
  276. const String text(xmlData->getAllSubText().trim());
  277. #ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
  278. // -------------------------------------------------------
  279. // Internal Data
  280. /**/ if (tag == "Active")
  281. {
  282. active = (text == "Yes");
  283. }
  284. else if (tag == "DryWet")
  285. {
  286. dryWet = carla_fixedValue(0.0f, 1.0f, text.getFloatValue());
  287. }
  288. else if (tag == "Volume")
  289. {
  290. volume = carla_fixedValue(0.0f, 1.27f, text.getFloatValue());
  291. }
  292. else if (tag == "Balance-Left")
  293. {
  294. balanceLeft = carla_fixedValue(-1.0f, 1.0f, text.getFloatValue());
  295. }
  296. else if (tag == "Balance-Right")
  297. {
  298. balanceRight = carla_fixedValue(-1.0f, 1.0f, text.getFloatValue());
  299. }
  300. else if (tag == "Panning")
  301. {
  302. panning = carla_fixedValue(-1.0f, 1.0f, text.getFloatValue());
  303. }
  304. else if (tag == "ControlChannel")
  305. {
  306. if (! text.startsWithIgnoreCase("n"))
  307. {
  308. const int value(text.getIntValue());
  309. if (value >= 1 && value <= MAX_MIDI_CHANNELS)
  310. ctrlChannel = static_cast<int8_t>(value-1);
  311. }
  312. }
  313. else if (tag == "Options")
  314. {
  315. const int value(text.getHexValue32());
  316. if (value > 0)
  317. options = static_cast<uint>(value);
  318. }
  319. #else
  320. if (false) {}
  321. #endif
  322. // -------------------------------------------------------
  323. // Program (current)
  324. else if (tag == "CurrentProgramIndex")
  325. {
  326. const int value(text.getIntValue());
  327. if (value >= 1)
  328. currentProgramIndex = value-1;
  329. }
  330. else if (tag == "CurrentProgramName")
  331. {
  332. currentProgramName = xmlSafeStringCharDup(text, false);
  333. }
  334. // -------------------------------------------------------
  335. // Midi Program (current)
  336. else if (tag == "CurrentMidiBank")
  337. {
  338. const int value(text.getIntValue());
  339. if (value >= 1)
  340. currentMidiBank = value-1;
  341. }
  342. else if (tag == "CurrentMidiProgram")
  343. {
  344. const int value(text.getIntValue());
  345. if (value >= 1)
  346. currentMidiProgram = value-1;
  347. }
  348. // -------------------------------------------------------
  349. // Parameters
  350. else if (tag == "Parameter")
  351. {
  352. Parameter* const stateParameter(new Parameter());
  353. for (XmlElement* xmlSubData = xmlData->getFirstChildElement(); xmlSubData != nullptr; xmlSubData = xmlSubData->getNextElement())
  354. {
  355. const String& pTag(xmlSubData->getTagName());
  356. const String pText(xmlSubData->getAllSubText().trim());
  357. /**/ if (pTag == "Index")
  358. {
  359. const int index(pText.getIntValue());
  360. if (index >= 0)
  361. stateParameter->index = index;
  362. }
  363. else if (pTag == "Name")
  364. {
  365. stateParameter->name = xmlSafeStringCharDup(pText, false);
  366. }
  367. else if (pTag == "Symbol")
  368. {
  369. stateParameter->symbol = xmlSafeStringCharDup(pText, false);
  370. }
  371. else if (pTag == "Value")
  372. {
  373. stateParameter->dummy = false;
  374. stateParameter->value = pText.getFloatValue();
  375. }
  376. #ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
  377. else if (pTag == "MidiChannel")
  378. {
  379. const int channel(pText.getIntValue());
  380. if (channel >= 1 && channel <= MAX_MIDI_CHANNELS)
  381. stateParameter->midiChannel = static_cast<uint8_t>(channel-1);
  382. }
  383. else if (pTag == "MidiCC")
  384. {
  385. const int cc(pText.getIntValue());
  386. if (cc > 0 && cc < MAX_MIDI_CONTROL)
  387. stateParameter->mappedControlIndex = static_cast<int16_t>(cc);
  388. }
  389. else if (pTag == "MappedControlIndex")
  390. {
  391. const int ctrl(pText.getIntValue());
  392. if (ctrl > CONTROL_INDEX_NONE && ctrl <= CONTROL_INDEX_MAX_ALLOWED)
  393. stateParameter->mappedControlIndex = static_cast<int16_t>(ctrl);
  394. }
  395. #endif
  396. }
  397. parameters.append(stateParameter);
  398. }
  399. // -------------------------------------------------------
  400. // Custom Data
  401. else if (tag == "CustomData")
  402. {
  403. CustomData* const stateCustomData(new CustomData());
  404. for (XmlElement* xmlSubData = xmlData->getFirstChildElement(); xmlSubData != nullptr; xmlSubData = xmlSubData->getNextElement())
  405. {
  406. const String& cTag(xmlSubData->getTagName());
  407. const String cText(xmlSubData->getAllSubText().trim());
  408. /**/ if (cTag == "Type")
  409. stateCustomData->type = xmlSafeStringCharDup(cText, false);
  410. else if (cTag == "Key")
  411. stateCustomData->key = xmlSafeStringCharDup(cText, false);
  412. else if (cTag == "Value")
  413. stateCustomData->value = carla_strdup(cText.toRawUTF8()); //xmlSafeStringCharDup(cText, false);
  414. }
  415. if (stateCustomData->isValid())
  416. customData.append(stateCustomData);
  417. else
  418. carla_stderr("Reading CustomData property failed, missing data");
  419. }
  420. // -------------------------------------------------------
  421. // Chunk
  422. else if (tag == "Chunk")
  423. {
  424. chunk = carla_strdup(text.toRawUTF8());
  425. }
  426. }
  427. }
  428. }
  429. return true;
  430. }
  431. // -----------------------------------------------------------------------
  432. // fillXmlStringFromStateSave
  433. void CarlaStateSave::dumpToMemoryStream(MemoryOutputStream& content) const
  434. {
  435. {
  436. MemoryOutputStream infoXml;
  437. infoXml << " <Info>\n";
  438. infoXml << " <Type>" << String(type != nullptr ? type : "") << "</Type>\n";
  439. infoXml << " <Name>" << xmlSafeString(name, true) << "</Name>\n";
  440. switch (getPluginTypeFromString(type))
  441. {
  442. case PLUGIN_NONE:
  443. break;
  444. case PLUGIN_INTERNAL:
  445. infoXml << " <Label>" << xmlSafeString(label, true) << "</Label>\n";
  446. break;
  447. case PLUGIN_LADSPA:
  448. infoXml << " <Binary>" << xmlSafeString(binary, true) << "</Binary>\n";
  449. infoXml << " <Label>" << xmlSafeString(label, true) << "</Label>\n";
  450. infoXml << " <UniqueID>" << water::int64(uniqueId) << "</UniqueID>\n";
  451. break;
  452. case PLUGIN_DSSI:
  453. infoXml << " <Binary>" << xmlSafeString(binary, true) << "</Binary>\n";
  454. infoXml << " <Label>" << xmlSafeString(label, true) << "</Label>\n";
  455. break;
  456. case PLUGIN_LV2:
  457. infoXml << " <URI>" << xmlSafeString(label, true) << "</URI>\n";
  458. break;
  459. case PLUGIN_VST2:
  460. infoXml << " <Binary>" << xmlSafeString(binary, true) << "</Binary>\n";
  461. infoXml << " <UniqueID>" << water::int64(uniqueId) << "</UniqueID>\n";
  462. break;
  463. case PLUGIN_VST3:
  464. infoXml << " <Binary>" << xmlSafeString(binary, true) << "</Binary>\n";
  465. infoXml << " <Label>" << xmlSafeString(label, true) << "</Label>\n";
  466. break;
  467. case PLUGIN_AU:
  468. infoXml << " <Identifier>" << xmlSafeString(label, true) << "</Identifier>\n";
  469. break;
  470. case PLUGIN_DLS:
  471. case PLUGIN_GIG:
  472. case PLUGIN_SF2:
  473. infoXml << " <Filename>" << xmlSafeString(binary, true) << "</Filename>\n";
  474. infoXml << " <Label>" << xmlSafeString(label, true) << "</Label>\n";
  475. break;
  476. case PLUGIN_SFZ:
  477. infoXml << " <Filename>" << xmlSafeString(binary, true) << "</Filename>\n";
  478. break;
  479. case PLUGIN_JACK:
  480. infoXml << " <Filename>" << xmlSafeString(binary, true) << "</Filename>\n";
  481. infoXml << " <Setup>" << xmlSafeString(label, true) << "</Setup>\n";
  482. break;
  483. }
  484. infoXml << " </Info>\n\n";
  485. content << infoXml;
  486. }
  487. content << " <Data>\n";
  488. #ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
  489. {
  490. MemoryOutputStream dataXml;
  491. dataXml << " <Active>" << (active ? "Yes" : "No") << "</Active>\n";
  492. if (carla_isNotEqual(dryWet, 1.0f))
  493. dataXml << " <DryWet>" << String(dryWet, 7) << "</DryWet>\n";
  494. if (carla_isNotEqual(volume, 1.0f))
  495. dataXml << " <Volume>" << String(volume, 7) << "</Volume>\n";
  496. if (carla_isNotEqual(balanceLeft, -1.0f))
  497. dataXml << " <Balance-Left>" << String(balanceLeft, 7) << "</Balance-Left>\n";
  498. if (carla_isNotEqual(balanceRight, 1.0f))
  499. dataXml << " <Balance-Right>" << String(balanceRight, 7) << "</Balance-Right>\n";
  500. if (carla_isNotEqual(panning, 0.0f))
  501. dataXml << " <Panning>" << String(panning, 7) << "</Panning>\n";
  502. if (ctrlChannel < 0)
  503. dataXml << " <ControlChannel>N</ControlChannel>\n";
  504. else
  505. dataXml << " <ControlChannel>" << int(ctrlChannel+1) << "</ControlChannel>\n";
  506. dataXml << " <Options>0x" << String::toHexString(static_cast<int>(options)) << "</Options>\n";
  507. content << dataXml;
  508. }
  509. #endif
  510. for (ParameterItenerator it = parameters.begin2(); it.valid(); it.next())
  511. {
  512. Parameter* const stateParameter(it.getValue(nullptr));
  513. CARLA_SAFE_ASSERT_CONTINUE(stateParameter != nullptr);
  514. MemoryOutputStream parameterXml;
  515. parameterXml << "\n";
  516. parameterXml << " <Parameter>\n";
  517. parameterXml << " <Index>" << String(stateParameter->index) << "</Index>\n";
  518. parameterXml << " <Name>" << xmlSafeString(stateParameter->name, true) << "</Name>\n";
  519. if (stateParameter->symbol != nullptr && stateParameter->symbol[0] != '\0')
  520. parameterXml << " <Symbol>" << xmlSafeString(stateParameter->symbol, true) << "</Symbol>\n";
  521. #ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
  522. if (stateParameter->mappedControlIndex > CONTROL_INDEX_NONE && stateParameter->mappedControlIndex <= CONTROL_INDEX_MAX_ALLOWED)
  523. {
  524. parameterXml << " <MidiChannel>" << stateParameter->midiChannel+1 << "</MidiChannel>\n";
  525. /*
  526. parameterXml << " <MappedMinimum>" << stateParameter->mappedMinimum << "</MappedMinimum>\n";
  527. parameterXml << " <MappedMaximum>" << stateParameter->mappedMaximum << "</MappedMaximum>\n";
  528. */
  529. parameterXml << " <MappedControlIndex>" << stateParameter->mappedControlIndex << "</MappedControlIndex>\n";
  530. // backwards compatibility for older carla versions
  531. if (stateParameter->mappedControlIndex > 0 && stateParameter->mappedControlIndex < MAX_MIDI_CONTROL)
  532. parameterXml << " <MidiCC>" << stateParameter->mappedControlIndex << "</MidiCC>\n";
  533. }
  534. #endif
  535. if (! stateParameter->dummy)
  536. parameterXml << " <Value>" << String(stateParameter->value, 15) << "</Value>\n";
  537. parameterXml << " </Parameter>\n";
  538. content << parameterXml;
  539. }
  540. if (currentProgramIndex >= 0 && currentProgramName != nullptr && currentProgramName[0] != '\0')
  541. {
  542. // ignore 'default' program
  543. if (currentProgramIndex > 0 || ! String(currentProgramName).equalsIgnoreCase("default"))
  544. {
  545. MemoryOutputStream programXml;
  546. programXml << "\n";
  547. programXml << " <CurrentProgramIndex>" << currentProgramIndex+1 << "</CurrentProgramIndex>\n";
  548. programXml << " <CurrentProgramName>" << xmlSafeString(currentProgramName, true) << "</CurrentProgramName>\n";
  549. content << programXml;
  550. }
  551. }
  552. if (currentMidiBank >= 0 && currentMidiProgram >= 0)
  553. {
  554. MemoryOutputStream midiProgramXml;
  555. midiProgramXml << "\n";
  556. midiProgramXml << " <CurrentMidiBank>" << currentMidiBank+1 << "</CurrentMidiBank>\n";
  557. midiProgramXml << " <CurrentMidiProgram>" << currentMidiProgram+1 << "</CurrentMidiProgram>\n";
  558. content << midiProgramXml;
  559. }
  560. for (CustomDataItenerator it = customData.begin2(); it.valid(); it.next())
  561. {
  562. CustomData* const stateCustomData(it.getValue(nullptr));
  563. CARLA_SAFE_ASSERT_CONTINUE(stateCustomData != nullptr);
  564. CARLA_SAFE_ASSERT_CONTINUE(stateCustomData->isValid());
  565. MemoryOutputStream customDataXml;
  566. customDataXml << "\n";
  567. customDataXml << " <CustomData>\n";
  568. customDataXml << " <Type>" << xmlSafeString(stateCustomData->type, true) << "</Type>\n";
  569. customDataXml << " <Key>" << xmlSafeString(stateCustomData->key, true) << "</Key>\n";
  570. if (std::strcmp(stateCustomData->type, CUSTOM_DATA_TYPE_CHUNK) == 0 || std::strlen(stateCustomData->value) >= 128)
  571. {
  572. customDataXml << " <Value>\n";
  573. customDataXml << xmlSafeStringFast(stateCustomData->value, true);
  574. customDataXml << "\n </Value>\n";
  575. }
  576. else
  577. {
  578. customDataXml << " <Value>";
  579. customDataXml << xmlSafeStringFast(stateCustomData->value, true);
  580. customDataXml << "</Value>\n";
  581. }
  582. customDataXml << " </CustomData>\n";
  583. content << customDataXml;
  584. }
  585. if (chunk != nullptr && chunk[0] != '\0')
  586. {
  587. MemoryOutputStream chunkXml, chunkSplt;
  588. getNewLineSplittedString(chunkSplt, chunk);
  589. chunkXml << "\n <Chunk>\n";
  590. chunkXml << chunkSplt;
  591. chunkXml << "\n </Chunk>\n";
  592. content << chunkXml;
  593. }
  594. content << " </Data>\n";
  595. }
  596. // -----------------------------------------------------------------------
  597. CARLA_BACKEND_END_NAMESPACE