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
{
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
92 jack_mixer_error_str();
96 const char * jack_client_name_ptr
,
121 get_midi_behavior_mode(
125 set_midi_behavior_mode(
127 enum midi_behavior_mode mode
);
132 const char * channel_name
,
137 jack_mixer_kmeter_t km
,
145 jack_mixer_kmeter_t km
,
146 jack_default_audio_sample_t
*p
,
152 jack_mixer_channel_t channel
);
154 /* returned values are in dBFS */
156 channel_stereo_meter_read(
157 jack_mixer_channel_t channel
,
161 /* returned value is in dBFS */
163 channel_mono_meter_read(
164 jack_mixer_channel_t channel
,
167 /* returned values are in dBFS */
169 channel_stereo_kmeter_read(
170 jack_mixer_channel_t channel
,
173 double * left_rms_ptr
,
174 double * right_rms_ptr
);
176 /* returned value is in dBFS */
178 channel_mono_kmeter_read(
179 jack_mixer_channel_t channel
,
181 double * mono_rms_ptr
);
185 jack_mixer_channel_t channel
);
188 channel_set_midi_change_callback(
189 jack_mixer_channel_t channel
,
190 void (*midi_change_callback
) (void*),
193 /* volume is in dBFS */
195 channel_volume_write(
196 jack_mixer_channel_t channel
,
201 jack_mixer_channel_t channel
);
204 channels_volumes_read(
205 jack_mixer_t mixer_ptr
);
207 /* balance is from -1.0 (full left) to +1.0 (full right) */
209 channel_balance_write(
210 jack_mixer_channel_t channel
,
214 channel_balance_read(
215 jack_mixer_channel_t channel
);
218 channel_get_balance_midi_cc(
219 jack_mixer_channel_t channel
);
222 channel_set_balance_midi_cc(
223 jack_mixer_channel_t channel
,
227 channel_get_volume_midi_cc(
228 jack_mixer_channel_t channel
);
231 channel_set_volume_midi_cc(
232 jack_mixer_channel_t channel
,
236 channel_get_mute_midi_cc(
237 jack_mixer_channel_t channel
);
240 channel_set_mute_midi_cc(
241 jack_mixer_channel_t channel
,
245 channel_get_solo_midi_cc(
246 jack_mixer_channel_t channel
);
249 channel_set_solo_midi_cc(
250 jack_mixer_channel_t channel
,
254 channel_set_midi_cc_volume_picked_up(
255 jack_mixer_channel_t channel
,
259 channel_set_midi_cc_balance_picked_up(
260 jack_mixer_channel_t channel
,
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
);
281 jack_mixer_channel_t channel
);
287 /* returned value is in dBFS */
289 channel_abspeak_read(
290 jack_mixer_channel_t channel
);
293 channel_abspeak_reset(
294 jack_mixer_channel_t channel
);
298 jack_mixer_channel_t channel
);
302 jack_mixer_channel_t channel
);
305 channel_is_out_muted(
306 jack_mixer_channel_t channel
);
310 jack_mixer_channel_t channel
);
314 jack_mixer_channel_t channel
);
318 jack_mixer_channel_t channel
);
322 jack_mixer_channel_t channel
,
326 channel_set_midi_scale(
327 jack_mixer_channel_t channel
,
328 jack_mixer_scale_t scale
);
331 channel_get_midi_in_got_events(
332 jack_mixer_channel_t channel
);
334 jack_mixer_output_channel_t
337 const char * channel_name
,
342 remove_output_channel(
343 jack_mixer_output_channel_t output_channel
);
346 output_channel_set_solo(
347 jack_mixer_output_channel_t output_channel
,
348 jack_mixer_channel_t channel
,
352 output_channel_set_muted(
353 jack_mixer_output_channel_t output_channel
,
354 jack_mixer_channel_t channel
,
358 output_channel_is_muted(
359 jack_mixer_output_channel_t output_channel
,
360 jack_mixer_channel_t channel
);
363 output_channel_is_solo(
364 jack_mixer_output_channel_t output_channel
,
365 jack_mixer_channel_t channel
);
368 output_channel_set_prefader(
369 jack_mixer_output_channel_t output_channel
,
373 output_channel_is_prefader(
374 jack_mixer_output_channel_t output_channel
);
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
);
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 */