1 /* -----------------------------------------------------------------------------
2  *
3  * Giada - Your Hardcore Loopmachine
4  *
5  * -----------------------------------------------------------------------------
6  *
7  * Copyright (C) 2010-2020 Giovanni A. Zuliani | Monocasual
8  *
9  * This file is part of Giada - Your Hardcore Loopmachine.
10  *
11  * Giada - Your Hardcore Loopmachine is free software: you can
12  * redistribute it and/or modify it under the terms of the GNU General
13  * Public License as published by the Free Software Foundation, either
14  * version 3 of the License, or (at your option) any later version.
15  *
16  * Giada - Your Hardcore Loopmachine is distributed in the hope that it
17  * will be useful, but WITHOUT ANY WARRANTY; without even the implied
18  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19  * See the GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with Giada - Your Hardcore Loopmachine. If not, see
23  * <http://www.gnu.org/licenses/>.
24  *
25  * -------------------------------------------------------------------------- */
26 
27 
28 #ifndef G_GLUE_IO_H
29 #define G_GLUE_IO_H
30 
31 
32 #include <atomic>
33 #include "core/types.h"
34 #include "core/midiEvent.h"
35 #include "core/model/model.h"
36 
37 
38 namespace giada {
39 namespace m
40 {
41 class Channel;
42 }
43 namespace c {
44 namespace io
45 {
46 struct PluginParamData
47 {
48     int         index;
49     std::string name;
50     uint32_t    value;
51 };
52 
53 struct PluginData
54 {
55     ID          id;
56     std::string name;
57     std::vector<PluginParamData> params;
58 };
59 
60 struct Channel_InputData
61 {
62     Channel_InputData() = default;
63     Channel_InputData(const m::Channel&);
64 
65     ID          channelId;
66     ChannelType channelType;
67     bool        enabled;
68     bool        velocityAsVol;
69     int         filter;
70 
71     uint32_t    keyPress;
72     uint32_t    keyRelease;
73     uint32_t    kill;
74     uint32_t    arm;
75     uint32_t    volume;
76     uint32_t    mute;
77     uint32_t    solo;
78     uint32_t    pitch;
79     uint32_t    readActions;
80 
81     std::vector<PluginData> plugins;
82 };
83 
84 struct Master_InputData
85 {
86     Master_InputData() = default;
87     Master_InputData(const m::model::MidiIn&);
88 
89     bool     enabled;
90     int      filter;
91 
92 	uint32_t rewind;
93 	uint32_t startStop;
94 	uint32_t actionRec;
95 	uint32_t inputRec;
96 	uint32_t volumeIn;
97 	uint32_t volumeOut;
98 	uint32_t beatDouble;
99 	uint32_t beatHalf;
100 	uint32_t metronome;
101 };
102 
103 struct MidiChannel_OutputData
104 {
105     MidiChannel_OutputData(const m::MidiSender&);
106 
107     bool enabled;
108     int  filter;
109 };
110 
111 struct Channel_OutputData
112 {
113     Channel_OutputData() = default;
114     Channel_OutputData(const m::Channel&);
115 
116     ID       channelId;
117     bool     lightningEnabled;
118     uint32_t lightningPlaying;
119     uint32_t lightningMute;
120     uint32_t lightningSolo;
121 
122     std::optional<MidiChannel_OutputData> output;
123 };
124 
125 Channel_InputData  channel_getInputData(ID channelId);
126 Channel_OutputData channel_getOutputData(ID channelId);
127 Master_InputData   master_getInputData();
128 
129 /* Channel functions. */
130 
131 void channel_enableMidiLearn(ID channelId, bool v);
132 void channel_enableMidiLightning(ID channelId, bool v);
133 void channel_enableMidiOutput(ID channelId, bool v);
134 void channel_enableVelocityAsVol(ID channelId, bool v);
135 void channel_setMidiInputFilter(ID channelId, int c);
136 void channel_setMidiOutputFilter(ID channelId, int c);
137 
138 /* channel_setKey
139 Set key 'k' to Sample Channel 'channelId'. Used for keyboard bindings. */
140 
141 void channel_setKey(ID channelId, int k);
142 
143 /* MIDI Learning functions. */
144 
145 void channel_startMidiLearn(int param, ID channelId);
146 void channel_clearMidiLearn(int param, ID channelId);
147 void master_clearMidiLearn (int param);
148 void master_startMidiLearn (int param);
149 void stopMidiLearn();
150 #ifdef WITH_VST
151 void plugin_startMidiLearn (int paramIndex, ID pluginId);
152 void plugin_clearMidiLearn (int param, ID pluginId);
153 #endif
154 
155 /* Master functions. */
156 
157 void master_enableMidiLearn(bool v);
158 void master_setMidiFilter(int c);
159 }}} // giada::c::io::
160 
161 #endif
162