]> git.parisson.com Git - timeside.git/commitdiff
add docstrings, cleanup
authorGuillaume Pellerin <yomguy@parisson.com>
Fri, 8 Nov 2013 01:06:21 +0000 (02:06 +0100)
committerGuillaume Pellerin <yomguy@parisson.com>
Fri, 8 Nov 2013 01:06:21 +0000 (02:06 +0100)
doc/source/api/grapher/index.rst
tests/test_graphing.py
timeside/grapher/__init__.py
timeside/grapher/waveform_contour.py [new file with mode: 0644]
timeside/grapher/waveform_contour_black.py [deleted file]
timeside/grapher/waveform_contour_white.py [deleted file]
timeside/grapher/waveform_simple.py
timeside/grapher/waveform_transparent.py

index 15ceebb2a56078e76a111e224f0e8c33d365323d..6b65320f72828b61d8cb5639677e47b1b372b34b 100644 (file)
@@ -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:
index cd5da61379dc5ed3e41f2b3508b94b391f1f8864..9999b07e5e6f1c4b214ce158b3aae437761406c9 100755 (executable)
@@ -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')
index 0d960388406a262a9e72aae0bb1395640aa46f1f..1cfd82029471bc7b5c1dc3cdabce5af49ae63a6c 100644 (file)
@@ -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.py b/timeside/grapher/waveform_contour.py
new file mode 100644 (file)
index 0000000..6fe2e38
--- /dev/null
@@ -0,0 +1,92 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright (c) 2007-2010 Guillaume Pellerin <yomguy@parisson.com>
+# Copyright (c) 2010 Olivier Guilyardi <olivier@samalyse.com>
+
+# 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 <http://www.gnu.org/licenses/>.
+
+
+from timeside.core import Processor, implements, interfacedoc, FixedSizeInputAdapter
+from timeside.api import IGrapher
+from timeside.grapher.core import *
+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)
+
+    @interfacedoc
+    def __init__(self, width=1024, height=256, bg_color=(0,0,0), color_scheme='default'):
+        super(WaveformContourBlack, self).__init__(width, height, bg_color, color_scheme)
+        self.contour = numpy.zeros(self.image_width)
+        self.ndiv = 4
+        self.x = numpy.r_[0:self.image_width-1:1]
+        self.symetry = True
+        self.color_offset = 160
+
+    @staticmethod
+    @interfacedoc
+    def id():
+        return "waveform_contour_black"
+
+    @staticmethod
+    @interfacedoc
+    def name():
+        return "Contour black"
+
+    @interfacedoc
+    def setup(self, channels=None, samplerate=None, blocksize=None, totalframes=None):
+        super(WaveformContourBlack, self).setup(channels, samplerate, blocksize, totalframes)
+
+    @interfacedoc
+    def process(self, frames, eod=False):
+        if len(frames) != 1:
+            buffer = frames[:,0].copy()
+            buffer.shape = (len(buffer),1)
+            for samples, end in self.pixels_adapter.process(buffer, eod):
+                if self.pixel_cursor < self.image_width:
+                    self.contour[self.pixel_cursor] = numpy.max(peaks(samples))
+                    self.pixel_cursor += 1
+        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_black.py b/timeside/grapher/waveform_contour_black.py
deleted file mode 100644 (file)
index 3f79d0a..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# Copyright (c) 2007-2010 Guillaume Pellerin <yomguy@parisson.com>
-# Copyright (c) 2010 Olivier Guilyardi <olivier@samalyse.com>
-
-# 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 <http://www.gnu.org/licenses/>.
-
-
-from timeside.core import Processor, implements, interfacedoc, FixedSizeInputAdapter
-from timeside.api import IGrapher
-from timeside.grapher.core import *
-from timeside.grapher.waveform_simple import Waveform
-
-
-class WaveformContourBlack(Waveform):
-
-    implements(IGrapher)
-
-    @interfacedoc
-    def __init__(self, width=1024, height=256, bg_color=(0,0,0), color_scheme='default'):
-        super(WaveformContourBlack, self).__init__(width, height, bg_color, color_scheme)
-        self.contour = numpy.zeros(self.image_width)
-        self.ndiv = 4
-        self.x = numpy.r_[0:self.image_width-1:1]
-        self.symetry = True
-        self.color_offset = 160
-
-    @staticmethod
-    @interfacedoc
-    def id():
-        return "waveform_contour_black"
-
-    @staticmethod
-    @interfacedoc
-    def name():
-        return "Contour black"
-
-    @interfacedoc
-    def setup(self, channels=None, samplerate=None, blocksize=None, totalframes=None):
-        super(WaveformContourBlack, self).setup(channels, samplerate, blocksize, totalframes)
-
-    @interfacedoc
-    def process(self, frames, eod=False):
-        if len(frames) != 1:
-            buffer = frames[:,0].copy()
-            buffer.shape = (len(buffer),1)
-            for samples, end in self.pixels_adapter.process(buffer, eod):
-                if self.pixel_cursor < self.image_width:
-                    self.contour[self.pixel_cursor] = numpy.max(peaks(samples))
-                    self.pixel_cursor += 1
-        if eod:
-            self.draw_peaks_contour()
-        return frames, eod
diff --git a/timeside/grapher/waveform_contour_white.py b/timeside/grapher/waveform_contour_white.py
deleted file mode 100644 (file)
index cdd3e95..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# Copyright (c) 2007-2010 Guillaume Pellerin <yomguy@parisson.com>
-# Copyright (c) 2010 Olivier Guilyardi <olivier@samalyse.com>
-
-# 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 <http://www.gnu.org/licenses/>.
-
-
-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)
index 49badface434ea37666cd15408e22196bc4af47e..887babe7920a927d962a813bb8f51c2137dd2e4f 100644 (file)
@@ -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)
index 0e5b246c5bc1f84139ea2b60a345abff136b4f0b..ee017c6f120ee95184c2a7b4cb28a9d12e51c58d 100644 (file)
@@ -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)