From 5ff119a56ce4dd34a8268fdc9048fc50c881206d Mon Sep 17 00:00:00 2001 From: drowe67 Date: Tue, 21 Oct 2014 19:54:17 +0000 Subject: [PATCH] patch from Alfred to support floats on demod input for FreeDV API git-svn-id: https://svn.code.sf.net/p/freetel/code@1905 01035d8c-6547-0410-b346-abe4f91aad63 --- codec2-dev/src/freedv_api.c | 18 +++++++++++++++++- codec2-dev/src/freedv_api.h | 1 + 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/codec2-dev/src/freedv_api.c b/codec2-dev/src/freedv_api.c index c20f5709..db3f72f1 100644 --- a/codec2-dev/src/freedv_api.c +++ b/codec2-dev/src/freedv_api.c @@ -284,7 +284,23 @@ int freedv_nin(struct freedv *f) { \*---------------------------------------------------------------------------*/ +// short version + int freedv_rx(struct freedv *f, short speech_out[], short demod_in[]) { + +float rxdata[FDMDV_MAX_SAMPLES_PER_FRAME]; +int i; + + for(i=0; inin; i++) rxdata[i] = (float)demod_in[i]/FDMDV_SCALE; + + return freedv_floatrx(f, speech_out, rxdata); + +} + + +// float version + +int freedv_floatrx(struct freedv *f, short speech_out[], float demod_in[]) { COMP rx_fdm[FDMDV_MAX_SAMPLES_PER_FRAME]; int bits_per_codec_frame, bytes_per_codec_frame, bits_per_fdmdv_frame; int reliable_sync_bit, i, j, bit, byte, nin_prev, nout; @@ -297,7 +313,7 @@ int freedv_rx(struct freedv *f, short speech_out[], short demod_in[]) { bits_per_fdmdv_frame = fdmdv_bits_per_frame(f->fdmdv); for(i=0; inin; i++) { - rx_fdm[i].real = (float)demod_in[i]/FDMDV_SCALE; + rx_fdm[i].real = demod_in[i]; rx_fdm[i].imag = 0; } diff --git a/codec2-dev/src/freedv_api.h b/codec2-dev/src/freedv_api.h index 909340e2..77a5e3d7 100644 --- a/codec2-dev/src/freedv_api.h +++ b/codec2-dev/src/freedv_api.h @@ -74,5 +74,6 @@ void freedv_close(struct freedv *freedv); void freedv_tx(struct freedv *f, short mod_out[], short speech_in[]); int freedv_nin(struct freedv *f); int freedv_rx(struct freedv *f, short speech_out[], short demod_in[]); +int freedv_floatrx(struct freedv *f, short speech_out[], float demod_in[]); #endif -- 2.25.1