1 /*****************************************************************************
3 * This file is part of jack_mixer
5 * Copyright (C) 2006 Nedko Arnaudov <nedko@arnaudov.name>
6 * Copyright (C) 2009-2011 Frederic Peters <fpeters@0d.be>
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 *****************************************************************************/
24 * jack_mix_box is a most minimalistic jack mixer, a set of mono input
25 * channels, mixed to a single output channel, with the volume of the
26 * input channels controlled by MIDI control change (CC) codes.
29 * jack_mix_box [ -n JACK_CLI_NAME ] MIDI_CC_1 MIDI_CC_2 ....
37 #include "jack_mixer.h"
40 main(int argc
, char *argv
[])
42 jack_mixer_scale_t scale
;
44 jack_mixer_channel_t main_mix_channel
;
45 char *jack_cli_name
= NULL
;
50 static struct option long_options
[] =
52 {"name", required_argument
, 0, 'n'},
57 c
= getopt_long (argc
, argv
, "n:", long_options
, &option_index
);
63 jack_cli_name
= strdup(optarg
);
66 fprintf(stderr
, "Unknown argument, aborting.\n");
72 fprintf(stderr
, "You must specify at least one input channel\n");
76 scale
= scale_create();
77 scale_add_threshold(scale
, -70.0, 0.0);
78 scale_add_threshold(scale
, 0.0, 1.0);
79 scale_calculate_coefficients(scale
);
81 if (jack_cli_name
== NULL
) {
82 jack_cli_name
= strdup("jack_mix_box");
85 mixer
= create(jack_cli_name
, false);
86 main_mix_channel
= get_main_mix_channel(mixer
);
87 channel_set_midi_scale(main_mix_channel
, scale
);
88 channel_volume_write(main_mix_channel
, 0);
89 channel_set_volume_midi_cc(main_mix_channel
, 0);
92 while (optind
< argc
) {
94 jack_mixer_channel_t channel
;
97 channel_name
= malloc(15);
98 if (snprintf(channel_name
, 15, "Channel %d", channel_index
) >= 15) {
101 channel
= add_channel(mixer
, channel_name
, false);
102 if (channel
== NULL
) {
103 fprintf(stderr
, "Failed to add channel %d, aborting\n", channel_index
);
106 channel_set_volume_midi_cc(channel
, atoi(argv
[optind
++]));
107 channel_set_midi_scale(channel
, scale
);
108 channel_volume_write(channel
, 0);