]> git.parisson.com Git - timeside.git/commitdiff
add unittest for graphers,
authoryomguy <yomguy@parisson.com>
Thu, 14 Apr 2011 21:23:20 +0000 (21:23 +0000)
committeryomguy <yomguy@parisson.com>
Thu, 14 Apr 2011 21:23:20 +0000 (21:23 +0000)
fix flac encoder,
change filenames of encoder unittest outputs,
transcoding still BROKEN in many cases,
grahers from MP3 and OGG seems to be broken also... :(

timeside/decoder/core.py
timeside/encoder/flac.py
timeside/tests/testgraphers.py [new file with mode: 0644]
timeside/tests/testlowlevelstreaming.py

index 3f3bb65b50bfe7d061f617f0b15e1b26766433c6..d35a2fa8158ab53b5a37399dad91d0f8d2f35fa7 100644 (file)
@@ -174,7 +174,8 @@ class FileDecoder(Processor):
             return array([0.]), True
         if buf == None:
             return array([0.]), True
-        return self.gst_buffer_to_numpy_array(buf), False
+        samples = self.gst_buffer_to_numpy_array(buf)
+        return samples, False
 
     @interfacedoc
     def release(self):
index 66db6b3443849b33bcba70f038bb0a87c49c05f8..0a1206687a5342d8b84be1658199029ed490520d 100644 (file)
@@ -62,13 +62,13 @@ class FlacEncoder(Processor):
         elif self.filename :
             self.pipe += '! filesink location=%s ' % self.filename
         else:
-            self.pipe += '! appsink name=sink sync=False '
+            self.pipe += '! appsink name=app sync=False '
             
         self.pipeline = gst.parse_launch(self.pipe)
         # store a pointer to appsrc in our encoder object
         self.src = self.pipeline.get_by_name('src')
         # store a pointer to appsink in our encoder object
-        self.sink = self.pipeline.get_by_name('sink')
+        self.app = self.pipeline.get_by_name('app')
         
         srccaps = gst.Caps("""audio/x-raw-float,
             endianness=(int)1234,
@@ -116,7 +116,7 @@ class FlacEncoder(Processor):
         buf = self.numpy_array_to_gst_buffer(frames)
         self.src.emit('push-buffer', buf)
         if self.streaming:
-            self.chunk = pull = self.sink.emit('pull-buffer')
+            self.chunk = self.app.emit('pull-buffer')
         return frames, eod
 
     def numpy_array_to_gst_buffer(self, frames):
diff --git a/timeside/tests/testgraphers.py b/timeside/tests/testgraphers.py
new file mode 100644 (file)
index 0000000..ec24418
--- /dev/null
@@ -0,0 +1,80 @@
+
+from timeside.core import *
+from timeside.decoder import *
+from timeside.analyzer import *
+from timeside.encoder import *
+from timeside.grapher import *
+from timeside.api import *
+
+from timeside.component import *
+from timeside.tests import TestCase, TestRunner
+import unittest
+
+import os.path
+
+__all__ = ['TestComponentArchitecture']
+
+class TestGraphers(TestCase):
+    "Test all graphers with various input media formats"
+
+    def setUp(self):
+        pass
+    
+    # WAVEFORMS
+    def testWav2Waveform(self):
+        "Test WAV to Waveform"
+        self.source = os.path.join (os.path.dirname(__file__),  "samples/sweep.wav")
+        self.image = "/tmp/test_waveform_sweep_wav.png"
+        self.grapher = Waveform(width=1024, height=256, bg_color=(0,0,0), color_scheme='default')
+
+    def testFlac2Waveform(self):
+        "Test FLAC to Waveform"
+        self.source = os.path.join (os.path.dirname(__file__),  "samples/sweep.flac")
+        self.image = "/tmp/test_waveform_sweep_flac.png"
+        self.grapher = Waveform(width=1024, height=256, bg_color=(0,0,0), color_scheme='default')
+    
+    def testMp32Waveform(self):
+        "Test MP3 to Waveform"
+        self.source = os.path.join (os.path.dirname(__file__),  "samples/sweep.mp3")
+        self.image = "/tmp/test_waveform_sweep_mp3.png"
+        self.grapher = Waveform(width=1024, height=256, bg_color=(0,0,0), color_scheme='default')
+    
+    def testOgg2Waveform(self):
+        "Test OGG to Waveform"
+        self.source = os.path.join (os.path.dirname(__file__),  "samples/sweep.ogg")
+        self.image = "/tmp/test_waveform_sweep_ogg.png"
+        self.grapher = Waveform(width=1024, height=256, bg_color=(0,0,0), color_scheme='default')
+    
+    # SPECTROGRAMS
+    def testWav2Spectrogram(self):
+        "Test WAV to Spectrogram"
+        self.source = os.path.join (os.path.dirname(__file__),  "samples/sweep.wav")
+        self.image = "/tmp/test_spectrogram_sweep_wav.png"
+        self.grapher = Spectrogram(width=1024, height=256, bg_color=(0,0,0), color_scheme='default')
+    
+    def testMp32Spectrogram(self):
+        "Test MP3 to Spectrogram"
+        self.source = os.path.join (os.path.dirname(__file__),  "samples/sweep.mp3")
+        self.image = "/tmp/test_spectrogram_sweep_mp3.png"
+        self.grapher = Spectrogram(width=1024, height=256, bg_color=(0,0,0), color_scheme='default')
+    
+    def testFlac2Spectrogram(self):
+        "Test FLAC to Spectrogram"
+        self.source = os.path.join (os.path.dirname(__file__),  "samples/sweep.flac")
+        self.image = "/tmp/test_spectrogram_sweep_flac.png"
+        self.grapher = Spectrogram(width=1024, height=256, bg_color=(0,0,0), color_scheme='default')
+    
+    def testOgg2Spectrogram(self):
+        "Test OGG to Spectrogram"
+        self.source = os.path.join (os.path.dirname(__file__),  "samples/sweep.ogg")
+        self.image = "/tmp/test_spectrogram_sweep_ogg.png"
+        self.grapher = Spectrogram(width=1024, height=256, bg_color=(0,0,0), color_scheme='default')
+     
+    def tearDown(self):
+        decoder = FileDecoder(self.source)
+        (decoder | self.grapher).run()
+        self.grapher.render(self.image)
+        
+if __name__ == '__main__':
+    unittest.main(testRunner=TestRunner())
+
index 5c74edf128fbb8242c73ee5292446822934dc9bf..f5af1cf6d6568117f79a559262031e8c1d722753 100644 (file)
@@ -23,8 +23,8 @@ class TestLowLevel(TestCase):
         "Test wav to mp3 conversion"
         self.source = os.path.join (os.path.dirname(__file__),  "samples/sweep.wav")
 
-        dest1 = "/tmp/test_filesink.mp3"
-        dest2 = "/tmp/test_appsink.mp3"
+        dest1 = "/tmp/test_wav_filesink.mp3"
+        dest2 = "/tmp/test_wav_appsink.mp3"
         self.f = open(dest2,'w')
 
         self.streaming=True
@@ -36,8 +36,8 @@ class TestLowLevel(TestCase):
         "Test flac to mp3 conversion"
         self.source = os.path.join (os.path.dirname(__file__),  "samples/sweep.flac")
 
-        dest1 = "/tmp/test_filesink.mp3"
-        dest2 = "/tmp/test_appsink.mp3"
+        dest1 = "/tmp/test_flac_filesink.mp3"
+        dest2 = "/tmp/test_flac_appsink.mp3"
         self.f = open(dest2,'w')
 
         self.streaming=True
@@ -50,8 +50,8 @@ class TestLowLevel(TestCase):
         return False
         self.source = os.path.join (os.path.dirname(__file__),  "samples/sweep.flac")
 
-        dest1 = "/tmp/test_filesink.ogg"
-        dest2 = "/tmp/test_appsink.ogg"
+        dest1 = "/tmp/test_flac_filesink.ogg"
+        dest2 = "/tmp/test_flac_appsink.ogg"
         self.f = open(dest2,'w')
 
         self.streaming=True
@@ -64,8 +64,8 @@ class TestLowLevel(TestCase):
         return False
         self.source = os.path.join (os.path.dirname(__file__),  "samples/sweep.wav")
 
-        dest1 = "/tmp/test_filesink.ogg"
-        dest2 = "/tmp/test_appsink.ogg"
+        dest1 = "/tmp/test_wav_filesink.ogg"
+        dest2 = "/tmp/test_wav_appsink.ogg"
         self.f = open(dest2,'w')
 
         self.streaming=True
@@ -73,6 +73,20 @@ class TestLowLevel(TestCase):
         encoder = VorbisEncoder(dest1, streaming=True)
         self.encoder = encoder
 
+    def testWav2Flac(self):
+        "Test wav to flac conversion"
+        return False
+        self.source = os.path.join (os.path.dirname(__file__),  "samples/sweep.wav")
+
+        dest1 = "/tmp/test_wav_filesink.flac"
+        dest2 = "/tmp/test_wav_appsink.flac"
+        self.f = open(dest2,'w')
+
+        self.streaming=True
+
+        encoder = FlacEncoder(dest1, streaming=True)
+        self.encoder = encoder
+
     def setUpDecoder(self):
         self.decoder = FileDecoder(self.source)
         self.decoder.setup()