]> git.parisson.com Git - timeside.git/commitdiff
try to get grapher example working
authoryomguy <yomguy@parisson.com>
Thu, 28 Jan 2010 13:00:25 +0000 (13:00 +0000)
committeryomguy <yomguy@parisson.com>
Thu, 28 Jan 2010 13:00:25 +0000 (13:00 +0000)
tests/api/examples.py
tests/api/test_pipe2.py [new file with mode: 0644]

index d5fb922b231c92e6ca44cf5199084536472511d4..7578443faec2235de4dd97cccbb473c92061a8e9 100644 (file)
@@ -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 (file)
index 0000000..d34a1b0
--- /dev/null
@@ -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()
+
+