diff dsp/rateconversion/TestResampler.cpp @ 142:f8fc21365a8c

Fix scaling on downsampling, another test
author Chris Cannam
date Mon, 14 Oct 2013 16:20:00 +0100
parents 54c9e0811ae7
children a4aa37f7af28
line wrap: on
line diff
--- a/dsp/rateconversion/TestResampler.cpp	Mon Oct 14 16:15:32 2013 +0100
+++ b/dsp/rateconversion/TestResampler.cpp	Mon Oct 14 16:20:00 2013 +0100
@@ -119,6 +119,8 @@
 
 BOOST_AUTO_TEST_CASE(interpolatedSine)
 {
+    // Interpolating a sinusoid should give us a sinusoid, once we've
+    // dropped the first few samples
     double in[1000];
     double out[2000];
     for (int i = 0; i < 1000; ++i) {
@@ -127,7 +129,22 @@
     for (int i = 0; i < 2000; ++i) {
 	out[i] = sin(i * M_PI / 4.0);
     }
-    testResamplerOneShot(8, 16, 1000, in, 200, out, 400);
+    testResamplerOneShot(8, 16, 1000, in, 200, out, 512);
+}
+
+BOOST_AUTO_TEST_CASE(decimatedSine)
+{
+    // Decimating a sinusoid should give us a sinusoid, once we've
+    // dropped the first few samples
+    double in[2000];
+    double out[1000];
+    for (int i = 0; i < 2000; ++i) {
+	in[i] = sin(i * M_PI / 8.0);
+    }
+    for (int i = 0; i < 1000; ++i) {
+	out[i] = sin(i * M_PI / 4.0);
+    }
+    testResamplerOneShot(16, 8, 2000, in, 200, out, 256);
 }
 
 BOOST_AUTO_TEST_SUITE_END()