From: Daniel Sheeler Date: Fri, 3 Jul 2020 16:39:59 +0000 (-0500) Subject: Add a prefader button to input channel control groups X-Git-Tag: release-13~27 X-Git-Url: https://git.0d.be/?p=jack_mixer.git;a=commitdiff_plain;h=ebf39e61432e05157ca086191544bb1c4e989e3e Add a prefader button to input channel control groups --- diff --git a/channel.py b/channel.py index fffc3b7..0d013bb 100644 --- a/channel.py +++ b/channel.py @@ -1150,20 +1150,22 @@ class ControlGroup(Gtk.Alignment): solo.set_label("S") solo.connect("toggled", self.on_solo_toggled) self.solo = solo + pre = Gtk.ToggleButton("Pre") + pre.connect("toggled", self.on_prefader_toggled) + self.buttons_box.pack_start(pre, True, True, button_padding) + self.buttons_box.pack_start(mute, True, True, button_padding) if self.output_channel.display_solo_buttons: - self.buttons_box.pack_end(solo, True, True, button_padding) - self.buttons_box.pack_end(mute, True, True, button_padding) + self.buttons_box.pack_start(solo, True, True, button_padding) def update(self): if self.output_channel.display_solo_buttons: if not self.solo in self.buttons_box.get_children(): - self.buttons_box.pack_end(self.solo, True, True, button_padding) - self.buttons_box.reorder_child(self.mute, -1) + self.buttons_box.pack_start(self.solo, True, True, button_padding) self.solo.show() else: - if self.solo in self.hbox.get_children(): - self.hbox.remove(self.solo) + if self.solo in self.buttons_box.get_children(): + self.buttons_box.remove(self.solo) self.label.set_text(self.output_channel.channel.name) set_background_color(self.vbox, self.output_channel.css_name, self.output_channel.color.to_string()) @@ -1175,3 +1177,6 @@ class ControlGroup(Gtk.Alignment): def on_solo_toggled(self, button): self.output_channel.channel.set_solo(self.input_channel.channel, button.get_active()) self.app.update_monitor(self) + + def on_prefader_toggled(self, button): + self.output_channel.channel.set_prefader(self.input_channel.channel, button.get_active() == 1) diff --git a/jack_mixer.c b/jack_mixer.c index 50a63a0..41cb004 100644 --- a/jack_mixer.c +++ b/jack_mixer.c @@ -114,6 +114,8 @@ struct output_channel { struct channel channel; GSList *soloed_channels; GSList *muted_channels; + GSList *prefader_channels; + bool system; /* system channel, without any associated UI */ bool prefader; }; @@ -727,7 +729,8 @@ mix_one( for (i = start ; i < end ; i++) { - if (! output_mix_channel->prefader) { + if (! output_mix_channel->prefader && + g_slist_find(output_mix_channel->prefader_channels, channel_ptr) == NULL) { frame_left = channel_ptr->frames_left[i-start]; } else { frame_left = channel_ptr->prefader_frames_left[i-start]; @@ -737,7 +740,8 @@ mix_one( mix_channel->tmp_mixed_frames_left[i] += frame_left; if (mix_channel->stereo) { - if (! output_mix_channel->prefader) { + if (! output_mix_channel->prefader && + g_slist_find(output_mix_channel->prefader_channels, channel_ptr) == NULL) { frame_right = channel_ptr->frames_right[i-start]; } else { frame_right = channel_ptr->prefader_frames_right[i-start]; @@ -1614,6 +1618,7 @@ create_output_channel( output_channel_ptr->soloed_channels = NULL; output_channel_ptr->muted_channels = NULL; + output_channel_ptr->prefader_channels = NULL; output_channel_ptr->system = system; output_channel_ptr->prefader = false; @@ -1714,6 +1719,7 @@ remove_output_channel( g_slist_free(output_channel_ptr->soloed_channels); g_slist_free(output_channel_ptr->muted_channels); + g_slist_free(output_channel_ptr->prefader_channels); free(channel_ptr->tmp_mixed_frames_left); free(channel_ptr->tmp_mixed_frames_right); @@ -1803,3 +1809,22 @@ output_channel_is_prefader( struct output_channel *output_channel_ptr = output_channel; return output_channel_ptr->prefader; } + +void +output_channel_set_in_prefader( + jack_mixer_output_channel_t output_channel, + jack_mixer_channel_t channel, + bool prefader_value) +{ + struct output_channel *output_channel_ptr = output_channel; + + if (prefader_value) { + if (g_slist_find(output_channel_ptr->prefader_channels, channel) != NULL) + return; + output_channel_ptr->prefader_channels = g_slist_prepend(output_channel_ptr->prefader_channels, channel); + } else { + if (g_slist_find(output_channel_ptr->prefader_channels, channel) == NULL) + return; + output_channel_ptr->prefader_channels = g_slist_remove(output_channel_ptr->prefader_channels, channel); + } +} diff --git a/jack_mixer.h b/jack_mixer.h index f993d36..5141fd2 100644 --- a/jack_mixer.h +++ b/jack_mixer.h @@ -289,4 +289,8 @@ bool output_channel_is_prefader( jack_mixer_output_channel_t output_channel); +void output_channel_set_in_prefader(jack_mixer_output_channel_t output_channel, + jack_mixer_channel_t input_channel, + bool prefader_value); + #endif /* #ifndef JACK_MIXER_H__DAEB51D8_5861_40F2_92E4_24CA495A384D__INCLUDED */ diff --git a/jack_mixer_c.c b/jack_mixer_c.c index 1ba9b08..c4359f3 100644 --- a/jack_mixer_c.c +++ b/jack_mixer_c.c @@ -779,12 +779,28 @@ OutputChannel_is_muted(OutputChannelObject *self, PyObject *args) return result; } +static PyObject* +OutputChannel_set_in_prefader(OutputChannelObject *self, PyObject *args) +{ + PyObject *channel; + unsigned char prefader; + + if (! PyArg_ParseTuple(args, "Ob", &channel, &prefader)) return NULL; + + output_channel_set_in_prefader(self->output_channel, + ((ChannelObject*)channel)->channel, + prefader); + + Py_INCREF(Py_None); + return Py_None; +} static PyMethodDef output_channel_methods[] = { {"remove", (PyCFunction)OutputChannel_remove, METH_VARARGS, "Remove"}, {"set_solo", (PyCFunction)OutputChannel_set_solo, METH_VARARGS, "Set a channel as solo"}, {"set_muted", (PyCFunction)OutputChannel_set_muted, METH_VARARGS, "Set a channel as muted"}, {"is_solo", (PyCFunction)OutputChannel_is_solo, METH_VARARGS, "Is a channel set as solo"}, {"is_muted", (PyCFunction)OutputChannel_is_muted, METH_VARARGS, "Is a channel set as muted"}, + {"set_prefader", (PyCFunction)OutputChannel_set_in_prefader, METH_VARARGS, "Set a channel as prefader"}, {NULL} };