]> git.parisson.com Git - timeside.git/commitdiff
Fix Travis-CI, for which Gsreamer seems to behave diffently. Relax Test on expected...
authorThomas Fillon <thomas@parisson.com>
Sun, 19 Oct 2014 10:05:29 +0000 (12:05 +0200)
committerThomas Fillon <thomas@parisson.com>
Sun, 19 Oct 2014 10:05:29 +0000 (12:05 +0200)
.travis.yml
tests/test_decoding.py
timeside/decoder/file.py
timeside/tools/data_samples.py

index 8f5bbdef4b4f0cd612d29387f9eb8efdf1dc6aea..eb204dbfbb6fd69d9f649735972917ca397edaa9 100644 (file)
@@ -25,7 +25,6 @@ before_script:
 - pip install coveralls
 
 script:
- - py.test --collect-only tests --ignore tests/sandbox
  - coverage run --source=timeside --omit=timeside/analyzer/aubio/aubio_*.py,timeside/analyzer/yaafe.py,timeside/analyzer/limsi_sad.py,timeside/analyzer/vamp_plugin.py setup.py test
 
 after_success:
index 5bd0091a75d76887a542ead5694bbfb6b2a04766..fce5429bfe399d69ae3f2d0c4c144786457993d1 100755 (executable)
@@ -5,7 +5,7 @@ from __future__ import division
 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
@@ -25,7 +25,6 @@ class TestDecoding(unittest.TestCase):
 
         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'
@@ -44,11 +43,7 @@ class TestDecoding(unittest.TestCase):
         "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"
@@ -59,7 +54,6 @@ class TestDecoding(unittest.TestCase):
         "Test ogg decoding"
         self.source = ts_samples["sweep.ogg"]
 
-        self.expected_totalframes = 352960
         self.expected_mime_type = 'application/ogg'
         self.test_exact_duration = False
 
@@ -67,7 +61,6 @@ class TestDecoding(unittest.TestCase):
         "Test mp3 decoding"
         self.source = ts_samples["sweep.mp3"]
 
-        self.expected_totalframes = 353664
         self.expected_mime_type = 'audio/mpeg'
         self.test_exact_duration = False
 
@@ -120,9 +113,8 @@ class TestDecoding(unittest.TestCase):
 
         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
@@ -132,6 +124,8 @@ class TestDecoding(unittest.TestCase):
                              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)
@@ -141,6 +135,7 @@ class TestDecoding(unittest.TestCase):
             self.assertAlmostEqual(self.source_duration,
                                    decoder.uri_duration,
                                    places=1)
+            self.assertAlmostEqual(totalframes, expected_totalframes, delta=69)
 
 
 class TestDecodingSegment(TestDecoding):
@@ -151,13 +146,9 @@ 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"
@@ -186,13 +177,10 @@ class TestDecodingSegmentDefaultStart(TestDecodingSegment):
         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):
@@ -202,9 +190,6 @@ 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()
@@ -220,7 +205,6 @@ class TestDecodingSegmentDefaultDuration(TestDecodingSegment):
     def testMp3(self):
         "Test mp3 decoding"
         super(TestDecodingSegment, self).testMp3()
-        self.expected_totalframes = 309565  # was  308701 ?
 
 
 class TestDecodingSegmentBadParameters(unittest.TestCase):
@@ -254,12 +238,10 @@ class TestDecodingMonoUpsampling(TestDecoding):
     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"
@@ -272,7 +254,6 @@ class TestDecodingMonoUpsampling(TestDecoding):
     def testWav32k(self):
         "Test 32kHz wav decoding"
         super(TestDecodingMonoUpsampling, self).testWav32k()
-        self.expected_totalframes = 384000
 
     def testFlac(self):
         "Test flac decoding"
@@ -281,7 +262,6 @@ class TestDecodingMonoUpsampling(TestDecoding):
     def testOgg(self):
         "Test ogg decoding"
         super(TestDecodingMonoUpsampling, self).testOgg()
-        self.expected_totalframes = 384140
 
 
 class TestDecodingMonoDownsampling(TestDecoding):
@@ -290,22 +270,17 @@ 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):
@@ -314,22 +289,17 @@ 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):
@@ -338,22 +308,17 @@ 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):
index 262220bfb6d7c7dc1c08bd9dc31849b1c1729a5c..9802a50c595faa7de4aad8d509507bc281404e93 100644 (file)
@@ -257,7 +257,7 @@ class FileDecoder(Decoder):
             self.input_channels = caps[0]["channels"]
             if not self.output_channels:
                 self.output_channels = self.input_channels
-            self.input_duration = length / 1.e9
+            self.input_duration = length / gst.SECOND
 
             self.input_totalframes = int(
                 self.input_duration * self.input_samplerate)
index 76c981669e13dac3cabab785425e693d69dd47a9..e7093736c9829da5ac1a7a669b778205a59bd646 100644 (file)
@@ -59,7 +59,8 @@ class NumpySrc:
             avalaible_sample = self.length - self.pos
             if avalaible_sample < length:
                 length = avalaible_sample
-            buf = gst.Buffer(self.array[self.pos:self.pos+length, :].data)
+            array = self.array[self.pos:self.pos+length]
+            buf = gst.Buffer(numpy.getbuffer(array.flatten()))
 
             buf.timestamp = self.pos * self.per_sample
             buf.duration = int(length*self.per_sample)