kopia lustrzana https://github.com/windytan/slowrx
commit
e7f58dc03b
|
@ -0,0 +1,3 @@
|
|||
slowrx
|
||||
rx
|
||||
rx-lum
|
2
Makefile
2
Makefile
|
@ -11,4 +11,4 @@ slowrx: common.h common.c slowrx.c gui.c video.c sync.c vis.c modespec.c pcm.c f
|
|||
$(CC) $(CFLAGS) $(OFLAGS) common.c modespec.c gui.c video.c vis.c sync.c pcm.c fsk.c slowrx.c -o slowrx -lfftw3 -lm `pkg-config --cflags --libs gtk+-3.0` -lgthread-2.0 -lpnglite -lasound
|
||||
|
||||
clean:
|
||||
rm -f *.o
|
||||
rm -f slowrx
|
||||
|
|
26
pcm.c
26
pcm.c
|
@ -84,17 +84,25 @@ void initPcmDevice() {
|
|||
|
||||
gtk_combo_box_set_active(GTK_COMBO_BOX(cardcombo), 0);
|
||||
|
||||
if (cardnum == 0) {
|
||||
sprintf(pcm_name,"default");
|
||||
} else {
|
||||
sprintf(pcm_name,"hw:%d",cardnum-1);
|
||||
}
|
||||
|
||||
snd_pcm_hw_params_alloca(&hwparams);
|
||||
|
||||
if (snd_pcm_open(&pcm_handle, pcm_name, PcmInStream, 0) < 0) {
|
||||
fprintf(stderr, "ALSA: Error opening PCM device %s\n", pcm_name);
|
||||
exit(EXIT_FAILURE);
|
||||
while (true) {
|
||||
if (cardnum == 0) {
|
||||
sprintf(pcm_name,"default");
|
||||
} else {
|
||||
sprintf(pcm_name,"hw:%d",cardnum-1);
|
||||
}
|
||||
|
||||
if (snd_pcm_open(&pcm_handle, pcm_name, PcmInStream, 0) < 0) {
|
||||
fprintf(stderr, "ALSA: Error opening PCM device %s\n", pcm_name);
|
||||
if (cardnum == 0) {
|
||||
exit(EXIT_FAILURE);
|
||||
} else {
|
||||
cardnum--;
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Init hwparams with full configuration space */
|
||||
|
|
15
slowrx.c
15
slowrx.c
|
@ -9,6 +9,8 @@
|
|||
#include <stdbool.h>
|
||||
#include <math.h>
|
||||
#include <time.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <pnglite.h>
|
||||
|
@ -19,6 +21,17 @@
|
|||
|
||||
#include "common.h"
|
||||
|
||||
void ensure_dir_exists(const char *dir) {
|
||||
struct stat buf;
|
||||
|
||||
int i = stat(dir, &buf);
|
||||
if (i != 0) {
|
||||
if (mkdir(dir, 0777) != 0) {
|
||||
perror("Unable to create directory for output file");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void *Listen() {
|
||||
|
||||
|
@ -168,6 +181,7 @@ void *Listen() {
|
|||
|
||||
setVU(0,-100);
|
||||
|
||||
ensure_dir_exists("rx-lum");
|
||||
LumFile = fopen(lumfilename,"w");
|
||||
if (LumFile == NULL) {
|
||||
perror("Unable to open luma file for writing");
|
||||
|
@ -184,6 +198,7 @@ void *Listen() {
|
|||
scaledpb = gdk_pixbuf_scale_simple (RxPixbuf, ModeSpec[Mode].ImgWidth, ModeSpec[Mode].ImgHeight * ModeSpec[Mode].YScale, GDK_INTERP_HYPER);
|
||||
pixels = gdk_pixbuf_get_pixels(scaledpb);
|
||||
|
||||
ensure_dir_exists("rx");
|
||||
png_open_file_write(&png, pngfilename);
|
||||
png_set_data(&png, ModeSpec[Mode].ImgWidth, ModeSpec[Mode].ImgHeight * ModeSpec[Mode].YScale, 8, PNG_TRUECOLOR, pixels);
|
||||
png_close_file(&png);
|
||||
|
|
Ładowanie…
Reference in New Issue