Implement averaged FFT
This commit is contained in:
parent
84e00184af
commit
f9d6d22fe2
3 changed files with 53 additions and 0 deletions
38
csdr.c
38
csdr.c
|
@ -1299,6 +1299,44 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!strcmp(argv[1],"logaveragepower_cf"))
|
||||||
|
{
|
||||||
|
bigbufs=1;
|
||||||
|
if(argc<=4) return badsyntax("need required parameters (add_db, table_size, avgnumber)");
|
||||||
|
float add_db=0;
|
||||||
|
int avgnumber=0;
|
||||||
|
int fft_size=0;
|
||||||
|
|
||||||
|
sscanf(argv[2],"%g",&add_db);
|
||||||
|
sscanf(argv[3],"%d",&fft_size);
|
||||||
|
sscanf(argv[4],"%d",&avgnumber);
|
||||||
|
|
||||||
|
if(!getbufsize()) return -2; //dummy
|
||||||
|
if(!sendbufsize(initialize_buffers())) return -2;
|
||||||
|
|
||||||
|
if(fft_size != the_bufsize) return -2;
|
||||||
|
|
||||||
|
//fprintf(stderr, "logaveragepower_cf %f %d=%d %d\n", add_db, fft_size, the_bufsize, avgnumber);
|
||||||
|
add_db -= 10*log10(avgnumber);
|
||||||
|
for(;;)
|
||||||
|
{
|
||||||
|
int i,n;
|
||||||
|
for(i = 0; i < the_bufsize; i++) {
|
||||||
|
output_buffer[i] = 0;
|
||||||
|
}
|
||||||
|
FEOF_CHECK;
|
||||||
|
for(n = 0; n < avgnumber; n++) {
|
||||||
|
FREAD_C;
|
||||||
|
//fprintf(stderr, "averaged %d\n", n);
|
||||||
|
accumulate_power_cf((complexf*)input_buffer, output_buffer, the_bufsize);
|
||||||
|
}
|
||||||
|
log_ff(NULL, output_buffer, the_bufsize, add_db);
|
||||||
|
FWRITE_R;
|
||||||
|
TRY_YIELD;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if(!strcmp(argv[1],"fft_exchange_sides_ff"))
|
if(!strcmp(argv[1],"fft_exchange_sides_ff"))
|
||||||
{
|
{
|
||||||
if(argc<=2) return badsyntax("need required parameters (fft_size)");
|
if(argc<=2) return badsyntax("need required parameters (fft_size)");
|
||||||
|
|
13
libcsdr.c
13
libcsdr.c
|
@ -949,6 +949,19 @@ void logpower_cf(complexf* input, float* output, int size, float add_db)
|
||||||
for(int i=0;i<size;i++) output[i]=10*output[i]+add_db; //@logpower_cf: pass 3
|
for(int i=0;i<size;i++) output[i]=10*output[i]+add_db; //@logpower_cf: pass 3
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void accumulate_power_cf(complexf* input, float* output, int size)
|
||||||
|
{
|
||||||
|
for(int i=0;i<size;i++) output[i] += iof(input,i)*iof(input,i) + qof(input,i)*qof(input,i); //@logpower_cf: pass 1
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void log_ff(float* input, float* output, int size, float add_db) {
|
||||||
|
for(int i=0;i<size;i++) output[i]=log10(output[i]); //@logpower_cf: pass 2
|
||||||
|
|
||||||
|
for(int i=0;i<size;i++) output[i]=10*output[i]+add_db; //@logpower_cf: pass 3
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
_____ _ _
|
_____ _ _
|
||||||
| __ \ | | (_)
|
| __ \ | | (_)
|
||||||
|
|
|
@ -138,6 +138,8 @@ void rational_resampler_get_lowpass_f(float* output, int output_size, int interp
|
||||||
void apply_window_c(complexf* input, complexf* output, int size, window_t window);
|
void apply_window_c(complexf* input, complexf* output, int size, window_t window);
|
||||||
void apply_window_f(float* input, float* output, int size, window_t window);
|
void apply_window_f(float* input, float* output, int size, window_t window);
|
||||||
void logpower_cf(complexf* input, float* output, int size, float add_db);
|
void logpower_cf(complexf* input, float* output, int size, float add_db);
|
||||||
|
void accumulate_power_cf(complexf* input, float* output, int size);
|
||||||
|
void log_ff(float* input, float* output, int size, float add_db);
|
||||||
|
|
||||||
typedef struct fractional_decimator_ff_s
|
typedef struct fractional_decimator_ff_s
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue