From: Guillaume Pellerin Date: Mon, 28 Oct 2013 23:45:19 +0000 (+0100) Subject: fix conflict between grapher parameters, add test_all_graphers X-Git-Tag: 0.5.1-0~13 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=f73a1a933742d7b3e771ff221755fea055410d3e;p=timeside.git fix conflict between grapher parameters, add test_all_graphers --- diff --git a/tests/api/test_all_graphers.py b/tests/api/test_all_graphers.py new file mode 100644 index 0000000..a62b855 --- /dev/null +++ b/tests/api/test_all_graphers.py @@ -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) diff --git a/timeside/grapher/core.py b/timeside/grapher/core.py index ddc3099..38c5f81 100644 --- a/timeside/grapher/core.py +++ b/timeside/grapher/core.py @@ -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) diff --git a/timeside/grapher/waveform_transparent.py b/timeside/grapher/waveform_transparent.py index fbf54f2..3fd21a3 100644 --- a/timeside/grapher/waveform_transparent.py +++ b/timeside/grapher/waveform_transparent.py @@ -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