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.

686 lines
23KB

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