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 *****************************************************************************/
28 #include <jack/jack.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)))
59 #define MAP(v, imin, imax, omin, omax) (((v) - (imin)) * ((omax) - (omin)) / ((imax) - (imin)) + (omin))
62 enum midi_behavior_mode
{
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
99 jack_mixer_error_str();
103 const char * jack_client_name_ptr
,
137 get_midi_behavior_mode(
141 set_midi_behavior_mode(
143 enum midi_behavior_mode mode
);
148 const char * channel_name
,
153 jack_mixer_kmeter_t km
,
154 jack_nframes_t fsize
,
160 jack_mixer_kmeter_t km
,
161 jack_default_audio_sample_t
*p
,
167 jack_mixer_channel_t channel
);
169 /* returned values are in dBFS */
171 channel_stereo_meter_read(
172 jack_mixer_channel_t channel
,
177 /* returned value is in dBFS */
179 channel_mono_meter_read(
180 jack_mixer_channel_t channel
,
184 /* returned values are in dBFS */
186 channel_stereo_kmeter_read(
187 jack_mixer_channel_t channel
,
190 double * left_rms_ptr
,
191 double * right_rms_ptr
,
194 /* returned value is in dBFS */
196 channel_mono_kmeter_read(
197 jack_mixer_channel_t channel
,
199 double * mono_rms_ptr
,
200 enum meter_mode mode
);
203 channel_mono_kmeter_reset(
204 jack_mixer_channel_t channel
);
207 channel_stereo_kmeter_reset(
208 jack_mixer_channel_t channel
);
212 jack_mixer_channel_t channel
);
215 channel_set_midi_change_callback(
216 jack_mixer_channel_t channel
,
217 void (*midi_change_callback
) (void*),
220 /* volume is in dBFS */
222 channel_volume_write(
223 jack_mixer_channel_t channel
,
228 jack_mixer_channel_t channel
);
231 channels_volumes_read(
232 jack_mixer_t mixer_ptr
);
234 /* balance is from -1.0 (full left) to +1.0 (full right) */
236 channel_balance_write(
237 jack_mixer_channel_t channel
,
241 channel_balance_read(
242 jack_mixer_channel_t channel
);
245 channel_get_balance_midi_cc(
246 jack_mixer_channel_t channel
);
249 channel_set_balance_midi_cc(
250 jack_mixer_channel_t channel
,
254 channel_get_volume_midi_cc(
255 jack_mixer_channel_t channel
);
258 channel_set_volume_midi_cc(
259 jack_mixer_channel_t channel
,
263 channel_get_mute_midi_cc(
264 jack_mixer_channel_t channel
);
267 channel_set_mute_midi_cc(
268 jack_mixer_channel_t channel
,
272 channel_get_solo_midi_cc(
273 jack_mixer_channel_t channel
);
276 channel_set_solo_midi_cc(
277 jack_mixer_channel_t channel
,
281 channel_set_midi_cc_volume_picked_up(
282 jack_mixer_channel_t channel
,
286 channel_set_midi_cc_balance_picked_up(
287 jack_mixer_channel_t channel
,
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
);
308 jack_mixer_channel_t channel
);
314 /* returned value is in dBFS */
316 channel_abspeak_read(
317 jack_mixer_channel_t channel
,
318 enum meter_mode modes
);
321 channel_abspeak_reset(
322 jack_mixer_channel_t channel
,
323 enum meter_mode mode
);
327 jack_mixer_channel_t channel
);
331 jack_mixer_channel_t channel
);
334 channel_is_out_muted(
335 jack_mixer_channel_t channel
);
339 jack_mixer_channel_t channel
);
343 jack_mixer_channel_t channel
);
347 jack_mixer_channel_t channel
);
351 jack_mixer_channel_t channel
,
355 channel_set_midi_scale(
356 jack_mixer_channel_t channel
,
357 jack_mixer_scale_t scale
);
360 channel_get_midi_in_got_events(
361 jack_mixer_channel_t channel
);
363 jack_mixer_output_channel_t
366 const char * channel_name
,
371 remove_output_channel(
372 jack_mixer_output_channel_t output_channel
);
375 output_channel_set_solo(
376 jack_mixer_output_channel_t output_channel
,
377 jack_mixer_channel_t channel
,
381 output_channel_set_muted(
382 jack_mixer_output_channel_t output_channel
,
383 jack_mixer_channel_t channel
,
387 output_channel_is_muted(
388 jack_mixer_output_channel_t output_channel
,
389 jack_mixer_channel_t channel
);
392 output_channel_is_solo(
393 jack_mixer_output_channel_t output_channel
,
394 jack_mixer_channel_t channel
);
397 output_channel_set_prefader(
398 jack_mixer_output_channel_t output_channel
,
402 output_channel_is_prefader(
403 jack_mixer_output_channel_t output_channel
);
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
);
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 */