From 969c37b494f2e573720269011957c5d3b0b35ecf Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Fri, 8 Nov 2013 02:06:21 +0100 Subject: [PATCH] add docstrings, cleanup --- doc/source/api/grapher/index.rst | 37 +++++++++----- tests/test_graphing.py | 16 +++--- timeside/grapher/__init__.py | 3 +- ...m_contour_black.py => waveform_contour.py} | 26 ++++++++++ timeside/grapher/waveform_contour_white.py | 49 ------------------- timeside/grapher/waveform_simple.py | 3 +- timeside/grapher/waveform_transparent.py | 3 +- 7 files changed, 61 insertions(+), 76 deletions(-) rename timeside/grapher/{waveform_contour_black.py => waveform_contour.py} (77%) delete mode 100644 timeside/grapher/waveform_contour_white.py diff --git a/doc/source/api/grapher/index.rst b/doc/source/api/grapher/index.rst index 15ceebb..6b65320 100644 --- a/doc/source/api/grapher/index.rst +++ b/doc/source/api/grapher/index.rst @@ -15,30 +15,41 @@ Core module Graphers ======== -Spectrogram + +Waveform ----------- -.. automodule:: timeside.grapher.spectrogram +.. automodule:: timeside.grapher.waveform_simple :members: -Waveform ------------ +WaveformCentroid +------------------ -.. automodule:: timeside.grapher.waveform +.. automodule:: timeside.grapher.waveform_centroid :members: -Simple Waveform ---------------- +WaveformTransparent +-------------------- -.. automodule:: timeside.grapher.waveform_simple +.. automodule:: timeside.grapher.waveform_centroid :members: -Contour Waveform (white) +WaveformContour ------------------------ -.. automodule:: timeside.grapher.waveform_contour_wh + +.. automodule:: timeside.grapher.waveform_contour :members: -Contour Waveform (black) ------------------------- -.. automodule:: timeside.grapher.waveform_contour_bk + +SpectrogramLog +--------------- + +.. automodule:: timeside.grapher.spectrogram_log + :members: + + +SpectrogramLin +--------------- + +.. automodule:: timeside.grapher.spectrogram_lin :members: diff --git a/tests/test_graphing.py b/tests/test_graphing.py index cd5da61..9999b07 100755 --- a/tests/test_graphing.py +++ b/tests/test_graphing.py @@ -103,28 +103,28 @@ class TestGraphing(TestCase): # WAVEFORMS CONTOUR BLACK def testWav2WaveformContourBlack(self): "Test WAV to WaveformContourBlack" - from timeside.grapher.waveform_contour_black import WaveformContourBlack + from timeside.grapher.waveform_contour import WaveformContourBlack self.source = os.path.join (os.path.dirname(__file__), "samples/sweep.wav") self.image = "/tmp/test_waveform_contour_bk_sweep_wav.png" self.grapher = WaveformContourBlack(width=1024, height=256, bg_color=(0,0,0), color_scheme='default') def testFlac2WaveformContourBlack(self): "Test FLAC to WaveformContourBlack" - from timeside.grapher.waveform_contour_black import WaveformContourBlack + from timeside.grapher.waveform_contour import WaveformContourBlack self.source = os.path.join (os.path.dirname(__file__), "samples/sweep.flac") self.image = "/tmp/test_waveform_contour_bk_sweep_flac.png" self.grapher = WaveformContourBlack(width=1024, height=256, bg_color=(0,0,0), color_scheme='default') def testMp32WaveformContourBlack(self): "Test MP3 to WaveformContourBlack" - from timeside.grapher.waveform_contour_black import WaveformContourBlack + from timeside.grapher.waveform_contour import WaveformContourBlack self.source = os.path.join (os.path.dirname(__file__), "samples/sweep.mp3") self.image = "/tmp/test_waveform_contour_bk_sweep_mp3.png" self.grapher = WaveformContourBlack(width=1024, height=256, bg_color=(0,0,0), color_scheme='default') def testOgg2WaveformContourBlack(self): "Test OGG to WaveformContourBlack" - from timeside.grapher.waveform_contour_black import WaveformContourBlack + from timeside.grapher.waveform_contour import WaveformContourBlack self.source = os.path.join (os.path.dirname(__file__), "samples/sweep.ogg") self.image = "/tmp/test_waveform_contour_bk_sweep_ogg.png" self.grapher = WaveformContourBlack(width=1024, height=256, bg_color=(0,0,0), color_scheme='default') @@ -132,28 +132,28 @@ class TestGraphing(TestCase): # WAVEFORMS CONTOUR WHITE def testWav2WaveformContourWhite(self): "Test WAV to WaveformContourWhite" - from timeside.grapher.waveform_contour_white import WaveformContourWhite + from timeside.grapher.waveform_contour import WaveformContourWhite self.source = os.path.join (os.path.dirname(__file__), "samples/sweep.wav") self.image = "/tmp/test_waveform_contour_wh_sweep_wav.png" self.grapher = WaveformContourWhite(width=1024, height=256, bg_color=(255,255,255), color_scheme='default') def testFlac2WaveformContourWhite(self): "Test FLAC to WaveformContourWhite" - from timeside.grapher.waveform_contour_white import WaveformContourWhite + from timeside.grapher.waveform_contour import WaveformContourWhite self.source = os.path.join (os.path.dirname(__file__), "samples/sweep.flac") self.image = "/tmp/test_waveform_contour_wh_sweep_flac.png" self.grapher = WaveformContourWhite(width=1024, height=256, bg_color=(255,255,255), color_scheme='default') def testMp32WaveformContourWhite(self): "Test MP3 to WaveformContourWhite" - from timeside.grapher.waveform_contour_white import WaveformContourWhite + from timeside.grapher.waveform_contour import WaveformContourWhite self.source = os.path.join (os.path.dirname(__file__), "samples/sweep.mp3") self.image = "/tmp/test_waveform_contour_wh_sweep_mp3.png" self.grapher = WaveformContourWhite(width=1024, height=256, bg_color=(255,255,255), color_scheme='default') def testOggWaveformContourWhite(self): "Test OGG to WaveformContourWhite" - from timeside.grapher.waveform_contour_white import WaveformContourWhite + from timeside.grapher.waveform_contour import WaveformContourWhite self.source = os.path.join (os.path.dirname(__file__), "samples/sweep.ogg") self.image = "/tmp/test_waveform_contour_wh_sweep_ogg.png" self.grapher = WaveformContourWhite(width=1024, height=256, bg_color=(255,255,255), color_scheme='default') diff --git a/timeside/grapher/__init__.py b/timeside/grapher/__init__.py index 0d96038..1cfd820 100644 --- a/timeside/grapher/__init__.py +++ b/timeside/grapher/__init__.py @@ -3,7 +3,6 @@ from waveform_simple import * from waveform_centroid import * from waveform_transparent import * -from waveform_contour_black import * -from waveform_contour_white import * +from waveform_contour import * from spectrogram_log import * from spectrogram_lin import * diff --git a/timeside/grapher/waveform_contour_black.py b/timeside/grapher/waveform_contour.py similarity index 77% rename from timeside/grapher/waveform_contour_black.py rename to timeside/grapher/waveform_contour.py index 3f79d0a..6fe2e38 100644 --- a/timeside/grapher/waveform_contour_black.py +++ b/timeside/grapher/waveform_contour.py @@ -26,6 +26,8 @@ from timeside.grapher.waveform_simple import Waveform class WaveformContourBlack(Waveform): + """ Builds a PIL image representing an amplitude coutour (envelop) of the audio stream. + """ implements(IGrapher) @@ -64,3 +66,27 @@ class WaveformContourBlack(Waveform): if eod: self.draw_peaks_contour() return frames, eod + + + +class WaveformContourWhite(WaveformContourBlack): + + """ Builds a PIL image representing an amplitude coutour (envelop) of the audio stream. + """ + + implements(IGrapher) + + @interfacedoc + def __init__(self, width=1024, height=256, bg_color=(255,255,255), color_scheme='default'): + super(WaveformContourWhite, self).__init__(width, height, bg_color, color_scheme) + self.color_offset = 60 + + @staticmethod + @interfacedoc + def id(): + return "waveform_contour_white" + + @staticmethod + @interfacedoc + def name(): + return "Contour white" diff --git a/timeside/grapher/waveform_contour_white.py b/timeside/grapher/waveform_contour_white.py deleted file mode 100644 index cdd3e95..0000000 --- a/timeside/grapher/waveform_contour_white.py +++ /dev/null @@ -1,49 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright (c) 2007-2010 Guillaume Pellerin -# Copyright (c) 2010 Olivier Guilyardi - -# This file is part of TimeSide. - -# TimeSide is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 2 of the License, or -# (at your option) any later version. - -# TimeSide is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with TimeSide. If not, see . - - -from timeside.core import Processor, implements, interfacedoc, FixedSizeInputAdapter -from timeside.api import IGrapher -from timeside.grapher.core import * -from timeside.grapher.waveform_contour_black import WaveformContourBlack - - -class WaveformContourWhite(WaveformContourBlack): - - implements(IGrapher) - - @interfacedoc - def __init__(self, width=1024, height=256, bg_color=(255,255,255), color_scheme='default'): - super(WaveformContourWhite, self).__init__(width, height, bg_color, color_scheme) - self.color_offset = 60 - - @staticmethod - @interfacedoc - def id(): - return "waveform_contour_white" - - @staticmethod - @interfacedoc - def name(): - return "Contour white" - - @interfacedoc - def setup(self, channels=None, samplerate=None, blocksize=None, totalframes=None): - super(WaveformContourWhite, self).setup(channels, samplerate, blocksize, totalframes) diff --git a/timeside/grapher/waveform_simple.py b/timeside/grapher/waveform_simple.py index 49badfa..887babe 100644 --- a/timeside/grapher/waveform_simple.py +++ b/timeside/grapher/waveform_simple.py @@ -25,8 +25,7 @@ from timeside.grapher.core import * class Waveform(Grapher): - """ Builds a PIL image representing a waveform of the audio stream. - Adds pixels iteratively thanks to the adapter providing fixed size frame buffers. + """ Builds a PIL image representing a simple waveform of the audio stream. """ implements(IGrapher) diff --git a/timeside/grapher/waveform_transparent.py b/timeside/grapher/waveform_transparent.py index 0e5b246..ee017c6 100644 --- a/timeside/grapher/waveform_transparent.py +++ b/timeside/grapher/waveform_transparent.py @@ -26,8 +26,7 @@ from timeside.grapher.waveform_simple import Waveform class WaveformTransparent(Waveform): - """ Builds a PIL image representing a waveform of the audio stream. - Adds pixels iteratively thanks to the adapter providing fixed size frame buffers. + """ Builds a PIL image representing a transparent waveform of the audio stream. """ implements(IGrapher) -- 2.39.5