1 /*
2  * Copyright (C) 2020-2021 Alexandros Theodotou <alex at zrythm dot org>
3  *
4  * This file is part of Zrythm
5  *
6  * Zrythm is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Affero General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * Zrythm is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU Affero General Public License for more details.
15  *
16  * You should have received a copy of the GNU Affero General Public License
17  * along with Zrythm.  If not, see <https://www.gnu.org/licenses/>.
18  */
19 
20 /**
21  * \file
22  *
23  * Plugin preset schemas.
24  */
25 
26 #ifndef __SCHEMAS_PLUGINS_PLUGIN_PRESET_H__
27 #define __SCHEMAS_PLUGINS_PLUGIN_PRESET_H__
28 
29 #include "schemas/plugins/plugin_identifier.h"
30 #include "utils/yaml.h"
31 
32 typedef struct PluginPresetIdentifier_v1
33 {
34   int              schema_version;
35   int              idx;
36   int              bank_idx;
37   PluginIdentifier_v1 plugin_id;
38 } PluginPresetIdentifier_v1;
39 
40 static const cyaml_schema_field_t
41 plugin_preset_identifier_fields_schema_v1[] =
42 {
43   YAML_FIELD_INT (
44     PluginPresetIdentifier_v1, schema_version),
45   YAML_FIELD_INT (
46     PluginPresetIdentifier_v1, idx),
47   YAML_FIELD_INT (
48     PluginPresetIdentifier_v1, bank_idx),
49   YAML_FIELD_MAPPING_EMBEDDED (
50     PluginPresetIdentifier_v1, plugin_id,
51     plugin_identifier_fields_schema_v1),
52 
53   CYAML_FIELD_END
54 };
55 
56 static const cyaml_schema_value_t
57 plugin_preset_identifier_schema_v1 = {
58   YAML_VALUE_PTR (
59     PluginPresetIdentifier_v1,
60     plugin_preset_identifier_fields_schema_v1),
61 };
62 
63 typedef struct PluginPreset_v1
64 {
65   int              schema_version;
66   char *           name;
67   char *           uri;
68   int              carla_program;
69   PluginPresetIdentifier_v1 id;
70 } PluginPreset_v1;
71 
72 static const cyaml_schema_field_t
73 plugin_preset_fields_schema_v1[] =
74 {
75   YAML_FIELD_INT (
76     PluginPreset_v1, schema_version),
77   YAML_FIELD_STRING_PTR (
78     PluginPreset_v1, name),
79   YAML_FIELD_STRING_PTR_OPTIONAL (
80     PluginPreset_v1, uri),
81   YAML_FIELD_INT (
82     PluginPreset_v1, carla_program),
83   YAML_FIELD_MAPPING_EMBEDDED (
84     PluginPreset_v1, id,
85     plugin_preset_identifier_fields_schema_v1),
86 
87   CYAML_FIELD_END
88 };
89 
90 static const cyaml_schema_value_t
91 plugin_preset_schema_v1 = {
92   YAML_VALUE_PTR (
93     PluginPreset_v1, plugin_preset_fields_schema_v1),
94 };
95 
96 typedef struct PluginBank_v1
97 {
98   int              schema_version;
99   PluginPreset_v1 **  presets;
100   int              num_presets;
101   size_t           presets_size;
102   char *           uri;
103   char *           name;
104   PluginPresetIdentifier_v1 id;
105 } PluginBank;
106 
107 static const cyaml_schema_field_t
108 plugin_bank_fields_schema_v1[] =
109 {
110   YAML_FIELD_STRING_PTR (
111     PluginBank_v1, schema_version),
112   YAML_FIELD_DYN_PTR_ARRAY_VAR_COUNT (
113     PluginBank_v1, presets,
114     plugin_preset_schema_v1),
115   YAML_FIELD_STRING_PTR (
116     PluginBank_v1, name),
117   YAML_FIELD_STRING_PTR_OPTIONAL (
118     PluginBank_v1, uri),
119   YAML_FIELD_MAPPING_EMBEDDED (
120     PluginBank_v1, id,
121     plugin_preset_identifier_fields_schema_v1),
122 
123   CYAML_FIELD_END
124 };
125 
126 static const cyaml_schema_value_t
127 plugin_bank_schema_v1 = {
128   YAML_VALUE_PTR (
129     PluginBank_v1, plugin_bank_fields_schema_v1),
130 };
131 
132 #endif
133