From e1fe65cb8b8c49af9ac30571bc8377c32bfb1673 Mon Sep 17 00:00:00 2001
From: John Melton G0ORX <john.d.melton@googlemail.com>
Date: Fri, 12 Mar 2021 09:48:43 +0000
Subject: [PATCH] Fix MIDI Config to select KEY

---
 midi_menu.c  | 16 ++++++++++++++++
 pulseaudio.c |  1 +
 receiver.c   |  1 -
 3 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/midi_menu.c b/midi_menu.c
index adf09cd..4fd8304 100644
--- a/midi_menu.c
+++ b/midi_menu.c
@@ -849,6 +849,7 @@ static int update(void *data) {
   int state=GPOINTER_TO_INT(data);
   gchar text[32];
   gint i=1;
+  gint j;
 
   switch(state) {
     case UPDATE_NEW:
@@ -891,6 +892,21 @@ static int update(void *data) {
       gtk_combo_box_text_remove_all(GTK_COMBO_BOX_TEXT(newAction));
       gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(newAction),NULL,"NONE");
       gtk_combo_box_set_active (GTK_COMBO_BOX(newAction),0);
+      if(thisEvent==MIDI_PITCH || thisEvent==MIDI_NOTE) {
+	i=1;
+	j=0;
+	while(ActionTable[i].action!=ACTION_NONE) {
+          if(ActionTable[i].type&MIDI_KEY) {
+            gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(newAction),NULL,ActionTable[i].str);
+            if(ActionTable[i].action==thisAction) {
+              gtk_combo_box_set_active(GTK_COMBO_BOX(newAction),j);
+            }
+            j++;
+          }
+          i++;
+        }
+
+      }
       sprintf(text,"%d",thisVal);
       gtk_label_set_text(GTK_LABEL(newVal),text);
       sprintf(text,"%d",thisMin);
diff --git a/pulseaudio.c b/pulseaudio.c
index c08783c..2435907 100644
--- a/pulseaudio.c
+++ b/pulseaudio.c
@@ -139,6 +139,7 @@ int audio_open_output(RECEIVER *rx) {
     sample_spec.rate=48000;
     sample_spec.channels=2;
     sample_spec.format=PA_SAMPLE_FLOAT32NE;
+   
 
     char stream_id[16];
     sprintf(stream_id,"RX-%d",rx->id);
diff --git a/receiver.c b/receiver.c
index 0bbaed4..c27749b 100644
--- a/receiver.c
+++ b/receiver.c
@@ -1073,7 +1073,6 @@ g_print("%s: id=%d sample_rate=%d\n",__FUNCTION__,rx->id, rx->sample_rate);
 
 
 g_print("%s (after restore): rx=%p id=%d audio_buffer_size=%d local_audio=%d\n",__FUNCTION__,rx,rx->id,rx->audio_buffer_size,rx->local_audio);
-  //rx->audio_buffer=g_new(guchar,rx->audio_buffer_size);
   int scale=rx->sample_rate/48000;
   rx->output_samples=rx->buffer_size/scale;
   rx->audio_output_buffer=g_new(gdouble,2*rx->output_samples);
-- 
2.45.2