From 8859e22254b21adf9d73cce1793775cca9aa143c Mon Sep 17 00:00:00 2001 From: drowe67 Date: Fri, 11 Jul 2014 06:56:03 +0000 Subject: [PATCH] 16<->8 kHz sample rate conversion filters git-svn-id: https://svn.code.sf.net/p/freetel/code@1755 01035d8c-6547-0410-b346-abe4f91aad63 --- codec2-dev/src/codec2_fdmdv.h | 6 +- codec2-dev/src/fdmdv.c | 41 +++++-------- codec2-dev/src/os.h | 98 +++++++++++++++--------------- codec2-dev/unittest/CMakeLists.txt | 4 +- 4 files changed, 68 insertions(+), 81 deletions(-) diff --git a/codec2-dev/src/codec2_fdmdv.h b/codec2-dev/src/codec2_fdmdv.h index 02a888ed..8dacab26 100644 --- a/codec2-dev/src/codec2_fdmdv.h +++ b/codec2-dev/src/codec2_fdmdv.h @@ -68,7 +68,7 @@ extern "C" { /* 8 to 48 kHz sample rate conversion */ -#define FDMDV_OS 6 /* oversampling rate */ +#define FDMDV_OS 2 /* oversampling rate */ #define FDMDV_OS_TAPS 48 /* number of OS filter taps */ /* FFT points */ @@ -107,8 +107,8 @@ void fdmdv_put_test_bits(struct FDMDV *f, int *sync, short error_patte void fdmdv_get_demod_stats(struct FDMDV *fdmdv_state, struct FDMDV_STATS *fdmdv_stats); void fdmdv_get_rx_spectrum(struct FDMDV *fdmdv_state, float mag_dB[], COMP rx_fdm[], int nin); -void fdmdv_8_to_48(float out48k[], float in8k[], int n); -void fdmdv_48_to_8(float out8k[], float in48k[], int n); +void fdmdv_8_to_16(float out16k[], float in8k[], int n); +void fdmdv_16_to_8(float out8k[], float in16k[], int n); void fdmdv_freq_shift(COMP rx_fdm_fcorr[], COMP rx_fdm[], float foff, COMP *foff_phase_rect, int nin); diff --git a/codec2-dev/src/fdmdv.c b/codec2-dev/src/fdmdv.c index e475d4be..0498aea0 100644 --- a/codec2-dev/src/fdmdv.c +++ b/codec2-dev/src/fdmdv.c @@ -1478,29 +1478,16 @@ void fdmdv_get_demod_stats(struct FDMDV *fdmdv, struct FDMDV_STATS *fdmdv_stats) /*---------------------------------------------------------------------------*\ - FUNCTION....: fdmdv_8_to_48() + FUNCTION....: fdmdv_8_to_16() AUTHOR......: David Rowe DATE CREATED: 9 May 2012 - Changes the sample rate of a signal from 8 to 48 kHz. Experience - with PC based modems has shown that PC sound cards have a more - accurate sample clock when set for 48 kHz than 8 kHz. - - n is the number of samples at the 8 kHz rate, there are FDMDV_OS*n samples - at the 48 kHz rate. A memory of FDMDV_OS_TAPS/FDMDV_OS samples is reqd for - in8k[] (see t48_8.c unit test as example). - - This is a classic polyphase upsampler. We take the 8 kHz samples - and insert (FDMDV_OS-1) zeroes between each sample, then - FDMDV_OS_TAPS FIR low pass filter the signal at 4kHz. As most of - the input samples are zeroes, we only need to multiply non-zero - input samples by filter coefficients. The zero insertion and - filtering are combined in the code below and I'm too lazy to explain - it further right now.... + Changes the sample rate of a signal from 8 to 16 kHz. Support function for + SM1000. \*---------------------------------------------------------------------------*/ -void fdmdv_8_to_48(float out48k[], float in8k[], int n) +void fdmdv_8_to_16(float out16k[], float in8k[], int n) { int i,j,k,l; @@ -1511,10 +1498,10 @@ void fdmdv_8_to_48(float out48k[], float in8k[], int n) for(i=0; i