From: drowe67 Date: Sun, 24 Mar 2013 05:49:45 +0000 (+0000) Subject: support for setting carrier separation X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=56b9f359f73325d4d1d5dc944d9e2a977e7788cc;p=freetel-svn-tracking.git support for setting carrier separation git-svn-id: https://svn.code.sf.net/p/freetel/code@1225 01035d8c-6547-0410-b346-abe4f91aad63 --- diff --git a/codec2-dev/src/codec2_fdmdv.h b/codec2-dev/src/codec2_fdmdv.h index 1d9db7d2..543b4d04 100644 --- a/codec2-dev/src/codec2_fdmdv.h +++ b/codec2-dev/src/codec2_fdmdv.h @@ -94,7 +94,9 @@ struct FDMDV * CODEC2_WIN32SUPPORT fdmdv_create(int Nc); void CODEC2_WIN32SUPPORT fdmdv_destroy(struct FDMDV *fdmdv_state); void CODEC2_WIN32SUPPORT fdmdv_use_old_qpsk_mapping(struct FDMDV *fdmdv_state); int CODEC2_WIN32SUPPORT fdmdv_bits_per_frame(struct FDMDV *fdmdv_state); - +float CODEC2_WIN32SUPPORT fdmdv_get_fsep(struct FDMDV *fdmdv_state); +void CODEC2_WIN32SUPPORT fdmdv_set_fsep(struct FDMDV *fdmdv_state, float fsep); + void CODEC2_WIN32SUPPORT fdmdv_mod(struct FDMDV *fdmdv_state, COMP tx_fdm[], int tx_bits[], int *sync_bit); void CODEC2_WIN32SUPPORT fdmdv_demod(struct FDMDV *fdmdv_state, int rx_bits[], int *reliable_sync_bit, COMP rx_fdm[], int *nin); diff --git a/codec2-dev/src/fdmdv.c b/codec2-dev/src/fdmdv.c index b1e76fa5..880cabb2 100644 --- a/codec2-dev/src/fdmdv.c +++ b/codec2-dev/src/fdmdv.c @@ -125,7 +125,6 @@ struct FDMDV * CODEC2_WIN32SUPPORT fdmdv_create(int Nc) { struct FDMDV *f; int c, i, k; - float carrier_freq; assert(NC == FDMDV_NC_MAX); /* check public and private #defines match */ assert(Nc <= NC); @@ -184,22 +183,9 @@ struct FDMDV * CODEC2_WIN32SUPPORT fdmdv_create(int Nc) f->rx_baseband_mem_timing[c][k].real = 0.0; f->rx_baseband_mem_timing[c][k].imag = 0.0; } - } - - /* 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); } - + + fdmdv_set_fsep(f, FSEP); f->freq[Nc].real = cos(2.0*PI*FDMDV_FCENTRE/FS); f->freq[Nc].imag = sin(2.0*PI*FDMDV_FCENTRE/FS); @@ -305,6 +291,32 @@ void CODEC2_WIN32SUPPORT fdmdv_get_test_bits(struct FDMDV *f, int tx_bits[]) } } +float CODEC2_WIN32SUPPORT fdmdv_get_fsep(struct FDMDV *f) +{ + return f->fsep; +} + +void CODEC2_WIN32SUPPORT fdmdv_set_fsep(struct FDMDV *f, float fsep) { + int c; + float carrier_freq; + + f->fsep = fsep; + /* Set up frequency of each carrier */ + + for(c=0; cNc/2; c++) { + carrier_freq = (-f->Nc/2 + c)*f->fsep + FDMDV_FCENTRE; + f->freq[c].real = cos(2.0*PI*carrier_freq/FS); + f->freq[c].imag = sin(2.0*PI*carrier_freq/FS); + } + + for(c=f->Nc/2; cNc; c++) { + carrier_freq = (-f->Nc/2 + c + 1)*f->fsep + FDMDV_FCENTRE; + f->freq[c].real = cos(2.0*PI*carrier_freq/FS); + f->freq[c].imag = sin(2.0*PI*carrier_freq/FS); + } +} + + /*---------------------------------------------------------------------------*\ FUNCTION....: bits_to_dqpsk_symbols() diff --git a/codec2-dev/src/fdmdv_internal.h b/codec2-dev/src/fdmdv_internal.h index 34ff7bde..e9b355d4 100644 --- a/codec2-dev/src/fdmdv_internal.h +++ b/codec2-dev/src/fdmdv_internal.h @@ -50,7 +50,7 @@ #define NSYM 6 /* number of symbols to filter over */ #define NFILTER (NSYM*M) /* size of tx/rx filters at sample rate M */ -#define FSEP 75 /* Separation between carriers (Hz) */ +#define FSEP 75 /* Default separation between carriers (Hz) */ #define NT 5 /* number of symbols we estimate timing over */ #define P 4 /* oversample factor used for initial rx symbol filtering */ @@ -77,7 +77,8 @@ struct FDMDV { - int Nc; + int Nc; + float fsep; /* test data (test frame) states */