From 4391e4e70162cc0ad61fc90ff341c3686998ef4b Mon Sep 17 00:00:00 2001 From: FreeArtMan Date: Sun, 4 Oct 2015 17:32:43 +0100 Subject: Terminal waterfall fixed, fft scaling --- test/ui_tui_waterfall.c | 57 +++++++++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 26 deletions(-) (limited to 'test') diff --git a/test/ui_tui_waterfall.c b/test/ui_tui_waterfall.c index fe009eb..bc4f297 100644 --- a/test/ui_tui_waterfall.c +++ b/test/ui_tui_waterfall.c @@ -12,7 +12,7 @@ #define CENTER_FREQ 446500000 #define FFT_LEVEL 10 #define FFT_SIZE (1 << FFT_LEVEL) -#define BUF_LENGHT (2 * FFT_SIZE) +#define SAMPLE_LENGHT (2 * FFT_SIZE) #define PRESCALE 8 #define POSTSCALE 2 @@ -103,28 +103,30 @@ int sdr_get_samples( uint8_t *buf, int len ) //better to have size size mod olen == 0 int normalise( uint8_t *ibuf, int ilen, uint8_t *obuf, int olen ) { - int i,j,m; - int ppi; + uint32_t i,j,m; + uint32_t ppi; + uint32_t sum; + div_t d; if ( ilen >= olen ) { - ppi = ilen / olen; + d = div(ilen,olen); + ppi = d.quot; + if (d.rem > 0) + ppi += 1; } else { + printf("Input buffer smaller ther output buffer\n"); return -1; } + m = 0; i = 0; - while ( (i < ilen) && (m < olen) ) + for (i=0,m=0; i < ilen+ppi; i += ppi, m++) { - uint32_t sum=0; - for ( j=0; jw; buf = malloc( buf_len ); - sample_len = BUF_LENGHT; + sample_len = SAMPLE_LENGHT; sample_buf = malloc( sample_len ); srand(0); //fake seed - for ( i=0; i<20;i++ ) + for ( i=0; i<400;i++ ) { //for (j=0; j