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.

102 lines
2.7KB

  1. // Copyright 2021 Jean Pierre Cimalando
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. //
  15. // SPDX-License-Identifier: Apache-2.0
  16. //
  17. #pragma once
  18. #include "ysfx.h"
  19. #include "ysfx_reader.hpp"
  20. #include "ysfx_utils.hpp"
  21. #include <string>
  22. #include <vector>
  23. #include <cstdint>
  24. struct ysfx_section_t;
  25. struct ysfx_toplevel_t;
  26. struct ysfx_slider_t;
  27. struct ysfx_header_t;
  28. using ysfx_section_u = std::unique_ptr<ysfx_section_t>;
  29. using ysfx_toplevel_u = std::unique_ptr<ysfx_toplevel_t>;
  30. using ysfx_slider_u = std::unique_ptr<ysfx_slider_t>;
  31. using ysfx_header_u = std::unique_ptr<ysfx_header_t>;
  32. struct ysfx_section_t {
  33. uint32_t line_offset = 0;
  34. std::string text;
  35. };
  36. struct ysfx_toplevel_t {
  37. ysfx_section_u header;
  38. ysfx_section_u init;
  39. ysfx_section_u slider;
  40. ysfx_section_u block;
  41. ysfx_section_u sample;
  42. ysfx_section_u serialize;
  43. ysfx_section_u gfx;
  44. uint32_t gfx_w = 0;
  45. uint32_t gfx_h = 0;
  46. };
  47. struct ysfx_parse_error {
  48. uint32_t line = 0;
  49. std::string message;
  50. explicit operator bool() { return !message.empty(); }
  51. };
  52. struct ysfx_slider_t {
  53. uint32_t id = 0;
  54. bool exists = false;
  55. ysfx_real def = 0;
  56. ysfx_real min = 0;
  57. ysfx_real max = 0;
  58. ysfx_real inc = 0;
  59. std::string var;
  60. std::string path;
  61. bool is_enum = false;
  62. ysfx::string_list enum_names;
  63. std::string desc;
  64. bool initially_visible = false;
  65. };
  66. struct ysfx_options_t {
  67. std::string gmem;
  68. uint32_t maxmem = 0;
  69. bool want_all_kb = false;
  70. bool no_meter = false;
  71. };
  72. struct ysfx_header_t {
  73. std::string desc;
  74. std::string author;
  75. ysfx::string_list tags;
  76. ysfx::string_list imports;
  77. ysfx::string_list in_pins;
  78. ysfx::string_list out_pins;
  79. bool explicit_pins = false;
  80. ysfx::string_list filenames;
  81. ysfx_options_t options;
  82. ysfx_slider_t sliders[ysfx_max_sliders];
  83. };
  84. struct ysfx_parsed_filename_t {
  85. uint32_t index;
  86. std::string filename;
  87. };
  88. bool ysfx_parse_toplevel(ysfx::text_reader &reader, ysfx_toplevel_t &toplevel, ysfx_parse_error *error);
  89. bool ysfx_parse_slider(const char *line, ysfx_slider_t &slider);
  90. bool ysfx_parse_filename(const char *line, ysfx_parsed_filename_t &filename);
  91. void ysfx_parse_header(ysfx_section_t *section, ysfx_header_t &header);