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
28 #include <jack/jack.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)))
59 #define MAP(v, imin, imax, omin, omax) (((v) - (imin)) * ((omax) - (omin)) / ((imax) - (imin)) + (omin))
62 enum midi_behavior_mode
{ Jump_To_Value
, Pick_Up
};
66 const char * jack_client_name_ptr
,
91 get_midi_behavior_mode(
95 set_midi_behavior_mode(
97 enum midi_behavior_mode mode
);
102 const char * channel_name
,
107 jack_mixer_kmeter_t km
,
115 jack_mixer_kmeter_t km
,
116 jack_default_audio_sample_t
*p
,
122 jack_mixer_channel_t channel
);
124 /* returned values are in dBFS */
126 channel_stereo_meter_read(
127 jack_mixer_channel_t channel
,
131 /* returned value is in dBFS */
133 channel_mono_meter_read(
134 jack_mixer_channel_t channel
,
138 /* returned values are in dBFS */
140 channel_stereo_kmeter_read(
141 jack_mixer_channel_t channel
,
144 double * left_rms_ptr
,
145 double * right_rms_ptr
);
147 /* returned value is in dBFS */
149 channel_mono_kmeter_read(
150 jack_mixer_channel_t channel
,
152 double * mono_rms_ptr
);
158 jack_mixer_channel_t channel
);
161 channel_set_midi_change_callback(
162 jack_mixer_channel_t channel
,
163 void (*midi_change_callback
) (void*),
166 /* volume is in dBFS */
168 channel_volume_write(
169 jack_mixer_channel_t channel
,
174 jack_mixer_channel_t channel
);
177 channels_volumes_read(
178 jack_mixer_t mixer_ptr
);
180 /* balance is from -1.0 (full left) to +1.0 (full right) */
182 channel_balance_write(
183 jack_mixer_channel_t channel
,
187 channel_balance_read(
188 jack_mixer_channel_t channel
);
191 channel_get_balance_midi_cc(
192 jack_mixer_channel_t channel
);
195 channel_set_balance_midi_cc(
196 jack_mixer_channel_t channel
,
200 channel_get_volume_midi_cc(
201 jack_mixer_channel_t channel
);
204 channel_set_volume_midi_cc(
205 jack_mixer_channel_t channel
,
209 channel_get_mute_midi_cc(
210 jack_mixer_channel_t channel
);
213 channel_set_mute_midi_cc(
214 jack_mixer_channel_t channel
,
218 channel_get_solo_midi_cc(
219 jack_mixer_channel_t channel
);
222 channel_set_solo_midi_cc(
223 jack_mixer_channel_t channel
,
227 channel_set_midi_cc_volume_picked_up(
228 jack_mixer_channel_t channel
,
232 channel_set_midi_cc_balance_picked_up(
233 jack_mixer_channel_t channel
,
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
);
254 jack_mixer_channel_t channel
);
260 /* returned value is in dBFS */
262 channel_abspeak_read(
263 jack_mixer_channel_t channel
);
266 channel_abspeak_reset(
267 jack_mixer_channel_t channel
);
271 jack_mixer_channel_t channel
);
275 jack_mixer_channel_t channel
);
278 channel_is_out_muted(
279 jack_mixer_channel_t channel
);
283 jack_mixer_channel_t channel
);
287 jack_mixer_channel_t channel
);
291 jack_mixer_channel_t channel
);
295 jack_mixer_channel_t channel
,
299 channel_set_midi_scale(
300 jack_mixer_channel_t channel
,
301 jack_mixer_scale_t scale
);
304 channel_get_midi_in_got_events(
305 jack_mixer_channel_t channel
);
307 jack_mixer_output_channel_t
310 const char * channel_name
,
315 remove_output_channel(
316 jack_mixer_output_channel_t output_channel
);
319 output_channel_set_solo(
320 jack_mixer_output_channel_t output_channel
,
321 jack_mixer_channel_t channel
,
325 output_channel_set_muted(
326 jack_mixer_output_channel_t output_channel
,
327 jack_mixer_channel_t channel
,
331 output_channel_is_muted(
332 jack_mixer_output_channel_t output_channel
,
333 jack_mixer_channel_t channel
);
336 output_channel_is_solo(
337 jack_mixer_output_channel_t output_channel
,
338 jack_mixer_channel_t channel
);
341 output_channel_set_prefader(
342 jack_mixer_output_channel_t output_channel
,
346 output_channel_is_prefader(
347 jack_mixer_output_channel_t output_channel
);
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
);
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 */