From c64d635640bcc9bc3df0b69ecd1b9279b70a5576 Mon Sep 17 00:00:00 2001 From: yomguy Date: Thu, 28 Jan 2010 13:00:25 +0000 Subject: [PATCH] try to get grapher example working --- tests/api/examples.py | 7 +++++-- tests/api/test_pipe2.py | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 tests/api/test_pipe2.py diff --git a/tests/api/examples.py b/tests/api/examples.py index d5fb922..7578443 100644 --- a/tests/api/examples.py +++ b/tests/api/examples.py @@ -210,6 +210,7 @@ class Waveform(Processor): @interfacedoc def __init__(self, width, height, output=None): + self.filename = output self.image = None if width: self.width = width @@ -223,7 +224,9 @@ class Waveform(Processor): self.filename = output else: raise Exception("Streaming not supported") - + self.bg_color = None + self.color_scheme = None + @staticmethod @interfacedoc def id(): @@ -235,7 +238,7 @@ class Waveform(Processor): return "Waveform test" @interfacedoc - def set_colors(self, background=None, scheme=None): + def set_colors(self, background, scheme): self.bg_color = background self.color_scheme = scheme diff --git a/tests/api/test_pipe2.py b/tests/api/test_pipe2.py new file mode 100644 index 0000000..d34a1b0 --- /dev/null +++ b/tests/api/test_pipe2.py @@ -0,0 +1,33 @@ +from timeside.tests.api import examples +from timeside.core import * +from timeside.api import * +from sys import stdout + +import os +source=os.path.dirname(__file__) + "../samples/guitar.wav" + +print "Normalizing %s" % source +decoder = examples.FileDecoder(source) +maxlevel = examples.MaxLevel() +waveform = examples.Waveform(1024, 256, 'waveform.png') +#waveform.set_colors((0xFF, 0xFF, 0xFF), 'iso') + +(decoder | maxlevel | waveform).run() + +gain = 1 +if maxlevel.result() > 0: + gain = 0.9 / maxlevel.result() + +print "input maxlevel: %f" % maxlevel.result() +print "gain: %f" % gain + +gain = examples.Gain(gain) +encoder = examples.WavEncoder("normalized.wav") + +subpipe = gain | maxlevel + +(decoder | subpipe | encoder).run() + +print "output maxlevel: %f" % maxlevel.result() + + -- 2.39.5