From 165bc00d19789897058049b1c3a04783ec8e4978 Mon Sep 17 00:00:00 2001 From: drowe67 Date: Tue, 19 Aug 2014 09:57:41 +0000 Subject: [PATCH] added -8-16 kHz sample rate conversion with shorts used for 16 kHz side git-svn-id: https://svn.code.sf.net/p/freetel/code@1809 01035d8c-6547-0410-b346-abe4f91aad63 --- codec2-dev/src/codec2_fdmdv.h | 2 + codec2-dev/src/fdmdv.c | 46 +++++++++++++- codec2-dev/unittest/CMakeLists.txt | 3 + codec2-dev/unittest/t16_8.c | 6 +- codec2-dev/unittest/t16_short_8.c | 98 ++++++++++++++++++++++++++++++ 5 files changed, 151 insertions(+), 4 deletions(-) create mode 100644 codec2-dev/unittest/t16_short_8.c diff --git a/codec2-dev/src/codec2_fdmdv.h b/codec2-dev/src/codec2_fdmdv.h index afe8381c..8e8978dc 100644 --- a/codec2-dev/src/codec2_fdmdv.h +++ b/codec2-dev/src/codec2_fdmdv.h @@ -109,7 +109,9 @@ void fdmdv_get_demod_stats(struct FDMDV *fdmdv_state, struct FDMDV_STA void fdmdv_get_rx_spectrum(struct FDMDV *fdmdv_state, float mag_dB[], COMP rx_fdm[], int nin); void fdmdv_8_to_16(float out16k[], float in8k[], int n); +void fdmdv_8_to_16_short(short out16k[], float in8k[], int n); void fdmdv_16_to_8(float out8k[], float in16k[], int n); +void fdmdv_16_short_to_8(float out8k[], short 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 238abd3f..b40bad53 100644 --- a/codec2-dev/src/fdmdv.c +++ b/codec2-dev/src/fdmdv.c @@ -1740,6 +1740,33 @@ void fdmdv_8_to_16(float out16k[], float in8k[], int n) } +void fdmdv_8_to_16_short(short out16k[], float in8k[], int n) +{ + int i,j,k,l; + float acc; + + /* make sure n is an integer multiple of the oversampling rate, ow + this function breaks */ + + assert((n % FDMDV_OS) == 0); + + for(i=0; i +#include +#include +#include +#include "codec2_fdmdv.h" + +#define N8 160 /* procssing buffer size at 8 kHz */ +#define N16 (N8*FDMDV_OS) +#define FRAMES 100 +#define TWO_PI 6.283185307 +#define FS 16000 + +#define SINE + +int main() { + float in8k[FDMDV_OS_TAPS_8K + N8]; + short out16k_short[N16]; + FILE *f16; + + short in16k_short[FDMDV_OS_TAPS_16K + N16]; + float out8k[N16]; + short out8k_short[N8]; + FILE *f8; + + int i,f,t,t1; + float freq = 800.0; + + f16 = fopen("out16_short.raw", "wb"); + assert(f16 != NULL); + f8 = fopen("out8.raw", "wb"); + assert(f8 != NULL); + + /* clear filter memories */ + + for(i=0; i