from timeside.decoder.file import FileDecoder
from timeside.core import ProcessPipe
-from unit_timeside import *
+from unit_timeside import unittest, TestRunner
from timeside.tools.data_samples import samples as ts_samples
import os.path
self.expected_samplerate = 44100
self.expected_channels = 2
- self.expected_totalframes = 352800
self.test_exact_duration = True
self.source_duration = 8
self.expected_mime_type = 'audio/x-wav'
"Test 32kHz wav decoding"
self.source = ts_samples["sweep_32000.wav"]
- expected_samplerate = 32000
- ratio = expected_samplerate / self.expected_samplerate
-
- self.expected_totalframes = int(self.expected_totalframes * ratio)
- self.expected_samplerate = expected_samplerate
+ self.expected_samplerate = 32000
def testFlac(self):
"Test flac decoding"
"Test ogg decoding"
self.source = ts_samples["sweep.ogg"]
- self.expected_totalframes = 352960
self.expected_mime_type = 'application/ogg'
self.test_exact_duration = False
"Test mp3 decoding"
self.source = ts_samples["sweep.mp3"]
- self.expected_totalframes = 353664
self.expected_mime_type = 'audio/mpeg'
self.test_exact_duration = False
self.assertEqual(decoder.mime_type(), self.expected_mime_type)
- #expected_totalframes = [self.expected_totalframes, self.expected_totalframes +32] # +32 to handle some issue with ogg
-
- self.assertEqual(totalframes, self.expected_totalframes)
+ expected_totalframes = int(decoder.input_duration *
+ decoder.output_samplerate)
input_duration = decoder.input_totalframes / decoder.input_samplerate
output_duration = decoder.totalframes() / decoder.output_samplerate
decoder.uri_duration)
self.assertEqual(self.source_duration,
decoder.uri_duration)
+ self.assertEqual(totalframes, expected_totalframes)
+
else:
self.assertAlmostEqual(input_duration, output_duration,
places=1)
self.assertAlmostEqual(self.source_duration,
decoder.uri_duration,
places=1)
+ self.assertAlmostEqual(totalframes, expected_totalframes, delta=69)
class TestDecodingSegment(TestDecoding):
self.duration = 3
self.source_duration = self.duration
- self.expected_totalframes = self.duration * self.expected_samplerate
-
def testMp3(self):
"Test mp3 decoding"
super(TestDecodingSegment, self).testMp3()
- self.expected_totalframes = self.duration * \
- self.expected_samplerate + 1
def testWav(self):
"Test wav decoding"
super(TestDecodingSegmentDefaultStart, self).setUp()
self.duration = 1
self.source_duration = self.duration
- self.expected_totalframes = self.duration * self.expected_samplerate
def testMp3(self):
"Test mp3 decoding"
super(TestDecodingSegmentDefaultStart, self).testMp3()
- self.expected_totalframes = self.duration * \
- self.expected_samplerate + 1
class TestDecodingSegmentDefaultDuration(TestDecodingSegment):
self.start = 1
self.source_duration -= self.start
- self.expected_totalframes = (self.expected_totalframes
- - self.start * self.expected_samplerate)
-
def testWav(self):
"Test wav decoding"
super(TestDecodingSegment, self).testWav()
def testMp3(self):
"Test mp3 decoding"
super(TestDecodingSegment, self).testMp3()
- self.expected_totalframes = 309565 # was 308701 ?
class TestDecodingSegmentBadParameters(unittest.TestCase):
def setUp(self):
super(TestDecodingMonoUpsampling, self).setUp()
self.samplerate, self.channels, self.blocksize = 48000, None, None
- self.expected_totalframes = 384000
def testMp3(self):
"Test mp3 decoding"
super(TestDecodingMonoUpsampling, self).testMp3()
- self.expected_totalframes = 384941
def testWav(self):
"Test wav decoding"
def testWav32k(self):
"Test 32kHz wav decoding"
super(TestDecodingMonoUpsampling, self).testWav32k()
- self.expected_totalframes = 384000
def testFlac(self):
"Test flac decoding"
def testOgg(self):
"Test ogg decoding"
super(TestDecodingMonoUpsampling, self).testOgg()
- self.expected_totalframes = 384140
class TestDecodingMonoDownsampling(TestDecoding):
super(TestDecodingMonoDownsampling, self).setUp()
self.samplerate, self.channels, self.blocksize = 16000, None, None
- self.expected_totalframes = 128000
-
def testWav32k(self):
"Test 32kHz wav decoding"
super(TestDecodingMonoDownsampling, self).testWav32k()
- self.expected_totalframes = 128000
def testOgg(self):
"Test ogg decoding"
super(TestDecodingMonoDownsampling, self).testOgg()
- self.expected_totalframes = 128027
def testMp3(self):
"Test mp3 decoding"
super(TestDecodingMonoDownsampling, self).testMp3()
- self.expected_totalframes = 128314
class TestDecodingStereoDownsampling(TestDecoding):
super(TestDecodingStereoDownsampling, self).setUp()
self.samplerate, self.channels, self.blocksize = 32000, 2, None
- self.expected_totalframes = 256000
-
def testWav32k(self):
"Test 32kHz wav decoding"
super(TestDecodingStereoDownsampling, self).testWav32k()
- self.expected_totalframes = 256000
def testOgg(self):
"Test ogg decoding"
super(TestDecodingStereoDownsampling, self).testOgg()
- self.expected_totalframes = 256085
def testMp3(self):
"Test mp3 decoding"
super(TestDecodingStereoDownsampling, self).testMp3()
- self.expected_totalframes = 256627
class TestDecodingStereoUpsampling(TestDecoding):
super(TestDecodingStereoUpsampling, self).setUp()
self.samplerate, self.channels, self.blocksize = 96000, 2, None
- self.expected_totalframes = 768000
-
def testWav32k(self):
"Test 32kHz wav decoding"
super(TestDecodingStereoUpsampling, self).testWav32k()
- self.expected_totalframes = 768000
def testOgg(self):
"Test ogg decoding"
super(TestDecodingStereoUpsampling, self).testOgg()
- self.expected_totalframes = 768279
def testMp3(self):
"Test mp3 decoding"
super(TestDecodingStereoUpsampling, self).testMp3()
- self.expected_totalframes = 769881
class TestDecodingShortBlock(TestDecoding):