From: drowe67 Date: Fri, 24 Feb 2017 04:44:24 +0000 (+0000) Subject: cohpsk and freedv API support for attenuating once carrier for 700C test purposes X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=47d2b2f8795cefc0b52ecf1c96991e408d4169c9;p=freetel-svn-tracking.git cohpsk and freedv API support for attenuating once carrier for 700C test purposes git-svn-id: https://svn.code.sf.net/p/freetel/code@3050 01035d8c-6547-0410-b346-abe4f91aad63 --- diff --git a/codec2-dev/src/codec2_cohpsk.h b/codec2-dev/src/codec2_cohpsk.h index 5520ec79..27d35cd2 100644 --- a/codec2-dev/src/codec2_cohpsk.h +++ b/codec2-dev/src/codec2_cohpsk.h @@ -63,5 +63,6 @@ void fdmdv_freq_shift_coh(COMP rx_fdm_fcorr[], COMP rx_fdm[], float foff, float float *cohpsk_get_rx_bits_lower(struct COHPSK *coh); float *cohpsk_get_rx_bits_upper(struct COHPSK *coh); +void cohpsk_set_carrier_ampl(struct COHPSK *coh, int c, float ampl); #endif diff --git a/codec2-dev/src/cohpsk.c b/codec2-dev/src/cohpsk.c index 58d13b29..2cdf0123 100644 --- a/codec2-dev/src/cohpsk.c +++ b/codec2-dev/src/cohpsk.c @@ -150,6 +150,10 @@ struct COHPSK *cohpsk_create(void) coh->rx_filter_memory[c][i].real = 0.0; coh->rx_filter_memory[c][i].imag = 0.0; } + + /* optional per-carrier amplitude weighting for testing */ + + coh->carrier_ampl[c] = 1.0; } fdmdv->fbb_rect.real = cosf(2.0*PI*FDMDV_FCENTRE/COHPSK_FS); fdmdv->fbb_rect.imag = sinf(2.0*PI*FDMDV_FCENTRE/COHPSK_FS); @@ -252,16 +256,6 @@ void bits_to_qpsk_symbols(COMP tx_symb[][COHPSK_NC*ND], int tx_bits[], int nbits i = c*NSYMROW + data_r; bits = (tx_bits[2*i]&0x1)<<1 | (tx_bits[2*i+1]&0x1); tx_symb[r][c] = fcmult(1.0/sqrtf(ND),qpsk_mod[bits]); - - /* test code to see what happens when we attenuate one - carrier, this may happen in practice with tx SSB filter - ripple. - - if (c==5) { - COMP attn = {0.5,0.0}; - tx_symb[r][c] = cmult(tx_symb[r][c], attn); - } - */ } } @@ -680,7 +674,7 @@ void cohpsk_mod(struct COHPSK *coh, COMP tx_fdm[], int tx_bits[]) for(r=0; rcarrier_ampl[c], tx_symb[r][c]); tx_filter_and_upconvert_coh(&tx_fdm[r*COHPSK_M], COHPSK_NC*ND , tx_onesym, fdmdv->tx_filter_memory, fdmdv->phase_tx, fdmdv->freq, &fdmdv->fbb_phase_tx, fdmdv->fbb_rect); } @@ -1285,8 +1279,13 @@ float *cohpsk_get_rx_bits_lower(struct COHPSK *coh) { return coh->rx_bits_lower; } - float *cohpsk_get_rx_bits_upper(struct COHPSK *coh) { return coh->rx_bits_upper; } +void cohpsk_set_carrier_ampl(struct COHPSK *coh, int c, float ampl) { + assert(c < COHPSK_NC*ND); + coh->carrier_ampl[c] = ampl; + fprintf(stderr, "cohpsk_set_carrier_ampl: %d %f\n", c, ampl); +} + diff --git a/codec2-dev/src/cohpsk_internal.h b/codec2-dev/src/cohpsk_internal.h index e8ce5541..369fc969 100644 --- a/codec2-dev/src/cohpsk_internal.h +++ b/codec2-dev/src/cohpsk_internal.h @@ -102,6 +102,10 @@ struct COHPSK { float rx_bits_lower[COHPSK_BITS_PER_FRAME]; float rx_bits_upper[COHPSK_BITS_PER_FRAME]; + + /* tx amplitude weights for each carrier for test/instrumentation */ + + float carrier_ampl[COHPSK_NC*ND]; }; void bits_to_qpsk_symbols(COMP tx_symb[][COHPSK_NC*COHPSK_ND], int tx_bits[], int nbits); diff --git a/codec2-dev/src/freedv_api.c b/codec2-dev/src/freedv_api.c index 9a64c658..302d69ab 100644 --- a/codec2-dev/src/freedv_api.c +++ b/codec2-dev/src/freedv_api.c @@ -1563,6 +1563,11 @@ void freedv_set_callback_error_pattern (struct freedv *f, freedv_calback_erro f->error_pattern_callback_state = state; } +void freedv_set_carrier_ampl(struct freedv *freedv, int c, float ampl) { + assert(freedv->mode == FREEDV_MODE_700C); + cohpsk_set_carrier_ampl(freedv->cohpsk, c, ampl); +} + /*---------------------------------------------------------------------------*\ FUNCTIONS...: freedv_set_alt_modem_samp_rate diff --git a/codec2-dev/src/freedv_api.h b/codec2-dev/src/freedv_api.h index 9d05d440..34ec730f 100644 --- a/codec2-dev/src/freedv_api.h +++ b/codec2-dev/src/freedv_api.h @@ -68,23 +68,35 @@ typedef void (*freedv_callback_datarx)(void *, unsigned char *packet, size_t siz typedef void (*freedv_callback_datatx)(void *, unsigned char *packet, size_t *size); -// FreeDV API functions: -// open, close +/*---------------------------------------------------------------------------*\ + + FreeDV API functions + +\*---------------------------------------------------------------------------*/ + +// open, close ---------------------------------------------------------------- + struct freedv *freedv_open(int mode); void freedv_close (struct freedv *freedv); -// Transmit + +// Transmit ------------------------------------------------------------------- + void freedv_tx (struct freedv *freedv, short mod_out[], short speech_in[]); void freedv_comptx (struct freedv *freedv, COMP mod_out[], short speech_in[]); void freedv_codectx (struct freedv *f, short mod_out[], unsigned char *packed_codec_bits); void freedv_datatx (struct freedv *f, short mod_out[]); int freedv_data_ntxframes (struct freedv *freedv); -// Receive + +// Receive ------------------------------------------------------------------- + int freedv_nin (struct freedv *freedv); int freedv_rx (struct freedv *freedv, short speech_out[], short demod_in[]); int freedv_floatrx (struct freedv *freedv, short speech_out[], float demod_in[]); int freedv_comprx (struct freedv *freedv, short speech_out[], COMP demod_in[]); int freedv_codecrx (struct freedv *freedv, unsigned char *packed_codec_bits, short demod_in[]); -// Set parameters + +// Set parameters ------------------------------------------------------------ + void freedv_set_callback_txt (struct freedv *freedv, freedv_callback_rx rx, freedv_callback_tx tx, void *callback_state); void freedv_set_callback_protocol (struct freedv *freedv, freedv_callback_protorx rx, freedv_callback_prototx tx, void *callback_state); void freedv_set_callback_data (struct freedv *freedv, freedv_callback_datarx datarx, freedv_callback_datatx datatx, void *callback_state); @@ -100,8 +112,10 @@ void freedv_set_callback_error_pattern (struct freedv *freedv, freedv_calback_e void freedv_set_varicode_code_num (struct freedv *freedv, int val); void freedv_set_data_header (struct freedv *freedv, unsigned char *header); int freedv_set_alt_modem_samp_rate (struct freedv *freedv, int samp_rate); +void freedv_set_carrier_ampl (struct freedv *freedv, int c, float ampl); + +// Get parameters ------------------------------------------------------------------------- -// Get parameters struct MODEM_STATS; int freedv_get_version(void); int freedv_get_mode (struct freedv *freedv); @@ -120,6 +134,7 @@ struct CODEC2 *freedv_get_codec2 (struct freedv *freedv); int freedv_get_n_codec_bits (struct freedv *freedv); int freedv_get_sz_error_pattern (struct freedv *freedv); int freedv_get_protocol_bits (struct freedv *freedv); + #endif #ifdef __cplusplus