From: yomguy Date: Mon, 6 Sep 2010 17:45:49 +0000 (+0000) Subject: add analyzer test X-Git-Tag: 0.3.2~105 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=51a5c7626b634687be57c3e6ed05ea07f6468ad0;p=timeside.git add analyzer test --- diff --git a/timeside/tests/api/test_analyzer.py b/timeside/tests/api/test_analyzer.py new file mode 100644 index 0000000..1ef11ea --- /dev/null +++ b/timeside/tests/api/test_analyzer.py @@ -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() +