From 2eac36bdc640115a53accccaa5049b78253a43ac Mon Sep 17 00:00:00 2001 From: drowe67 Date: Thu, 10 May 2012 03:41:25 +0000 Subject: [PATCH] added a spruious 10 kHz signal to test 48 to 8 kHz downsampler, seems to work OK git-svn-id: https://svn.code.sf.net/p/freetel/code@409 01035d8c-6547-0410-b346-abe4f91aad63 --- codec2-dev/src/fdmdv.c | 4 ++-- codec2-dev/unittest/t48_8.c | 30 +++++++++++++++++++++++++----- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/codec2-dev/src/fdmdv.c b/codec2-dev/src/fdmdv.c index 2f7ab3c8..bb78ffac 100644 --- a/codec2-dev/src/fdmdv.c +++ b/codec2-dev/src/fdmdv.c @@ -1183,7 +1183,7 @@ void fdmdv_get_demod_stats(struct FDMDV *fdmdv, struct FDMDV_STATS *fdmdv_stats) 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 example). + 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 @@ -1220,7 +1220,7 @@ void fdmdv_8_to_48(float out48k[], float in8k[], int n) n is the number of samples at the 8 kHz rate, there are FDMDV_OS*n samples at the 48 kHz rate. As above however a memory of - FDMDV_OS_TAPS samples is reqd for in48k[] (see example). + FDMDV_OS_TAPS samples is reqd for in48k[] (see t48_8.c unit test as example). Low pass filter the 48 kHz signal at 4 kHz using the same filter as the upsampler, then just output every FDMDV_OS-th filtered sample. diff --git a/codec2-dev/unittest/t48_8.c b/codec2-dev/unittest/t48_8.c index 236bb78f..e476d986 100644 --- a/codec2-dev/unittest/t48_8.c +++ b/codec2-dev/unittest/t48_8.c @@ -1,4 +1,20 @@ -/* Unit test for 48 to 8 kHz sample rate conversion functions */ +/* + t48_8.c + David Rowe + May 10 2012 + + Unit test for 48 to 8 kHz sample rate conversion functions. I + evaluated output by plotting using Octave and looking for jaggies: + + pl("../unittest/out48.raw",1,3000) + pl("../unittest/out8.raw",1,3000) + + Listening to it also shows up anything nasty: + + $ play -s -2 -r 48000 out48.raw + $ play -s -2 -r 8000 out8.raw + + */ #include #include @@ -25,7 +41,7 @@ int main() { short out8k_short[N8]; FILE *f8; - int i,f,t; + int i,f,t,t1; float freq = 505.0; f48 = fopen("out48.raw", "wb"); @@ -40,7 +56,7 @@ int main() { for(i=0; i