Revert "jack_mixer.desktop, add NSM keys (#186)" until nsm code does not cause ladish...
[jack_mixer.git] / src / jack_mixer.h
blob8bf334d176499fc845096176c82ec6848be13550
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 enum meter_mode {
68 Pre_Fader,
69 Post_Fader
73 typedef enum {
74 JACK_MIXER_NO_ERROR,
75 JACK_MIXER_ERROR_JACK_CLIENT_CREATE,
76 JACK_MIXER_ERROR_JACK_MIDI_IN_CREATE,
77 JACK_MIXER_ERROR_JACK_MIDI_OUT_CREATE,
78 JACK_MIXER_ERROR_JACK_SET_PROCESS_CALLBACK,
79 JACK_MIXER_ERROR_JACK_SET_BUFFER_SIZE_CALLBACK,
80 JACK_MIXER_ERROR_JACK_ACTIVATE,
81 JACK_MIXER_ERROR_CHANNEL_MALLOC,
82 JACK_MIXER_ERROR_CHANNEL_NAME_MALLOC,
83 JACK_MIXER_ERROR_PORT_REGISTER,
84 JACK_MIXER_ERROR_PORT_REGISTER_LEFT,
85 JACK_MIXER_ERROR_PORT_REGISTER_RIGHT,
86 JACK_MIXER_ERROR_JACK_RENAME_PORT,
87 JACK_MIXER_ERROR_JACK_RENAME_PORT_LEFT,
88 JACK_MIXER_ERROR_JACK_RENAME_PORT_RIGHT,
89 JACK_MIXER_ERROR_PORT_NAME_MALLOC,
90 JACK_MIXER_ERROR_INVALID_CC,
91 JACK_MIXER_ERROR_NO_FREE_CC,
92 JACK_MIXER_ERROR_COUNT
93 } jack_mixer_error_t;
95 jack_mixer_error_t
96 jack_mixer_error();
98 const char*
99 jack_mixer_error_str();
101 jack_mixer_t
102 create(
103 const char * jack_client_name_ptr,
104 bool stereo);
106 void
107 destroy(
108 jack_mixer_t mixer);
110 unsigned int
111 get_channels_count(
112 jack_mixer_t mixer);
114 const char*
115 get_client_name(
116 jack_mixer_t mixer);
118 bool
119 get_kmetering(
120 jack_mixer_t mixer);
122 void
123 set_kmetering(
124 jack_mixer_t mixer,
125 bool flag);
127 int8_t
128 get_last_midi_cc(
129 jack_mixer_t mixer);
131 void
132 set_last_midi_cc(
133 jack_mixer_t mixer,
134 int8_t new_cc);
137 get_midi_behavior_mode(
138 jack_mixer_t mixer);
140 void
141 set_midi_behavior_mode(
142 jack_mixer_t mixer,
143 enum midi_behavior_mode mode);
145 jack_mixer_channel_t
146 add_channel(
147 jack_mixer_t mixer,
148 const char * channel_name,
149 bool stereo);
151 void
152 kmeter_init(
153 jack_mixer_kmeter_t km,
154 jack_nframes_t fsize,
155 jack_nframes_t sr
158 void
159 kmeter_process(
160 jack_mixer_kmeter_t km,
161 jack_default_audio_sample_t *p,
162 int start,
163 int end);
165 const char *
166 channel_get_name(
167 jack_mixer_channel_t channel);
169 /* returned values are in dBFS */
170 void
171 channel_stereo_meter_read(
172 jack_mixer_channel_t channel,
173 double * left_ptr,
174 double * right_ptr,
175 enum meter_mode);
177 /* returned value is in dBFS */
178 void
179 channel_mono_meter_read(
180 jack_mixer_channel_t channel,
181 double * mono_ptr,
182 enum meter_mode);
184 /* returned values are in dBFS */
185 void
186 channel_stereo_kmeter_read(
187 jack_mixer_channel_t channel,
188 double * left_ptr,
189 double * right_ptr,
190 double * left_rms_ptr,
191 double * right_rms_ptr,
192 enum meter_mode);
194 /* returned value is in dBFS */
195 void
196 channel_mono_kmeter_read(
197 jack_mixer_channel_t channel,
198 double * mono_ptr,
199 double * mono_rms_ptr,
200 enum meter_mode mode);
202 void
203 channel_mono_kmeter_reset(
204 jack_mixer_channel_t channel);
206 void
207 channel_stereo_kmeter_reset(
208 jack_mixer_channel_t channel);
210 bool
211 channel_is_stereo(
212 jack_mixer_channel_t channel);
214 void
215 channel_set_midi_change_callback(
216 jack_mixer_channel_t channel,
217 void (*midi_change_callback) (void*),
218 void *user_data);
220 /* volume is in dBFS */
221 void
222 channel_volume_write(
223 jack_mixer_channel_t channel,
224 double volume);
226 double
227 channel_volume_read(
228 jack_mixer_channel_t channel);
230 void
231 channels_volumes_read(
232 jack_mixer_t mixer_ptr);
234 /* balance is from -1.0 (full left) to +1.0 (full right) */
235 void
236 channel_balance_write(
237 jack_mixer_channel_t channel,
238 double balance);
240 double
241 channel_balance_read(
242 jack_mixer_channel_t channel);
244 int8_t
245 channel_get_balance_midi_cc(
246 jack_mixer_channel_t channel);
249 channel_set_balance_midi_cc(
250 jack_mixer_channel_t channel,
251 int8_t new_cc);
253 int8_t
254 channel_get_volume_midi_cc(
255 jack_mixer_channel_t channel);
258 channel_set_volume_midi_cc(
259 jack_mixer_channel_t channel,
260 int8_t new_cc);
262 int8_t
263 channel_get_mute_midi_cc(
264 jack_mixer_channel_t channel);
267 channel_set_mute_midi_cc(
268 jack_mixer_channel_t channel,
269 int8_t new_cc);
271 int8_t
272 channel_get_solo_midi_cc(
273 jack_mixer_channel_t channel);
276 channel_set_solo_midi_cc(
277 jack_mixer_channel_t channel,
278 int8_t new_cc);
280 void
281 channel_set_midi_cc_volume_picked_up(
282 jack_mixer_channel_t channel,
283 bool status);
285 void
286 channel_set_midi_cc_balance_picked_up(
287 jack_mixer_channel_t channel,
288 bool status);
291 channel_autoset_volume_midi_cc(
292 jack_mixer_channel_t channel);
295 channel_autoset_balance_midi_cc(
296 jack_mixer_channel_t channel);
299 channel_autoset_mute_midi_cc(
300 jack_mixer_channel_t channel);
303 channel_autoset_solo_midi_cc(
304 jack_mixer_channel_t channel);
306 void
307 remove_channel(
308 jack_mixer_channel_t channel);
310 void
311 remove_channels(
312 jack_mixer_t mixer);
314 /* returned value is in dBFS */
315 double
316 channel_abspeak_read(
317 jack_mixer_channel_t channel,
318 enum meter_mode modes);
320 void
321 channel_abspeak_reset(
322 jack_mixer_channel_t channel,
323 enum meter_mode mode);
325 void
326 channel_out_mute(
327 jack_mixer_channel_t channel);
329 void
330 channel_out_unmute(
331 jack_mixer_channel_t channel);
333 bool
334 channel_is_out_muted(
335 jack_mixer_channel_t channel);
337 void
338 channel_solo(
339 jack_mixer_channel_t channel);
341 void
342 channel_unsolo(
343 jack_mixer_channel_t channel);
345 bool
346 channel_is_soloed(
347 jack_mixer_channel_t channel);
350 channel_rename(
351 jack_mixer_channel_t channel,
352 const char * name);
354 void
355 channel_set_midi_scale(
356 jack_mixer_channel_t channel,
357 jack_mixer_scale_t scale);
359 bool
360 channel_get_midi_in_got_events(
361 jack_mixer_channel_t channel);
363 jack_mixer_output_channel_t
364 add_output_channel(
365 jack_mixer_t mixer,
366 const char * channel_name,
367 bool stereo,
368 bool system);
370 void
371 remove_output_channel(
372 jack_mixer_output_channel_t output_channel);
374 void
375 output_channel_set_solo(
376 jack_mixer_output_channel_t output_channel,
377 jack_mixer_channel_t channel,
378 bool solo_value);
380 void
381 output_channel_set_muted(
382 jack_mixer_output_channel_t output_channel,
383 jack_mixer_channel_t channel,
384 bool muted_value);
386 bool
387 output_channel_is_muted(
388 jack_mixer_output_channel_t output_channel,
389 jack_mixer_channel_t channel);
391 bool
392 output_channel_is_solo(
393 jack_mixer_output_channel_t output_channel,
394 jack_mixer_channel_t channel);
396 void
397 output_channel_set_prefader(
398 jack_mixer_output_channel_t output_channel,
399 bool pfl_value);
401 bool
402 output_channel_is_prefader(
403 jack_mixer_output_channel_t output_channel);
405 void
406 output_channel_set_in_prefader(
407 jack_mixer_output_channel_t output_channel,
408 jack_mixer_channel_t input_channel,
409 bool prefader_value);
411 bool
412 output_channel_is_in_prefader(
413 jack_mixer_output_channel_t output_channel,
414 jack_mixer_channel_t channel);
416 #endif /* #ifndef _JACK_MIXER_H */