1 /*
2  * Copyright (C) 2018, 2020 Alexandros Theodotou <alex at zrythm dot org>
3  *
4  * This file is part of ZPlugins
5  *
6  * ZPlugins is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Affero General Public License as
8  * published by the Free Software Foundation, either version 3 of the
9  * License, or (at your option) any later version.
10  *
11  * ZPlugins 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 General Affero Public License
17  * along with ZPlugins.  If not, see <https://www.gnu.org/licenses/>.
18  */
19 
20 /**
21  * \file
22  *
23  * Common code for both the DSP and the UI.
24  */
25 
26 #ifndef __Z_CHORDZ_COMMON_H__
27 #define __Z_CHORDZ_COMMON_H__
28 
29 #include PLUGIN_CONFIG
30 
31 #include "../common.h"
32 
33 typedef struct ChordzUris
34 {
35 } ChordzUris;
36 
37 typedef enum PortIndex
38 {
39   /** GUI to plugin communication. */
40   CHORDZ_CONTROL,
41   /** Plugin to UI communication. */
42   CHORDZ_NOTIFY,
43 
44   CHORDZ_SCALE,
45   CHORDZ_MAJOR,
46   CHORDZ_BASS,
47   CHORDZ_FIRST,
48   CHORDZ_THIRD,
49   CHORDZ_FIFTH,
50   CHORDZ_SEVENTH,
51   CHORDZ_OCTAVE,
52   CHORDZ_NINTH,
53   CHORDZ_ELEVENTH,
54   CHORDZ_THIRTEENTH,
55 
56   /** Outputs. */
57   CHORDZ_MIDI_OUT,
58 
59   NUM_PORTS,
60 } PortIndex;
61 
62 typedef enum ChordzScales
63 {
64   SCALE_C,
65   SCALE_CS,
66   SCALE_D,
67   SCALE_DS,
68   SCALE_E,
69   SCALE_F,
70   SCALE_FS,
71   SCALE_G,
72   SCALE_GS,
73   SCALE_A,
74   SCALE_AS,
75   SCALE_B
76 } ChordzScales;
77 
78 /**
79  * Group of variables needed by both the DSP and
80  * the UI.
81  */
82 typedef struct ChordzCommon
83 {
84   /** Custom URIs. */
85   ChordzUris      uris;
86 
87   PluginCommon    pl_common;
88 } ChordzCommon;
89 
90 static inline void
map_uris(LV2_URID_Map * urid_map,ChordzCommon * chordz_common)91 map_uris (
92   LV2_URID_Map*  urid_map,
93   ChordzCommon * chordz_common)
94 {
95   map_common_uris (
96     urid_map, &chordz_common->pl_common.uris);
97 
98 #define MAP(x,uri) \
99   chordz_common->uris.x = \
100     urid_map->map (urid_map->handle, uri)
101 
102   /* custom URIs */
103 
104 #undef MAP
105 }
106 
107 #endif
108