Minor fix for flake8 complaint about comment whitespace
[jack_mixer.git] / jack_mixer.h
bloba9164a071c34da02282bfb9fa4ea0acd23ffccbc
1 /* -*- Mode: C ; c-basic-offset: 2 -*- */
2 /*****************************************************************************
4 * This file is part of jack_mixer
6 * Copyright (C) 2006 Nedko Arnaudov <nedko@arnaudov.name>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2 of the License
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21 *****************************************************************************/
23 #ifndef JACK_MIXER_H__DAEB51D8_5861_40F2_92E4_24CA495A384D__INCLUDED
24 #define JACK_MIXER_H__DAEB51D8_5861_40F2_92E4_24CA495A384D__INCLUDED
26 #include <stdbool.h>
27 #include <stdint.h>
28 #include <jack/jack.h>
30 #include "scale.h"
32 typedef void * jack_mixer_t;
33 typedef void * jack_mixer_kmeter_t;
34 typedef void * jack_mixer_channel_t;
35 typedef void * jack_mixer_output_channel_t;
36 typedef void * jack_mixer_threshold_t;
38 /* Masks bits for channel.midi_out_has_events */
39 #define CHANNEL_VOLUME 1
40 #define CHANNEL_BALANCE 2
41 #define CHANNEL_MUTE 4
42 #define CHANNEL_SOLO 8
44 #define VOLUME_TRANSITION_SECONDS 0.01
46 #define BALANCE_PICKUP_THRESHOLD 0.015625 // -1.0..+1.0 / 128
48 #define PEAK_FRAMES_CHUNK 4800
50 // we don't know how much to allocate, but we don't want to wait with
51 // allocating until we're in the process() callback, so we just take a
52 // fairly big chunk: 4 periods per buffer, 4096 samples per period.
53 // (not sure if the '*4' is needed)
54 #define MAX_BLOCK_SIZE (4 * 4096)
56 #define FLOAT_EXISTS(x) (!((x) - (x)))
58 #ifndef MAP
59 #define MAP(v, imin, imax, omin, omax) (((v) - (imin)) * ((omax) - (omin)) / ((imax) - (imin)) + (omin))
60 #endif
62 enum midi_behavior_mode { Jump_To_Value, Pick_Up };
64 jack_mixer_t
65 create(
66 const char * jack_client_name_ptr,
67 bool stereo);
69 void
70 destroy(
71 jack_mixer_t mixer);
73 unsigned int
74 get_channels_count(
75 jack_mixer_t mixer);
77 const char*
78 get_client_name(
79 jack_mixer_t mixer);
81 int8_t
82 get_last_midi_cc(
83 jack_mixer_t mixer);
85 unsigned int
86 set_last_midi_cc(
87 jack_mixer_t mixer,
88 int8_t new_cc);
90 int
91 get_midi_behavior_mode(
92 jack_mixer_t mixer);
94 unsigned int
95 set_midi_behavior_mode(
96 jack_mixer_t mixer,
97 enum midi_behavior_mode mode);
99 jack_mixer_channel_t
100 add_channel(
101 jack_mixer_t mixer,
102 const char * channel_name,
103 bool stereo);
105 void
106 kmeter_init(
107 jack_mixer_kmeter_t km,
108 int sr,
109 int fsize,
110 float hold,
111 float fall);
113 void
114 kmeter_process(
115 jack_mixer_kmeter_t km,
116 jack_default_audio_sample_t *p,
117 int start,
118 int end);
120 const char *
121 channel_get_name(
122 jack_mixer_channel_t channel);
124 /* returned values are in dBFS */
125 void
126 channel_stereo_meter_read(
127 jack_mixer_channel_t channel,
128 double * left_ptr,
129 double * right_ptr);
131 /* returned value is in dBFS */
132 void
133 channel_mono_meter_read(
134 jack_mixer_channel_t channel,
135 double * mono_ptr);
138 /* returned values are in dBFS */
139 void
140 channel_stereo_kmeter_read(
141 jack_mixer_channel_t channel,
142 double * left_ptr,
143 double * right_ptr,
144 double * left_rms_ptr,
145 double * right_rms_ptr);
147 /* returned value is in dBFS */
148 void
149 channel_mono_kmeter_read(
150 jack_mixer_channel_t channel,
151 double * mono_ptr,
152 double * mono_rms_ptr);
156 bool
157 channel_is_stereo(
158 jack_mixer_channel_t channel);
160 void
161 channel_set_midi_change_callback(
162 jack_mixer_channel_t channel,
163 void (*midi_change_callback) (void*),
164 void *user_data);
166 /* volume is in dBFS */
167 void
168 channel_volume_write(
169 jack_mixer_channel_t channel,
170 double volume);
172 double
173 channel_volume_read(
174 jack_mixer_channel_t channel);
176 void
177 channels_volumes_read(
178 jack_mixer_t mixer_ptr);
180 /* balance is from -1.0 (full left) to +1.0 (full right) */
181 void
182 channel_balance_write(
183 jack_mixer_channel_t channel,
184 double balance);
186 double
187 channel_balance_read(
188 jack_mixer_channel_t channel);
190 int8_t
191 channel_get_balance_midi_cc(
192 jack_mixer_channel_t channel);
194 unsigned int
195 channel_set_balance_midi_cc(
196 jack_mixer_channel_t channel,
197 int8_t new_cc);
199 int8_t
200 channel_get_volume_midi_cc(
201 jack_mixer_channel_t channel);
203 unsigned int
204 channel_set_volume_midi_cc(
205 jack_mixer_channel_t channel,
206 int8_t new_cc);
208 int8_t
209 channel_get_mute_midi_cc(
210 jack_mixer_channel_t channel);
212 unsigned int
213 channel_set_mute_midi_cc(
214 jack_mixer_channel_t channel,
215 int8_t new_cc);
217 int8_t
218 channel_get_solo_midi_cc(
219 jack_mixer_channel_t channel);
221 unsigned int
222 channel_set_solo_midi_cc(
223 jack_mixer_channel_t channel,
224 int8_t new_cc);
226 void
227 channel_set_midi_cc_volume_picked_up(
228 jack_mixer_channel_t channel,
229 bool status);
231 void
232 channel_set_midi_cc_balance_picked_up(
233 jack_mixer_channel_t channel,
234 bool status);
237 channel_autoset_volume_midi_cc(
238 jack_mixer_channel_t channel);
241 channel_autoset_balance_midi_cc(
242 jack_mixer_channel_t channel);
245 channel_autoset_mute_midi_cc(
246 jack_mixer_channel_t channel);
249 channel_autoset_solo_midi_cc(
250 jack_mixer_channel_t channel);
252 void
253 remove_channel(
254 jack_mixer_channel_t channel);
256 void
257 remove_channels(
258 jack_mixer_t mixer);
260 /* returned value is in dBFS */
261 double
262 channel_abspeak_read(
263 jack_mixer_channel_t channel);
265 void
266 channel_abspeak_reset(
267 jack_mixer_channel_t channel);
269 void
270 channel_out_mute(
271 jack_mixer_channel_t channel);
273 void
274 channel_out_unmute(
275 jack_mixer_channel_t channel);
277 bool
278 channel_is_out_muted(
279 jack_mixer_channel_t channel);
281 void
282 channel_solo(
283 jack_mixer_channel_t channel);
285 void
286 channel_unsolo(
287 jack_mixer_channel_t channel);
289 bool
290 channel_is_soloed(
291 jack_mixer_channel_t channel);
293 void
294 channel_rename(
295 jack_mixer_channel_t channel,
296 const char * name);
298 void
299 channel_set_midi_scale(
300 jack_mixer_channel_t channel,
301 jack_mixer_scale_t scale);
303 bool
304 channel_get_midi_in_got_events(
305 jack_mixer_channel_t channel);
307 jack_mixer_output_channel_t
308 add_output_channel(
309 jack_mixer_t mixer,
310 const char * channel_name,
311 bool stereo,
312 bool system);
314 void
315 remove_output_channel(
316 jack_mixer_output_channel_t output_channel);
318 void
319 output_channel_set_solo(
320 jack_mixer_output_channel_t output_channel,
321 jack_mixer_channel_t channel,
322 bool solo_value);
324 void
325 output_channel_set_muted(
326 jack_mixer_output_channel_t output_channel,
327 jack_mixer_channel_t channel,
328 bool muted_value);
330 bool
331 output_channel_is_muted(
332 jack_mixer_output_channel_t output_channel,
333 jack_mixer_channel_t channel);
335 bool
336 output_channel_is_solo(
337 jack_mixer_output_channel_t output_channel,
338 jack_mixer_channel_t channel);
340 void
341 output_channel_set_prefader(
342 jack_mixer_output_channel_t output_channel,
343 bool pfl_value);
345 bool
346 output_channel_is_prefader(
347 jack_mixer_output_channel_t output_channel);
349 void
350 output_channel_set_in_prefader(
351 jack_mixer_output_channel_t output_channel,
352 jack_mixer_channel_t input_channel,
353 bool prefader_value);
355 bool
356 output_channel_is_in_prefader(
357 jack_mixer_output_channel_t output_channel,
358 jack_mixer_channel_t channel);
360 #endif /* #ifndef JACK_MIXER_H__DAEB51D8_5861_40F2_92E4_24CA495A384D__INCLUDED */