]> git.rkrishnan.org Git - pihpsdr.git/commitdiff
added menu to select low latency filters (Menu->FFT)
authorJohn Melton - G0ORX/N6LYT <john.d.melton@googlemail.com>
Fri, 10 Mar 2017 16:19:09 +0000 (16:19 +0000)
committerJohn Melton - G0ORX/N6LYT <john.d.melton@googlemail.com>
Fri, 10 Mar 2017 16:19:09 +0000 (16:19 +0000)
12 files changed:
Makefile
fft_menu.c [new file with mode: 0644]
fft_menu.h [new file with mode: 0644]
new_menu.c
new_protocol.c
new_protocol.h
old_protocol.c
radio.c
radio.h
receiver.c
toolbar.c
transmitter.c

index f6d25abbe304ae51a150efcc53ba2cfa9cb5d1c8..4799d1bdbd319746b9ae5445c1f5632aa40611b9 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -146,16 +146,13 @@ ifeq ($(I2C_INCLUDE),I2C)
   I2C_OBJS=i2c.o
 endif
 
-#uncomment if build for SHORT FRAMES (MIC and Audio)
-SHORT_FRAMES=-D SHORT_FRAMES
-
 GTKINCLUDES=`pkg-config --cflags gtk+-3.0`
 GTKLIBS=`pkg-config --libs gtk+-3.0`
 
 AUDIO_LIBS=-lasound
 #AUDIO_LIBS=-lsoundio
 
-OPTIONS=-g -Wno-deprecated-declarations -D $(UNAME_N) $(RADIOBERRY_OPTIONS) $(USBOZY_OPTIONS) $(I2C_OPTIONS) $(GPIO_OPTIONS) $(LIMESDR_OPTIONS) $(FREEDV_OPTIONS) $(LOCALCW_OPTIONS) $(PSK_OPTIONS) $(SHORT_FRAMES) -D GIT_DATE='"$(GIT_DATE)"' -D GIT_VERSION='"$(GIT_VERSION)"' $(DEBUG_OPTION) -O3
+OPTIONS=-g -Wno-deprecated-declarations -D $(UNAME_N) $(RADIOBERRY_OPTIONS) $(USBOZY_OPTIONS) $(I2C_OPTIONS) $(GPIO_OPTIONS) $(LIMESDR_OPTIONS) $(FREEDV_OPTIONS) $(LOCALCW_OPTIONS) $(PSK_OPTIONS) -D GIT_DATE='"$(GIT_DATE)"' -D GIT_VERSION='"$(GIT_VERSION)"' $(DEBUG_OPTION) -O3
 
 LIBS=-lrt -lm -lwdsp -lpthread $(AUDIO_LIBS) $(USBOZY_LIBS) $(PSKLIBS) $(GTKLIBS) $(GPIO_LIBS) $(SOAPYSDRLIBS) $(FREEDVLIBS)
 INCLUDES=$(GTKINCLUDES)
@@ -194,6 +191,7 @@ filter_menu.c \
 noise_menu.c \
 agc_menu.c \
 vox_menu.c \
+fft_menu.c \
 diversity_menu.c \
 freqent_menu.c \
 tx_menu.c \
@@ -260,6 +258,7 @@ filter_menu.h \
 noise_menu.h \
 agc_menu.h \
 vox_menu.h \
+fft_menu.h \
 diversity_menu.h \
 freqent_menu.h \
 tx_menu.h \
@@ -323,6 +322,7 @@ filter_menu.o \
 noise_menu.o \
 agc_menu.o \
 vox_menu.o \
+fft_menu.o \
 diversity_menu.o \
 freqent_menu.o \
 tx_menu.o \
@@ -371,9 +371,17 @@ clean:
        -rm -f $(PROGRAM)
 
 install:
-       cp pihpsdr ../pihpsdr
-       cp pihpsdr ./release/pihpsdr
-       cd release; echo $(GIT_VERSION) > pihpsdr/latest
-       cd release; tar cvf pihpsdr_$(GIT_VERSION).tar pihpsdr
-       cd release; tar cvf pihpsdr.tar pihpsdr
+       if [ ! -d ~/pihpsdr ];then \
+               mkdir ~/pihpsdr; \
+               if [ -d "./release/pihpsdr" ];then  \
+                       cp ./release/pihpsdr/* ~/pihpsdr; \
+               fi \
+       fi
+       cp pihpsdr ~/pihpsdr
+       if [ -d "./release" ];then  \
+               cp pihpsdr ./release/pihpsdr; \
+               cd release; echo $(GIT_VERSION) > pihpsdr/latest; \
+               cd release; tar cvf pihpsdr_$(GIT_VERSION).tar pihpsdr; \
+               cd release; tar cvf pihpsdr.tar pihpsdr; \
+       fi
 
diff --git a/fft_menu.c b/fft_menu.c
new file mode 100644 (file)
index 0000000..5f7bca7
--- /dev/null
@@ -0,0 +1,135 @@
+/* Copyright (C)
+* 2017 - John Melton, G0ORX/N6LYT
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+*
+*/
+
+#include <gtk/gtk.h>
+#include <semaphore.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "new_menu.h"
+#include "fft_menu.h"
+#include "radio.h"
+
+static GtkWidget *parent_window=NULL;
+
+static GtkWidget *menu_b=NULL;
+
+static GtkWidget *dialog=NULL;
+
+static gboolean close_cb (GtkWidget *widget, GdkEventButton *event, gpointer data) {
+  if(dialog!=NULL) {
+    gtk_widget_destroy(dialog);
+    dialog=NULL;
+    sub_menu=NULL;
+  }
+  return TRUE;
+}
+
+static void filter_type_cb(GtkWidget *widget, gpointer data) {
+  set_filter_type((int)data);
+}
+
+#ifdef SET_FILTER_SIZE
+static void filter_size_cb(GtkWidget *widget, gpointer data) {
+  set_filter_size((int)data);
+}
+#endif
+
+void fft_menu(GtkWidget *parent) {
+  parent_window=parent;
+
+  dialog=gtk_dialog_new();
+  gtk_window_set_transient_for(GTK_WINDOW(dialog),GTK_WINDOW(parent_window));
+  gtk_window_set_decorated(GTK_WINDOW(dialog),FALSE);
+
+  GdkRGBA color;
+  color.red = 1.0;
+  color.green = 1.0;
+  color.blue = 1.0;
+  color.alpha = 1.0;
+  gtk_widget_override_background_color(dialog,GTK_STATE_FLAG_NORMAL,&color);
+
+  GtkWidget *content=gtk_dialog_get_content_area(GTK_DIALOG(dialog));
+
+  GtkWidget *grid=gtk_grid_new();
+  gtk_grid_set_column_spacing (GTK_GRID(grid),10);
+  //gtk_grid_set_row_spacing (GTK_GRID(grid),10);
+  //gtk_grid_set_row_homogeneous(GTK_GRID(grid),TRUE);
+  //gtk_grid_set_column_homogeneous(GTK_GRID(grid),TRUE);
+
+  GtkWidget *close_b=gtk_button_new_with_label("Close");
+  g_signal_connect (close_b, "button_press_event", G_CALLBACK(close_cb), NULL);
+  gtk_grid_attach(GTK_GRID(grid),close_b,0,0,1,1);
+
+  int x=0;
+
+  GtkWidget *filter_type_label=gtk_label_new("Filter Type: ");
+  gtk_grid_attach(GTK_GRID(grid),filter_type_label,x,1,1,1);
+  
+  GtkWidget *linear_phase=gtk_radio_button_new_with_label(NULL,"Linear Phase");
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (linear_phase), receiver[0]->low_latency==0);
+  gtk_grid_attach(GTK_GRID(grid),linear_phase,x,2,1,1);
+  g_signal_connect(linear_phase,"pressed",G_CALLBACK(filter_type_cb),(gpointer *)0);
+
+  GtkWidget *low_latency=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(linear_phase),"Low Latency");
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (low_latency), receiver[0]->low_latency==1);
+  gtk_grid_attach(GTK_GRID(grid),low_latency,x,3,1,1);
+  g_signal_connect(low_latency,"pressed",G_CALLBACK(filter_type_cb),(gpointer *)1);
+
+  x++;
+
+#ifdef SET_FILTER_SIZE
+  GtkWidget *filter_size_label=gtk_label_new("Filter Size: ");
+  gtk_grid_attach(GTK_GRID(grid),filter_size_label,x,1,1,1);
+  
+  GtkWidget *filter_1024=gtk_radio_button_new_with_label(NULL,"1024");
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (filter_1024), receiver[0]->fft_size==1024);
+  gtk_grid_attach(GTK_GRID(grid),filter_1024,x,2,1,1);
+  g_signal_connect(filter_1024,"pressed",G_CALLBACK(filter_size_cb),(gpointer *)1024);
+
+  GtkWidget *filter_2048=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(filter_1024),"2048");
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (filter_2048), receiver[0]->fft_size==2048);
+  gtk_grid_attach(GTK_GRID(grid),filter_2048,x,3,1,1);
+  g_signal_connect(filter_2048,"pressed",G_CALLBACK(filter_size_cb),(gpointer *)2048);
+
+  GtkWidget *filter_4096=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(filter_2048),"4096");
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (filter_4096), receiver[0]->fft_size==4096);
+  gtk_grid_attach(GTK_GRID(grid),filter_4096,x,4,1,1);
+  g_signal_connect(filter_4096,"pressed",G_CALLBACK(filter_size_cb),(gpointer *)4096);
+
+  GtkWidget *filter_8192=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(filter_4096),"8192");
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (filter_8192), receiver[0]->fft_size==8192);
+  gtk_grid_attach(GTK_GRID(grid),filter_8192,x,5,1,1);
+  g_signal_connect(filter_8192,"pressed",G_CALLBACK(filter_size_cb),(gpointer *)8192);
+
+  GtkWidget *filter_16384=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(filter_8192),"16384");
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (filter_16384), receiver[0]->fft_size==16384);
+  gtk_grid_attach(GTK_GRID(grid),filter_16384,x,6,1,1);
+  g_signal_connect(filter_16384,"pressed",G_CALLBACK(filter_size_cb),(gpointer *)16394);
+
+  x++;
+#endif
+  gtk_container_add(GTK_CONTAINER(content),grid);
+
+  sub_menu=dialog;
+
+  gtk_widget_show_all(dialog);
+
+}
+
diff --git a/fft_menu.h b/fft_menu.h
new file mode 100644 (file)
index 0000000..0e4841c
--- /dev/null
@@ -0,0 +1,20 @@
+/* Copyright (C)
+* 2017 - John Melton, G0ORX/N6LYT
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+*
+*/
+
+void fft_menu(GtkWidget *parent);
index 9734c42e57b39852b61895b2ea4e7265e02682fa..f45d20cde17fbb055cd695cf6e8161316daa1587 100644 (file)
@@ -55,6 +55,7 @@
 #include "encoder_menu.h"
 #endif
 #include "vfo_menu.h"
+#include "fft_menu.h"
 #include "main.h"
 
 
@@ -272,6 +273,16 @@ static gboolean vox_b_cb (GtkWidget *widget, GdkEventButton *event, gpointer dat
   return TRUE;
 }
 
+void start_fft() {
+  cleanup();
+  fft_menu(top_window);
+}
+
+static gboolean fft_b_cb (GtkWidget *widget, GdkEventButton *event, gpointer data) {
+  start_fft();
+  return TRUE;
+}
+
 void start_diversity() {
   cleanup();
   diversity_menu(top_window);
@@ -483,6 +494,11 @@ void new_menu()
     gtk_grid_attach(GTK_GRID(grid),vox_b,(i%5),i/5,1,1);
     i++;
 
+    GtkWidget *fft_b=gtk_button_new_with_label("FFT");
+    g_signal_connect (fft_b, "button-press-event", G_CALLBACK(fft_b_cb), NULL);
+    gtk_grid_attach(GTK_GRID(grid),fft_b,(i%5),i/5,1,1);
+    i++;
+
 #ifdef DIVERSITY
     if(RECEIVERS==2) {
       GtkWidget *diversity_b=gtk_button_new_with_label("Diversity");
index 65433cc9576010476c2e0f15af63c7e533bdd089..bfda6776cb664477a1b1c621af8ff04f27306b26 100644 (file)
@@ -142,11 +142,7 @@ static int outputsamples;
 static int leftaudiosample;
 static int rightaudiosample;
 static long audiosequence;
-#ifdef SHORT_FRAMES
 static unsigned char audiobuffer[260]; // was 1444
-#else
-static unsigned char audiobuffer[1444]; // was 1444
-#endif
 static int audioindex;
 
 #ifdef FREEDV
index ee0d0cc95423b7e2a4abc6ee3d4a61669aa8ed95..ec3dd9f7dd413da8b15c770501df338b3d29a753 100644 (file)
 #define RX_IQ_TO_HOST_PORT_6 1041
 #define RX_IQ_TO_HOST_PORT_7 1042
 
-//#define BUFFER_SIZE 1024
 
-#ifdef SHORT_FRAMES
 #define MIC_SAMPLES 64
-#else
-#define MIC_SAMPLES 720
-#endif
 
 extern int data_socket;
 extern sem_t response_sem;
index dd5af16a6a7793a49ff6e48ed11207b7c6a53645..bf0f3efdcfd7e5fed291d4b0cff8310911985308 100644 (file)
@@ -463,9 +463,9 @@ static void process_ozy_input_buffer(char  *buffer) {
   int b=0;
   unsigned char ozy_samples[8*8];
   int bytes;
-  int last_ptt;
-  int last_dot;
-  int last_dash;
+  int previous_ptt;
+  int previous_dot;
+  int previous_dash;
   int left_sample;
   int right_sample;
   short mic_sample;
@@ -482,15 +482,25 @@ static void process_ozy_input_buffer(char  *buffer) {
     control_in[3]=buffer[b++];
     control_in[4]=buffer[b++];
 
-    last_ptt=ptt;
-    last_dot=dot;
-    last_dash=dash;
+    previous_ptt=ptt;
+    previous_dot=dot;
+    previous_dash=dash;
     ptt=(control_in[0]&0x01)==0x01;
     dash=(control_in[0]&0x02)==0x02;
     dot=(control_in[0]&0x04)==0x04;
 
-    if(last_ptt!=ptt) {
-      g_idle_add(ptt_update,(gpointer)ptt);
+if(ptt!=previous_ptt) {
+  fprintf(stderr,"ptt=%d\n",ptt);
+}
+if(dot!=previous_dot) {
+  fprintf(stderr,"dot=%d\n",dot);
+}
+if(dash!=previous_dash) {
+  fprintf(stderr,"dash=%d\n",dash);
+}
+
+    if(previous_ptt!=ptt || dot!=previous_dot || dash!=previous_dash) {
+      g_idle_add(ptt_update,(gpointer)(ptt | dot | dash));
     }
 
     switch((control_in[0]>>3)&0x1F) {
@@ -914,9 +924,9 @@ void ozy_send_buffer() {
       if(mode!=modeCWU && mode!=modeCWL) {
         // output_buffer[C1]|=0x00;
       } else {
-        if((tune==1) || (mox==1) || (vox==1) || (cw_keyer_internal==0)) {
+        if((tune==1) || (vox==1) || (cw_keyer_internal==0)) {
           output_buffer[C1]|=0x00;
-        } else {
+        } else if(mox==1) {
           output_buffer[C1]|=0x01;
         }
       }
@@ -941,6 +951,11 @@ void ozy_send_buffer() {
   }
 
   // set mox
+  if(split) {
+    mode=vfo[1].mode;
+  } else {
+    mode=vfo[0].mode;
+  }
   if(mode==modeCWU || mode==modeCWL) {
     if(tune) {
       output_buffer[C0]|=0x01;
diff --git a/radio.c b/radio.c
index 48206a3ece8998dd6e67fcec2e32a0aecfd2d216..d3d096a9ecb1f183c7a76b665e6f0eca8a8b4a49 100644 (file)
--- a/radio.c
+++ b/radio.c
@@ -1325,3 +1325,27 @@ void calculate_display_average(RECEIVER *rx) {
   SetDisplayAvBackmult(rx->id, 0, display_avb);
   SetDisplayNumAverage(rx->id, 0, display_average);
 }
+
+void set_filter_type(int filter_type) {
+  int i;
+
+  fprintf(stderr,"set_filter_type: %d\n",filter_type);
+  for(i=0;i<RECEIVERS;i++) {
+    receiver[i]->low_latency=filter_type;
+    RXASetMP(receiver[i]->id, filter_type);
+  }
+  transmitter->low_latency=filter_type;
+  TXASetMP(transmitter->id, filter_type);
+}
+
+void set_filter_size(int filter_size) {
+  int i;
+
+  fprintf(stderr,"set_filter_size: %d\n",filter_size);
+  for(i=0;i<RECEIVERS;i++) {
+    receiver[i]->fft_size=filter_size;
+    RXASetNC(receiver[i]->id, filter_size);
+  }
+  transmitter->fft_size=filter_size;
+  TXASetNC(transmitter->id, filter_size);
+}
diff --git a/radio.h b/radio.h
index c457030921f59b82f0c8a956282ea459c356f4d1..c3bc0df049d0a6ef9893bc7e839acdb5ebdb9870 100644 (file)
--- a/radio.h
+++ b/radio.h
@@ -278,4 +278,6 @@ extern void radioSaveState();
 
 extern void calculate_display_average();
 
+extern void set_filter_type(int filter_type);
+extern void set_filter_size(int filter_size);
 #endif
index 459dd53c26c97d96e49d75f8d034e8740b7a5024..6bad5f3ec3326e75e73cb3189bc04ea375483354 100644 (file)
@@ -784,10 +784,14 @@ fprintf(stderr,"create_receiver: id=%d output_samples=%d\n",rx->id,rx->output_sa
 
 fprintf(stderr,"create_receiver: id=%d after restore adc=%d\n",rx->id, rx->adc);
 
-fprintf(stderr,"create_receiver: OpenChannel id=%d buffer_size=%d fft_size=%d sample_rate=%d\n",rx->id,rx->buffer_size, rx->fft_size, rx->sample_rate);
+fprintf(stderr,"create_receiver: OpenChannel id=%d buffer_size=%d fft_size=%d sample_rate=%d\n",
+        rx->id,
+        rx->buffer_size,
+        2048, // rx->fft_size,
+        rx->sample_rate);
   OpenChannel(rx->id,
               rx->buffer_size,
-              rx->fft_size,
+              2048, // rx->fft_size,
               rx->sample_rate,
               48000, // dsp rate
               48000, // output rate
@@ -795,6 +799,11 @@ fprintf(stderr,"create_receiver: OpenChannel id=%d buffer_size=%d fft_size=%d sa
               1, // run
               0.010, 0.025, 0.0, 0.010, 0);
 
+fprintf(stderr,"RXASetNC %d\n",rx->fft_size);
+  RXASetNC(rx->id, rx->fft_size);
+fprintf(stderr,"RXASetMP %d\n",rx->low_latency);
+  RXASetMP(rx->id, rx->low_latency);
+
   b=band_get_band(vfo[rx->id].band);
   BANDSTACK *bs=b->bandstack;
   BANDSTACK_ENTRY *entry=&bs->entry[vfo[rx->id].bandstack];
@@ -802,8 +811,6 @@ fprintf(stderr,"create_receiver: OpenChannel id=%d buffer_size=%d fft_size=%d sa
   FILTER *band_filter=&band_filters[vfo[rx->id].filter];
   set_filter(rx,band_filter->low,band_filter->high);
   
-  RXASetNC(rx->id, rx->fft_size);
-  RXASetMP(rx->id, rx->low_latency);
 
   SetRXAFMDeviation(rx->id,(double)deviation);
 
index 182602708e6786d2638262175332dcbf2db1632c..078f2fd4cebaa7d3f14b011fdec3c799de70a972 100644 (file)
--- a/toolbar.c
+++ b/toolbar.c
@@ -593,17 +593,21 @@ int mox_update(void *data) {
 }
 
 int ptt_update(void *data) {
+
+  return mox_update(data);
+/*
   int mode;
   if(split) {
     mode=vfo[1].mode;
   } else {
     mode=vfo[0].mode;
   }
-  if(protocol==NEW_PROTOCOL || (mode!=modeCWU && mode!=modeCWL)) {
+  if(protocol==NEW_PROTOCOL || protocol==ORIGINAL_PROTOCOL || (mode!=modeCWU && mode!=modeCWL)) {
     mox_cb(NULL,NULL);
   }
   g_idle_add(vfo_update,NULL);
   return 0;
+*/
 }
 
 void tune_cb(GtkWidget *widget, gpointer data) {
index 289aa834d9e5fdcb9df3a03136af9acd33284f15..3a9420a18ab048144787f1d150e801732d7c9664 100644 (file)
@@ -401,14 +401,14 @@ fprintf(stderr,"transmitter: allocate buffers: mic_input_buffer=%d iq_output_buf
   fprintf(stderr,"create_transmitter: OpenChannel id=%d buffer_size=%d fft_size=%d sample_rate=%d dspRate=%d outputRate=%d\n",
               tx->id,
               tx->buffer_size,
-              tx->fft_size,
+              2048, // tx->fft_size,
               tx->mic_sample_rate,
               tx->mic_dsp_rate,
               tx->iq_output_rate);
 
   OpenChannel(tx->id,
               tx->buffer_size,
-              tx->fft_size,
+              2048, // tx->fft_size,
               tx->mic_sample_rate,
               tx->mic_dsp_rate,
               tx->iq_output_rate,
@@ -416,8 +416,9 @@ fprintf(stderr,"transmitter: allocate buffers: mic_input_buffer=%d iq_output_buf
               0, // run
               0.010, 0.025, 0.0, 0.010, 0);
 
-fprintf(stderr,"TXASetNC\n");
+fprintf(stderr,"TXASetNC: %d\n",tx->fft_size);
   TXASetNC(tx->id, tx->fft_size);
+fprintf(stderr,"TXASetMP: %d\n",tx->low_latency);
   TXASetMP(tx->id, tx->low_latency);
 
   SetTXAMode(tx->id, tx->mode);