From: drowe67 Date: Thu, 28 Feb 2013 01:06:38 +0000 (+0000) Subject: started modifying for variable number of carriers X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=1aaa2397aa96439a349e797bc0ad668969b03a86;p=freetel-svn-tracking.git started modifying for variable number of carriers git-svn-id: https://svn.code.sf.net/p/freetel/code@1174 01035d8c-6547-0410-b346-abe4f91aad63 --- diff --git a/codec2-dev/src/codec2_fdmdv.h b/codec2-dev/src/codec2_fdmdv.h index 46b3a6a1..38e97140 100644 --- a/codec2-dev/src/codec2_fdmdv.h +++ b/codec2-dev/src/codec2_fdmdv.h @@ -57,6 +57,7 @@ extern "C" { #include "comp.h" +#define FDMDV_NC 14 /* default number of data carriers */ #define FDMDV_BITS_PER_FRAME 28 /* 20ms frames, 1400 bit/s */ #define FDMDV_NOM_SAMPLES_PER_FRAME 160 /* modulator output samples/frame and nominal demod samples/frame */ /* at 8000 Hz sample rate */ @@ -88,7 +89,7 @@ struct FDMDV_STATS { float clock_offset; /* Estimated tx/rx sample clock offset in ppm */ }; -struct FDMDV * CODEC2_WIN32SUPPORT fdmdv_create(void); +struct FDMDV * CODEC2_WIN32SUPPORT fdmdv_create(int Nc); void CODEC2_WIN32SUPPORT fdmdv_destroy(struct FDMDV *fdmdv_state); void CODEC2_WIN32SUPPORT fdmdv_mod(struct FDMDV *fdmdv_state, COMP tx_fdm[], int tx_bits[], int *sync_bit); diff --git a/codec2-dev/src/fdmdv.c b/codec2-dev/src/fdmdv.c index 9fe7aa38..1fcd3d59 100644 --- a/codec2-dev/src/fdmdv.c +++ b/codec2-dev/src/fdmdv.c @@ -119,12 +119,14 @@ static float cabsolute(COMP a) \*---------------------------------------------------------------------------*/ -struct FDMDV * CODEC2_WIN32SUPPORT fdmdv_create(void) +struct FDMDV * CODEC2_WIN32SUPPORT fdmdv_create(int Nc) { struct FDMDV *f; int c, i, k; float carrier_freq; + assert(NC == FDMDV_NC); /* check public and private #defines match */ + assert(Nc <= NC); assert(FDMDV_BITS_PER_FRAME == NC*NB); assert(FDMDV_NOM_SAMPLES_PER_FRAME == M); assert(FDMDV_MAX_SAMPLES_PER_FRAME == (M+M/P)); @@ -133,13 +135,15 @@ struct FDMDV * CODEC2_WIN32SUPPORT fdmdv_create(void) if (f == NULL) return NULL; + f->Nc = Nc; + f->current_test_bit = 0; for(i=0; irx_test_bits_mem[i] = 0; f->tx_pilot_bit = 0; - for(c=0; cprev_tx_symbols[c].real = 1.0; f->prev_tx_symbols[c].imag = 0.0; f->prev_rx_symbols[c].real = 1.0; @@ -159,8 +163,8 @@ struct FDMDV * CODEC2_WIN32SUPPORT fdmdv_create(void) This helped PAPR for a few dB. We don't need to adjust rx phase as DQPSK takes care of that. */ - f->phase_tx[c].real = cos(2.0*PI*c/(NC+1)); - f->phase_tx[c].imag = sin(2.0*PI*c/(NC+1)); + f->phase_tx[c].real = cos(2.0*PI*c/(Nc+1)); + f->phase_tx[c].imag = sin(2.0*PI*c/(Nc+1)); f->phase_rx[c].real = 1.0; f->phase_rx[c].imag = 0.0; @@ -177,24 +181,24 @@ struct FDMDV * CODEC2_WIN32SUPPORT fdmdv_create(void) /* Set up frequency of each carrier */ - for(c=0; cfreq[c].real = cos(2.0*PI*carrier_freq/FS); f->freq[c].imag = sin(2.0*PI*carrier_freq/FS); } - for(c=NC/2; cfreq[c].real = cos(2.0*PI*carrier_freq/FS); f->freq[c].imag = sin(2.0*PI*carrier_freq/FS); } - f->freq[NC].real = cos(2.0*PI*FDMDV_FCENTRE/FS); - f->freq[NC].imag = sin(2.0*PI*FDMDV_FCENTRE/FS); + f->freq[Nc].real = cos(2.0*PI*FDMDV_FCENTRE/FS); + f->freq[Nc].imag = sin(2.0*PI*FDMDV_FCENTRE/FS); /* Generate DBPSK pilot Look Up Table (LUT) */ - generate_pilot_lut(f->pilot_lut, &f->freq[NC]); + generate_pilot_lut(f->pilot_lut, &f->freq[Nc]); /* freq Offset estimation states */ @@ -223,7 +227,7 @@ struct FDMDV * CODEC2_WIN32SUPPORT fdmdv_create(void) f->coarse_fine = COARSE; f->bad_sync = 0; - for(c=0; csig_est[c] = 0.0; f->noise_est[c] = 0.0; } diff --git a/codec2-dev/src/fdmdv_demod.c b/codec2-dev/src/fdmdv_demod.c index 391843f1..d8a43b88 100644 --- a/codec2-dev/src/fdmdv_demod.c +++ b/codec2-dev/src/fdmdv_demod.c @@ -105,7 +105,7 @@ int main(int argc, char *argv[]) rx_spec_log = (float*)malloc(sizeof(float)*FDMDV_NSPEC*MAX_FRAMES); assert(rx_spec_log != NULL); - fdmdv = fdmdv_create(); + fdmdv = fdmdv_create(FDMDV_NC); f = 0; state = 0; nin = FDMDV_NOM_SAMPLES_PER_FRAME; diff --git a/codec2-dev/src/fdmdv_get_test_bits.c b/codec2-dev/src/fdmdv_get_test_bits.c index 3a18b8ca..234dac34 100644 --- a/codec2-dev/src/fdmdv_get_test_bits.c +++ b/codec2-dev/src/fdmdv_get_test_bits.c @@ -63,7 +63,7 @@ int main(int argc, char *argv[]) numBits = atoi(argv[2]); nCodecFrames = numBits/BITS_PER_CODEC_FRAME; - fdmdv = fdmdv_create(); + fdmdv = fdmdv_create(FDMDV_NC); for(n=0; n