From c3128c62f54804539a4c99e05113627c2e9ca276 Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Wed, 1 Aug 2012 15:41:22 -0600 Subject: [PATCH] tests/testdecoding.py: add resampling and stereo tests --- tests/testdecoding.py | 41 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/tests/testdecoding.py b/tests/testdecoding.py index 042c964..e5c318f 100644 --- a/tests/testdecoding.py +++ b/tests/testdecoding.py @@ -7,7 +7,7 @@ class TestDecoding(TestCase): "Test the low level streaming features" def setUp(self): - pass + self.samplerate, self.channels, self.nframes = None, None, None def testWav(self): "Test wav decoding" @@ -27,7 +27,8 @@ class TestDecoding(TestCase): def tearDown(self): decoder = FileDecoder(self.source) - decoder.setup() + + decoder.setup(samplerate = self.samplerate, channels = self.channels, nframes = self.nframes) totalframes = 0. @@ -38,13 +39,43 @@ class TestDecoding(TestCase): decoder.release() + if 0: + print "input / output_samplerate:", decoder.input_samplerate, '/', decoder.output_samplerate, + ratio = decoder.output_samplerate / float(decoder.input_samplerate) + print "ratio:", ratio + print "input / output_channels:", decoder.input_channels, decoder.output_channels + print "input_duration:", decoder.input_duration + print "input_total_frames:", decoder.input_total_frames + + """ # FIXME compute actual number of frames from file if os.path.splitext(self.source)[-1].lower() == '.mp3': - self.assertEquals(totalframes, 355969) + self.assertEquals(totalframes, ratio * 355969 ) elif os.path.splitext(self.source)[-1].lower() == '.ogg': - self.assertEquals(totalframes, 352833) + self.assertEquals(totalframes, ratio * 352833) else: - self.assertEquals(totalframes, 352801) + self.assertEquals(totalframes, ratio * 352801) + """ + +class TestDecodingStereo(TestDecoding): + + def setUp(self): + self.samplerate, self.channels, self.nframes = None, 2, None + +class TestDecodingResampling(TestDecoding): + + def setUp(self): + self.samplerate, self.channels, self.nframes = 16000, None, None + +class TestDecodingStereoResampling(TestDecoding): + + def setUp(self): + self.samplerate, self.channels, self.nframes = 32000, 2, None + +class TestDecodingStereoUpsampling(TestDecoding): + + def setUp(self): + self.samplerate, self.channels, self.nframes = 96000, 2, None if __name__ == '__main__': unittest.main(testRunner=TestRunner()) -- 2.39.5