Remove unused line in meson file
[jack_mixer.git] / src / jack_mixer.h
blob85ce6ba5021f79e09f1825c246b4b6e34bf9d89e
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
24 #define _JACK_MIXER_H
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_channel_t;
34 typedef void * jack_mixer_kmeter_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 {
63 Jump_To_Value,
64 Pick_Up
67 typedef enum {
68 JACK_MIXER_NO_ERROR,
69 JACK_MIXER_ERROR_JACK_CLIENT_CREATE,
70 JACK_MIXER_ERROR_JACK_MIDI_IN_CREATE,
71 JACK_MIXER_ERROR_JACK_MIDI_OUT_CREATE,
72 JACK_MIXER_ERROR_JACK_SET_PROCESS_CALLBACK,
73 JACK_MIXER_ERROR_JACK_ACTIVATE,
74 JACK_MIXER_ERROR_CHANNEL_MALLOC,
75 JACK_MIXER_ERROR_CHANNEL_NAME_MALLOC,
76 JACK_MIXER_ERROR_PORT_REGISTER,
77 JACK_MIXER_ERROR_PORT_REGISTER_LEFT,
78 JACK_MIXER_ERROR_PORT_REGISTER_RIGHT,
79 JACK_MIXER_ERROR_JACK_RENAME_PORT,
80 JACK_MIXER_ERROR_JACK_RENAME_PORT_LEFT,
81 JACK_MIXER_ERROR_JACK_RENAME_PORT_RIGHT,
82 JACK_MIXER_ERROR_PORT_NAME_MALLOC,
83 JACK_MIXER_ERROR_INVALID_CC,
84 JACK_MIXER_ERROR_NO_FREE_CC,
85 JACK_MIXER_ERROR_COUNT
86 } jack_mixer_error_t;
88 jack_mixer_error_t
89 jack_mixer_error();
91 const char*
92 jack_mixer_error_str();
94 jack_mixer_t
95 create(
96 const char * jack_client_name_ptr,
97 bool stereo);
99 void
100 destroy(
101 jack_mixer_t mixer);
103 unsigned int
104 get_channels_count(
105 jack_mixer_t mixer);
107 const char*
108 get_client_name(
109 jack_mixer_t mixer);
111 int8_t
112 get_last_midi_cc(
113 jack_mixer_t mixer);
115 void
116 set_last_midi_cc(
117 jack_mixer_t mixer,
118 int8_t new_cc);
121 get_midi_behavior_mode(
122 jack_mixer_t mixer);
124 void
125 set_midi_behavior_mode(
126 jack_mixer_t mixer,
127 enum midi_behavior_mode mode);
129 jack_mixer_channel_t
130 add_channel(
131 jack_mixer_t mixer,
132 const char * channel_name,
133 bool stereo);
135 void
136 kmeter_init(
137 jack_mixer_kmeter_t km,
138 int sr,
139 int fsize,
140 float hold,
141 float fall);
143 void
144 kmeter_process(
145 jack_mixer_kmeter_t km,
146 jack_default_audio_sample_t *p,
147 int start,
148 int end);
150 const char *
151 channel_get_name(
152 jack_mixer_channel_t channel);
154 /* returned values are in dBFS */
155 void
156 channel_stereo_meter_read(
157 jack_mixer_channel_t channel,
158 double * left_ptr,
159 double * right_ptr);
161 /* returned value is in dBFS */
162 void
163 channel_mono_meter_read(
164 jack_mixer_channel_t channel,
165 double * mono_ptr);
167 /* returned values are in dBFS */
168 void
169 channel_stereo_kmeter_read(
170 jack_mixer_channel_t channel,
171 double * left_ptr,
172 double * right_ptr,
173 double * left_rms_ptr,
174 double * right_rms_ptr);
176 /* returned value is in dBFS */
177 void
178 channel_mono_kmeter_read(
179 jack_mixer_channel_t channel,
180 double * mono_ptr,
181 double * mono_rms_ptr);
183 bool
184 channel_is_stereo(
185 jack_mixer_channel_t channel);
187 void
188 channel_set_midi_change_callback(
189 jack_mixer_channel_t channel,
190 void (*midi_change_callback) (void*),
191 void *user_data);
193 /* volume is in dBFS */
194 void
195 channel_volume_write(
196 jack_mixer_channel_t channel,
197 double volume);
199 double
200 channel_volume_read(
201 jack_mixer_channel_t channel);
203 void
204 channels_volumes_read(
205 jack_mixer_t mixer_ptr);
207 /* balance is from -1.0 (full left) to +1.0 (full right) */
208 void
209 channel_balance_write(
210 jack_mixer_channel_t channel,
211 double balance);
213 double
214 channel_balance_read(
215 jack_mixer_channel_t channel);
217 int8_t
218 channel_get_balance_midi_cc(
219 jack_mixer_channel_t channel);
222 channel_set_balance_midi_cc(
223 jack_mixer_channel_t channel,
224 int8_t new_cc);
226 int8_t
227 channel_get_volume_midi_cc(
228 jack_mixer_channel_t channel);
231 channel_set_volume_midi_cc(
232 jack_mixer_channel_t channel,
233 int8_t new_cc);
235 int8_t
236 channel_get_mute_midi_cc(
237 jack_mixer_channel_t channel);
240 channel_set_mute_midi_cc(
241 jack_mixer_channel_t channel,
242 int8_t new_cc);
244 int8_t
245 channel_get_solo_midi_cc(
246 jack_mixer_channel_t channel);
249 channel_set_solo_midi_cc(
250 jack_mixer_channel_t channel,
251 int8_t new_cc);
253 void
254 channel_set_midi_cc_volume_picked_up(
255 jack_mixer_channel_t channel,
256 bool status);
258 void
259 channel_set_midi_cc_balance_picked_up(
260 jack_mixer_channel_t channel,
261 bool status);
264 channel_autoset_volume_midi_cc(
265 jack_mixer_channel_t channel);
268 channel_autoset_balance_midi_cc(
269 jack_mixer_channel_t channel);
272 channel_autoset_mute_midi_cc(
273 jack_mixer_channel_t channel);
276 channel_autoset_solo_midi_cc(
277 jack_mixer_channel_t channel);
279 void
280 remove_channel(
281 jack_mixer_channel_t channel);
283 void
284 remove_channels(
285 jack_mixer_t mixer);
287 /* returned value is in dBFS */
288 double
289 channel_abspeak_read(
290 jack_mixer_channel_t channel);
292 void
293 channel_abspeak_reset(
294 jack_mixer_channel_t channel);
296 void
297 channel_out_mute(
298 jack_mixer_channel_t channel);
300 void
301 channel_out_unmute(
302 jack_mixer_channel_t channel);
304 bool
305 channel_is_out_muted(
306 jack_mixer_channel_t channel);
308 void
309 channel_solo(
310 jack_mixer_channel_t channel);
312 void
313 channel_unsolo(
314 jack_mixer_channel_t channel);
316 bool
317 channel_is_soloed(
318 jack_mixer_channel_t channel);
321 channel_rename(
322 jack_mixer_channel_t channel,
323 const char * name);
325 void
326 channel_set_midi_scale(
327 jack_mixer_channel_t channel,
328 jack_mixer_scale_t scale);
330 bool
331 channel_get_midi_in_got_events(
332 jack_mixer_channel_t channel);
334 jack_mixer_output_channel_t
335 add_output_channel(
336 jack_mixer_t mixer,
337 const char * channel_name,
338 bool stereo,
339 bool system);
341 void
342 remove_output_channel(
343 jack_mixer_output_channel_t output_channel);
345 void
346 output_channel_set_solo(
347 jack_mixer_output_channel_t output_channel,
348 jack_mixer_channel_t channel,
349 bool solo_value);
351 void
352 output_channel_set_muted(
353 jack_mixer_output_channel_t output_channel,
354 jack_mixer_channel_t channel,
355 bool muted_value);
357 bool
358 output_channel_is_muted(
359 jack_mixer_output_channel_t output_channel,
360 jack_mixer_channel_t channel);
362 bool
363 output_channel_is_solo(
364 jack_mixer_output_channel_t output_channel,
365 jack_mixer_channel_t channel);
367 void
368 output_channel_set_prefader(
369 jack_mixer_output_channel_t output_channel,
370 bool pfl_value);
372 bool
373 output_channel_is_prefader(
374 jack_mixer_output_channel_t output_channel);
376 void
377 output_channel_set_in_prefader(
378 jack_mixer_output_channel_t output_channel,
379 jack_mixer_channel_t input_channel,
380 bool prefader_value);
382 bool
383 output_channel_is_in_prefader(
384 jack_mixer_output_channel_t output_channel,
385 jack_mixer_channel_t channel);
387 #endif /* #ifndef _JACK_MIXER_H */