]> git.rkrishnan.org Git - pihpsdr.git/commitdiff
updated LimeSDR protocol. Changes calls to setVox to use g_idel_add. Some code cleanup
authorJohn Melton - G0ORX/N6LYT <john.d.melton@googlemail.com>
Sat, 18 Feb 2017 10:09:42 +0000 (10:09 +0000)
committerJohn Melton - G0ORX/N6LYT <john.d.melton@googlemail.com>
Sat, 18 Feb 2017 10:09:42 +0000 (10:09 +0000)
13 files changed:
Makefile
audio.c
lime_protocol.c
lime_protocol.h
radio.c
radio.h
receiver.c
receiver.h
rx_menu.c
store_menu.c
vfo.c
vox.c
vox_menu.c

index 736b0a435bb5a3d2a67049f12c8c03fbf80f27ba..bb20ced1e2b001215685a5dc3432945320c99984 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -29,7 +29,7 @@ USBOZY_INCLUDE=USBOZY
 #UNAME_N=odroid
 #UNAME_N=up
 #UNAME_N=pine64
-UNAME_N=x86
+UNAME_N=jetsen
 
 CC=gcc
 LINK=gcc
diff --git a/audio.c b/audio.c
index 39f135947169e4597943528b45216b7f327843e2..70a346d3aa7150c149a05004e66186426c099ff4 100644 (file)
--- a/audio.c
+++ b/audio.c
@@ -439,8 +439,8 @@ fprintf(stderr,"output_device: %s\n",device_id);
     
     if(strncmp("dmix:", name, 5)==0/* || strncmp("pulse", name, 5)==0*/) {
       fprintf(stderr,"name=%s descr=%s io=%s\n",name, descr, io);
-      
       device_id=malloc(64);
+      
       snprintf(device_id, 64, "%s", name);
       output_devices[n_output_devices++]=device_id;
 fprintf(stderr,"output_device: %s\n",device_id);
index 07ae695326d84f771c50fcd9854d95847355252a..c7e1d92941ad90ce341bec15a4ff321563d454d2 100644 (file)
@@ -1,4 +1,3 @@
-#include <pthread.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
 #include "discovered.h"
 #include "lime_protocol.h"
 #include "radio.h"
+#include "receiver.h"
 #include "SoapySDR/Constants.h"
 #include "SoapySDR/Device.h"
 
 static double bandwidth=3000000.0;
 
-static int lime_sample_rate=
-static size_t receiver;
+static size_t lime_receiver;
 static SoapySDRDevice *lime_device;
 static SoapySDRStream *stream;
+static int lime_sample_rate;
 static int display_width;
-static int buffer_size=BUFFER_SIZE;
+static int lime_buffer_size=BUFFER_SIZE;
 static int outputsamples;
-static int fft_size=4096;
+static int lime_fft_size=4096;
 static int dspRate=48000;
 static int outputRate=48000;
 static float *buffer;
@@ -35,17 +35,19 @@ static int max_samples;
 static long long saved_frequency=0LL;
 static int saved_antenna=-1;
 
-static double iqinputbuffer[BUFFER_SIZE*2];
+//static double iqinputbuffer[BUFFER_SIZE*2];
 static double audiooutputbuffer[BUFFER_SIZE*2];
 static int samples=0;
 
-static pthread_t receive_thread_id;
-static void *receive_thread(void* arg);
+static GThread *receive_thread_id;
+static gpointer receive_thread(gpointer data);
 
-static void *resampler;
 static int actual_rate;
+#ifdef RESAMPLE
+static void *resampler;
 static double resamples[1024*2];
 static double resampled[1024*2];
+#endif
 
 #ifdef TIMING
 static int rate_samples;
@@ -53,13 +55,16 @@ static int rate_samples;
 
 static int running;
 
+void lime_protocol_change_sample_rate(int rate) {
+}
+
 void lime_protocol_init(int rx,int pixels,int sample_rate) {
   SoapySDRKwargs args;
   int rc;
 
-fprintf(stderr,"lime_protocol_init: receiver=%d pixels=%d sample_rate=%d\n",rx,pixels,sample_rate);
+fprintf(stderr,"lime_protocol_init: lime_receiver=%d pixels=%d sample_rate=%d\n",rx,pixels,sample_rate);
 
-  receiver=(size_t)rx;
+  lime_receiver=(size_t)rx;
   display_width=pixels;
   lime_sample_rate=sample_rate;
 
@@ -94,7 +99,7 @@ fprintf(stderr,"lime_protocol_init: receiver=%d pixels=%d sample_rate=%d\n",rx,p
 
   // initialize the radio
 fprintf(stderr,"lime_protocol: receive_thread: SoapySDRDevice_make\n");
-  lime_device=SoapySDRDevice_make(discovered->info.soapy.args);
+  lime_device=SoapySDRDevice_make(radio->info.soapy.args);
   if(lime_device==NULL) {
     fprintf(stderr,"lime_protocol: SoapySDRDevice_make failed: %s\n",SoapySDRDevice_lastError());
     _exit(-1);
@@ -104,23 +109,22 @@ fprintf(stderr,"lime_protocol: set antenna to NONE\n");
   lime_protocol_set_antenna(0);
 
 fprintf(stderr,"lime_protocol: setting samplerate=%f\n",(double)sample_rate);
-  rc=SoapySDRDevice_setSampleRate(lime_device,SOAPY_SDR_RX,receiver,(double)sample_rate);
+  rc=SoapySDRDevice_setSampleRate(lime_device,SOAPY_SDR_RX,lime_receiver,(double)sample_rate);
   if(rc!=0) {
     fprintf(stderr,"lime_protocol: SoapySDRDevice_setSampleRate(%f) failed: %s\n",(double)sample_rate,SoapySDRDevice_lastError());
   }
 
-  actual_rate=(int)SoapySDRDevice_getSampleRate(lime_device, SOAPY_SDR_RX, receiver);
+  actual_rate=(int)SoapySDRDevice_getSampleRate(lime_device, SOAPY_SDR_RX, lime_receiver);
 fprintf(stderr,"lime_protocol: actual samplerate= %d\n",actual_rate);
+#ifdef RESAMPLE
 if(sample_rate==768000 && actual_rate==767999) {
   actual_rate=768000;
   fprintf(stderr,"lime_protocol: forced actual_rate\n");
 }
-
-void lime_protocol_change_sample_rate(int rate) {
-}
+#endif
 
 fprintf(stderr,"lime_protocol: setting bandwidth =%f\n",bandwidth);
-  rc=SoapySDRDevice_setBandwidth(lime_device,SOAPY_SDR_RX,receiver,bandwidth);
+  rc=SoapySDRDevice_setBandwidth(lime_device,SOAPY_SDR_RX,lime_receiver,bandwidth);
   if(rc!=0) {
     fprintf(stderr,"lime_protocol: SoapySDRDevice_setBandwidth(%f) failed: %s\n",bandwidth,SoapySDRDevice_lastError());
   }
@@ -132,7 +136,7 @@ fprintf(stderr,"lime_protocol: setting save_frequency: %lld\n",saved_frequency);
 
 /*
 fprintf(stderr,"lime_protocol: set baseband frequency\n");
-  rc=SoapySDRDevice_setFrequencyComponent(lime_device,SOAPY_SDR_RX,receiver,"BB",0.0,&args);
+  rc=SoapySDRDevice_setFrequencyComponent(lime_device,SOAPY_SDR_RX,lime_receiver,"BB",0.0,&args);
   if(rc!=0) {
     fprintf(stderr,"lime_protocol: SoapySDRDevice_setFrequencyComponent(BB) failed: %s\n",SoapySDRDevice_lastError());
   }
@@ -142,23 +146,23 @@ fprintf(stderr,"setting antennal to LNAL\n");
   lime_protocol_set_antenna(2);
 
 fprintf(stderr,"setting Gain LNA=30.0\n");
-  rc=SoapySDRDevice_setGainElement(lime_device,SOAPY_SDR_RX,receiver,"LNA",30.0);
+  rc=SoapySDRDevice_setGainElement(lime_device,SOAPY_SDR_RX,lime_receiver,"LNA",30.0);
   if(rc!=0) {
     fprintf(stderr,"lime_protocol: SoapySDRDevice_setGain LNA failed: %s\n",SoapySDRDevice_lastError());
   }
 fprintf(stderr,"setting Gain PGA=19.0\n");
-  rc=SoapySDRDevice_setGainElement(lime_device,SOAPY_SDR_RX,receiver,"PGA",19.0);
+  rc=SoapySDRDevice_setGainElement(lime_device,SOAPY_SDR_RX,lime_receiver,"PGA",19.0);
   if(rc!=0) {
     fprintf(stderr,"lime_protocol: SoapySDRDevice_setGain PGA failed: %s\n",SoapySDRDevice_lastError());
   }
 fprintf(stderr,"setting Gain TIA=12.0\n");
-  rc=SoapySDRDevice_setGainElement(lime_device,SOAPY_SDR_RX,receiver,"TIA",12.0);
+  rc=SoapySDRDevice_setGainElement(lime_device,SOAPY_SDR_RX,lime_receiver,"TIA",12.0);
   if(rc!=0) {
     fprintf(stderr,"lime_protocol: SoapySDRDevice_setGain TIA failed: %s\n",SoapySDRDevice_lastError());
   }
 
 fprintf(stderr,"lime_protocol: receive_thread: SoapySDRDevice_setupStream\n");
-  size_t channels=(size_t)receiver;
+  size_t channels=(size_t)lime_receiver;
   rc=SoapySDRDevice_setupStream(lime_device,&stream,SOAPY_SDR_RX,"CF32",&channels,1,&args);
   if(rc!=0) {
     fprintf(stderr,"lime_protocol: SoapySDRDevice_setupStream failed: %s\n",SoapySDRDevice_lastError());
@@ -170,10 +174,12 @@ fprintf(stderr,"max_samples=%d\n",max_samples);
 
   buffer=(float *)malloc(max_samples*sizeof(float)*2);
 
+#ifdef RESAMPLE
   if(actual_rate!=sample_rate) {
 fprintf(stderr,"lime_protocol: creating resampler from %d to %d\n",actual_rate,sample_rate);
     resampler=create_resample (1, max_samples, resamples, resampled, actual_rate, sample_rate, 0.0, 0, 1.0);
   }
+#endif
 
   rc=SoapySDRDevice_activateStream(lime_device, stream, 0, 0LL, 0);
   if(rc!=0) {
@@ -193,20 +199,19 @@ fprintf(stderr,"lime_protocol: setting save_frequency: %lld\n",saved_frequency);
   }
 
 fprintf(stderr,"lime_protocol_init: audio_open_output\n");
-  if(audio_open_output()!=0) {
-    local_audio=false;
+  if(audio_open_output(receiver[0])!=0) {
+    receiver[0]->local_audio=false;
     fprintf(stderr,"audio_open_output failed\n");
   }
 
 fprintf(stderr,"lime_protocol_init: create receive_thread\n");
-  rc=pthread_create(&receive_thread_id,NULL,receive_thread,NULL);
-  if(rc != 0) {
-    fprintf(stderr,"lime_protocol: pthread_create failed on receive_thread: rc=%d\n", rc);
-    _exit(-1);
+  receive_thread_id = g_thread_new( "lime protocol", receive_thread, NULL);
+  if( ! receive_thread_id )
+  {
+    fprintf(stderr,"g_thread_new failed for receive_thread\n");
+    exit( -1 );
   }
-
-
-
+  fprintf(stderr, "receive_thread: id=%p\n",receive_thread_id);
 }
 
 static void *receive_thread(void *arg) {
@@ -229,7 +234,8 @@ fprintf(stderr,"lime_protocol: receive_thread\n");
   while(running) {
     elements=SoapySDRDevice_readStream(lime_device,stream,(void *)&buffer,max_samples,&flags,&timeNs,timeoutUs);
 //fprintf(stderr,"read %d elements\n",elements);
-    if(actual_rate!=sample_rate) {
+#ifdef RESAMPLE
+    if(actual_rate!=lime_sample_rate) {
       for(i=0;i<elements;i++) {
         resamples[i*2]=(double)buffer[i*2];
         resamples[(i*2)+1]=(double)buffer[(i*2)+1];
@@ -238,50 +244,16 @@ fprintf(stderr,"lime_protocol: receive_thread\n");
       outsamples=xresample(resampler);
 
       for(i=0;i<outsamples;i++) {
-        iqinputbuffer[samples*2]=(double)resampled[i*2];
-        iqinputbuffer[(samples*2)+1]=(double)resampled[(i*2)+1];
-        samples++;
-#ifdef TIMING
-        rate_samples++;
-        if(rate_samples==sample_rate) {
-          gettimeofday(&tv, NULL); end_time=tv.tv_usec + 1000000 * tv.tv_sec;
-          fprintf(stderr,"%d samples in %ld\n",rate_samples, end_time-start_time);
-          start_time=end_time;
-          rate_samples=0;
-        }
-#endif
-        if(samples==buffer_size) {
-          int error;
-          fexchange0(CHANNEL_RX0, iqinputbuffer, audiooutputbuffer, &error);
-          if(error!=0) {
-            fprintf(stderr,"fexchange0 (CHANNEL_RX0) returned error: %d\n", error);
-          }
-
-          if(local_audio) {
-            audio_write(audiooutputbuffer,outputsamples);
-          }
-          Spectrum0(1, CHANNEL_RX0, 0, 0, iqinputbuffer);
-          samples=0;
-        }
+        add_iq_samples(receiver[0],(double)resampled[i*2],(double)resampled[(i*2)+1]);
       }
     } else {
+#endif
       for(i=0;i<elements;i++) {
-        iqinputbuffer[samples*2]=(double)buffer[i*2];
-        iqinputbuffer[(samples*2)+1]=(double)buffer[(i*2)+1];
-        samples++;
-        if(samples==buffer_size) {
-          int error;
-          fexchange0(CHANNEL_RX0, iqinputbuffer, audiooutputbuffer, &error);
-          if(error!=0) {
-            fprintf(stderr,"fexchange0 (CHANNEL_RX0) returned error: %d\n", error);
-          }
-
-          audio_write(audiooutputbuffer,outputsamples);
-          Spectrum0(1, CHANNEL_RX0, 0, 0, iqinputbuffer);
-          samples=0;
-        }
+        add_iq_samples(receiver[0],(double)buffer[i*2],(double)buffer[(i*2)+1]);
       }
+#ifdef RESAMPLE
     }
+#endif
   }
 
 fprintf(stderr,"lime_protocol: receive_thread: SoapySDRDevice_closeStream\n");
@@ -304,8 +276,7 @@ void lime_protocol_set_frequency(long long f) {
     SoapySDRKwargs args;
     args.size=0;
 fprintf(stderr,"lime_protocol: setFrequency: %lld\n",f);
-    //rc=SoapySDRDevice_setFrequencyComponent(lime_device,SOAPY_SDR_RX,receiver,"RF",(double)f,&args);
-    rc=SoapySDRDevice_setFrequency(lime_device,SOAPY_SDR_RX,receiver,(double)f,&args);
+    rc=SoapySDRDevice_setFrequency(lime_device,SOAPY_SDR_RX,lime_receiver,(double)f,&args);
     if(rc!=0) {
       fprintf(stderr,"lime_protocol: SoapySDRDevice_setFrequency() failed: %s\n",SoapySDRDevice_lastError());
     }
@@ -320,41 +291,41 @@ void lime_protocol_set_antenna(int ant) {
  // char *antstr;
   if(lime_device!=NULL) {
 /*
-    antstr=SoapySDRDevice_getAntenna(lime_device,SOAPY_SDR_RX,receiver);
+    antstr=SoapySDRDevice_getAntenna(lime_device,SOAPY_SDR_RX,lime_receiver);
     fprintf(stderr,"lime_protocol: set_antenna: current antenna=%s\n",antstr);
 */
     switch(ant) {
       case 0:
 fprintf(stderr,"lime_protocol: setAntenna: NONE\n");
-        rc=SoapySDRDevice_setAntenna(lime_device,SOAPY_SDR_RX,receiver,"NONE");
+        rc=SoapySDRDevice_setAntenna(lime_device,SOAPY_SDR_RX,lime_receiver,"NONE");
         if(rc!=0) {
           fprintf(stderr,"lime_protocol: SoapySDRDevice_setAntenna NONE failed: %s\n",SoapySDRDevice_lastError());
         }
         break;
       case 1:
 fprintf(stderr,"lime_protocol: setAntenna: LNAH\n");
-        rc=SoapySDRDevice_setAntenna(lime_device,SOAPY_SDR_RX,receiver,"LNAH");
+        rc=SoapySDRDevice_setAntenna(lime_device,SOAPY_SDR_RX,lime_receiver,"LNAH");
         if(rc!=0) {
           fprintf(stderr,"lime_protocol: SoapySDRDevice_setAntenna LNAH failed: %s\n",SoapySDRDevice_lastError());
         }
         break;
       case 2:
 fprintf(stderr,"lime_protocol: setAntenna: LNAL\n");
-        rc=SoapySDRDevice_setAntenna(lime_device,SOAPY_SDR_RX,receiver,"LNAL");
+        rc=SoapySDRDevice_setAntenna(lime_device,SOAPY_SDR_RX,lime_receiver,"LNAL");
         if(rc!=0) {
           fprintf(stderr,"lime_protocol: SoapySDRDevice_setAntenna LNAL failed: %s\n",SoapySDRDevice_lastError());
         }
         break;
       case 3:
 fprintf(stderr,"lime_protocol: setAntenna: LNAW\n");
-        rc=SoapySDRDevice_setAntenna(lime_device,SOAPY_SDR_RX,receiver,"LNAW");
+        rc=SoapySDRDevice_setAntenna(lime_device,SOAPY_SDR_RX,lime_receiver,"LNAW");
         if(rc!=0) {
           fprintf(stderr,"lime_protocol: SoapySDRDevice_setAntenna LNAW failed: %s\n",SoapySDRDevice_lastError());
         }
         break;
     }
 /*
-    antstr=SoapySDRDevice_getAntenna(lime_device,SOAPY_SDR_RX,receiver);
+    antstr=SoapySDRDevice_getAntenna(lime_device,SOAPY_SDR_RX,lime_receiver);
     fprintf(stderr,"lime_protocol: set_antenna: antenna=%s\n",antstr);
 */
   } else {
@@ -366,7 +337,7 @@ fprintf(stderr,"lime_protocol: setAntenna: LNAW\n");
 void lime_protocol_set_attenuation(int attenuation) {
   int rc;
   fprintf(stderr,"setting Gain LNA=%f\n",30.0-(double)attenuation);
-  rc=SoapySDRDevice_setGainElement(lime_device,SOAPY_SDR_RX,receiver,"LNA",30.0-(double)attenuation);
+  rc=SoapySDRDevice_setGainElement(lime_device,SOAPY_SDR_RX,lime_receiver,"LNA",30.0-(double)attenuation);
   if(rc!=0) {
     fprintf(stderr,"lime_protocol: SoapySDRDevice_setGain LNA failed: %s\n",SoapySDRDevice_lastError());
   }
index ec2fd96e1b23c778d849fa41eff125e8f7e2d769..91d7d25f2d26f924805552f92b4c2288796814eb 100644 (file)
 
 #define BUFFER_SIZE 1024
 
-void lime_protocol_init(int rx,int pixels);
+void lime_protocol_init(int rx,int pixels,int sample_rate);
 void lime_protocol_stop();
 void lime_protocol_set_frequency(long long f);
 void lime_protocol_set_antenna(int ant);
 void lime_protocol_set_attenuation(int attenuation);
+void lime_protocol_change_sample_rate(int rate);
 
 #endif
diff --git a/radio.c b/radio.c
index 851ddc7c83da9d5f075d9b1daec77351aaa663ad..92f0c74874f424a3b2fc1b05e9ec13feb1d00f7c 100644 (file)
--- a/radio.c
+++ b/radio.c
@@ -441,7 +441,7 @@ fprintf(stderr,"receiver %d: height=%d y=%d\n",receiver[i]->id,rx_height,y);
       break;
 #ifdef LIMESDR
     case LIMESDR_PROTOCOL:
-      lime_protocol_init(0,display_width);
+      lime_protocol_init(0,display_width,receiver[0]->sample_rate);
       break;
 #endif
   }
@@ -560,6 +560,8 @@ static void rxtx(int state) {
   int i;
   int y=VFO_HEIGHT;
 
+fprintf(stderr,"rxtx: state=%d\n",state);
+
   if(state) {
     // switch to tx
     for(i=0;i<receivers;i++) {
@@ -617,12 +619,19 @@ int getMox() {
 }
 
 void setVox(int state) {
+fprintf(stderr,"setVox: vox=%d state=%d\n",vox,state);
   if(vox!=state && !tune) {
     vox=state;
     rxtx(state);
   }
 }
 
+int vox_changed(void *data) {
+  setVox((int)data);
+  return 0;
+}
+
+
 void setTune(int state) {
   int i;
 
@@ -752,12 +761,13 @@ void setFrequency(long long f) {
 #ifdef LIMESDR
     case LIMESDR_PROTOCOL:
       {
-      long long minf=entry->frequency-(long long)(active_receiver->sample_rate/2);
-      long long maxf=entry->frequency+(long long)(active_receiver->sample_rate/2);
+fprintf(stderr,"setFrequency: %lld\n",f);
+      long long minf=vfo[v].frequency-(long long)(active_receiver->sample_rate/2);
+      long long maxf=vfo[v].frequency+(long long)(active_receiver->sample_rate/2);
       if(f<minf) f=minf;
       if(f>maxf) f=maxf;
-      ddsOffset=f-entry->frequency;
-      wdsp_set_offset(ddsOffset);
+      vfo[v].offset=f-vfo[v].frequency;
+      set_offset(active_receiver,vfo[v].offset);
       return;
       }
       break;
@@ -774,8 +784,8 @@ void setFrequency(long long f) {
 #ifdef LIMESDR
     case LIMESDR_PROTOCOL:
       lime_protocol_set_frequency(f);
-      ddsOffset=0;
-      wdsp_set_offset(ddsOffset);
+      vfo[v].offset=0;
+      set_offset(active_receiver,vfo[v].offset);
       break;
 #endif
   }
diff --git a/radio.h b/radio.h
index 0c41d568770198c5e8b73352df97beacba14809b..c457030921f59b82f0c8a956282ea459c356f4d1 100644 (file)
--- a/radio.h
+++ b/radio.h
@@ -253,6 +253,8 @@ extern void setMox(int state);
 extern int getMox();
 extern void setTune(int state);
 extern int getTune();
+extern void setVox(int state);
+extern int vox_changed(void *data);
 extern double getDrive();
 extern void setDrive(double d);
 extern void calcDriveLevel();
index 221572c77080e9da7ce597aa5822068b29c0a408..40fa39e4a0ad7029c82105e41411cd3f7ee69861 100644 (file)
@@ -34,6 +34,9 @@
 #include "mode.h"
 #include "new_protocol.h"
 #include "old_protocol.h"
+#ifdef LIME_PROTOOCL
+#include "lime_protocol.h"
+#endif
 #include "property.h"
 #include "radio.h"
 #include "receiver.h"
@@ -248,6 +251,9 @@ void receiver_save_state(RECEIVER *rx) {
   sprintf(name,"receiver.%d.local_audio",rx->id);
   sprintf(value,"%d",rx->local_audio);
   setProperty(name,value);
+  sprintf(name,"receiver.%d.mute_when_not_active",rx->id);
+  sprintf(value,"%d",rx->mute_when_not_active);
+  setProperty(name,value);
   sprintf(name,"receiver.%d.audio_device",rx->id);
   sprintf(value,"%d",rx->audio_device);
   setProperty(name,value);
@@ -375,6 +381,9 @@ fprintf(stderr,"receiver_restore_state: id=%d\n",rx->id);
   sprintf(name,"receiver.%d.local_audio",rx->id);
   value=getProperty(name);
   if(value) rx->local_audio=atoi(value);
+  sprintf(name,"receiver.%d.mute_when_not_active",rx->id);
+  value=getProperty(name);
+  if(value) rx->mute_when_not_active=atoi(value);
   sprintf(name,"receiver.%d.audio_device",rx->id);
   value=getProperty(name);
   if(value) rx->audio_device=atoi(value);
@@ -742,6 +751,7 @@ fprintf(stderr,"create_receiver: id=%d default adc=%d\n",rx->id, rx->adc);
   
   rx->playback_handle=NULL;
   rx->local_audio=0;
+  rx->mute_when_not_active=0;
   rx->audio_channel=STEREO;
   rx->audio_device=-1;
 
@@ -960,16 +970,20 @@ static void process_rx_buffer(RECEIVER *rx) {
     }
 
     if(rx->local_audio) {
-      switch(rx->audio_channel) {
-        case STEREO:
-          audio_write(rx,left_audio_sample,right_audio_sample);
-          break;
-        case LEFT:
-          audio_write(rx,left_audio_sample,0);
-          break;
-        case RIGHT:
-          audio_write(rx,0,right_audio_sample);
-          break;
+      if(rx!=active_receiver && rx->mute_when_not_active) {
+        audio_write(rx,0,0);
+      } else {
+        switch(rx->audio_channel) {
+          case STEREO:
+            audio_write(rx,left_audio_sample,right_audio_sample);
+            break;
+          case LEFT:
+            audio_write(rx,left_audio_sample,0);
+            break;
+          case RIGHT:
+            audio_write(rx,0,right_audio_sample);
+            break;
+        }
       }
     }
 
index 75e36a786fbe6c0bcefa372ae13a4877d31adb96..56c2a2b635c597afc1bb33ed705090b2c15570e8 100644 (file)
@@ -110,6 +110,7 @@ typedef struct _receiver {
   GdkPixbuf *pixbuf;
 
   int local_audio;
+  int mute_when_not_active;
   int audio_device;
   snd_pcm_t *playback_handle;
   int playback_offset;
index 3d1318dccb446dbb5d26aee875af5e2b2f6fbc63..4c4ed23c77891e69fff62bfcbecdae0a88b8caf6 100644 (file)
--- a/rx_menu.c
+++ b/rx_menu.c
@@ -82,6 +82,10 @@ static void local_audio_cb(GtkWidget *widget, gpointer data) {
   }
 }
 
+static void mute_audio_cb(GtkWidget *widget, gpointer data) {
+  active_receiver->mute_when_not_active=gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
+}
+
 static void local_output_changed_cb(GtkWidget *widget, gpointer data) {
   active_receiver->audio_device=(int)(long)data;
   if(active_receiver->local_audio) {
@@ -322,6 +326,12 @@ void rx_menu(GtkWidget *parent) {
     gtk_grid_attach(GTK_GRID(grid),right_b,x,++row,1,1);
     g_signal_connect(right_b,"toggled",G_CALLBACK(audio_channel_cb),(gpointer)RIGHT);
   }
+
+  GtkWidget *mute_audio_b=gtk_check_button_new_with_label("Mute when not active");
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (mute_audio_b), active_receiver->mute_when_not_active);
+  gtk_widget_show(mute_audio_b);
+  gtk_grid_attach(GTK_GRID(grid),mute_audio_b,x,++row,1,1);
+  g_signal_connect(mute_audio_b,"toggled",G_CALLBACK(mute_audio_cb),NULL);
   
   gtk_container_add(GTK_CONTAINER(content),grid);
 
index a91cadaafdc297ea6f8cc6f3064a972d712db115..71e79ae844f78ce65e5f18d5f0ca79e749962bbc 100644 (file)
@@ -39,6 +39,8 @@ static GtkWidget *parent_window=NULL;
 
 static GtkWidget *dialog=NULL;
 
+GtkWidget *store_button[NUM_OF_MEMORYS];
+
 static gboolean store_close_cb (GtkWidget *widget, GdkEventButton *event, gpointer data) {
   if(dialog!=NULL) {
     gtk_widget_destroy(dialog);
@@ -51,7 +53,7 @@ static gboolean store_close_cb (GtkWidget *widget, GdkEventButton *event, gpoint
 static gboolean store_select_cb (GtkWidget *widget, gpointer data) {
    int index = (int) data;
    fprintf(stderr,"STORE BUTTON PUSHED=%d\n",index);
-   char workstr[16];
+   char workstr[40];
      
    /* Update mem[data] with current info  */
 
@@ -64,6 +66,9 @@ static gboolean store_select_cb (GtkWidget *widget, gpointer data) {
     fprintf(stderr,"store_select_cb: mode=%d\n",mem[index].mode);
     fprintf(stderr,"store_select_cb: filter=%d\n",mem[index].filter);
 
+    sprintf(workstr,"M%d=%8.6f MHz", index,((double) mem[index].frequency)/1000000.0);
+    gtk_button_set_label(GTK_BUTTON(store_button[index]),workstr);
+
    // Save in the file now..
    memSaveState();
 }
@@ -85,14 +90,18 @@ static gboolean recall_select_cb (GtkWidget *widget, gpointer data) {
     vfo[active_receiver->id].band = get_band_from_frequency(new_freq);
     vfo[active_receiver->id].mode = mem[index].mode;
     vfo[active_receiver->id].filter = mem[index].filter;
-    vfo_band_changed(vfo[active_receiver->id].band);
+    //vfo_band_changed(vfo[active_receiver->id].band);
+    vfo_filter_changed(mem[index].filter);
+    vfo_mode_changed(mem[index].mode);
+    g_idle_add(vfo_update,NULL);
+
 }
 
 void store_menu(GtkWidget *parent) {
   GtkWidget *b;
   int i;
   BAND *band;
-  char label_str[20];
+  char label_str[50];
 
   parent_window=parent;
 
@@ -126,8 +135,9 @@ void store_menu(GtkWidget *parent) {
      g_signal_connect(b,"pressed",G_CALLBACK(store_select_cb),(gpointer *) i);
      gtk_grid_attach(GTK_GRID(grid),b,2,i,1,1);
 
-     sprintf(label_str,"Recall M%d",i); 
+     sprintf(label_str,"M%d=%8.6f MHz",i,((double) mem[i].frequency)/1000000.0);
      b=gtk_button_new_with_label(label_str);
+     store_button[i]= b;
      g_signal_connect(b,"pressed",G_CALLBACK(recall_select_cb),(gpointer *) i);
      gtk_grid_attach(GTK_GRID(grid),b,3,i,1,1);
   }
diff --git a/vfo.c b/vfo.c
index 58533fab3847df40b9e7d8a5ad0020257e28a4b6..dff1464974ac96a6fdf0f53fe389096185fddad0 100644 (file)
--- a/vfo.c
+++ b/vfo.c
@@ -418,6 +418,7 @@ void vfo_move(long long hz) {
     switch(protocol) {
 #ifdef LIMESDR
       case LIMESDR_PROTOCOL:
+        vfo[id].ctun_frequency=((vfo[id].ctun_frequency-hz)/step)*step;
         break;
 #endif
       default:
@@ -439,6 +440,7 @@ void vfo_move_to(long long hz) {
     switch(protocol) {
 #ifdef LIMESDR
       case LIMESDR_PROTOCOL:
+        vfo[id].ctun_frequency=(vfo[id].frequency+hz)/step*step;
         break;
 #endif
       default:
@@ -642,7 +644,7 @@ int vfo_update(void *data) {
         } else {
             cairo_set_source_rgb(cr, 1, 1, 0);
         }
-        sprintf(temp_text,"RIT: %d Hz",vfo[id].rit);
+        sprintf(temp_text,"RIT: %lld Hz",vfo[id].rit);
         cairo_move_to(cr, 5, 50);  
         cairo_set_font_size(cr, 12);
         cairo_show_text(cr, temp_text);
diff --git a/vox.c b/vox.c
index cfd78b5cc77c70f2f86e52c99853923c072949b5..7b99e558101fba2b2ad99c187c04e9cca2fc1fc8 100644 (file)
--- a/vox.c
+++ b/vox.c
@@ -29,7 +29,8 @@ static guint vox_timeout;
 static double peak=0.0;
 
 static int vox_timeout_cb(gpointer data) {
-  setVox(0);
+  //setVox(0);
+  g_idle_add(vox_changed,(gpointer)0);
   g_idle_add(vfo_update,NULL);
   return FALSE;
 }
@@ -62,7 +63,8 @@ void update_vox(TRANSMITTER *tx) {
       if(previous_vox) {
         g_source_remove(vox_timeout);
       } else {
-        setVox(1);
+        //setVox(1);
+        g_idle_add(vox_changed,(gpointer)1);
       }
       vox_timeout=g_timeout_add((int)vox_hang,vox_timeout_cb,NULL);
     }
@@ -75,6 +77,8 @@ void update_vox(TRANSMITTER *tx) {
 void vox_cancel() {
   if(vox) {
     g_source_remove(vox_timeout);
-    setVox(0);
+    //setVox(0);
+    g_idle_add(vox_changed,(gpointer)0);
+    g_idle_add(vfo_update,NULL);
   }
 }
index 27ac1131ef72408de784fa877bcc0451f5a6146b..8b710f7fe215281b9ff98047dc10e89d3151b83b 100644 (file)
@@ -96,7 +96,7 @@ static gboolean close_cb (GtkWidget *widget, GdkEventButton *event, gpointer dat
 
 static gboolean enable_cb (GtkWidget *widget, GdkEventButton *event, gpointer data) {
   vox_enabled=vox_enabled==1?0:1;
-  gtk_button_set_label(GTK_BUTTON(widget),vox_enabled==0?"VOX On":"VOX Off");
+  gtk_button_set_label(GTK_BUTTON(widget),vox_enabled==0?"VOX Enable":"VOX Disable");
   vfo_update(NULL);
   return TRUE;
 }
@@ -155,7 +155,7 @@ void vox_menu(GtkWidget *parent) {
   led=create_led(10,10);
   gtk_grid_attach(GTK_GRID(grid),led,2,0,1,1);
  
-  GtkWidget *enable_b=gtk_button_new_with_label(vox_enabled==0?"VOX On":"VOX Off");
+  GtkWidget *enable_b=gtk_button_new_with_label(vox_enabled==0?"VOX Enable":"VOX Disable");
   g_signal_connect (enable_b, "pressed", G_CALLBACK(enable_cb), NULL);
   gtk_grid_attach(GTK_GRID(grid),enable_b,3,0,1,1);