]> git.0d.be Git - jack_mixer.git/commitdiff
Shore up sensing midi cc
authorDaniel Sheeler <dsheeler@pobox.com>
Sun, 3 May 2020 17:37:50 +0000 (12:37 -0500)
committerDaniel Sheeler <dsheeler@pobox.com>
Sun, 3 May 2020 17:37:50 +0000 (12:37 -0500)
channel.py
jack_mixer.c
jack_mixer.h
jack_mixer_c.c

index 1a0bb945a4ebc63d5f87fd92c4d5650c8ff25481..c5fe61fd23042db02e0aca5d2f991540915b9067 100644 (file)
@@ -787,12 +787,15 @@ class ChannelPropertiesDialog(gtk.Dialog):
         gobject.timeout_add_seconds(1, close_sense_timeout, window, entry)
 
     def on_sense_midi_volume_clicked(self, *args):
+        self.mixer.last_midi_channel = int(self.entry_volume_cc.get_text())
         self.sense_popup_dialog(self.entry_volume_cc)
 
     def on_sense_midi_balance_clicked(self, *args):
+        self.mixer.last_midi_channel = int(self.entry_balance_cc.get_text())
         self.sense_popup_dialog(self.entry_balance_cc)
 
     def on_sense_midi_mute_clicked(self, *args):
+        self.mixer.last_midi_channel = int(self.entry_mute_cc.get_text())
         self.sense_popup_dialog(self.entry_mute_cc)
 
     def on_response_cb(self, dlg, response_id, *args):
index c7a0736a82ae067c33759005aefe96a441e2a162..9feeb3232468dcd6bdcc43d648e5eb1f838c88ed 100644 (file)
@@ -122,7 +122,7 @@ struct jack_mixer
 
   jack_port_t * port_midi_in;
   jack_port_t * port_midi_out;
-  unsigned int last_midi_channel;
+  int last_midi_channel;
 
   struct channel* midi_cc_map[128];
 };
@@ -243,10 +243,10 @@ channel_get_balance_midi_cc(
 unsigned int
 channel_set_balance_midi_cc(
   jack_mixer_channel_t channel,
-  unsigned int new_cc)
+  int new_cc)
 {
-  if (new_cc > 127) {
-    return 2; /* error: over limit CC */
+  if (new_cc < 0 || new_cc > 127) {
+    return 2; /* error: outside limit CC */
   }
   if (channel_ptr->mixer_ptr->midi_cc_map[new_cc] != NULL) {
       if (channel_ptr->mixer_ptr->midi_cc_map[new_cc]->midi_cc_volume_index == new_cc) {
@@ -274,10 +274,10 @@ channel_get_volume_midi_cc(
 
 unsigned int
 channel_set_volume_midi_cc(
-  jack_mixer_channel_t channel, unsigned int new_cc)
+  jack_mixer_channel_t channel, int new_cc)
 {
-  if (new_cc > 127) {
-    return 2; /* error: over limit CC */
+  if (new_cc< 0 || new_cc > 127) {
+    return 2; /* error: outside limit CC */
   }
   if (channel_ptr->mixer_ptr->midi_cc_map[new_cc] != NULL) {
       if (channel_ptr->mixer_ptr->midi_cc_map[new_cc]->midi_cc_volume_index == new_cc) {
@@ -306,10 +306,10 @@ channel_get_mute_midi_cc(
 unsigned int
 channel_set_mute_midi_cc(
   jack_mixer_channel_t channel,
-  unsigned int new_cc)
+  int new_cc)
 {
-  if (new_cc > 127) {
-    return 2; /* error: over limit CC */
+  if (new_cc < 0 || new_cc > 127) {
+    return 2; /* error: outside limit CC */
   }
   if (channel_ptr->mixer_ptr->midi_cc_map[new_cc] != NULL) {
       if (channel_ptr->mixer_ptr->midi_cc_map[new_cc]->midi_cc_volume_index == new_cc) {
@@ -1092,7 +1092,7 @@ create(
   mixer_ptr->input_channels_list = NULL;
   mixer_ptr->output_channels_list = NULL;
 
-  mixer_ptr->last_midi_channel = 0;
+  mixer_ptr->last_midi_channel = -1;
 
   for (i = 0 ; i < 128 ; i++)
   {
@@ -1191,13 +1191,21 @@ get_client_name(
   return jack_get_client_name(mixer_ctx_ptr->jack_client);
 }
 
-unsigned int
+int
 get_last_midi_channel(
   jack_mixer_t mixer)
 {
   return mixer_ctx_ptr->last_midi_channel;
 }
 
+unsigned int
+set_last_midi_channel(
+  jack_mixer_t mixer,
+  int new_channel) {
+  mixer_ctx_ptr->last_midi_channel = new_channel;
+  return 0;
+}
+
 jack_mixer_channel_t
 add_channel(
   jack_mixer_t mixer,
index f0f0f0d01179e125ef9e17571355dcfb51da4e6b..cb40bb3f91d1e88722238454b3db4494ea8539de 100644 (file)
@@ -56,10 +56,15 @@ const char*
 get_client_name(
   jack_mixer_t mixer);
 
-unsigned int
+int
 get_last_midi_channel(
   jack_mixer_t mixer);
 
+unsigned int
+set_last_midi_channel(
+  jack_mixer_t mixer,
+  int new_channel);
+
 jack_mixer_channel_t
 add_channel(
   jack_mixer_t mixer,
@@ -120,7 +125,7 @@ channel_get_balance_midi_cc(
 unsigned int
 channel_set_balance_midi_cc(
   jack_mixer_channel_t channel,
-  unsigned int new_cc);
+  int new_cc);
 
 int
 channel_get_volume_midi_cc(
@@ -129,7 +134,7 @@ channel_get_volume_midi_cc(
 unsigned int
 channel_set_volume_midi_cc(
   jack_mixer_channel_t channel,
-  unsigned int new_cc);
+  int new_cc);
 
 int
 channel_get_mute_midi_cc(
@@ -138,7 +143,7 @@ channel_get_mute_midi_cc(
 unsigned int
 channel_set_mute_midi_cc(
   jack_mixer_channel_t channel,
-  unsigned int new_cc);
+  int new_cc);
 
 void
 channel_autoset_midi_cc(
index 0a19b8f63ff26d67716a601a0bd80433ea8cf7c2..c8ba38d0d5620b9ad3c755159585c33c49996565 100644 (file)
@@ -371,7 +371,7 @@ Channel_get_balance_midi_cc(ChannelObject *self, void *closure)
 static int
 Channel_set_balance_midi_cc(ChannelObject *self, PyObject *value, void *closure)
 {
-       unsigned int new_cc;
+       int new_cc;
        unsigned int result;
 
        new_cc = PyInt_AsLong(value);
@@ -379,9 +379,7 @@ Channel_set_balance_midi_cc(ChannelObject *self, PyObject *value, void *closure)
        if (result == 0) {
                return 0;
        }
-       if (result == 1) {
-               PyErr_SetString(PyExc_RuntimeError, "value already in use");
-       } else if (result == 2) {
+       if (result == 2) {
                PyErr_SetString(PyExc_RuntimeError, "value out of range");
        }
        return -1;
@@ -396,7 +394,7 @@ Channel_get_volume_midi_cc(ChannelObject *self, void *closure)
 static int
 Channel_set_volume_midi_cc(ChannelObject *self, PyObject *value, void *closure)
 {
-       unsigned int new_cc;
+       int new_cc;
        unsigned int result;
 
        new_cc = PyInt_AsLong(value);
@@ -404,9 +402,7 @@ Channel_set_volume_midi_cc(ChannelObject *self, PyObject *value, void *closure)
        if (result == 0) {
                return 0;
        }
-       if (result == 1) {
-               PyErr_SetString(PyExc_RuntimeError, "value already in use");
-       } else if (result == 2) {
+       if (result == 2) {
                PyErr_SetString(PyExc_RuntimeError, "value out of range");
        }
        return -1;
@@ -421,7 +417,7 @@ Channel_get_mute_midi_cc(ChannelObject *self, void *closure)
 static int
 Channel_set_mute_midi_cc(ChannelObject *self, PyObject *value, void *closure)
 {
-       unsigned int new_cc;
+       int new_cc;
        unsigned int result;
 
        new_cc = PyInt_AsLong(value);
@@ -429,9 +425,7 @@ Channel_set_mute_midi_cc(ChannelObject *self, PyObject *value, void *closure)
        if (result == 0) {
                return 0;
        }
-       if (result == 1) {
-               PyErr_SetString(PyExc_RuntimeError, "value already in use");
-       } else if (result == 2) {
+       if (result == 2) {
                PyErr_SetString(PyExc_RuntimeError, "value out of range");
        }
        return -1;
@@ -832,11 +826,24 @@ Mixer_get_last_midi_channel(MixerObject *self, void *closure)
        return PyInt_FromLong(get_last_midi_channel(self->mixer));
 }
 
+static int
+Mixer_set_last_midi_channel(MixerObject *self, PyObject *value, void *closure)
+{
+       int new_channel;
+       unsigned int result;
+
+       new_channel = PyInt_AsLong(value);
+       result = set_last_midi_channel(self->mixer, new_channel);
+       if (result == 0) {
+               return 0;
+       }
+       return -1;
+}
 
 static PyGetSetDef Mixer_getseters[] = {
        {"channels_count", (getter)Mixer_get_channels_count, NULL,
                "channels count", NULL},
-       {"last_midi_channel", (getter)Mixer_get_last_midi_channel, NULL,
+       {"last_midi_channel", (getter)Mixer_get_last_midi_channel, (setter)Mixer_set_last_midi_channel,
                "last midi channel", NULL},
        {NULL}
 };