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.

117 lines
3.1KB

  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. #ifndef CARLA_STATE_UTILS_HPP_INCLUDED
  18. #define CARLA_STATE_UTILS_HPP_INCLUDED
  19. #include "CarlaBackend.h"
  20. #include "LinkedList.hpp"
  21. #include "juce_core.h"
  22. CARLA_BACKEND_START_NAMESPACE
  23. // -----------------------------------------------------------------------
  24. struct CarlaStateSave {
  25. struct Parameter {
  26. bool isInput;
  27. int32_t index;
  28. const char* name;
  29. const char* symbol;
  30. float value;
  31. #ifndef BUILD_BRIDGE
  32. uint8_t midiChannel;
  33. int16_t midiCC;
  34. #endif
  35. Parameter() noexcept;
  36. ~Parameter() noexcept;
  37. CARLA_DECLARE_NON_COPY_STRUCT(Parameter)
  38. };
  39. typedef LinkedList<Parameter*> ParameterList;
  40. typedef LinkedList<Parameter*>::Itenerator ParameterItenerator;
  41. struct CustomData {
  42. const char* type;
  43. const char* key;
  44. const char* value;
  45. CustomData() noexcept;
  46. ~CustomData() noexcept;
  47. CARLA_DECLARE_NON_COPY_STRUCT(CustomData)
  48. };
  49. typedef LinkedList<CustomData*> CustomDataList;
  50. typedef LinkedList<CustomData*>::Itenerator CustomDataItenerator;
  51. const char* type;
  52. const char* name;
  53. const char* label;
  54. const char* binary;
  55. int64_t uniqueId;
  56. #ifndef BUILD_BRIDGE
  57. bool active;
  58. float dryWet;
  59. float volume;
  60. float balanceLeft;
  61. float balanceRight;
  62. float panning;
  63. int8_t ctrlChannel;
  64. uint options;
  65. #endif
  66. int32_t currentProgramIndex;
  67. const char* currentProgramName;
  68. int32_t currentMidiBank;
  69. int32_t currentMidiProgram;
  70. const char* chunk;
  71. ParameterList parameters;
  72. CustomDataList customData;
  73. CarlaStateSave() noexcept;
  74. ~CarlaStateSave() noexcept;
  75. void clear() noexcept;
  76. bool fillFromXmlElement(const juce::XmlElement* const xmlElement);
  77. juce::String toString() const;
  78. CARLA_DECLARE_NON_COPY_STRUCT(CarlaStateSave)
  79. };
  80. static inline
  81. juce::String xmlSafeString(const juce::String& string, const bool toXml)
  82. {
  83. juce::String newString(string);
  84. if (toXml)
  85. return newString.replace("&","&amp;").replace("<","&lt;").replace(">","&gt;").replace("'","&apos;").replace("\"","&quot;");
  86. else
  87. return newString.replace("&lt;","<").replace("&gt;",">").replace("&apos;","'").replace("&quot;","\"").replace("&amp;","&");
  88. }
  89. // -----------------------------------------------------------------------
  90. CARLA_BACKEND_END_NAMESPACE
  91. #endif // CARLA_STATE_UTILS_HPP_INCLUDED