From efe2c849bc2046c700b138f959672cf374b758c0 Mon Sep 17 00:00:00 2001 From: drowe67 Date: Sun, 26 Jul 2015 23:21:57 +0000 Subject: [PATCH] fixed bug in 7500-8000Hz resampler git-svn-id: https://svn.code.sf.net/p/freetel/code@2244 01035d8c-6547-0410-b346-abe4f91aad63 --- codec2-dev/src/fdmdv.c | 2 +- codec2-dev/src/freedv_api.c | 29 +++++++++++++++++++++++------ codec2-dev/src/freedv_api.h | 2 +- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/codec2-dev/src/fdmdv.c b/codec2-dev/src/fdmdv.c index 7ff16c59..bab288d5 100644 --- a/codec2-dev/src/fdmdv.c +++ b/codec2-dev/src/fdmdv.c @@ -422,7 +422,7 @@ void tx_filter_and_upconvert(COMP tx_fdm[], int Nc, COMP tx_symbols[], for(c=0; ctest_frames = f->smooth_symbols = 0; f->freedv_put_error_pattern = NULL; f->error_pattern_callback_state = NULL; - f->snr_squelch_thresh = 2.0; - f->squelch_en = 1; if (mode == FREEDV_MODE_1600) { + f->snr_squelch_thresh = 2.0; + f->squelch_en = 1; Nc = 16; f->tx_sync_bit = 0; codec2_mode = CODEC2_MODE_1300; @@ -103,6 +103,8 @@ struct freedv *freedv_open(int mode) { } if (mode == FREEDV_MODE_700) { + f->snr_squelch_thresh = 0.0; + f->squelch_en = 0; codec2_mode = CODEC2_MODE_700; f->cohpsk = cohpsk_create(); f->nin = COHPSK_NOM_SAMPLES_PER_FRAME; @@ -729,18 +731,33 @@ int freedv_comprx(struct freedv *f, short speech_out[], COMP demod_in[]) { } else { float t,a,b,s; - int t1,t2; + int t1; /* if not in sync pass through analog samples */ /* this lets us "hear" whats going on, e.g. during tuning */ /* need to linearly interp as Fs in and out slightly different */ + /* this is a bit crude (compared to analog FreeDV mode) + but it's probably OK for a tuning aid off air signals */ for(i=0, t=0.0; in_speech_samples; i++, t+=(float)f->modem_sample_rate/FS) { - t1 = floor(t); t2 = ceil(t); + t1 = floor(t); a = t - t1; - b = t2 - t1; - s = b*demod_in[t1].real + a*demod_in[t2].real; + b = 1.0 - a; + + /* avoid running past end of input array */ + + if (t1 < (f->nin-1)) + s = b*demod_in[t1].real + a*demod_in[t1+1].real; + else + s = b*demod_in[t1].real; + speech_out[i] = FDMDV_SCALE*s; + /* + if ((i < 10) || (i > 590)) { + printf("i: %d t: %f t1: %d a: %f b: %f s[t1]: %f s[t2]: %f s: %f\n", + i,t,t1,a,b,demod_in[t1].real, demod_in[t1+1].real, s); + } + */ } nout = f->n_speech_samples; //fprintf(stderr, "%d %d %d\n", f->n_speech_samples, speech_out[0], speech_out[nin_prev-1]); diff --git a/codec2-dev/src/freedv_api.h b/codec2-dev/src/freedv_api.h index 556e01ce..c6921ed2 100644 --- a/codec2-dev/src/freedv_api.h +++ b/codec2-dev/src/freedv_api.h @@ -50,7 +50,7 @@ struct freedv { struct COHPSK *cohpsk; int n_speech_samples; - int n_nom_modem_samples; // size of tx and most rx modenm sample buffers + int n_nom_modem_samples; // size of tx and most rx modem sample buffers int n_max_modem_samples; // make your rx modem sample buffers this big int modem_sample_rate; // ATM caller is responsible for meeting this (TBC) -- 2.25.1