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.0KB

  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 StateParameter {
  25. bool isInput;
  26. int32_t index;
  27. const char* name;
  28. const char* symbol;
  29. float value;
  30. #ifndef BUILD_BRIDGE
  31. uint8_t midiChannel;
  32. int16_t midiCC;
  33. #endif
  34. StateParameter() noexcept;
  35. ~StateParameter() noexcept;
  36. CARLA_DECLARE_NON_COPY_STRUCT(StateParameter)
  37. };
  38. struct StateCustomData {
  39. const char* type;
  40. const char* key;
  41. const char* value;
  42. StateCustomData() noexcept;
  43. ~StateCustomData() noexcept;
  44. CARLA_DECLARE_NON_COPY_STRUCT(StateCustomData)
  45. };
  46. typedef LinkedList<StateParameter*> StateParameterList;
  47. typedef LinkedList<StateCustomData*> StateCustomDataList;
  48. typedef LinkedList<StateParameter*>::Itenerator StateParameterItenerator;
  49. typedef LinkedList<StateCustomData*>::Itenerator StateCustomDataItenerator;
  50. struct StateSave {
  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. StateParameterList parameters;
  72. StateCustomDataList customData;
  73. StateSave() noexcept;
  74. ~StateSave() noexcept;
  75. void clear() noexcept;
  76. bool fillFromXmlElement(const juce::XmlElement* const xmlElement);
  77. juce::String toString() const;
  78. CARLA_DECLARE_NON_COPY_STRUCT(StateSave)
  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