From: Chef Date: Mon, 10 Aug 2020 14:20:15 +0000 (+0200) Subject: Store equalizer settings by mode, such that you can have equalizer X-Git-Url: https://git.rkrishnan.org/pf/vdrive/simplejson//%22?a=commitdiff_plain;h=a06ba131e4be412798830ce9c0e22316a0e884d5;p=pihpsdr.git Store equalizer settings by mode, such that you can have equalizer settings for LSB and then, when switching to DIGU, have no equalizer, and when switching back to LSB you have your original settings back (just as with the noise reduction settings). --- diff --git a/client_server.c b/client_server.c index 5692538..aace4b8 100644 --- a/client_server.c +++ b/client_server.c @@ -1306,6 +1306,11 @@ g_print("send_squelch rx=%d enable=%d squelch=%d\n",rx,enable,squelch); } } +void send_eq(int s, int rxeq, int txeq) { + // inform client about RX/TX equalizer status + // NOT-YET +} + void send_noise(int s,int rx,int nb,int nb2,int nr,int nr2,int anf,int snb) { NOISE_COMMAND command; g_print("send_noise rx=%d nb=%d nb2=%d nr=%d nr2=%d anf=%d snb=%d\n",rx,nb,nb2,nr,nr2,anf,snb); diff --git a/client_server.h b/client_server.h index 926b93f..6287f74 100644 --- a/client_server.h +++ b/client_server.h @@ -488,6 +488,7 @@ extern void send_agc_gain(int s,int rx,int gain,int hang,int thresh); extern void send_attenuation(int s,int rx,int attenuation); extern void send_squelch(int s,int rx,int enable,int squelch); extern void send_noise(int s,int rx,int nb,int nb2,int nr,int nr2,int anf,int snb); +extern void send_eq(int s, int rxeq, int txeq); extern void send_band(int s,int rx,int band); extern void send_mode(int s,int rx,int mode); extern void send_filter(int s,int rx,int filter); diff --git a/equalizer_menu.c b/equalizer_menu.c index 1d6faa3..fdfea86 100644 --- a/equalizer_menu.c +++ b/equalizer_menu.c @@ -30,6 +30,8 @@ #include "equalizer_menu.h" #include "radio.h" #include "channel.h" +#include "ext.h" +#include "vfo.h" static GtkWidget *parent_window=NULL; @@ -86,26 +88,55 @@ static gboolean rx_rb_cb (GtkWidget *widget, GdkEventButton *event, gpointer dat return FALSE; } +void set_eq() { + SetTXAGrphEQ(transmitter->id, tx_equalizer); + SetTXAEQRun(transmitter->id, enable_tx_equalizer); + SetRXAGrphEQ(active_receiver->id, rx_equalizer); + SetRXAEQRun(active_receiver->id, enable_rx_equalizer); +} + +void update_eq() { +#ifdef CLIENT_SERVER + if(radio_is_remote) { + send_eq(client_socket,enable_rx_eq, enable_tx_equalizer); + } else { +#endif + set_eq(); +#ifdef CLIENT_SERVER + } +#endif +} + static gboolean enable_cb (GtkWidget *widget, GdkEventButton *event, gpointer data) { + int m; if(tx_menu) { enable_tx_equalizer=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); - SetTXAEQRun(transmitter->id, enable_tx_equalizer); + m=vfo[get_tx_vfo()].mode; + mode_settings[m].en_txeq = enable_tx_equalizer; } else { enable_rx_equalizer=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); - SetRXAEQRun(active_receiver->id, enable_rx_equalizer); + m=vfo[active_receiver->id].mode; + mode_settings[m].en_rxeq = enable_rx_equalizer; } + update_eq(); + // EQ status is now shown in VFO bar + g_idle_add(ext_vfo_update, NULL); return FALSE; } static void value_changed_cb (GtkWidget *widget, gpointer data) { int i=GPOINTER_TO_UINT(data); + int m; if(tx_menu) { tx_equalizer[i]=(int)gtk_range_get_value(GTK_RANGE(widget)); - SetTXAGrphEQ(transmitter->id, tx_equalizer); + m=vfo[get_tx_vfo()].mode; + mode_settings[m].txeq[i]=tx_equalizer[i]; } else { rx_equalizer[i]=(int)gtk_range_get_value(GTK_RANGE(widget)); - SetRXAGrphEQ(active_receiver->id, rx_equalizer); + m=vfo[active_receiver->id].mode; + mode_settings[m].rxeq[i]=rx_equalizer[i]; } + update_eq(); } void equalizer_menu(GtkWidget *parent) { diff --git a/equalizer_menu.h b/equalizer_menu.h index 3a370ef..ae9891d 100644 --- a/equalizer_menu.h +++ b/equalizer_menu.h @@ -18,3 +18,5 @@ */ void equalizer_menu(GtkWidget *parent); + +void update_eq(); diff --git a/ext.c b/ext.c index ee1c92b..41ad26f 100644 --- a/ext.c +++ b/ext.c @@ -49,6 +49,7 @@ #endif #include "ext.h" #include "zoompan.h" +#include "equalizer_menu.h" // The following calls functions can be called usig g_idle_add @@ -684,6 +685,11 @@ int ext_update_noise(void *data) { return 0; } +int ext_update_eq(void *data) { + update_eq(); + return 0; +} + int ext_set_duplex(void *data) { setDuplex(); return 0; diff --git a/ext.h b/ext.h index 75f9d35..a64cf4c 100644 --- a/ext.h +++ b/ext.h @@ -125,6 +125,7 @@ extern int ext_set_rf_gain(void *data); extern int ext_set_duplex(void *data); extern int ext_update_noise(void *data); +extern int ext_update_eq(void *data); #ifdef PURESIGNAL extern int ext_start_ps(void *data); #endif diff --git a/vfo.c b/vfo.c index 668ea35..cb13f64 100644 --- a/vfo.c +++ b/vfo.c @@ -108,6 +108,36 @@ void modesettings_save_state() { sprintf(name,"modeset.%d.snb", i); sprintf(value,"%d", mode_settings[i].snb); setProperty(name,value); + sprintf(name,"modeset.%d.en_txeq", i); + sprintf(value,"%d", mode_settings[i].en_txeq); + setProperty(name,value); + sprintf(name,"modeset.%d.txeq.0", i); + sprintf(value,"%d", mode_settings[i].txeq[0]); + setProperty(name,value); + sprintf(name,"modeset.%d.txeq.1", i); + sprintf(value,"%d", mode_settings[i].txeq[1]); + setProperty(name,value); + sprintf(name,"modeset.%d.txeq.2", i); + sprintf(value,"%d", mode_settings[i].txeq[2]); + setProperty(name,value); + sprintf(name,"modeset.%d.txeq.3", i); + sprintf(value,"%d", mode_settings[i].txeq[3]); + setProperty(name,value); + sprintf(name,"modeset.%d.en_rxeq", i); + sprintf(value,"%d", mode_settings[i].en_rxeq); + setProperty(name,value); + sprintf(name,"modeset.%d.rxeq.0", i); + sprintf(value,"%d", mode_settings[i].rxeq[0]); + setProperty(name,value); + sprintf(name,"modeset.%d.rxeq.1", i); + sprintf(value,"%d", mode_settings[i].rxeq[1]); + setProperty(name,value); + sprintf(name,"modeset.%d.rxeq.2", i); + sprintf(value,"%d", mode_settings[i].rxeq[2]); + setProperty(name,value); + sprintf(name,"modeset.%d.rxeq.3", i); + sprintf(value,"%d", mode_settings[i].rxeq[3]); + setProperty(name,value); } } @@ -126,6 +156,16 @@ void modesettings_restore_state() { mode_settings[i].nb2=0; mode_settings[i].anf=0; mode_settings[i].snb=0; + mode_settings[i].en_txeq=0; + mode_settings[i].txeq[0]=0; + mode_settings[i].txeq[1]=0; + mode_settings[i].txeq[2]=0; + mode_settings[i].txeq[3]=0; + mode_settings[i].en_rxeq=0; + mode_settings[i].rxeq[0]=0; + mode_settings[i].rxeq[1]=0; + mode_settings[i].rxeq[2]=0; + mode_settings[i].rxeq[3]=0; sprintf(name,"modeset.%d.filter",i); value=getProperty(name); @@ -148,6 +188,36 @@ void modesettings_restore_state() { sprintf(name,"modeset.%d.snb",i); value=getProperty(name); if(value) mode_settings[i].snb=atoi(value); + sprintf(name,"modeset.%d.en_txeq",i); + value=getProperty(name); + if(value) mode_settings[i].en_txeq=atoi(value); + sprintf(name,"modeset.%d.txeq.0",i); + value=getProperty(name); + if(value) mode_settings[i].txeq[0]=atoi(value); + sprintf(name,"modeset.%d.txeq.1",i); + value=getProperty(name); + if(value) mode_settings[i].txeq[1]=atoi(value); + sprintf(name,"modeset.%d.txeq.2",i); + value=getProperty(name); + if(value) mode_settings[i].txeq[2]=atoi(value); + sprintf(name,"modeset.%d.txeq.3",i); + value=getProperty(name); + if(value) mode_settings[i].txeq[3]=atoi(value); + sprintf(name,"modeset.%d.en_rxeq",i); + value=getProperty(name); + if(value) mode_settings[i].en_rxeq=atoi(value); + sprintf(name,"modeset.%d.rxeq.0",i); + value=getProperty(name); + if(value) mode_settings[i].rxeq[0]=atoi(value); + sprintf(name,"modeset.%d.rxeq.1",i); + value=getProperty(name); + if(value) mode_settings[i].rxeq[1]=atoi(value); + sprintf(name,"modeset.%d.rxeq.2",i); + value=getProperty(name); + if(value) mode_settings[i].rxeq[2]=atoi(value); + sprintf(name,"modeset.%d.rxeq.3",i); + value=getProperty(name); + if(value) mode_settings[i].rxeq[3]=atoi(value); } } @@ -315,9 +385,20 @@ void vfo_band_changed(int id,int b) { active_receiver->nb2=mode_settings[m].nb2; active_receiver->anf=mode_settings[m].anf; active_receiver->snb=mode_settings[m].snb; + enable_rx_equalizer =mode_settings[m].en_rxeq; + rx_equalizer[0] =mode_settings[m].rxeq[0]; + rx_equalizer[1] =mode_settings[m].rxeq[1]; + rx_equalizer[2] =mode_settings[m].rxeq[2]; + rx_equalizer[3] =mode_settings[m].rxeq[3]; + enable_tx_equalizer =mode_settings[m].en_txeq; + tx_equalizer[0] =mode_settings[m].txeq[0]; + tx_equalizer[1] =mode_settings[m].txeq[1]; + tx_equalizer[2] =mode_settings[m].txeq[2]; + tx_equalizer[3] =mode_settings[m].txeq[3]; // make changes effective g_idle_add(ext_update_noise, NULL); + g_idle_add(ext_update_eq , NULL); // turn off ctun vfo[id].ctun=0; @@ -427,9 +508,20 @@ void vfo_mode_changed(int m) { active_receiver->nb2=mode_settings[m].nb2; active_receiver->anf=mode_settings[m].anf; active_receiver->snb=mode_settings[m].snb; + enable_rx_equalizer =mode_settings[m].en_rxeq; + rx_equalizer[0] =mode_settings[m].rxeq[0]; + rx_equalizer[1] =mode_settings[m].rxeq[1]; + rx_equalizer[2] =mode_settings[m].rxeq[2]; + rx_equalizer[3] =mode_settings[m].rxeq[3]; + enable_tx_equalizer =mode_settings[m].en_txeq; + tx_equalizer[0] =mode_settings[m].txeq[0]; + tx_equalizer[1] =mode_settings[m].txeq[1]; + tx_equalizer[2] =mode_settings[m].txeq[2]; + tx_equalizer[3] =mode_settings[m].txeq[3]; // make changes effective g_idle_add(ext_update_noise, NULL); + g_idle_add(ext_update_eq , NULL); switch(id) { case 0: receiver_mode_changed(receiver[0]); @@ -1126,7 +1218,7 @@ void vfo_update() { if(can_transmit) { cairo_move_to(cr, 330, 50); if (transmitter->compressor) { - sprintf(temp_text,"CMPR %d dB",(int) transmitter->compressor_level); + sprintf(temp_text,"CMPR %d",(int) transmitter->compressor_level); cairo_set_source_rgb(cr, 1.0, 1.0, 0.0); cairo_show_text(cr, temp_text); } else { @@ -1134,6 +1226,16 @@ void vfo_update() { cairo_show_text(cr, "CMPR OFF"); } } + // + // Indicate whether an equalizer is active + // + cairo_move_to(cr, 400, 50); + if ((isTransmitting() && enable_tx_equalizer) || (!isTransmitting() && enable_rx_equalizer)) { + cairo_set_source_rgb(cr, 1.0, 1.0, 0.0); + } else { + cairo_set_source_rgb(cr, 0.7, 0.7, 0.7); + } + cairo_show_text(cr, "EQ"); cairo_move_to(cr, 500, 50); if(diversity_enabled) { diff --git a/vfo.h b/vfo.h index 55e0562..e1df7a3 100644 --- a/vfo.h +++ b/vfo.h @@ -50,15 +50,20 @@ extern struct _vfo vfo[MAX_VFOS]; // // Store filter and NR settings on a per-mode basis +// all elements are "on/off" // struct _mode_settings { int filter; - int nb; - int nb2; - int nr; - int nr2; - int anf; - int snb; + int nb; // Noise blanker #1 + int nb2; // Noise blanker #2 + int nr; // Noise reduction #1 + int nr2; // Noise reduction #2 + int anf; // Automatic notch filter + int snb; // Spectral noise blanker + int en_txeq; // TX equalizer on/off + int en_rxeq; // RX equalizer on/off + int txeq[4]; // TX equalizer settings + int rxeq[4]; // RX equalizer settings }; extern struct _mode_settings mode_settings[];