From 2707ecc8ab32164060de53e4774e682a718aecb3 Mon Sep 17 00:00:00 2001 From: F5OEO Date: Wed, 21 Mar 2018 10:06:22 +0000 Subject: [PATCH] Use new blocking method --- src/fm_mpx.c | 6 ++++-- src/pi_fm_rds.cpp | 36 ++++++++++++------------------------ 2 files changed, 16 insertions(+), 26 deletions(-) diff --git a/src/fm_mpx.c b/src/fm_mpx.c index e185bcc..23870ad 100644 --- a/src/fm_mpx.c +++ b/src/fm_mpx.c @@ -118,6 +118,7 @@ int fm_mpx_open(char *filename, size_t len) { // Choose a cutoff frequency for the low-pass FIR filter float cutoff_freq = 15700; + //float cutoff_freq = 3000; //For NBFM if(in_samplerate/2 < cutoff_freq) cutoff_freq = in_samplerate/2 * .8; @@ -236,6 +237,7 @@ int fm_mpx_get_samples(float *mpx_buffer) { // Sanity checks if ( iphase < 0 ) {iphase=0; printf("low\n"); }// Seems to run faster with these checks in place if ( iphase >= FIR_PHASES ) {iphase=FIR_PHASES-2; printf("high\n"); } + if( channels > 1 ) { for(int fi=0; fiGetBufferAvailable(); - - if (free_slots >= DATA_SIZE) - { - int Index=fmmod->GetUserMemIndex(); - // get more baseband samples if necessary - - if( fm_mpx_get_samples(data) < 0 ) { + if( fm_mpx_get_samples(data) < 0 ) { terminate(0); } data_len = DATA_SIZE; - - - - for(int i=0;i< data_len;i++) + for(int i=0;i< data_len;i++) { - float dval = data[i]*deviation_scale_factor; - //printf("%f\n",dval); - fmmod->SetFrequencySample(Index+i,dval); + + devfreq[i] = data[i]*deviation_scale_factor; + + } - - } - + fmmod->SetFrequencySamples(devfreq,data_len); } return 0; @@ -286,8 +274,8 @@ int main(int argc, char **argv) { } else if(strcmp("-freq", arg)==0 && param != NULL) { i++; carrier_freq = 1e6 * atof(param); - if(carrier_freq < 76e6 || carrier_freq > 108e6) - fatal("Incorrect frequency specification. Must be in megahertz, of the form 107.9, between 76 and 108.\n"); + //if(carrier_freq < 76e6 || carrier_freq > 108e6) + // fatal("Incorrect frequency specification. Must be in megahertz, of the form 107.9, between 76 and 108.\n"); } else if(strcmp("-pi", arg)==0 && param != NULL) { i++; pi = (uint16_t) strtol(param, NULL, 16);