added a spruious 10 kHz signal to test 48 to 8 kHz downsampler, seems to work OK
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Thu, 10 May 2012 03:41:25 +0000 (03:41 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Thu, 10 May 2012 03:41:25 +0000 (03:41 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@409 01035d8c-6547-0410-b346-abe4f91aad63

codec2-dev/src/fdmdv.c
codec2-dev/unittest/t48_8.c

index 2f7ab3c84a2f5300bb63fcbc6f91d2a375f789f4..bb78ffac4adf72d3faca1c2366da8ea72bc5f670 100644 (file)
@@ -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.
index 236bb78f0ce17d69adc7bc37d8e4ef619a1e01b0..e476d986a2addb04154d00463dc872f5bf332450 100644 (file)
@@ -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 <assert.h>
 #include <stdlib.h>
@@ -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<FDMDV_OS_TAPS; i++)
        in48k[i] = 0.0;
 
-    t = 0;
+    t = t1 = 0;
     for(f=0; f<FRAMES; f++) {
 
 #ifdef DC
@@ -64,10 +80,14 @@ int main() {
            out48k_short[i] = (short)out48k[i];
        fwrite(out48k_short, sizeof(short), N48, f48);
        
+       /* add a 10 kHz spurious signal for fun, we want down sampler to
+          knock this out */
+
+       for(i=0; i<N48; i++,t1++)
+           in48k[i+FDMDV_OS_TAPS] = out48k[i] + 16000.0*cos(TWO_PI*t1*1E4/FS);
+
        /* downsample and update filter memory */
 
-       for(i=0; i<N48; i++)
-           in48k[i+FDMDV_OS_TAPS] = out48k[i];
        fdmdv_48_to_8(out8k, &in48k[FDMDV_OS_TAPS], N8);
        for(i=0; i<FDMDV_OS_TAPS; i++)
            in48k[i] = in48k[i+N48];