]> git.0d.be Git - jack_mixer.git/commitdiff
Add a 'solo all' button
authorDaniel Sheeler <dsheeler@pobox.com>
Mon, 4 May 2020 02:30:25 +0000 (21:30 -0500)
committerDaniel Sheeler <dsheeler@pobox.com>
Mon, 4 May 2020 02:30:25 +0000 (21:30 -0500)
channel.py
jack_mixer.c
jack_mixer.h
jack_mixer.py
jack_mixer_c.c

index c5fe61fd23042db02e0aca5d2f991540915b9067..a140dd92af46062b72f97a5059bafe62d9dd6e6f 100644 (file)
@@ -304,7 +304,9 @@ class InputChannel(Channel):
             self.channel.balance_midi_cc = self.future_balance_midi_cc
         if self.future_mute_midi_cc != None:
             self.channel.mute_midi_cc = self.future_mute_midi_cc
-        self.channel.midi_scale = self.slider_scale.scale
+        if self.app._init_solo_channels and self.channel_name in self.app._init_solo_channels:
+            self.channel.solo = True
+
         self.channel.midi_scale = self.slider_scale.scale
 
         self.on_volume_changed(self.slider_adjustment)
@@ -328,11 +330,21 @@ class InputChannel(Channel):
 #         self.label_stereo.set_size_request(0, -1)
 #         self.vbox.pack_start(self.label_stereo, True)
 
+        self.hbox_mutesolo = gtk.HBox()
+
         self.mute = gtk.ToggleButton()
         self.mute.set_label("M")
         self.mute.set_active(self.channel.out_mute)
         self.mute.connect("toggled", self.on_mute_toggled)
-        self.vbox.pack_start(self.mute, True)
+        self.hbox_mutesolo.pack_start(self.mute, True)
+
+        self.solo = gtk.ToggleButton()
+        self.solo.set_label("S")
+        self.solo.set_active(self.channel.solo)
+        self.solo.connect("toggled", self.on_solo_toggled)
+        self.hbox_mutesolo.pack_start(self.solo, True)
+
+        self.vbox.pack_start(self.hbox_mutesolo, False)
 
         frame = gtk.Frame()
         frame.set_shadow_type(gtk.SHADOW_IN)
index 9feeb3232468dcd6bdcc43d648e5eb1f838c88ed..45425d029858bcb951cca39d46c781b2331c715f 100644 (file)
@@ -119,6 +119,7 @@ struct jack_mixer
   jack_client_t * jack_client;
   GSList *input_channels_list;
   GSList *output_channels_list;
+  GSList *soloed_channels;
 
   jack_port_t * port_midi_in;
   jack_port_t * port_midi_out;
@@ -533,6 +534,33 @@ channel_is_out_muted(
   return channel_ptr->out_mute;
 }
 
+void
+channel_solo(
+  jack_mixer_channel_t channel)
+{
+  if (g_slist_find(channel_ptr->mixer_ptr->soloed_channels, channel) != NULL)
+    return;
+  channel_ptr->mixer_ptr->soloed_channels = g_slist_prepend(channel_ptr->mixer_ptr->soloed_channels, channel);
+}
+
+void
+channel_unsolo(
+  jack_mixer_channel_t channel)
+{
+  if (g_slist_find(channel_ptr->mixer_ptr->soloed_channels, channel) == NULL)
+    return;
+  channel_ptr->mixer_ptr->soloed_channels = g_slist_remove(channel_ptr->mixer_ptr->soloed_channels, channel);
+}
+
+bool
+channel_is_soloed(
+  jack_mixer_channel_t channel)
+{
+  if (g_slist_find(channel_ptr->mixer_ptr->soloed_channels, channel))
+    return true;
+  return false;
+}
+
 void
 channel_set_midi_scale(
   jack_mixer_channel_t channel,
@@ -593,41 +621,37 @@ mix_one(
       continue;
     }
 
-    if (output_mix_channel->soloed_channels &&
-        g_slist_find(output_mix_channel->soloed_channels, channel_ptr) == NULL) {
-      /* skip channels that are not soloed, when some are */
-      continue;
-    }
-
-    for (i = start ; i < end ; i++)
-    {
-      if (! output_mix_channel->prefader) {
-        frame_left = channel_ptr->frames_left[i-start];
-      } else {
-        frame_left = channel_ptr->prefader_frames_left[i-start];
-      }
-      if (frame_left == NAN)
-        break;
-      mix_channel->tmp_mixed_frames_left[i] += frame_left;
+    if ((!channel_ptr->mixer_ptr->soloed_channels && !output_mix_channel->soloed_channels) ||
+        (channel_ptr->mixer_ptr->soloed_channels && 
+         g_slist_find(channel_ptr->mixer_ptr->soloed_channels, channel_ptr) != NULL) ||
+        (output_mix_channel->soloed_channels &&
+        g_slist_find(output_mix_channel->soloed_channels, channel_ptr) != NULL)) {
 
-      if (mix_channel->stereo)
+      for (i = start ; i < end ; i++)
       {
         if (! output_mix_channel->prefader) {
-          frame_right = channel_ptr->frames_right[i-start];
+          frame_left = channel_ptr->frames_left[i-start];
         } else {
-          frame_right = channel_ptr->prefader_frames_right[i-start];
+          frame_left = channel_ptr->prefader_frames_left[i-start];
         }
-        if (frame_right == NAN)
+        if (frame_left == NAN)
           break;
-
-        mix_channel->tmp_mixed_frames_right[i] += frame_right;
+        mix_channel->tmp_mixed_frames_left[i] += frame_left;
+        if (mix_channel->stereo)
+        {
+          if (! output_mix_channel->prefader) {
+            frame_right = channel_ptr->frames_right[i-start];
+          } else {
+            frame_right = channel_ptr->prefader_frames_right[i-start];
+          }
+          if (frame_right == NAN)
+            break;
+          mix_channel->tmp_mixed_frames_right[i] += frame_right;
+        }
       }
-
     }
-
   }
 
-
   /* process main mix channel */
   unsigned int steps = mix_channel->num_volume_transition_steps;
   for (i = start ; i < end ; i++)
@@ -1092,6 +1116,8 @@ create(
   mixer_ptr->input_channels_list = NULL;
   mixer_ptr->output_channels_list = NULL;
 
+  mixer_ptr->soloed_channels = NULL;
+
   mixer_ptr->last_midi_channel = -1;
 
   for (i = 0 ; i < 128 ; i++)
index cb40bb3f91d1e88722238454b3db4494ea8539de..01a334b514a8ee6c3edc695fdde5fc191b26a459 100644 (file)
@@ -174,6 +174,18 @@ bool
 channel_is_out_muted(
   jack_mixer_channel_t channel);
 
+void
+channel_solo(
+  jack_mixer_channel_t channel);
+
+void
+channel_unsolo(
+  jack_mixer_channel_t channel);
+
+bool
+channel_is_soloed(
+  jack_mixer_channel_t channel);
+
 void
 channel_rename(
   jack_mixer_channel_t channel,
index 53262f694651aa277ac0a084b1ba433a3a5de752..3f8a6c19a7aaad124aac83cb6fd8303143c61f49 100755 (executable)
@@ -103,6 +103,8 @@ class JackMixer(SerializedObject):
     # name of settngs file that is currently open
     current_filename = None
 
+    _init_solo_channels = None
+
     def __init__(self, name, lash_client):
         self.mixer = jack_mixer_c.Mixer(name)
         if not self.mixer:
@@ -684,7 +686,12 @@ Franklin Street, Fifth Floor, Boston, MA 02110-130159 USA''')
         s.unserialize(self, b)
         for channel in self.unserialized_channels:
             if isinstance(channel, InputChannel):
+                print self._init_solo_channels, hasattr(channel, 'name'), channel.channel_name
+                if self._init_solo_channels and channel.channel_name in self._init_solo_channels:
+                    channel.solo = True
+                    print channel.channel_name, 'solo ', channel.solo
                 self.add_channel_precreated(channel)
+        self._init_solo_channels = None
         for channel in self.unserialized_channels:
             if isinstance(channel, OutputChannel):
                 self.add_output_channel_precreated(channel)
@@ -694,12 +701,21 @@ Franklin Street, Fifth Floor, Boston, MA 02110-130159 USA''')
     def serialize(self, object_backend):
         object_backend.add_property('geometry',
                         '%sx%s' % (self.window.allocation.width, self.window.allocation.height))
+        solo_channels = []
+        for input_channel in self.channels:
+            if input_channel.channel.solo:
+                solo_channels.append(input_channel)
+        if solo_channels:
+            object_backend.add_property('solo_channels', '|'.join([x.channel.name for x in solo_channels]))
 
     def unserialize_property(self, name, value):
         if name == 'geometry':
             width, height = value.split('x')
             self.window.resize(int(width), int(height))
             return True
+        if name == 'solo_channels':
+            self._init_solo_channels = value.split('|')
+            return True
 
     def unserialize_child(self, name):
         if name == InputChannel.serialization_name():
index c8ba38d0d5620b9ad3c755159585c33c49996565..a04e97fdfb63a981783bf97da3220f3d07f107dd 100644 (file)
@@ -257,6 +257,32 @@ Channel_set_out_mute(ChannelObject *self, PyObject *value, void *closure)
        return 0;
 }
 
+static PyObject*
+Channel_get_solo(ChannelObject *self, void *closure)
+{
+    printf ("get_solo\n");
+       PyObject *result;
+
+       if (channel_is_soloed(self->channel)) {
+               result = Py_True;
+       } else {
+               result = Py_False;
+       }
+       Py_INCREF(result);
+       return result;
+}
+
+static int
+Channel_set_solo(ChannelObject *self, PyObject *value, void *closure)
+{
+       if (value == Py_True) {
+               channel_solo(self->channel);
+       } else {
+               channel_unsolo(self->channel);
+       }
+       return 0;
+}
+
 static PyObject*
 Channel_get_meter(ChannelObject *self, void *closure)
 {
@@ -445,7 +471,6 @@ Channel_get_midi_in_got_events(ChannelObject *self, void *closure)
        return result;
 }
 
-
 static PyGetSetDef Channel_getseters[] = {
        {"is_stereo",
                (getter)Channel_get_is_stereo, NULL,
@@ -459,6 +484,9 @@ static PyGetSetDef Channel_getseters[] = {
        {"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",
                (getter)Channel_get_meter, NULL,
                "meter", NULL},