2011-07-07 14:09:57 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2011-08-20 11:49:29 +00:00
|
|
|
#include <stdbool.h>
|
2011-07-07 14:09:57 +00:00
|
|
|
#include <math.h>
|
|
|
|
|
2011-07-29 20:09:42 +00:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#include <alsa/asoundlib.h>
|
2012-12-25 20:43:26 +00:00
|
|
|
|
|
|
|
#ifdef GPL
|
2011-08-16 21:29:38 +00:00
|
|
|
#include <fftw3.h>
|
2012-12-25 20:43:26 +00:00
|
|
|
#endif
|
2011-07-29 20:09:42 +00:00
|
|
|
|
2011-07-07 14:09:57 +00:00
|
|
|
#include "common.h"
|
|
|
|
|
2011-08-16 21:29:38 +00:00
|
|
|
gint16 *PcmBuffer = NULL;
|
2011-08-08 21:36:47 +00:00
|
|
|
int PcmPointer = 0;
|
2011-08-20 05:51:27 +00:00
|
|
|
int MaxPcm = 0;
|
2011-08-18 00:04:28 +00:00
|
|
|
guchar *StoredLum = NULL;
|
2011-08-20 11:49:29 +00:00
|
|
|
bool *HasSync = NULL;
|
2011-08-16 21:29:38 +00:00
|
|
|
double *in = NULL;
|
|
|
|
double *out = NULL;
|
2011-08-11 11:48:35 +00:00
|
|
|
gshort HedrShift = 0;
|
2011-08-30 16:21:03 +00:00
|
|
|
int PWRdBthresh[10] = {-3, -5, -10, -15, -20, -25, -30, -40, -50, -60};
|
2011-08-08 21:36:47 +00:00
|
|
|
int SNRdBthresh[10] = {30, 15, 10, 5, 3, 0, -3, -5, -10, -15};
|
2011-08-20 11:49:29 +00:00
|
|
|
bool Adaptive = true;
|
|
|
|
bool ManualActivated = false;
|
|
|
|
bool Abort = false;
|
2011-08-08 21:36:47 +00:00
|
|
|
|
|
|
|
GtkWidget *RxImage = NULL;
|
|
|
|
GtkWidget *statusbar = NULL;
|
|
|
|
GtkWidget *vugrid = NULL;
|
|
|
|
GtkWidget *infolabel = NULL;
|
|
|
|
GtkWidget *cardcombo = NULL;
|
2011-08-10 20:43:17 +00:00
|
|
|
GtkWidget *modecombo = NULL;
|
|
|
|
GtkWidget *togslant = NULL;
|
|
|
|
GtkWidget *togsave = NULL;
|
|
|
|
GtkWidget *togadapt = NULL;
|
|
|
|
GtkWidget *togrx = NULL;
|
2011-08-12 20:06:23 +00:00
|
|
|
GtkWidget *togfsk = NULL;
|
2011-08-10 20:43:17 +00:00
|
|
|
GtkWidget *btnabort = NULL;
|
|
|
|
GtkWidget *btnstart = NULL;
|
|
|
|
GtkWidget *manualframe = NULL;
|
|
|
|
GtkWidget *shiftspin = NULL;
|
|
|
|
GtkWidget *pwrimage = NULL;
|
|
|
|
GtkWidget *snrimage = NULL;
|
2011-08-12 20:06:23 +00:00
|
|
|
GtkWidget *idlabel = NULL;
|
2011-08-08 21:36:47 +00:00
|
|
|
|
2011-08-13 12:26:49 +00:00
|
|
|
GdkPixbuf *RxPixbuf = NULL;
|
|
|
|
GdkPixbuf *DispPixbuf = NULL;
|
|
|
|
GdkPixbuf *pixbufPWR = NULL;
|
|
|
|
GdkPixbuf *pixbufSNR = NULL;
|
|
|
|
|
|
|
|
GtkListStore *savedstore = NULL;
|
|
|
|
|
2011-08-08 21:36:47 +00:00
|
|
|
snd_pcm_t *pcm_handle = NULL;
|
2011-07-29 20:09:42 +00:00
|
|
|
|
2011-08-16 21:29:38 +00:00
|
|
|
fftw_plan Plan1024 = NULL;
|
|
|
|
fftw_plan Plan2048 = NULL;
|
|
|
|
|
2011-08-20 05:51:27 +00:00
|
|
|
// Return the FFT bin index matching the given frequency
|
|
|
|
guint GetBin (double Freq, guint FFTLen) {
|
2011-08-16 21:29:38 +00:00
|
|
|
return (Freq / 44100 * FFTLen);
|
2011-07-07 14:09:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Clip to [0..255]
|
2011-08-11 11:48:35 +00:00
|
|
|
guchar clip (double a) {
|
2011-07-07 14:09:57 +00:00
|
|
|
if (a < 0) return 0;
|
|
|
|
else if (a > 255) return 255;
|
2011-08-20 05:51:27 +00:00
|
|
|
return (guchar)round(a);
|
2011-07-07 14:09:57 +00:00
|
|
|
}
|
|
|
|
|
2011-08-12 09:33:49 +00:00
|
|
|
// Convert degrees -> radians
|
2011-07-07 14:09:57 +00:00
|
|
|
double deg2rad (double Deg) {
|
2011-08-10 20:43:17 +00:00
|
|
|
return (Deg / 180) * M_PI;
|
2011-07-07 14:09:57 +00:00
|
|
|
}
|
2011-08-02 23:42:56 +00:00
|
|
|
|
2011-08-12 09:33:49 +00:00
|
|
|
// Quit
|
2011-08-02 23:42:56 +00:00
|
|
|
void delete_event() {
|
|
|
|
gtk_main_quit ();
|
|
|
|
}
|
2011-08-10 20:43:17 +00:00
|
|
|
|
2011-08-12 09:33:49 +00:00
|
|
|
// Transform the NoiseAdapt toggle state into a variable
|
2011-08-10 20:43:17 +00:00
|
|
|
void GetAdaptive() {
|
|
|
|
Adaptive = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(togadapt));
|
|
|
|
}
|
|
|
|
|
2011-08-12 09:33:49 +00:00
|
|
|
// Manual Start clicked
|
2011-08-10 20:43:17 +00:00
|
|
|
void ManualStart() {
|
2011-08-20 11:49:29 +00:00
|
|
|
ManualActivated = true;
|
2011-08-11 11:48:35 +00:00
|
|
|
}
|
|
|
|
|
2011-08-12 09:33:49 +00:00
|
|
|
// Abort clicked
|
2011-08-11 11:48:35 +00:00
|
|
|
void AbortRx() {
|
2011-08-20 11:49:29 +00:00
|
|
|
Abort = true;
|
2011-08-10 20:43:17 +00:00
|
|
|
}
|