1 /*
2  * Copyright (C) 2018-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  * Project schema.
24  */
25 
26 #ifndef __SCHEMAS_PROJECT_H__
27 #define __SCHEMAS_PROJECT_H__
28 
29 typedef enum SelectionType_v1
30 {
31   SELECTION_TYPE_TRACKLIST_v1,
32   SELECTION_TYPE_TIMELINE_v1,
33   SELECTION_TYPE_INSERT_v1,
34   SELECTION_TYPE_MIDI_FX_v1,
35   SELECTION_TYPE_EDITOR_v1,
36 } SelectionType_v1;
37 
38 static const cyaml_strval_t
39 selection_type_strings_v1[] =
40 {
41   { "Tracklist", SELECTION_TYPE_TRACKLIST_v1 },
42   { "Timeline", SELECTION_TYPE_TIMELINE_v1 },
43   { "Insert", SELECTION_TYPE_INSERT_v1 },
44   { "MIDI FX", SELECTION_TYPE_MIDI_FX_v1 },
45   { "Editor", SELECTION_TYPE_EDITOR_v1 },
46 };
47 
48 typedef struct Project_v1
49 {
50   int                  schema_version;
51   char *               title;
52   char *               datetime_str;
53   Tracklist_v1 *       tracklist;
54   ClipEditor_v1 *      clip_editor;
55   Timeline_v1 *        timeline;
56   SnapGrid_v1          snap_grid_timeline;
57   QuantizeOptions_v1   quantize_opts_timeline;
58   SnapGrid_v1          snap_grid_midi;
59   QuantizeOptions_v1   quantize_opts_editor;
60   AutomationSelections_v1 automation_selections;
61   AudioSelections_v1   audio_selections;
62   ChordSelections_v1   chord_selections;
63   TimelineSelections_v1 timeline_selections;
64   MidiArrangerSelections_v1 midi_arranger_selections;
65   TracklistSelections_v1 * tracklist_selections;
66   MixerSelections_v1   mixer_selections;
67   RegionLinkGroupManager_v1 region_link_group_manager;
68   AudioEngine_v1 *     audio_engine;
69   MidiMappings_v1 *    midi_mappings;
70   SelectionType_v1     last_selection;
71   char *               version;
72 } Project_v1;
73 
74 static const cyaml_schema_field_t
75   project_fields_schema_v1[] =
76 {
77   YAML_FIELD_INT (
78     Project_v1, schema_version),
79   YAML_FIELD_INT (
80     Project_v1, title),
81   YAML_FIELD_STRING_PTR (
82     Project_v1, title),
83   YAML_FIELD_STRING_PTR (
84     Project_v1, datetime_str),
85   YAML_FIELD_STRING_PTR (
86     Project_v1, version),
87   YAML_FIELD_MAPPING_PTR (
88     Project_v1, tracklist, tracklist_fields_schema_v1),
89   YAML_FIELD_MAPPING_PTR (
90     Project_v1, clip_editor,
91     clip_editor_fields_schema_v1),
92   YAML_FIELD_MAPPING_PTR (
93     Project_v1, timeline,
94     timeline_fields_schema_v1),
95   YAML_FIELD_MAPPING_EMBEDDED (
96     Project_v1, snap_grid_timeline,
97     snap_grid_fields_schema_v1),
98   YAML_FIELD_MAPPING_EMBEDDED (
99     Project_v1, quantize_opts_timeline,
100     quantize_options_fields_schema_v1),
101   YAML_FIELD_MAPPING_PTR (
102     Project_v1, audio_engine, engine_fields_schema_v1),
103   YAML_FIELD_MAPPING_EMBEDDED (
104     Project_v1, snap_grid_midi,
105     snap_grid_fields_schema_v1),
106   YAML_FIELD_MAPPING_EMBEDDED (
107     Project_v1, quantize_opts_editor,
108     quantize_options_fields_schema_v1),
109   YAML_FIELD_MAPPING_EMBEDDED (
110     Project_v1, mixer_selections,
111     mixer_selections_fields_schema_v1),
112   YAML_FIELD_MAPPING_EMBEDDED (
113     Project_v1, timeline_selections,
114     timeline_selections_fields_schema_v1),
115   YAML_FIELD_MAPPING_EMBEDDED (
116     Project_v1, midi_arranger_selections,
117     midi_arranger_selections_fields_schema_v1),
118   YAML_FIELD_MAPPING_EMBEDDED (
119     Project_v1, chord_selections,
120     chord_selections_fields_schema_v1),
121   YAML_FIELD_MAPPING_EMBEDDED (
122     Project_v1, automation_selections,
123     automation_selections_fields_schema_v1),
124   YAML_FIELD_MAPPING_EMBEDDED (
125     Project_v1, audio_selections,
126     audio_selections_fields_schema_v1),
127   YAML_FIELD_MAPPING_PTR (
128     Project_v1, tracklist_selections,
129     tracklist_selections_fields_schema_v1),
130   YAML_FIELD_MAPPING_EMBEDDED (
131     Project_v1, region_link_group_manager,
132     region_link_group_manager_fields_schema_v1),
133   YAML_FIELD_MAPPING_PTR (
134     Project_v1, midi_mappings,
135     midi_mappings_fields_schema_v1),
136   /* ignore undo history */
137   CYAML_FIELD_IGNORE (
138     "undo_manger", CYAML_FLAG_OPTIONAL),
139   YAML_FIELD_ENUM (
140     Project_v1, last_selection,
141     selection_type_strings_v1),
142 
143   CYAML_FIELD_END
144 };
145 
146 static const cyaml_schema_value_t
147   project_schema_v1 =
148 {
149   YAML_VALUE_PTR (
150     Project_v1, project_fields_schema_v1),
151 };
152 
153 Project *
154 schemas_project_upgrade_from_v1 (
155   Project_v1 * v1);
156 
157 Project *
158 schemas_project_deserialize (
159   const char * yaml);
160 
161 #endif
162