]> git.rkrishnan.org Git - pihpsdr.git/commitdiff
a) moved call to set_agc down when creating receivers, such that
authorDL1YCF <dl1ycf@darc.de>
Sun, 3 Oct 2021 11:02:33 +0000 (13:02 +0200)
committerDL1YCF <dl1ycf@darc.de>
Sun, 3 Oct 2021 11:02:33 +0000 (13:02 +0200)
the AGC threshold line is calculated correctly at the beginning
of the program
b) straightened arguments of set_agc
c) use set_agc instead of direct WDSP calls when possible

actions.c
agc_menu.c
dsp_menu.c
ext.c
receiver.c
receiver.h
sliders.c

index 39335bd31cada25f22ce3cd234d972bff4b89897..4ba5881aac4e9d821508534ff12e7653b2d3d308 100644 (file)
--- a/actions.c
+++ b/actions.c
@@ -270,7 +270,7 @@ int process_action(void *data) {
         if(active_receiver->agc>+AGC_LAST) {
           active_receiver->agc=0;
         }
-        set_agc(active_receiver, active_receiver->agc);
+        set_agc(active_receiver);
         g_idle_add(ext_vfo_update, NULL);
       }
       break;
index 36e2caaf096430885e2b0427161712a09e20d90f..b79b6f6e2a27f085ff6e03d934caf8bf091afb64 100644 (file)
@@ -65,7 +65,7 @@ static void agc_select_cb (GtkToggleButton *widget, gpointer        data) {
       send_agc(client_socket,active_receiver->id,active_receiver->agc);
     } else {
 #endif
-      set_agc(active_receiver, active_receiver->agc);
+      set_agc(active_receiver);
       g_idle_add(ext_vfo_update, NULL);
 #ifdef CLIENT_SERVER
     }
index ca036705e97489d73889661bac88cc35c1d788e3..8a375f6794476d65d8700acf996eaa19a9f736ef 100644 (file)
@@ -58,13 +58,7 @@ static gboolean delete_event(GtkWidget *widget, GdkEvent *event, gpointer user_d
 
 static void agc_hang_threshold_value_changed_cb(GtkWidget *widget, gpointer data) {
   active_receiver->agc_hang_threshold=(int)gtk_range_get_value(GTK_RANGE(widget));
-  if(active_receiver->agc==AGC_LONG || active_receiver->agc==AGC_SLOW) {
-    SetRXAAGCHangThreshold(active_receiver->id, (int)active_receiver->agc_hang_threshold);
-    //
-    // recalculate position of hang line for panadapter
-    //
-    GetRXAAGCHangLevel(active_receiver->id, &active_receiver->agc_hang);
-  }
+  set_agc(active_receiver);
 }
 
 static void pre_post_agc_cb(GtkToggleButton *widget, gpointer data) {
diff --git a/ext.c b/ext.c
index 7cfa1de22212732f9fb981adf3adf33c705e17d9..8cb611f9f642453f2da860bac1573e55ec0ffa8e 100644 (file)
--- a/ext.c
+++ b/ext.c
@@ -656,7 +656,7 @@ int ext_agc_update(void *data) {
   if(active_receiver->agc>+AGC_LAST) {
     active_receiver->agc=0;
   }
-  set_agc(active_receiver, active_receiver->agc);
+  set_agc(active_receiver);
   g_idle_add(ext_vfo_update, NULL);
   return 0;
 }
index 0ac4b10b4f057d19f102f6b0141e435edb6a98ec..2707fb256aa1e1973ca580bfdac03abdc58b8262 100644 (file)
@@ -705,13 +705,13 @@ void set_deviation(RECEIVER *rx) {
   SetRXAFMDeviation(rx->id, (double)rx->deviation);
 }
 
-void set_agc(RECEIVER *rx, int agc) {
+void set_agc(RECEIVER *rx) {
  
-  SetRXAAGCMode(rx->id, agc);
+  SetRXAAGCMode(rx->id, rx->agc);
   //SetRXAAGCThresh(rx->id, agc_thresh_point, 4096.0, rx->sample_rate);
   SetRXAAGCSlope(rx->id,rx->agc_slope);
   SetRXAAGCTop(rx->id,rx->agc_gain);
-  switch(agc) {
+  switch(rx->agc) {
     case AGC_OFF:
       break;
     case AGC_LONG:
@@ -1145,8 +1145,6 @@ g_print("%s: OpenChannel id=%d buffer_size=%d fft_size=%d sample_rate=%d\n",
   RXASetNC(rx->id, rx->fft_size);
   RXASetMP(rx->id, rx->low_latency);
 
-  set_agc(rx, rx->agc);
-
   SetRXAAMDSBMode(rx->id, 0);
   SetRXAShiftRun(rx->id, 0);
 
@@ -1199,6 +1197,8 @@ g_print("%s: rx=%p id=%d local_audio=%d\n",__FUNCTION__,rx,rx->id,rx->local_audi
       rx->local_audio=0;
     }
   }
+  // defer set_agc until here, otherwise the AGC threshold is not computed correctly
+  set_agc(rx);
   return rx;
 }
 
index ce511fd439631d6b0a019503042771e95e55360a..eb88e2b8c540c1138e79cabfb2bc11d13e5afa45 100644 (file)
@@ -181,7 +181,7 @@ extern void receiver_change_pan(RECEIVER *rx,double pan);
 
 extern void set_mode(RECEIVER* rx,int m);
 extern void set_filter(RECEIVER *rx,int low,int high);
-extern void set_agc(RECEIVER *rx, int agc);
+extern void set_agc(RECEIVER *rx);
 extern void set_offset(RECEIVER *rx, long long offset);
 extern void set_deviation(RECEIVER *rx);
 
index d2da100c9db02234d5273e37ae3b653567eb34c0..476352cb5586ceeabae2082b88d11a31a5533b42 100644 (file)
--- a/sliders.c
+++ b/sliders.c
@@ -273,9 +273,7 @@ static void agcgain_value_changed_cb(GtkWidget *widget, gpointer data) {
     send_agc_gain(client_socket,active_receiver->id,(int)active_receiver->agc_gain,(int)active_receiver->agc_hang,(int)active_receiver->agc_thresh);
   } else {
 #endif
-    SetRXAAGCTop(active_receiver->id, active_receiver->agc_gain);
-    GetRXAAGCHangLevel(active_receiver->id, &active_receiver->agc_hang);
-    GetRXAAGCThresh(active_receiver->id, &active_receiver->agc_thresh, 4096.0, (double)active_receiver->sample_rate);
+  set_agc(active_receiver);
 #ifdef CLIENT_SERVER
   }
 #endif
@@ -284,9 +282,7 @@ static void agcgain_value_changed_cb(GtkWidget *widget, gpointer data) {
 void set_agc_gain(int rx,double value) {
   g_print("%s\n",__FUNCTION__);
   receiver[rx]->agc_gain=value;
-  SetRXAAGCTop(receiver[rx]->id, receiver[rx]->agc_gain);
-  GetRXAAGCHangLevel(receiver[rx]->id, &receiver[rx]->agc_hang);
-  GetRXAAGCThresh(receiver[rx]->id, &receiver[rx]->agc_thresh, 4096.0, (double)receiver[rx]->sample_rate);
+  set_agc(receiver[rx]);
   if(display_sliders) {
     gtk_range_set_value (GTK_RANGE(agc_scale),receiver[rx]->agc_gain);
   } else {