Zrythm
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
plugin_identifier.h
Go to the documentation of this file.
1// clang-format off
2// SPDX-FileCopyrightText: © 2020-2021, 2023 Alexandros Theodotou <alex@zrythm.org>
3// SPDX-License-Identifier: LicenseRef-ZrythmLicense
4// clang-format on
5
12#ifndef __PLUGINS_PLUGIN_IDENTIFIER_H__
13#define __PLUGINS_PLUGIN_IDENTIFIER_H__
14
15#include "zrythm-config.h"
16
17#include <stdbool.h>
18
19#include "utils/yaml.h"
20
27#define PLUGIN_IDENTIFIER_SCHEMA_VERSION 1
28
29typedef enum PluginSlotType
30{
31 PLUGIN_SLOT_INVALID,
32 PLUGIN_SLOT_INSERT,
33 PLUGIN_SLOT_MIDI_FX,
34 PLUGIN_SLOT_INSTRUMENT,
35
39
40static const cyaml_strval_t plugin_slot_type_strings[] = {
41 {"Invalid", PLUGIN_SLOT_INVALID },
42 { "Insert", PLUGIN_SLOT_INSERT },
43 { "MIDI FX", PLUGIN_SLOT_MIDI_FX },
44 { "Instrument", PLUGIN_SLOT_INSTRUMENT},
45 { "Modulator", PLUGIN_SLOT_MODULATOR },
46};
47
48static inline const char *
49plugin_slot_type_to_string (PluginSlotType type)
50{
51 return plugin_slot_type_strings[type].str;
52}
53
57typedef struct PluginIdentifier
58{
59 int schema_version;
60
61 PluginSlotType slot_type;
62
64 unsigned int track_name_hash;
65
73 int slot;
75
76static const cyaml_schema_field_t plugin_identifier_fields_schema[] = {
77 YAML_FIELD_INT (PluginIdentifier, schema_version),
78 YAML_FIELD_ENUM (PluginIdentifier, slot_type, plugin_slot_type_strings),
79 YAML_FIELD_UINT (PluginIdentifier, track_name_hash),
80 YAML_FIELD_INT (PluginIdentifier, slot),
81
82 CYAML_FIELD_END
83};
84
85static const cyaml_schema_value_t plugin_identifier_schema = {
86 CYAML_VALUE_MAPPING (
87 CYAML_FLAG_POINTER,
89 plugin_identifier_fields_schema),
90};
91
92void
93plugin_identifier_init (PluginIdentifier * self);
94
95static inline int
96plugin_identifier_is_equal (
97 const PluginIdentifier * a,
98 const PluginIdentifier * b)
99{
100 return a->slot_type == b->slot_type
101 && a->track_name_hash == b->track_name_hash && a->slot == b->slot;
102}
103
104void
105plugin_identifier_copy (PluginIdentifier * dest, const PluginIdentifier * src);
106
107NONNULL bool
108plugin_identifier_validate (const PluginIdentifier * self);
109
114bool
116 PluginSlotType slot_type,
117 int slot);
118
119void
120plugin_identifier_print (const PluginIdentifier * self, char * str);
121
122uint32_t
123plugin_identifier_get_hash (const void * id);
124
129#endif
bool plugin_identifier_validate_slot_type_slot_combo(PluginSlotType slot_type, int slot)
Verifies that slot_type and slot is a valid combination.
PluginSlotType
@ PLUGIN_SLOT_MODULATOR
Plugin is part of a modulator.
Plugin identifier.
int slot
The slot this plugin is in the channel, or the index if this is part of a modulator.
unsigned int track_name_hash
Track name hash.
YAML utils.