]> git.0d.be Git - jack_mixer.git/commitdiff
Add a prefader button to input channel control groups
authorDaniel Sheeler <dsheeler@pobox.com>
Fri, 3 Jul 2020 16:39:59 +0000 (11:39 -0500)
committerDaniel Sheeler <dsheeler@pobox.com>
Fri, 3 Jul 2020 16:39:59 +0000 (11:39 -0500)
channel.py
jack_mixer.c
jack_mixer.h
jack_mixer_c.c

index fffc3b7dad33e3839b43a5cafb06f44780454253..0d013bb5d3cf0f842ce2dc36a3aa5e53ca2631bd 100644 (file)
@@ -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)
index 50a63a0640ee86be0cdba416326b99e7240c9819..41cb00470cf90acc3f0b8e3cf920edca99deb98e 100644 (file)
@@ -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);
+  }
+}
index f993d36ae515ff6ee935319df5dd5955d252515d..5141fd26648036ec2b582c4adf9dcab654be44fc 100644 (file)
@@ -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 */
index 1ba9b08916e65e53afd517ddb4c212b503e7600f..c4359f376ff53acad85f9ad8f391a248170c6263 100644 (file)
@@ -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}
 };