comparison dsp/rateconversion/TestResampler.cpp @ 367:0721657fdd1d

Fix scaling on downsampling, another test
author Chris Cannam <c.cannam@qmul.ac.uk>
date Mon, 14 Oct 2013 16:20:00 +0100
parents 767947956fc1
children a4aa37f7af28
comparison
equal deleted inserted replaced
366:767947956fc1 367:0721657fdd1d
117 } 117 }
118 } 118 }
119 119
120 BOOST_AUTO_TEST_CASE(interpolatedSine) 120 BOOST_AUTO_TEST_CASE(interpolatedSine)
121 { 121 {
122 // Interpolating a sinusoid should give us a sinusoid, once we've
123 // dropped the first few samples
122 double in[1000]; 124 double in[1000];
123 double out[2000]; 125 double out[2000];
124 for (int i = 0; i < 1000; ++i) { 126 for (int i = 0; i < 1000; ++i) {
125 in[i] = sin(i * M_PI / 2.0); 127 in[i] = sin(i * M_PI / 2.0);
126 } 128 }
127 for (int i = 0; i < 2000; ++i) { 129 for (int i = 0; i < 2000; ++i) {
128 out[i] = sin(i * M_PI / 4.0); 130 out[i] = sin(i * M_PI / 4.0);
129 } 131 }
130 testResamplerOneShot(8, 16, 1000, in, 200, out, 400); 132 testResamplerOneShot(8, 16, 1000, in, 200, out, 512);
133 }
134
135 BOOST_AUTO_TEST_CASE(decimatedSine)
136 {
137 // Decimating a sinusoid should give us a sinusoid, once we've
138 // dropped the first few samples
139 double in[2000];
140 double out[1000];
141 for (int i = 0; i < 2000; ++i) {
142 in[i] = sin(i * M_PI / 8.0);
143 }
144 for (int i = 0; i < 1000; ++i) {
145 out[i] = sin(i * M_PI / 4.0);
146 }
147 testResamplerOneShot(16, 8, 2000, in, 200, out, 256);
131 } 148 }
132 149
133 BOOST_AUTO_TEST_SUITE_END() 150 BOOST_AUTO_TEST_SUITE_END()
134 151