kopia lustrzana https://github.com/windytan/slowrx
replace stdbool with gboolean
rodzic
1a7e913638
commit
4a787e492d
35
common.c
35
common.c
|
@ -1,6 +1,5 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdbool.h>
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
@ -12,13 +11,13 @@
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
bool Abort = false;
|
gboolean Abort = FALSE;
|
||||||
bool Adaptive = true;
|
gboolean Adaptive = TRUE;
|
||||||
double *in = NULL;
|
double *in = NULL;
|
||||||
bool *HasSync = NULL;
|
gboolean *HasSync = NULL;
|
||||||
gshort HedrShift = 0;
|
gshort HedrShift = 0;
|
||||||
bool ManualActivated = false;
|
gboolean ManualActivated = FALSE;
|
||||||
bool ManualResync = false;
|
gboolean ManualResync = FALSE;
|
||||||
double *out = NULL;
|
double *out = NULL;
|
||||||
guchar *StoredLum = NULL;
|
guchar *StoredLum = NULL;
|
||||||
|
|
||||||
|
@ -89,7 +88,7 @@ void saveCurrentPic() {
|
||||||
ensure_dir_exists(g_key_file_get_string(config,"slowrx","rxdir",NULL));
|
ensure_dir_exists(g_key_file_get_string(config,"slowrx","rxdir",NULL));
|
||||||
gdk_pixbuf_savev(scaledpb, pngfilename->str, "png", NULL, NULL, NULL);
|
gdk_pixbuf_savev(scaledpb, pngfilename->str, "png", NULL, NULL, NULL);
|
||||||
g_object_unref(scaledpb);
|
g_object_unref(scaledpb);
|
||||||
g_string_free(pngfilename, true);
|
g_string_free(pngfilename, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -108,12 +107,12 @@ void evt_GetAdaptive() {
|
||||||
|
|
||||||
// Manual Start clicked
|
// Manual Start clicked
|
||||||
void evt_ManualStart() {
|
void evt_ManualStart() {
|
||||||
ManualActivated = true;
|
ManualActivated = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Abort clicked during rx
|
// Abort clicked during rx
|
||||||
void evt_AbortRx() {
|
void evt_AbortRx() {
|
||||||
Abort = true;
|
Abort = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Another device selected from list
|
// Another device selected from list
|
||||||
|
@ -121,8 +120,8 @@ void evt_changeDevices() {
|
||||||
|
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
pcm.BufferDrop = false;
|
pcm.BufferDrop = FALSE;
|
||||||
Abort = true;
|
Abort = TRUE;
|
||||||
|
|
||||||
pthread_join(thread1, NULL);
|
pthread_join(thread1, NULL);
|
||||||
|
|
||||||
|
@ -164,7 +163,7 @@ void evt_clearPix() {
|
||||||
// Manual slant adjust
|
// Manual slant adjust
|
||||||
void evt_clickimg(GtkWidget *widget, GdkEventButton* event, GdkWindowEdge edge) {
|
void evt_clickimg(GtkWidget *widget, GdkEventButton* event, GdkWindowEdge edge) {
|
||||||
static double prevx=0,prevy=0,newrate;
|
static double prevx=0,prevy=0,newrate;
|
||||||
static bool secondpress=false;
|
static gboolean secondpress=FALSE;
|
||||||
double x,y,dx,dy,xic;
|
double x,y,dx,dy,xic;
|
||||||
|
|
||||||
(void)widget;
|
(void)widget;
|
||||||
|
@ -176,12 +175,12 @@ void evt_clickimg(GtkWidget *widget, GdkEventButton* event, GdkWindowEdge edge)
|
||||||
y = event->y * (ModeSpec[CurrentPic.Mode].ImgWidth / 500.0) / ModeSpec[CurrentPic.Mode].YScale;
|
y = event->y * (ModeSpec[CurrentPic.Mode].ImgWidth / 500.0) / ModeSpec[CurrentPic.Mode].YScale;
|
||||||
|
|
||||||
if (secondpress) {
|
if (secondpress) {
|
||||||
secondpress=false;
|
secondpress=FALSE;
|
||||||
|
|
||||||
dx = x - prevx;
|
dx = x - prevx;
|
||||||
dy = y - prevy;
|
dy = y - prevy;
|
||||||
|
|
||||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(gui.tog_setedge),false);
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(gui.tog_setedge),FALSE);
|
||||||
|
|
||||||
// Adjust sample rate, if in sensible limits
|
// Adjust sample rate, if in sensible limits
|
||||||
newrate = CurrentPic.Rate + CurrentPic.Rate * (dx * ModeSpec[CurrentPic.Mode].PixelLen) / (dy * ModeSpec[CurrentPic.Mode].YScale * ModeSpec[CurrentPic.Mode].LineLen);
|
newrate = CurrentPic.Rate + CurrentPic.Rate * (dx * ModeSpec[CurrentPic.Mode].PixelLen) / (dy * ModeSpec[CurrentPic.Mode].YScale * ModeSpec[CurrentPic.Mode].LineLen);
|
||||||
|
@ -197,16 +196,16 @@ void evt_clickimg(GtkWidget *widget, GdkEventButton* event, GdkWindowEdge edge)
|
||||||
CurrentPic.Skip -= ModeSpec[CurrentPic.Mode].LineLen * CurrentPic.Rate;
|
CurrentPic.Skip -= ModeSpec[CurrentPic.Mode].LineLen * CurrentPic.Rate;
|
||||||
|
|
||||||
// Signal the listener to exit from GetVIS() and re-process the pic
|
// Signal the listener to exit from GetVIS() and re-process the pic
|
||||||
ManualResync = true;
|
ManualResync = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
secondpress = true;
|
secondpress = TRUE;
|
||||||
prevx = x;
|
prevx = x;
|
||||||
prevy = y;
|
prevy = y;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
secondpress=false;
|
secondpress=FALSE;
|
||||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(gui.tog_setedge), false);
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(gui.tog_setedge), FALSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
14
common.h
14
common.h
|
@ -6,12 +6,12 @@
|
||||||
#define BUFLEN 4096
|
#define BUFLEN 4096
|
||||||
#define SYNCPIXLEN 1.5e-3
|
#define SYNCPIXLEN 1.5e-3
|
||||||
|
|
||||||
extern bool Abort;
|
extern gboolean Abort;
|
||||||
extern bool Adaptive;
|
extern gboolean Adaptive;
|
||||||
extern bool *HasSync;
|
extern gboolean *HasSync;
|
||||||
extern double *in;
|
extern double *in;
|
||||||
extern bool ManualActivated;
|
extern gboolean ManualActivated;
|
||||||
extern bool ManualResync;
|
extern gboolean ManualResync;
|
||||||
extern double *out;
|
extern double *out;
|
||||||
extern guchar *StoredLum;
|
extern guchar *StoredLum;
|
||||||
extern pthread_t thread1;
|
extern pthread_t thread1;
|
||||||
|
@ -23,7 +23,7 @@ struct _PcmData {
|
||||||
int PeakVal;
|
int PeakVal;
|
||||||
gint16 *Buffer;
|
gint16 *Buffer;
|
||||||
int WindowPtr;
|
int WindowPtr;
|
||||||
bool BufferDrop;
|
gboolean BufferDrop;
|
||||||
};
|
};
|
||||||
extern PcmData pcm;
|
extern PcmData pcm;
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ void createGUI ();
|
||||||
double deg2rad (double Deg);
|
double deg2rad (double Deg);
|
||||||
double FindSync (guchar Mode, double Rate, int *Skip);
|
double FindSync (guchar Mode, double Rate, int *Skip);
|
||||||
void GetFSK (char *dest);
|
void GetFSK (char *dest);
|
||||||
bool GetVideo (guchar Mode, double Rate, int Skip, bool Redraw);
|
gboolean GetVideo (guchar Mode, double Rate, int Skip, gboolean Redraw);
|
||||||
guchar GetVIS ();
|
guchar GetVIS ();
|
||||||
guint GetBin (double Freq, guint FFTLen);
|
guint GetBin (double Freq, guint FFTLen);
|
||||||
int initPcmDevice ();
|
int initPcmDevice ();
|
||||||
|
|
7
fsk.c
7
fsk.c
|
@ -1,5 +1,4 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdbool.h>
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <alsa/asoundlib.h>
|
#include <alsa/asoundlib.h>
|
||||||
|
@ -23,7 +22,7 @@ void GetFSK (char *dest) {
|
||||||
guint FFTLen = 2048, i=0, LoBin, HiBin, MidBin, TestNum=0, TestPtr=0;
|
guint FFTLen = 2048, i=0, LoBin, HiBin, MidBin, TestNum=0, TestPtr=0;
|
||||||
guchar Bit = 0, AsciiByte = 0, BytePtr = 0, TestBits[24] = {0}, BitPtr=0;
|
guchar Bit = 0, AsciiByte = 0, BytePtr = 0, TestBits[24] = {0}, BitPtr=0;
|
||||||
double HiPow,LoPow,Hann[970];
|
double HiPow,LoPow,Hann[970];
|
||||||
bool InSync = false;
|
gboolean InSync = FALSE;
|
||||||
|
|
||||||
// Bit-reversion lookup table
|
// Bit-reversion lookup table
|
||||||
static const guchar BitRev[] = {
|
static const guchar BitRev[] = {
|
||||||
|
@ -41,7 +40,7 @@ void GetFSK (char *dest) {
|
||||||
// Create 22ms Hann window
|
// Create 22ms Hann window
|
||||||
for (i = 0; i < 970; i++) Hann[i] = 0.5 * (1 - cos( 2 * M_PI * i / 969.0 ) );
|
for (i = 0; i < 970; i++) Hann[i] = 0.5 * (1 - cos( 2 * M_PI * i / 969.0 ) );
|
||||||
|
|
||||||
while ( true ) {
|
while ( TRUE ) {
|
||||||
|
|
||||||
// Read data from DSP
|
// Read data from DSP
|
||||||
readPcm(InSync ? 970: 485);
|
readPcm(InSync ? 970: 485);
|
||||||
|
@ -78,7 +77,7 @@ void GetFSK (char *dest) {
|
||||||
for (i=0; i<12; i++) TestNum |= TestBits[(TestPtr - (23-i*2)) % 24] << (11-i);
|
for (i=0; i<12; i++) TestNum |= TestBits[(TestPtr - (23-i*2)) % 24] << (11-i);
|
||||||
|
|
||||||
if (BitRev[(TestNum >> 6) & 0x3f] == 0x20 && BitRev[TestNum & 0x3f] == 0x2a) {
|
if (BitRev[(TestNum >> 6) & 0x3f] == 0x20 && BitRev[TestNum & 0x3f] == 0x2a) {
|
||||||
InSync = true;
|
InSync = TRUE;
|
||||||
AsciiByte = 0;
|
AsciiByte = 0;
|
||||||
BitPtr = 0;
|
BitPtr = 0;
|
||||||
BytePtr = 0;
|
BytePtr = 0;
|
||||||
|
|
7
gui.c
7
gui.c
|
@ -1,5 +1,4 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdbool.h>
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <alsa/asoundlib.h>
|
#include <alsa/asoundlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
@ -61,13 +60,13 @@ void createGUI() {
|
||||||
|
|
||||||
savedstore = GTK_LIST_STORE(gtk_icon_view_get_model(GTK_ICON_VIEW(gui.iconview)));
|
savedstore = GTK_LIST_STORE(gtk_icon_view_get_model(GTK_ICON_VIEW(gui.iconview)));
|
||||||
|
|
||||||
pixbuf_rx = gdk_pixbuf_new (GDK_COLORSPACE_RGB, false, 8, 320, 256);
|
pixbuf_rx = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, 320, 256);
|
||||||
gdk_pixbuf_fill(pixbuf_rx, 0x000000ff);
|
gdk_pixbuf_fill(pixbuf_rx, 0x000000ff);
|
||||||
pixbuf_disp = gdk_pixbuf_scale_simple (pixbuf_rx, 500, 400, GDK_INTERP_BILINEAR);
|
pixbuf_disp = gdk_pixbuf_scale_simple (pixbuf_rx, 500, 400, GDK_INTERP_BILINEAR);
|
||||||
gtk_image_set_from_pixbuf(GTK_IMAGE(gui.image_rx), pixbuf_disp);
|
gtk_image_set_from_pixbuf(GTK_IMAGE(gui.image_rx), pixbuf_disp);
|
||||||
|
|
||||||
pixbuf_PWR = gdk_pixbuf_new (GDK_COLORSPACE_RGB, false, 8, 100, 20);
|
pixbuf_PWR = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, 100, 20);
|
||||||
pixbuf_SNR = gdk_pixbuf_new (GDK_COLORSPACE_RGB, false, 8, 100, 20);
|
pixbuf_SNR = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, 100, 20);
|
||||||
|
|
||||||
gtk_combo_box_set_active(GTK_COMBO_BOX(gui.combo_mode), 0);
|
gtk_combo_box_set_active(GTK_COMBO_BOX(gui.combo_mode), 0);
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdbool.h>
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <alsa/asoundlib.h>
|
#include <alsa/asoundlib.h>
|
||||||
|
|
||||||
|
|
15
pcm.c
15
pcm.c
|
@ -1,6 +1,5 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdbool.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
@ -31,7 +30,7 @@ void readPcm(gint numsamples) {
|
||||||
else if (samplesread < 0) {
|
else if (samplesread < 0) {
|
||||||
printf("ALSA error %d (%s)\n", samplesread, snd_strerror(samplesread));
|
printf("ALSA error %d (%s)\n", samplesread, snd_strerror(samplesread));
|
||||||
gtk_widget_set_tooltip_text(gui.image_devstatus, "ALSA error");
|
gtk_widget_set_tooltip_text(gui.image_devstatus, "ALSA error");
|
||||||
Abort = true;
|
Abort = TRUE;
|
||||||
pthread_exit(NULL);
|
pthread_exit(NULL);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -43,7 +42,7 @@ void readPcm(gint numsamples) {
|
||||||
gtk_image_set_from_stock(GTK_IMAGE(gui.image_devstatus),GTK_STOCK_DIALOG_WARNING,GTK_ICON_SIZE_SMALL_TOOLBAR);
|
gtk_image_set_from_stock(GTK_IMAGE(gui.image_devstatus),GTK_STOCK_DIALOG_WARNING,GTK_ICON_SIZE_SMALL_TOOLBAR);
|
||||||
gtk_widget_set_tooltip_text(gui.image_devstatus, "Device is dropping samples");
|
gtk_widget_set_tooltip_text(gui.image_devstatus, "Device is dropping samples");
|
||||||
gdk_threads_leave();
|
gdk_threads_leave();
|
||||||
pcm.BufferDrop = true;
|
pcm.BufferDrop = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -111,24 +110,24 @@ int initPcmDevice(char *wanteddevname) {
|
||||||
char pcm_name[30];
|
char pcm_name[30];
|
||||||
unsigned int exact_rate = 44100;
|
unsigned int exact_rate = 44100;
|
||||||
int card;
|
int card;
|
||||||
bool found;
|
gboolean found;
|
||||||
char *cardname;
|
char *cardname;
|
||||||
|
|
||||||
pcm.BufferDrop = false;
|
pcm.BufferDrop = FALSE;
|
||||||
|
|
||||||
snd_pcm_hw_params_alloca(&hwparams);
|
snd_pcm_hw_params_alloca(&hwparams);
|
||||||
|
|
||||||
card = -1;
|
card = -1;
|
||||||
found = false;
|
found = FALSE;
|
||||||
if (strcmp(wanteddevname,"default") == 0) {
|
if (strcmp(wanteddevname,"default") == 0) {
|
||||||
found=true;
|
found=TRUE;
|
||||||
} else {
|
} else {
|
||||||
do {
|
do {
|
||||||
snd_card_next(&card);
|
snd_card_next(&card);
|
||||||
if (card != -1) {
|
if (card != -1) {
|
||||||
snd_card_get_name(card,&cardname);
|
snd_card_get_name(card,&cardname);
|
||||||
if (strcmp(cardname, wanteddevname) == 0) {
|
if (strcmp(cardname, wanteddevname) == 0) {
|
||||||
found=true;
|
found=TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
45
slowrx.c
45
slowrx.c
|
@ -6,7 +6,6 @@
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdbool.h>
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
@ -29,22 +28,22 @@ void *Listen() {
|
||||||
guchar Mode=0;
|
guchar Mode=0;
|
||||||
struct tm *timeptr = NULL;
|
struct tm *timeptr = NULL;
|
||||||
time_t timet;
|
time_t timet;
|
||||||
bool Finished;
|
gboolean Finished;
|
||||||
char id[20];
|
char id[20];
|
||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
|
|
||||||
while (true) {
|
while (TRUE) {
|
||||||
|
|
||||||
gdk_threads_enter ();
|
gdk_threads_enter ();
|
||||||
gtk_widget_set_sensitive (gui.grid_vu, true);
|
gtk_widget_set_sensitive (gui.grid_vu, TRUE);
|
||||||
gtk_widget_set_sensitive (gui.button_abort, false);
|
gtk_widget_set_sensitive (gui.button_abort, FALSE);
|
||||||
gtk_widget_set_sensitive (gui.button_clear, true);
|
gtk_widget_set_sensitive (gui.button_clear, TRUE);
|
||||||
gdk_threads_leave ();
|
gdk_threads_leave ();
|
||||||
|
|
||||||
pcm.WindowPtr = 0;
|
pcm.WindowPtr = 0;
|
||||||
snd_pcm_prepare(pcm.handle);
|
snd_pcm_prepare(pcm.handle);
|
||||||
snd_pcm_start (pcm.handle);
|
snd_pcm_start (pcm.handle);
|
||||||
Abort = false;
|
Abort = FALSE;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
|
||||||
|
@ -56,10 +55,10 @@ void *Listen() {
|
||||||
|
|
||||||
// If manual resync was requested, redraw image
|
// If manual resync was requested, redraw image
|
||||||
if (ManualResync) {
|
if (ManualResync) {
|
||||||
ManualResync = false;
|
ManualResync = FALSE;
|
||||||
snd_pcm_drop(pcm.handle);
|
snd_pcm_drop(pcm.handle);
|
||||||
printf("getvideo at %.2f skip %d\n",CurrentPic.Rate,CurrentPic.Skip);
|
printf("getvideo at %.2f skip %d\n",CurrentPic.Rate,CurrentPic.Skip);
|
||||||
GetVideo(CurrentPic.Mode, CurrentPic.Rate, CurrentPic.Skip, true);
|
GetVideo(CurrentPic.Mode, CurrentPic.Rate, CurrentPic.Skip, TRUE);
|
||||||
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(gui.tog_save)))
|
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(gui.tog_save)))
|
||||||
saveCurrentPic();
|
saveCurrentPic();
|
||||||
pcm.WindowPtr = 0;
|
pcm.WindowPtr = 0;
|
||||||
|
@ -91,7 +90,7 @@ void *Listen() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allocate space for sync signal
|
// Allocate space for sync signal
|
||||||
HasSync = calloc((int)(ModeSpec[CurrentPic.Mode].LineLen * ModeSpec[CurrentPic.Mode].ImgHeight / SYNCPIXLEN +1), sizeof(bool));
|
HasSync = calloc((int)(ModeSpec[CurrentPic.Mode].LineLen * ModeSpec[CurrentPic.Mode].ImgHeight / SYNCPIXLEN +1), sizeof(gboolean));
|
||||||
if (HasSync == NULL) {
|
if (HasSync == NULL) {
|
||||||
perror("Listen: Unable to allocate memory for sync signal");
|
perror("Listen: Unable to allocate memory for sync signal");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
@ -101,22 +100,22 @@ void *Listen() {
|
||||||
strftime(rctime, sizeof(rctime)-1, "%H:%Mz", timeptr);
|
strftime(rctime, sizeof(rctime)-1, "%H:%Mz", timeptr);
|
||||||
gdk_threads_enter ();
|
gdk_threads_enter ();
|
||||||
gtk_label_set_text (GTK_LABEL(gui.label_fskid), "");
|
gtk_label_set_text (GTK_LABEL(gui.label_fskid), "");
|
||||||
gtk_widget_set_sensitive (gui.frame_manual, false);
|
gtk_widget_set_sensitive (gui.frame_manual, FALSE);
|
||||||
gtk_widget_set_sensitive (gui.frame_slant, false);
|
gtk_widget_set_sensitive (gui.frame_slant, FALSE);
|
||||||
gtk_widget_set_sensitive (gui.combo_card, false);
|
gtk_widget_set_sensitive (gui.combo_card, FALSE);
|
||||||
gtk_widget_set_sensitive (gui.button_abort, true);
|
gtk_widget_set_sensitive (gui.button_abort, TRUE);
|
||||||
gtk_widget_set_sensitive (gui.button_clear, false);
|
gtk_widget_set_sensitive (gui.button_clear, FALSE);
|
||||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(gui.tog_setedge), false);
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(gui.tog_setedge), FALSE);
|
||||||
gtk_statusbar_push (GTK_STATUSBAR(gui.statusbar), 0, "Receiving video..." );
|
gtk_statusbar_push (GTK_STATUSBAR(gui.statusbar), 0, "Receiving video..." );
|
||||||
gtk_label_set_markup (GTK_LABEL(gui.label_lastmode), ModeSpec[CurrentPic.Mode].Name);
|
gtk_label_set_markup (GTK_LABEL(gui.label_lastmode), ModeSpec[CurrentPic.Mode].Name);
|
||||||
gtk_label_set_markup (GTK_LABEL(gui.label_utc), rctime);
|
gtk_label_set_markup (GTK_LABEL(gui.label_utc), rctime);
|
||||||
gdk_threads_leave ();
|
gdk_threads_leave ();
|
||||||
printf(" getvideo @ %.1f Hz, Skip %d, HedrShift %+d Hz\n", 44100.0, 0, CurrentPic.HedrShift);
|
printf(" getvideo @ %.1f Hz, Skip %d, HedrShift %+d Hz\n", 44100.0, 0, CurrentPic.HedrShift);
|
||||||
|
|
||||||
Finished = GetVideo(CurrentPic.Mode, 44100, 0, false);
|
Finished = GetVideo(CurrentPic.Mode, 44100, 0, FALSE);
|
||||||
|
|
||||||
gdk_threads_enter ();
|
gdk_threads_enter ();
|
||||||
gtk_widget_set_sensitive (gui.button_abort, false);
|
gtk_widget_set_sensitive (gui.button_abort, FALSE);
|
||||||
gdk_threads_leave ();
|
gdk_threads_leave ();
|
||||||
|
|
||||||
id[0] = '\0';
|
id[0] = '\0';
|
||||||
|
@ -140,14 +139,14 @@ void *Listen() {
|
||||||
setVU(0,-100);
|
setVU(0,-100);
|
||||||
gdk_threads_enter ();
|
gdk_threads_enter ();
|
||||||
gtk_statusbar_push (GTK_STATUSBAR(gui.statusbar), 0, "Calculating slant..." );
|
gtk_statusbar_push (GTK_STATUSBAR(gui.statusbar), 0, "Calculating slant..." );
|
||||||
gtk_widget_set_sensitive (gui.grid_vu, false);
|
gtk_widget_set_sensitive (gui.grid_vu, FALSE);
|
||||||
gdk_threads_leave ();
|
gdk_threads_leave ();
|
||||||
printf(" FindSync @ %.1f Hz\n",CurrentPic.Rate);
|
printf(" FindSync @ %.1f Hz\n",CurrentPic.Rate);
|
||||||
CurrentPic.Rate = FindSync(CurrentPic.Mode, CurrentPic.Rate, &CurrentPic.Skip);
|
CurrentPic.Rate = FindSync(CurrentPic.Mode, CurrentPic.Rate, &CurrentPic.Skip);
|
||||||
|
|
||||||
// Final image
|
// Final image
|
||||||
printf(" getvideo @ %.1f Hz, Skip %d, HedrShift %+d Hz\n", CurrentPic.Rate, CurrentPic.Skip, CurrentPic.HedrShift);
|
printf(" getvideo @ %.1f Hz, Skip %d, HedrShift %+d Hz\n", CurrentPic.Rate, CurrentPic.Skip, CurrentPic.HedrShift);
|
||||||
GetVideo(CurrentPic.Mode, CurrentPic.Rate, CurrentPic.Skip, true);
|
GetVideo(CurrentPic.Mode, CurrentPic.Rate, CurrentPic.Skip, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
free (HasSync);
|
free (HasSync);
|
||||||
|
@ -177,9 +176,9 @@ void *Listen() {
|
||||||
}
|
}
|
||||||
|
|
||||||
gdk_threads_enter ();
|
gdk_threads_enter ();
|
||||||
gtk_widget_set_sensitive (gui.frame_slant, true);
|
gtk_widget_set_sensitive (gui.frame_slant, TRUE);
|
||||||
gtk_widget_set_sensitive (gui.frame_manual, true);
|
gtk_widget_set_sensitive (gui.frame_manual, TRUE);
|
||||||
gtk_widget_set_sensitive (gui.combo_card, true);
|
gtk_widget_set_sensitive (gui.combo_card, TRUE);
|
||||||
gdk_threads_leave ();
|
gdk_threads_leave ();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
5
sync.c
5
sync.c
|
@ -1,5 +1,4 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdbool.h>
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <fftw3.h>
|
#include <fftw3.h>
|
||||||
|
@ -24,14 +23,14 @@ double FindSync (guchar Mode, double Rate, int *Skip) {
|
||||||
gushort xAcc[700] = {0};
|
gushort xAcc[700] = {0};
|
||||||
gushort lines[600][(MAXSLANT-MINSLANT)*2];
|
gushort lines[600][(MAXSLANT-MINSLANT)*2];
|
||||||
gushort cy, cx, Retries = 0;
|
gushort cy, cx, Retries = 0;
|
||||||
bool SyncImg[700][630] = {{false}};
|
gboolean SyncImg[700][630] = {{FALSE}};
|
||||||
double t=0, slantAngle, s;
|
double t=0, slantAngle, s;
|
||||||
double ConvoFilter[8] = { 1,1,1,1,-1,-1,-1,-1 };
|
double ConvoFilter[8] = { 1,1,1,1,-1,-1,-1,-1 };
|
||||||
double convd, maxconvd=0;
|
double convd, maxconvd=0;
|
||||||
int xmax=0;
|
int xmax=0;
|
||||||
|
|
||||||
// Repeat until slant < 0.5° or until we give up
|
// Repeat until slant < 0.5° or until we give up
|
||||||
while (true) {
|
while (TRUE) {
|
||||||
|
|
||||||
// Draw the 2D sync signal at current rate
|
// Draw the 2D sync signal at current rate
|
||||||
|
|
||||||
|
|
19
video.c
19
video.c
|
@ -1,6 +1,5 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdbool.h>
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
@ -14,10 +13,10 @@
|
||||||
* Mode: M1, M2, S1, S2, R72, R36...
|
* Mode: M1, M2, S1, S2, R72, R36...
|
||||||
* Rate: exact sampling rate used
|
* Rate: exact sampling rate used
|
||||||
* Skip: number of PCM samples to skip at the beginning (for sync phase adjustment)
|
* Skip: number of PCM samples to skip at the beginning (for sync phase adjustment)
|
||||||
* Redraw: false = Apply windowing and FFT to the signal, true = Redraw from cached FFT data
|
* Redraw: FALSE = Apply windowing and FFT to the signal, TRUE = Redraw from cached FFT data
|
||||||
* returns: true when finished, false when aborted
|
* returns: TRUE when finished, FALSE when aborted
|
||||||
*/
|
*/
|
||||||
bool GetVideo(guchar Mode, double Rate, int Skip, bool Redraw) {
|
gboolean GetVideo(guchar Mode, double Rate, int Skip, gboolean Redraw) {
|
||||||
|
|
||||||
guint MaxBin = 0;
|
guint MaxBin = 0;
|
||||||
guint VideoPlusNoiseBins=0, ReceiverBins=0, NoiseOnlyBins=0;
|
guint VideoPlusNoiseBins=0, ReceiverBins=0, NoiseOnlyBins=0;
|
||||||
|
@ -80,7 +79,7 @@ bool GetVideo(guchar Mode, double Rate, int Skip, bool Redraw) {
|
||||||
// Initialize pixbuffer
|
// Initialize pixbuffer
|
||||||
if (!Redraw) {
|
if (!Redraw) {
|
||||||
g_object_unref(pixbuf_rx);
|
g_object_unref(pixbuf_rx);
|
||||||
pixbuf_rx = gdk_pixbuf_new (GDK_COLORSPACE_RGB, false, 8, ModeSpec[Mode].ImgWidth, ModeSpec[Mode].ImgHeight);
|
pixbuf_rx = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, ModeSpec[Mode].ImgWidth, ModeSpec[Mode].ImgHeight);
|
||||||
gdk_pixbuf_fill(pixbuf_rx, 0);
|
gdk_pixbuf_fill(pixbuf_rx, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,7 +98,7 @@ bool GetVideo(guchar Mode, double Rate, int Skip, bool Redraw) {
|
||||||
Length = ModeSpec[Mode].LineLen * ModeSpec[Mode].ImgHeight * 44100;
|
Length = ModeSpec[Mode].LineLen * ModeSpec[Mode].ImgHeight * 44100;
|
||||||
SyncTargetBin = GetBin(1200+CurrentPic.HedrShift, FFTLen);
|
SyncTargetBin = GetBin(1200+CurrentPic.HedrShift, FFTLen);
|
||||||
LopassBin = GetBin(5000, FFTLen);
|
LopassBin = GetBin(5000, FFTLen);
|
||||||
Abort = false;
|
Abort = FALSE;
|
||||||
SyncSampleNum = 0;
|
SyncSampleNum = 0;
|
||||||
|
|
||||||
// Loop through signal
|
// Loop through signal
|
||||||
|
@ -143,8 +142,8 @@ bool GetVideo(guchar Mode, double Rate, int Skip, bool Redraw) {
|
||||||
|
|
||||||
// If there is more than twice the amount of power per Hz in the
|
// If there is more than twice the amount of power per Hz in the
|
||||||
// sync band than in the video band, we have a sync signal here
|
// sync band than in the video band, we have a sync signal here
|
||||||
if (Psync > 2*Praw) HasSync[SyncSampleNum] = true;
|
if (Psync > 2*Praw) HasSync[SyncSampleNum] = TRUE;
|
||||||
else HasSync[SyncSampleNum] = false;
|
else HasSync[SyncSampleNum] = FALSE;
|
||||||
|
|
||||||
NextSyncTime += SYNCPIXLEN;
|
NextSyncTime += SYNCPIXLEN;
|
||||||
SyncSampleNum ++;
|
SyncSampleNum ++;
|
||||||
|
@ -394,12 +393,12 @@ bool GetVideo(guchar Mode, double Rate, int Skip, bool Redraw) {
|
||||||
pcm.PeakVal = 0;
|
pcm.PeakVal = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Abort) return false;
|
if (Abort) return FALSE;
|
||||||
|
|
||||||
pcm.WindowPtr ++;
|
pcm.WindowPtr ++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return TRUE;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
21
vis.c
21
vis.c
|
@ -1,5 +1,4 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdbool.h>
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <alsa/asoundlib.h>
|
#include <alsa/asoundlib.h>
|
||||||
|
@ -24,7 +23,7 @@ guchar GetVIS () {
|
||||||
//gushort pcm.PeakVal = 0;
|
//gushort pcm.PeakVal = 0;
|
||||||
guint FFTLen = 2048, i=0, j=0, k=0, MaxBin = 0;
|
guint FFTLen = 2048, i=0, j=0, k=0, MaxBin = 0;
|
||||||
double Power[2048] = {0}, HedrBuf[100] = {0}, tone[100] = {0}, Hann[882] = {0};
|
double Power[2048] = {0}, HedrBuf[100] = {0}, tone[100] = {0}, Hann[882] = {0};
|
||||||
bool gotvis = false;
|
gboolean gotvis = FALSE;
|
||||||
guchar Bit[8] = {0}, ParityBit = 0;
|
guchar Bit[8] = {0}, ParityBit = 0;
|
||||||
|
|
||||||
for (i = 0; i < FFTLen; i++) in[i] = 0;
|
for (i = 0; i < FFTLen; i++) in[i] = 0;
|
||||||
|
@ -32,7 +31,7 @@ guchar GetVIS () {
|
||||||
// Create 20ms Hann window
|
// Create 20ms Hann window
|
||||||
for (i = 0; i < 882; i++) Hann[i] = 0.5 * (1 - cos( (2 * M_PI * (double)i) / 881 ) );
|
for (i = 0; i < 882; i++) Hann[i] = 0.5 * (1 - cos( (2 * M_PI * (double)i) / 881 ) );
|
||||||
|
|
||||||
ManualActivated = false;
|
ManualActivated = FALSE;
|
||||||
|
|
||||||
printf("Waiting for header\n");
|
printf("Waiting for header\n");
|
||||||
|
|
||||||
|
@ -40,7 +39,7 @@ guchar GetVIS () {
|
||||||
gtk_statusbar_push( GTK_STATUSBAR(gui.statusbar), 0, "Listening" );
|
gtk_statusbar_push( GTK_STATUSBAR(gui.statusbar), 0, "Listening" );
|
||||||
gdk_threads_leave();
|
gdk_threads_leave();
|
||||||
|
|
||||||
while ( true ) {
|
while ( TRUE ) {
|
||||||
|
|
||||||
if (Abort || ManualResync) return(0);
|
if (Abort || ManualResync) return(0);
|
||||||
|
|
||||||
|
@ -78,7 +77,7 @@ guchar GetVIS () {
|
||||||
// Is there a pattern that looks like (the end of) a calibration header + VIS?
|
// Is there a pattern that looks like (the end of) a calibration header + VIS?
|
||||||
// Tolerance ±25 Hz
|
// Tolerance ±25 Hz
|
||||||
CurrentPic.HedrShift = 0;
|
CurrentPic.HedrShift = 0;
|
||||||
gotvis = false;
|
gotvis = FALSE;
|
||||||
for (i = 0; i < 3; i++) {
|
for (i = 0; i < 3; i++) {
|
||||||
if (CurrentPic.HedrShift != 0) break;
|
if (CurrentPic.HedrShift != 0) break;
|
||||||
for (j = 0; j < 3; j++) {
|
for (j = 0; j < 3; j++) {
|
||||||
|
@ -93,12 +92,12 @@ guchar GetVIS () {
|
||||||
|
|
||||||
// Attempt to read VIS
|
// Attempt to read VIS
|
||||||
|
|
||||||
gotvis = true;
|
gotvis = TRUE;
|
||||||
for (k = 0; k < 8; k++) {
|
for (k = 0; k < 8; k++) {
|
||||||
if (tone[6*3+i+3*k] > tone[0+j] - 625 && tone[6*3+i+3*k] < tone[0+j] - 575) Bit[k] = 0;
|
if (tone[6*3+i+3*k] > tone[0+j] - 625 && tone[6*3+i+3*k] < tone[0+j] - 575) Bit[k] = 0;
|
||||||
else if (tone[6*3+i+3*k] > tone[0+j] - 825 && tone[6*3+i+3*k] < tone[0+j] - 775) Bit[k] = 1;
|
else if (tone[6*3+i+3*k] > tone[0+j] - 825 && tone[6*3+i+3*k] < tone[0+j] - 775) Bit[k] = 1;
|
||||||
else { // erroneous bit
|
else { // erroneous bit
|
||||||
gotvis = false;
|
gotvis = FALSE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,10 +116,10 @@ guchar GetVIS () {
|
||||||
|
|
||||||
if (Parity != ParityBit) {
|
if (Parity != ParityBit) {
|
||||||
printf(" Parity fail\n");
|
printf(" Parity fail\n");
|
||||||
gotvis = false;
|
gotvis = FALSE;
|
||||||
} else if (VISmap[VIS] == UNKNOWN) {
|
} else if (VISmap[VIS] == UNKNOWN) {
|
||||||
printf(" Unknown VIS\n");
|
printf(" Unknown VIS\n");
|
||||||
gotvis = false;
|
gotvis = FALSE;
|
||||||
} else {
|
} else {
|
||||||
gdk_threads_enter();
|
gdk_threads_enter();
|
||||||
gtk_combo_box_set_active (GTK_COMBO_BOX(gui.combo_mode), VISmap[VIS]-1);
|
gtk_combo_box_set_active (GTK_COMBO_BOX(gui.combo_mode), VISmap[VIS]-1);
|
||||||
|
@ -140,8 +139,8 @@ guchar GetVIS () {
|
||||||
if (ManualActivated) {
|
if (ManualActivated) {
|
||||||
|
|
||||||
gdk_threads_enter();
|
gdk_threads_enter();
|
||||||
gtk_widget_set_sensitive( gui.frame_manual, false );
|
gtk_widget_set_sensitive( gui.frame_manual, FALSE );
|
||||||
gtk_widget_set_sensitive( gui.combo_card, false );
|
gtk_widget_set_sensitive( gui.combo_card, FALSE );
|
||||||
gdk_threads_leave();
|
gdk_threads_leave();
|
||||||
|
|
||||||
selmode = gtk_combo_box_get_active (GTK_COMBO_BOX(gui.combo_mode)) + 1;
|
selmode = gtk_combo_box_get_active (GTK_COMBO_BOX(gui.combo_mode)) + 1;
|
||||||
|
|
Ładowanie…
Reference in New Issue