From 05cb9cfc3c45b8d39e449de075105cb80302d39a Mon Sep 17 00:00:00 2001 From: drowe67 Date: Tue, 24 Apr 2018 07:02:49 +0000 Subject: [PATCH] adjusted ofdm levels to be the same as fdmdv - C git-svn-id: https://svn.code.sf.net/p/freetel/code@3524 01035d8c-6547-0410-b346-abe4f91aad63 --- codec2-dev/src/codec2_ofdm.h | 2 ++ codec2-dev/src/freedv_api.c | 30 ++++++++++++++++++------------ codec2-dev/src/ofdm_demod.c | 3 +-- codec2-dev/src/ofdm_mod.c | 6 ++---- 4 files changed, 23 insertions(+), 18 deletions(-) diff --git a/codec2-dev/src/codec2_ofdm.h b/codec2-dev/src/codec2_ofdm.h index d2a4b5a4..3fc69833 100644 --- a/codec2-dev/src/codec2_ofdm.h +++ b/codec2-dev/src/codec2_ofdm.h @@ -41,6 +41,8 @@ extern "C" { /* Defines */ +#define OFDM_AMP_SCALE (2E5*1.1491/1.06) /* use to scale to 16 bit short */ + struct OFDM; /* Default configuration for '700D' mode */ diff --git a/codec2-dev/src/freedv_api.c b/codec2-dev/src/freedv_api.c index eb21a47f..2333abc2 100644 --- a/codec2-dev/src/freedv_api.c +++ b/codec2-dev/src/freedv_api.c @@ -68,9 +68,11 @@ * Changed all input and output sample rates to 8000 sps. Rates for FREEDV_MODE_700 and 700B were 7500. */ -#define NORM_PWR_COHPSK 1.74 /* experimentally derived fudge factor to normalise power for cohpsk modes */ -#define NORM_PWR_FSK 0.193 /* experimentally derived fudge factor to normalise power for fsk modes */ -#define NORM_PWR_OFDM 10.00 /* todo: experimentally derived fudge factor to normalise power for OFDM modes */ +/* experimentally derived fudge factors to normalise power across modes */ + +#define NORM_PWR_COHPSK 1.74 +#define NORM_PWR_FSK 0.193 +#define NORM_PWR_OFDM 1.00 /* OFDM payload data test frame for 700D */ @@ -927,7 +929,7 @@ static void freedv_comptx_700d(struct freedv *f, COMP mod_out[]) { for(i=0; in_nat_modem_samples; i++) { asam.real = crealf(tx_sams[i]); asam.imag = cimagf(tx_sams[i]); - mod_out[i] = fcmult(FDMDV_SCALE*NORM_PWR_OFDM, asam); + mod_out[i] = fcmult(OFDM_AMP_SCALE*NORM_PWR_OFDM, asam); } assert(f->clip == 0); /* todo: support clipping, requires some simulations and testing */ @@ -1110,10 +1112,16 @@ int freedv_rx(struct freedv *f, short speech_out[], short demod_in[]) { if ( (f->mode == FREEDV_MODE_1600) || (f->mode == FREEDV_MODE_700) || (f->mode == FREEDV_MODE_700B) || (f->mode == FREEDV_MODE_700C) || (f->mode == FREEDV_MODE_700D)) { + + float gain = 1.0; + if (f->mode == FREEDV_MODE_700D) { + gain = 2.0; /* keep levels the same as Octave simulations and C unit tests for real signals */ + } + /* FDM RX happens with complex samps, so do that */ COMP rx_fdm[f->n_max_modem_samples]; for(i=0; inin]; for(i=0; inin; i++) { - rxbuf_in[i].real = demod_in_8kHz[i].real/ASCALE; - rxbuf_in[i].imag = demod_in_8kHz[i].imag/ASCALE; + rxbuf_in[i].real = demod_in_8kHz[i].real/OFDM_AMP_SCALE; + rxbuf_in[i].imag = demod_in_8kHz[i].imag/OFDM_AMP_SCALE; } /* echo samples back out as default (say if sync not found) */ @@ -1607,7 +1613,7 @@ static int freedv_comprx_700d(struct freedv *f, COMP demod_in_8kHz[], int *valid /* TODO estimate this properly from signal */ - float EsNo = 10.0; + float EsNo = 3.0; /* looking for modem sync */ @@ -1621,7 +1627,7 @@ static int freedv_comprx_700d(struct freedv *f, COMP demod_in_8kHz[], int *valid ofdm_demod(ofdm, rx_bits, rxbuf_in); assert((OFDM_NUWBITS+OFDM_NTXTBITS+coded_bits_per_frame) == OFDM_BITSPERFRAME); - +t /* now we need to buffer for de-interleaving -------------------------------------*/ /* shift interleaved symbol buffers to make room for new symbols */ diff --git a/codec2-dev/src/ofdm_demod.c b/codec2-dev/src/ofdm_demod.c index 3c00cad0..199e6f71 100644 --- a/codec2-dev/src/ofdm_demod.c +++ b/codec2-dev/src/ofdm_demod.c @@ -46,7 +46,6 @@ #include "gp_interleaver.h" #include "interldpc.h" -#define ASCALE (2E5*1.1491/2.0) /* scale from shorts back to floats */ #define NFRAMES 100 /* just log the first 100 frames */ #define NDISCARD 20 /* BER2measure disctrds first 20 frames */ @@ -198,7 +197,7 @@ int main(int argc, char *argv[]) /* scale and demod */ for(i=0; i