From: Guillaume Pellerin Date: Tue, 29 Oct 2013 00:14:34 +0000 (+0100) Subject: add test_all, add __repr__ to ProcessPipe X-Git-Tag: 0.5.1-0~12 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=0729dbee534a0cd8ebd3b4146432d361785fb3eb;p=timeside.git add test_all, add __repr__ to ProcessPipe --- diff --git a/tests/api/test_all.py b/tests/api/test_all.py new file mode 100644 index 0000000..db33418 --- /dev/null +++ b/tests/api/test_all.py @@ -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) + diff --git a/timeside/core.py b/timeside/core.py index 3bfdd16..06323cb 100644 --- a/timeside/core.py +++ b/timeside/core.py @@ -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."""