]> git.rkrishnan.org Git - pihpsdr.git/commitdiff
sample rate change + dither + random option available for radioberry
authorPA3GSB <admin@pa3gsb.nl>
Sat, 28 Jan 2017 15:56:55 +0000 (16:56 +0100)
committerPA3GSB <admin@pa3gsb.nl>
Sat, 28 Jan 2017 15:56:55 +0000 (16:56 +0100)
general_menu.c
radioberry.c
radioberry.h
wdsp_init.c

index f3757df6d0f5320bc8496b7764c91510486dc2de..5b55a174040b66fb62621210e77b79e3d473b813 100644 (file)
@@ -158,11 +158,20 @@ static void rx_preamp_cb(GtkWidget *widget, gpointer data) {
 }
 
 static void sample_rate_cb(GtkWidget *widget, gpointer data) {
-  if(protocol==ORIGINAL_PROTOCOL) {
-    old_protocol_new_sample_rate((int)data);
-  } else {
-    new_protocol_new_sample_rate((int)data);
-  }
+ switch(protocol) {
+    case ORIGINAL_PROTOCOL:
+      old_protocol_new_sample_rate((int)data);
+      break;
+    case NEW_PROTOCOL:
+      new_protocol_new_sample_rate((int)data);
+      break;
+#ifdef RADIOBERRY
+       case RADIOBERRY_PROTOCOL:
+               radioberry_new_sample_rate((int)data);
+               break;
+#endif
+  }  
+  
 }
 
 static void rit_cb(GtkWidget *widget,gpointer data) {
@@ -203,7 +212,12 @@ void general_menu(GtkWidget *parent) {
   gtk_grid_attach(GTK_GRID(grid),vfo_divisor,4,2,1,1);
   g_signal_connect(vfo_divisor,"value_changed",G_CALLBACK(vfo_divisor_value_changed_cb),NULL);
 
-  if(protocol==ORIGINAL_PROTOCOL || protocol==NEW_PROTOCOL) {
+  if(protocol==ORIGINAL_PROTOCOL || protocol==NEW_PROTOCOL
+#ifdef RADIOBERRY
+  || protocol==RADIOBERRY_PROTOCOL) {
+#else
+       ){
+#endif  
     GtkWidget *rx_dither_b=gtk_check_button_new_with_label("Dither");
     //gtk_widget_override_font(rx_dither_b, pango_font_description_from_string("Arial 18"));
     gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (rx_dither_b), rx_dither);
@@ -241,6 +255,9 @@ void general_menu(GtkWidget *parent) {
       g_signal_connect(bias_b,"toggled",G_CALLBACK(bias_cb),NULL);
     }
 
+#ifdef RADIOBERRY
+  if (protocol==ORIGINAL_PROTOCOL || protocol==NEW_PROTOCOL) {
+#endif  
     GtkWidget *alex_b=gtk_check_button_new_with_label("ALEX");
     gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (alex_b), filter_board==ALEX);
     gtk_grid_attach(GTK_GRID(grid),alex_b,1,1,1,1);
@@ -251,13 +268,20 @@ void general_menu(GtkWidget *parent) {
 
     g_signal_connect(alex_b,"toggled",G_CALLBACK(alex_cb),apollo_b);
     g_signal_connect(apollo_b,"toggled",G_CALLBACK(apollo_cb),alex_b);
-
+#ifdef RADIOBERRY
+       }
+#endif 
   }
 
   GtkWidget *sample_rate_label=gtk_label_new("Sample Rate:");
   gtk_grid_attach(GTK_GRID(grid),sample_rate_label,0,1,1,1);
 
-  if(protocol==ORIGINAL_PROTOCOL || protocol==NEW_PROTOCOL) {
+  if(protocol==ORIGINAL_PROTOCOL || protocol==NEW_PROTOCOL
+ #ifdef RADIOBERRY
+  || protocol==RADIOBERRY_PROTOCOL) {
+#else
+       ){
+#endif  
     GtkWidget *sample_rate_48=gtk_radio_button_new_with_label(NULL,"48000");
     gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sample_rate_48), sample_rate==48000);
     gtk_grid_attach(GTK_GRID(grid),sample_rate_48,0,2,1,1);
index d888fab7c40401a18eec0240cbf066caf39fffa8..dd2d7e42363624e1bad0fe495be2081859f3286d 100644 (file)
@@ -115,6 +115,33 @@ float timedifference_msec(struct timeval t0, struct timeval t1)
     return (t1.tv_sec - t0.tv_sec) * 1000.0f + (t1.tv_usec - t0.tv_usec) / 1000.0f;
 }
 
+void radioberry_calc_buffers() {
+  switch(sample_rate) {
+    case 48000:
+      output_buffer_size=OUTPUT_BUFFER_SIZE;
+      break;
+    case 96000:
+      output_buffer_size=OUTPUT_BUFFER_SIZE/2;
+      break;
+    case 192000:
+      output_buffer_size=OUTPUT_BUFFER_SIZE/4;
+      break;
+    case 384000:
+      output_buffer_size=OUTPUT_BUFFER_SIZE/8;
+      break;
+    default:
+      fprintf(stderr,"Invalid sample rate: %d. Defaulting to 48K.\n",sample_rate);
+      break;
+  }
+}
+
+void radioberry_new_sample_rate(int rate){
+  sample_rate=rate;
+  radioberry_calc_buffers();
+  setSampleSpeed();
+  wdsp_new_sample_rate(rate);
+}
+
 void radioberry_protocol_init(int rx,int pixels) {
   int i;
 
@@ -125,23 +152,7 @@ void radioberry_protocol_init(int rx,int pixels) {
   receiver=rx;
   display_width=pixels;
  
-       switch(sample_rate) {
-       case 48000:
-         output_buffer_size=OUTPUT_BUFFER_SIZE;
-         break;
-       case 96000:
-         output_buffer_size=OUTPUT_BUFFER_SIZE/2;
-         break;
-       case 192000:
-         output_buffer_size=OUTPUT_BUFFER_SIZE/4;
-         break;
-       case 384000:
-         output_buffer_size=OUTPUT_BUFFER_SIZE/8;
-         break;
-       default:
-         fprintf(stderr,"Invalid sample rate: %d. Defaulting to 48K.\n",sample_rate);
-         break;
-       }
+       radioberry_calc_buffers();
 
        fprintf(stderr,"radioberry_protocol: buffer size: =%d\n", buffer_size);
   
index 4dd584403b641d8cf4caf2b447aeb630e0755819..9d651ae5342bd5e190cd1f719f220df59b941032 100644 (file)
@@ -21,3 +21,4 @@
 void radioberry_protocol_stop();
 void radioberry_protocol_init(int rx,int pixels);
 void *radioberry_protocol_process_local_mic(unsigned char *buffer,int le);
+void radioberry_new_sample_rate(int rate);
index e890cf14470d05792401e766112f900a50a3660d..8b9d575c5b5fa28cd437ae19a9f6876f5497b181 100644 (file)
@@ -410,7 +410,7 @@ void wdsp_init(int rx,int pixels,int protocol) {
 
 void wdsp_new_sample_rate(int rate) {
 
-  if(protocol==ORIGINAL_PROTOCOL | protocol==RADIOBERRY_PROTOCOL) {
+  if(protocol==ORIGINAL_PROTOCOL || protocol==RADIOBERRY_PROTOCOL) {
     SetChannelState(CHANNEL_TX,0,0);
     calc_tx_buffer_size();
     initAnalyzer(CHANNEL_TX,tx_buffer_size);