kopia lustrzana https://github.com/windytan/slowrx
pull/1/merge
rodzic
1cda00e00b
commit
050d878072
3
slowrx.c
3
slowrx.c
|
@ -42,7 +42,7 @@ void *Cam() {
|
|||
while (1) {
|
||||
|
||||
//PcmInStream = popen( "sox -q -t alsa hw:0 -t .raw -b 16 -c 1 -e signed-integer -r 44100 -L - 2>/dev/null", "r");
|
||||
PcmInStream = popen( "sox -q SSTV_sunset_audio.ogg -t raw -b 16 -c 1 -e signed-integer -r 44100 -L - 2>/dev/null", "r");
|
||||
PcmInStream = popen( "sox -q iss.ogg -t raw -b 16 -c 1 -e signed-integer -r 44100 -L - 2>/dev/null", "r");
|
||||
|
||||
// Wait for VIS
|
||||
HedrShift = 0;
|
||||
|
@ -127,6 +127,7 @@ void *Cam() {
|
|||
LumFile = fopen(lumfilename,"w");
|
||||
if (LumFile == NULL) {
|
||||
perror("Unable to open luma file for writing");
|
||||
while (1);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
|
19
sync.c
19
sync.c
|
@ -14,10 +14,10 @@
|
|||
*/
|
||||
double FindSync (unsigned int Length, int Mode, double Rate, int *Skip) {
|
||||
|
||||
unsigned int i, s, j, TotPix;
|
||||
unsigned int i, s, TotPix;
|
||||
double NextImgSample;
|
||||
double t=0, slantAngle;
|
||||
unsigned char SyncImg[SYNCW][500];
|
||||
unsigned char SyncImg[SYNCW][630];
|
||||
int x,y;
|
||||
|
||||
double Praw, Psync;
|
||||
|
@ -39,7 +39,7 @@ double FindSync (unsigned int Length, int Mode, double Rate, int *Skip) {
|
|||
unsigned short int xAcc[SYNCW] = {0};
|
||||
unsigned short int xMax = 0;
|
||||
unsigned short int Leftmost;
|
||||
double Pwr[2048], TotPwr=0;
|
||||
double Pwr[2048];
|
||||
|
||||
// FFT plan
|
||||
fftw_plan Plan;
|
||||
|
@ -63,11 +63,13 @@ double FindSync (unsigned int Length, int Mode, double Rate, int *Skip) {
|
|||
Plan = fftw_plan_r2r_1d(FFTLen, in, out, FFTW_FORWARD, FFTW_ESTIMATE);
|
||||
|
||||
// Create 50-point Hann window
|
||||
double Hann[50] = {0};
|
||||
double Hann[50];
|
||||
for (i = 0; i < 50; i++) Hann[i] = 0.5 * (1 - cos( 2 * M_PI * i / 49.0) );
|
||||
|
||||
// Zero fill input array
|
||||
for (i = 0; i < FFTLen; i++) in[i] = 0;
|
||||
memset(in, 0, FFTLen * sizeof(in[0]));
|
||||
|
||||
int LopassBin = GetBin(3000, FFTLen, 44100);
|
||||
|
||||
printf("power est.\n");
|
||||
|
||||
|
@ -75,19 +77,19 @@ double FindSync (unsigned int Length, int Mode, double Rate, int *Skip) {
|
|||
for (s = 0; s < Length; s+=50) {
|
||||
|
||||
// Hann window
|
||||
for (i = 0; i < 50; i++) in[i] = PCM[s+i] * 32768 * Hann[i];
|
||||
for (i = 0; i < 50; i++) in[i] = PCM[s+i] * Hann[i];
|
||||
|
||||
// FFT
|
||||
fftw_execute(Plan);
|
||||
|
||||
// Power in the whole band
|
||||
Praw = 0;
|
||||
for (i=0;i<GetBin(3000, FFTLen, 44100);i++) {
|
||||
for (i=0;i<LopassBin;i++) {
|
||||
Pwr[i] = pow(out[i], 2) + pow(out[FFTLen-i], 2);
|
||||
Praw += Pwr[i];
|
||||
}
|
||||
|
||||
Praw /= (FFTLen/2.0)*(3000/22050.0);
|
||||
Praw /= (FFTLen/2.0) * ( LopassBin/(FFTLen/2.0));
|
||||
|
||||
// Power around the sync band
|
||||
i = GetBin(1200+HedrShift, FFTLen, 44100);
|
||||
|
@ -107,7 +109,6 @@ double FindSync (unsigned int Length, int Mode, double Rate, int *Skip) {
|
|||
|
||||
printf("hough\n");
|
||||
|
||||
|
||||
// Repeat until slant < 0.5° or until we give up
|
||||
while (1) {
|
||||
|
||||
|
|
11
video.c
11
video.c
|
@ -1,6 +1,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#include <fftw3.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
|
@ -210,18 +211,18 @@ int GetVideo(int Mode, double Rate, int Skip, int FShift, int Adaptive, int Redr
|
|||
// Calculate video-plus-noise power (1500-2300 Hz)
|
||||
|
||||
for (n = GetBin(1500+HedrShift, 2048, 44100); n <= GetBin(2300+HedrShift, 2048, 44100); n++) {
|
||||
Pvideo_plus_noise += pow(SNR_out[n], 2);// + pow(SNR_out[2048 - n], 2);
|
||||
Pvideo_plus_noise += pow(SNR_out[n], 2) + pow(SNR_out[2048 - n], 2);
|
||||
VideoPlusNoiseBins++;
|
||||
}
|
||||
|
||||
// Calculate noise-only power (400-800 Hz + 2700-3400 Hz)
|
||||
|
||||
for (n = GetBin(400+HedrShift, 2048, 44100); n <= GetBin(800+HedrShift, 2048, 44100); n++) {
|
||||
Pnoise_only += pow(SNR_out[n], 2);// + pow(SNR_out[2048 - n], 2);
|
||||
Pnoise_only += pow(SNR_out[n], 2) + pow(SNR_out[2048 - n], 2);
|
||||
NoiseOnlyBins++;
|
||||
}
|
||||
for (n = GetBin(2700+HedrShift, 2048, 44100); n <= GetBin(3400+HedrShift, 2048, 44100); n++) {
|
||||
Pnoise_only += pow(SNR_out[n], 2);// + pow(SNR_out[2048 - n], 2);
|
||||
Pnoise_only += pow(SNR_out[n], 2) + pow(SNR_out[2048 - n], 2);
|
||||
NoiseOnlyBins++;
|
||||
}
|
||||
|
||||
|
@ -271,6 +272,7 @@ int GetVideo(int Mode, double Rate, int Skip, int FShift, int Adaptive, int Redr
|
|||
AvgSNR = ((AvgSNR * NumSNR) + SNR) / (NumSNR + 1);
|
||||
NumSNR++;
|
||||
|
||||
memset(in, 0, sizeof(double)*1024);
|
||||
|
||||
// Select window function based on SNR
|
||||
|
||||
|
@ -286,9 +288,6 @@ int GetVideo(int Mode, double Rate, int Skip, int FShift, int Adaptive, int Redr
|
|||
for (i = 0; i < 37; i++) in[i] = (Sample + i >= (37>>1) ? PCM[Sample + i - (37 >> 1)] * Cheb[i] : 0);
|
||||
}
|
||||
|
||||
// Zero padding
|
||||
for (i = WinLength; i < FFTLen; i++) in[i] = 0;
|
||||
|
||||
// FFT
|
||||
if (FFTLen == 1024) fftw_execute(BigPlan);
|
||||
else fftw_execute(Plan);
|
||||
|
|
1
vis.c
1
vis.c
|
@ -163,7 +163,6 @@ int GetVIS () {
|
|||
gtk_label_set_markup(GTK_LABEL(infolabel), infostr);
|
||||
gdk_threads_leave();
|
||||
} else {
|
||||
printf(" Parity check OK\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue