]> git.parisson.com Git - timeside.git/commitdiff
add analyzer test
authoryomguy <yomguy@parisson.com>
Mon, 6 Sep 2010 17:45:49 +0000 (17:45 +0000)
committeryomguy <yomguy@parisson.com>
Mon, 6 Sep 2010 17:45:49 +0000 (17:45 +0000)
timeside/tests/api/test_analyzer.py [new file with mode: 0644]

diff --git a/timeside/tests/api/test_analyzer.py b/timeside/tests/api/test_analyzer.py
new file mode 100644 (file)
index 0000000..1ef11ea
--- /dev/null
@@ -0,0 +1,46 @@
+# -*- coding: utf-8 -*-
+
+import timeside
+from sys import stdout
+import os.path
+import numpy
+
+
+class TestAnalyzer:
+    
+    graphers = timeside.core.processors(timeside.api.IGrapher)
+    decoders = timeside.core.processors(timeside.api.IDecoder)
+    encoders= timeside.core.processors(timeside.api.IEncoder)
+    analyzers = timeside.core.processors(timeside.api.IAnalyzer)
+    
+    def __init__(self, path):
+        self.source = os.path.join(os.path.dirname(__file__), path)
+        print "Processing %s" % self.source
+        self.decoder  = timeside.decoder.FileDecoder(self.source)
+        print 'format: ', self.decoder.format()
+        self.pipe = self.decoder
+        self.analyzers_sub_pipe = []
+
+    def process(self):
+        for analyzer in self.analyzers:
+            sub_pipe = analyzer()
+            self.analyzers_sub_pipe.append(sub_pipe)
+            self.pipe = self.pipe | sub_pipe
+        self.pipe.run()
+    
+    def results(self):
+        analyzers = []
+        for analyzer in self.analyzers_sub_pipe:
+            value = analyzer.result()
+            analyzers.append({'name':analyzer.name(),
+                            'id':analyzer.id(),
+                            'unit':analyzer.unit(),
+                            'value':str(value)})
+        print analyzers
+
+
+test = TestAnalyzer('../samples/guitar.wav')
+#test = TestAnalyzer('/mnt/data4/Music1/Cellar_playlist_tmp/JanoB/VirulentAcidMix.wav')
+test.process()
+test.results()
+