]> git.parisson.com Git - timeside.git/commitdiff
fix conflict between grapher parameters, add test_all_graphers
authorGuillaume Pellerin <yomguy@parisson.com>
Mon, 28 Oct 2013 23:45:19 +0000 (00:45 +0100)
committerGuillaume Pellerin <yomguy@parisson.com>
Mon, 28 Oct 2013 23:45:19 +0000 (00:45 +0100)
tests/api/test_all_graphers.py [new file with mode: 0644]
timeside/grapher/core.py
timeside/grapher/waveform_transparent.py

diff --git a/tests/api/test_all_graphers.py b/tests/api/test_all_graphers.py
new file mode 100644 (file)
index 0000000..a62b855
--- /dev/null
@@ -0,0 +1,28 @@
+# -*- coding: utf-8 -*-
+
+import os, sys
+import timeside
+
+audio_file = sys.argv[-1]
+audio_filename = audio_file.split(os.sep)[-1]
+img_dir = '../results/img'
+
+if not os.path.exists(img_dir):
+    os.makedirs(img_dir)
+
+decoder  = timeside.decoder.FileDecoder(audio_file)
+graphers = timeside.core.processors(timeside.api.IGrapher)
+pipe = decoder
+proc_list = []
+
+for grapher in graphers:
+    proc = grapher()
+    proc_list.append(proc)
+    print proc.id()
+    pipe = pipe | proc
+
+pipe.run()
+
+for grapher in proc_list:
+    image = img_dir + os.sep + audio_filename + '-' + grapher.id() + '.png'
+    grapher.render(image)
index ddc3099a98bf4246b1da6dec1e195d1adcdca8d7..38c5f8164709058081df8eef998d389efc0ca0d0 100644 (file)
@@ -129,16 +129,16 @@ class Grapher(Processor):
 
     def setup(self, channels=None, samplerate=None, blocksize=None, totalframes=None):
         super(Grapher, self).setup(channels, samplerate, blocksize, totalframes)
-        self.samplerate = samplerate
-        self.higher_freq = self.samplerate/2
-        self.blocksize = blocksize
-        self.totalframes = totalframes
+        self.sample_rate = samplerate
+        self.higher_freq = self.sample_rate/2
+        self.block_size = blocksize
+        self.total_frames = totalframes
         self.image = Image.new("RGBA", (self.image_width, self.image_height), self.bg_color)
-        self.samples_per_pixel = self.totalframes / float(self.image_width)
+        self.samples_per_pixel = self.total_frames / float(self.image_width)
         self.buffer_size = int(round(self.samples_per_pixel, 0))
         self.pixels_adapter = FixedSizeInputAdapter(self.buffer_size, 1, pad=False)
-        self.pixels_adapter_totalframes = self.pixels_adapter.blocksize(self.totalframes)
-        self.spectrum = Spectrum(self.fft_size, self.samplerate, self.blocksize, self.totalframes,
+        self.pixels_adapter_totalframes = self.pixels_adapter.blocksize(self.total_frames)
+        self.spectrum = Spectrum(self.fft_size, self.sample_rate, self.block_size, self.total_frames,
                                  self.lower_freq, self.higher_freq, numpy.hanning)
         self.pixel = self.image.load()
         self.draw = ImageDraw.Draw(self.image)
index fbf54f2da4c128d7d97f5ed349e8550fecd1f38d..3fd21a3bf339dc0c326293f937483fb5f8a1de96 100644 (file)
@@ -60,7 +60,7 @@ class WaveformTransparent(Waveform):
                     self.draw_peaks_inverted(self.pixel_cursor, peaks(samples), self.line_color)
                     self.pixel_cursor += 1
             if self.pixel_cursor == self.image_width-1:
-                self.draw_peaks(self.pixel_cursor, peaks(samples), self.bg_color)
+                self.draw_peaks_inverted(self.pixel_cursor, peaks(samples), self.line_color)
                 self.pixel_cursor += 1
         return frames, eod