]> git.0d.be Git - jack_mixer.git/commitdiff
Add per output channel mute button
authorDaniel Sheeler <dsheeler@pobox.com>
Sat, 25 Apr 2020 14:17:46 +0000 (09:17 -0500)
committerDaniel Sheeler <dsheeler@pobox.com>
Sat, 25 Apr 2020 14:17:46 +0000 (09:17 -0500)
channel.py
jack_mixer.c
jack_mixer.h
jack_mixer.py
jack_mixer_c.c

index c24702e09d3a38353fb7d1872551c8302f6d2fdb..da163ae5467c1d6331f73498ee9064b503295971 100644 (file)
@@ -546,6 +546,12 @@ class OutputChannel(Channel):
             break
         self.label_name_event_box.modify_bg(gtk.STATE_NORMAL, self.color_tuple[1])
         self.vbox.pack_start(self.label_name_event_box, True)
+        self.mute = gtk.ToggleButton()
+        self.mute.set_label("M")
+        self.mute.set_active(self.channel.mute)
+        self.mute.connect("toggled", self.on_mute_toggled)
+        self.vbox.pack_start(self.mute, False)
+
         frame = gtk.Frame()
         frame.set_shadow_type(gtk.SHADOW_IN)
         frame.add(self.abspeak);
@@ -595,6 +601,10 @@ class OutputChannel(Channel):
             if event.button == 1:
                 self.on_channel_properties()
 
+    def on_mute_toggled(self, button):
+        self.channel.out_mute = self.mute.get_active()
+        self.app.update_monitor(self.app.main_mix)
+
     def unrealize(self):
         # remove control groups from input channels
         for input_channel in self.app.channels:
@@ -674,6 +684,11 @@ class MainMixChannel(Channel):
         self.label_name.set_text(self.channel_name)
         self.label_name.set_size_request(0, -1)
         self.vbox.pack_start(self.label_name, False)
+        self.mute = gtk.ToggleButton()
+        self.mute.set_label("M")
+        self.mute.set_active(self.channel.mute)
+        self.mute.connect("toggled", self.on_mute_toggled)
+        self.vbox.pack_start(self.mute, False)
         frame = gtk.Frame()
         frame.set_shadow_type(gtk.SHADOW_IN)
         frame.add(self.abspeak);
@@ -708,6 +723,10 @@ class MainMixChannel(Channel):
         self._init_muted_channels = None
         self._init_solo_channels = None
 
+    def on_mute_toggled(self, button):
+        self.channel.out_mute = self.mute.get_active()
+        self.app.update_monitor(self.app.main_mix)
+
     def unrealize(self):
         Channel.unrealize(self)
         self.channel = False
index 48cebf79541617298a8802f31ee2c5a20e26784f..c6cb00ecb3f4e02c127c6b713521897842652e0c 100644 (file)
@@ -58,6 +58,7 @@ struct channel
   struct jack_mixer * mixer_ptr;
   char * name;
   bool stereo;
+  bool out_mute;
   float volume_transition_seconds;
   unsigned int num_volume_transition_steps;
   float volume;
@@ -80,6 +81,8 @@ struct channel
   float peak_left;
   float peak_right;
 
+  jack_default_audio_sample_t * tmp_mixed_frames_left;
+  jack_default_audio_sample_t * tmp_mixed_frames_right;
   jack_default_audio_sample_t * frames_left;
   jack_default_audio_sample_t * frames_right;
   jack_default_audio_sample_t * prefader_frames_left;
@@ -479,6 +482,20 @@ channel_unmute(
   output_channel_set_muted(channel_ptr->mixer_ptr->main_mix_channel, channel, false);
 }
 
+void
+channel_out_mute(
+  jack_mixer_channel_t channel)
+{
+  channel_ptr->out_mute = true;
+}
+
+void
+channel_out_unmute(
+  jack_mixer_channel_t channel)
+{
+  channel_ptr->out_mute = false;
+}
+
 void
 channel_solo(
   jack_mixer_channel_t channel)
@@ -502,6 +519,13 @@ channel_is_muted(
   return false;
 }
 
+bool
+channel_is_out_muted(
+  jack_mixer_channel_t channel)
+{
+  return channel_ptr->out_mute;
+}
+
 bool
 channel_is_soloed(
   jack_mixer_channel_t channel)
@@ -557,12 +581,11 @@ mix_one(
 
   for (i = start; i < end; i++)
   {
-    mix_channel->left_buffer_ptr[i] = 0.0;
+    mix_channel->left_buffer_ptr[i] = mix_channel->tmp_mixed_frames_left[i] = 0.0;
     if (mix_channel->stereo)
-      mix_channel->right_buffer_ptr[i] = 0.0;
+      mix_channel->right_buffer_ptr[i] = mix_channel->tmp_mixed_frames_right[i] = 0.0;
   }
 
-
   for (node_ptr = channels_list; node_ptr; node_ptr = g_slist_next(node_ptr))
   {
     channel_ptr = node_ptr->data;
@@ -587,7 +610,7 @@ mix_one(
       }
       if (frame_left == NAN)
         break;
-      mix_channel->left_buffer_ptr[i] += frame_left;
+      mix_channel->tmp_mixed_frames_left[i] += frame_left;
 
       if (mix_channel->stereo)
       {
@@ -599,7 +622,7 @@ mix_one(
         if (frame_right == NAN)
           break;
 
-        mix_channel->right_buffer_ptr[i] += frame_right;
+        mix_channel->tmp_mixed_frames_right[i] += frame_right;
       }
 
     }
@@ -639,11 +662,11 @@ mix_one(
         vol_l = vol * (1 - bal);
         vol_r = vol * (1 + bal);
       }
-      mix_channel->left_buffer_ptr[i] *= vol_l;
-      mix_channel->right_buffer_ptr[i] *= vol_r;
+      mix_channel->tmp_mixed_frames_left[i] *= vol_l;
+      mix_channel->tmp_mixed_frames_right[i] *= vol_r;
     }
 
-    frame_left = fabsf(mix_channel->left_buffer_ptr[i]);
+    frame_left = fabsf(mix_channel->tmp_mixed_frames_left[i]);
     if (mix_channel->peak_left < frame_left)
     {
       mix_channel->peak_left = frame_left;
@@ -656,7 +679,7 @@ mix_one(
 
     if (mix_channel->stereo)
     {
-      frame_right = fabsf(mix_channel->right_buffer_ptr[i]);
+      frame_right = fabsf(mix_channel->tmp_mixed_frames_right[i]);
       if (mix_channel->peak_right < frame_right)
       {
         mix_channel->peak_right = frame_right;
@@ -692,6 +715,11 @@ mix_one(
       mix_channel->balance = mix_channel->balance_new;
       mix_channel->balance_idx = 0;
     }
+
+    if (!mix_channel->out_mute) {
+        mix_channel->left_buffer_ptr[i] = mix_channel->tmp_mixed_frames_left[i];
+        mix_channel->right_buffer_ptr[i] = mix_channel->tmp_mixed_frames_right[i];
+    }
   }
 }
 
@@ -1368,6 +1396,7 @@ create_output_channel(
   }
 
   channel_ptr->stereo = stereo;
+  channel_ptr->out_mute = false;
 
   channel_ptr->volume_transition_seconds = VOLUME_TRANSITION_SECONDS;
   channel_ptr->num_volume_transition_steps =
@@ -1385,6 +1414,8 @@ create_output_channel(
   channel_ptr->peak_right = 0.0;
   channel_ptr->peak_frames = 0;
 
+  channel_ptr->tmp_mixed_frames_left = calloc(MAX_BLOCK_SIZE, sizeof(jack_default_audio_sample_t));
+  channel_ptr->tmp_mixed_frames_right = calloc(MAX_BLOCK_SIZE, sizeof(jack_default_audio_sample_t));
   channel_ptr->frames_left = calloc(MAX_BLOCK_SIZE, sizeof(jack_default_audio_sample_t));
   channel_ptr->frames_right = calloc(MAX_BLOCK_SIZE, sizeof(jack_default_audio_sample_t));
   channel_ptr->prefader_frames_left = calloc(MAX_BLOCK_SIZE, sizeof(jack_default_audio_sample_t));
index f56d9aed01914d829f346fa5bf7f2318ee40520c..82817c626c416f43a29743bb60e4e3435a0511f7 100644 (file)
@@ -160,6 +160,14 @@ void
 channel_unmute(
   jack_mixer_channel_t channel);
 
+void
+channel_out_mute(
+  jack_mixer_channel_t channel);
+
+void
+channel_out_unmute(
+  jack_mixer_channel_t channel);
+
 void
 channel_solo(
   jack_mixer_channel_t channel);
@@ -172,6 +180,10 @@ bool
 channel_is_muted(
   jack_mixer_channel_t channel);
 
+bool
+channel_is_out_muted(
+  jack_mixer_channel_t channel);
+
 bool
 channel_is_soloed(
   jack_mixer_channel_t channel);
index 51823af84a73f2dea96c5b18a9894a2d71f244dc..0f5740ddd0171b56be59247934c52ef8408bfa19 100755 (executable)
@@ -572,6 +572,7 @@ class JackMixer(SerializedObject):
             return
         self.monitor_channel.volume = channel.channel.volume
         self.monitor_channel.balance = channel.channel.balance
+        self.monitor_channel.out_mute = channel.channel.mute
         if type(self.monitored_channel) is OutputChannel:
             # sync solo/muted channels
             for input_channel in self.channels:
index 00d0cb6f72e98b7343c8c455eeb910a7400a3a78..4445efee161e91c102953da2767b316b08e4b990 100644 (file)
@@ -246,6 +246,20 @@ Channel_get_mute(ChannelObject *self, void *closure)
        return result;
 }
 
+static PyObject*
+Channel_get_out_mute(ChannelObject *self, void *closure)
+{
+       PyObject *result;
+
+    if (channel_is_out_muted(self->channel)) {
+               result = Py_True;
+       } else {
+               result = Py_False;
+       }
+       Py_INCREF(result);
+       return result;
+}
+
 static int
 Channel_set_mute(ChannelObject *self, PyObject *value, void *closure)
 {
@@ -257,6 +271,17 @@ Channel_set_mute(ChannelObject *self, PyObject *value, void *closure)
        return 0;
 }
 
+static int
+Channel_set_out_mute(ChannelObject *self, PyObject *value, void *closure)
+{
+       if (value == Py_True) {
+               channel_out_mute(self->channel);
+       } else {
+               channel_out_unmute(self->channel);
+       }
+       return 0;
+}
+
 static PyObject*
 Channel_get_solo(ChannelObject *self, void *closure)
 {
@@ -465,7 +490,10 @@ static PyGetSetDef Channel_getseters[] = {
        {"mute", 
                (getter)Channel_get_mute, (setter)Channel_set_mute,
                "mute", NULL},
-       {"solo", 
+       {"out_mute",
+               (getter)Channel_get_out_mute, (setter)Channel_set_out_mute,
+               "out_mute", NULL},
+       {"solo",
                (getter)Channel_get_solo, (setter)Channel_set_solo,
                "solo", NULL},
        {"meter",