]> git.parisson.com Git - timeside.git/commitdiff
add test_all, add __repr__ to ProcessPipe
authorGuillaume Pellerin <yomguy@parisson.com>
Tue, 29 Oct 2013 00:14:34 +0000 (01:14 +0100)
committerGuillaume Pellerin <yomguy@parisson.com>
Tue, 29 Oct 2013 00:14:34 +0000 (01:14 +0100)
tests/api/test_all.py [new file with mode: 0644]
timeside/core.py

diff --git a/tests/api/test_all.py b/tests/api/test_all.py
new file mode 100644 (file)
index 0000000..db33418
--- /dev/null
@@ -0,0 +1,48 @@
+# -*- coding: utf-8 -*-
+
+import os, sys
+import timeside
+
+audio_file = sys.argv[-1]
+audio_filename = audio_file.split(os.sep)[-1]
+result_dir = '../results/'
+
+if not os.path.exists(result_dir):
+    os.makedirs(result_dir)
+
+decoder  = timeside.decoder.FileDecoder(audio_file)
+graphers = timeside.core.processors(timeside.api.IGrapher)
+encoders = timeside.core.processors(timeside.api.IEncoder)
+analyzers = timeside.core.processors(timeside.api.IAnalyzer)
+
+grapher_list = []
+analyzer_list = []
+encoder_list = []
+
+pipe = decoder
+
+for grapher in graphers:
+    proc = grapher()
+    grapher_list.append(proc)
+    print proc.id()
+    pipe = pipe | proc
+
+for analyzer in analyzers:
+    proc = analyzer()
+    analyzer_list.append(proc)
+    print proc.id()
+    pipe = pipe | proc
+
+for encoder in encoders:
+    path = result_dir + os.sep + audio_filename + '.' + encoder.file_extension()
+    proc = encoder(path, overwrite=True)
+    encoder_list.append(proc)
+    pipe = pipe | proc
+
+print pipe
+pipe.run()
+
+for grapher in grapher_list:
+    image = result_dir + os.sep + audio_filename + '-' + grapher.id() + '.png'
+    grapher.render(image)
+
index 3bfdd160fba2c20ff571a83a96c2961f7cf5ad7e..06323cbbd95dbf7b4232251ba49555404e5969a5 100644 (file)
@@ -235,6 +235,14 @@ class ProcessPipe(object):
 
         return self
 
+    def __repr__(self):
+        pipe = ''
+        for item in self.processors:
+            pipe += item.id()
+            if item != self.processors[-1]:
+                pipe += ' | '
+        return pipe
+
     def run(self):
         """Setup/reset all processors in cascade and stream audio data along
         the pipe. Also returns the pipe itself."""