]> git.parisson.com Git - timeside.git/commitdiff
Fix doctest and add plot example to spectrogram
authorThomas Fillon <thomas@parisson.com>
Tue, 21 Oct 2014 09:25:57 +0000 (11:25 +0200)
committerThomas Fillon <thomas@parisson.com>
Tue, 21 Oct 2014 09:25:57 +0000 (11:25 +0200)
doc/source/conf.py
doc/source/tutorial/frames_stack.rst
doc/source/tutorial/quick_start.rst
timeside/analyzer/level.py
timeside/analyzer/spectrogram.py
timeside/encoder/audiosink.py

index d36a1edc79fbea06750473964cb26e7ddf16e5a0..349d6c359d6e0d02f849da9b652afd9985363ce1 100644 (file)
@@ -26,7 +26,13 @@ sys.path.insert(0, os.path.abspath('../../'))
 
 # Add any Sphinx extension module names here, as strings. They can be extensions
 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
-extensions = ['sphinx.ext.autodoc', 'sphinx.ext.coverage', 'sphinx.ext.viewcode', 'sphinx.ext.autosummary', 'sphinx.ext.doctest', 'numpydoc']
+extensions = ['sphinx.ext.autodoc',
+              'sphinx.ext.coverage',
+              'sphinx.ext.viewcode',
+              'sphinx.ext.autosummary',
+              'sphinx.ext.doctest', 'numpydoc',
+              'matplotlib.sphinxext.mathmpl',
+              'matplotlib.sphinxext.plot_directive']
 
 doctest_path = os.path.abspath('../../')
 doctest_global_setup = '''
index b14002f5cdf3ffedd8405920de0d76dc5599280d..4d50a0da8149560aecd2e4e88a232367b0ca24dc 100644 (file)
@@ -23,7 +23,7 @@ Setup an arbitrary analyzer to check that decoding process from file and from st
 >>> pitch = get_processor('aubio_pitch')()
 >>> pipe = (decoder | pitch)
 >>> print pipe.processors #doctest: +ELLIPSIS
-[gst_dec-{}, aubio_pitch-{}]
+[gst_dec-{}, aubio_pitch-{"blocksize_s": 0.0, "stepsize_s": 0.0}]
 
 
 Run the pipe:
index c8207ff90dfb2e118043c188dc9bf2d7577634c8..bbbb3acc34f33bbdc09f76df0399d05a268ba06a 100644 (file)
@@ -62,4 +62,4 @@ analysis and encoding:
    >>> encoders = get_processor('gst_mp3_enc')('sweep.mp3') | get_processor('gst_flac_enc')('sweep.flac')
    >>> (decoder | levels | encoders).run()
    >>> print levels.results
-   {'...': AnalyzerResult(id_metadata=IdMetadata(id='level.max', name='Level Max', unit='dBFS', description='', date='...', version='...', author='TimeSide', proc_uuid='...', res_uuid='...'), data_object=GlobalValueObject(value=array([-6.021]), y_value=array([], dtype=float64)), audio_metadata=AudioMetadata(uri='.../sweep.wav', start=0.0, duration=8.0, is_segment=False, sha1='...', channels=2, channelsManagement=''), parameters={}), '...': AnalyzerResult(id_metadata=IdMetadata(id='level.rms', name='Level RMS', unit='dBFS', description='', date='...', version='...', author='TimeSide', proc_uuid='...', res_uuid='...'), data_object=GlobalValueObject(value=array([-9.856]), y_value=array([], dtype=float64)), audio_metadata=AudioMetadata(uri='.../sweep.wav', start=0.0, duration=8.0, is_segment=False, sha1='...', channels=2, channelsManagement=''), parameters={})}
+   {'...': AnalyzerResult(id_metadata=IdMetadata(id='level.max', name='Level Max', unit='dBFS', description='', date='...', version='...', author='TimeSide', proc_uuid='...', res_uuid='...'), data_object=GlobalValueObject(value=array([ 0.]), y_value=array([], dtype=float64)), audio_metadata=AudioMetadata(uri='.../sweep.wav', start=0.0, duration=8.0, is_segment=False, sha1='...', channels=2, channelsManagement=''), parameters={}), '...': AnalyzerResult(id_metadata=IdMetadata(id='level.rms', name='Level RMS', unit='dBFS', description='', date='...', version='...', author='TimeSide', proc_uuid='...', res_uuid='...'), data_object=GlobalValueObject(value=array([-2.995]), y_value=array([], dtype=float64)), audio_metadata=AudioMetadata(uri='.../sweep.wav', start=0.0, duration=8.0, is_segment=False, sha1='...', channels=2, channelsManagement=''), parameters={})}
index 9b4cc4c776965d2e43e4ec51329261195a03f0d9..edf477574364c31a402f581c38cd61f8885fb1fe 100644 (file)
@@ -29,7 +29,8 @@ from timeside.analyzer.utils import MACHINE_EPSILON
 
 class Level(Analyzer):
 
-    """RMS level analyzer"""
+    """RMS level analyzer
+    """
     implements(IValueAnalyzer)
 
     @interfacedoc
@@ -93,3 +94,7 @@ class Level(Analyzer):
 
         rms_level.data_object.value = np.round(20 * np.log10(rms_val), 3)
         self.add_result(rms_level)
+
+if __name__ == "__main__":
+    import doctest
+    print doctest.testmod(verbose=True)
index 10a745abf5546ff88bf5f4f556896916a10d3d8b..33a34599902abf1eb5caaa28caf25081a1ce18a7 100644 (file)
@@ -18,6 +18,7 @@
 # along with TimeSide.  If not, see <http://www.gnu.org/licenses/>.
 
 # Author: Paul Brossier <piem@piem.org>
+
 from __future__ import division
 from timeside.core import implements, interfacedoc
 from timeside.analyzer.core import Analyzer
@@ -26,12 +27,12 @@ from timeside.analyzer.preprocessors import downmix_to_mono, frames_adapter
 from timeside.tools.parameters import Int, HasTraits
 from timeside.tools.buffering import BufferTable
 
-
 import numpy as np
 
 
 class Spectrogram(Analyzer):
-    """Spectrogram analyzer
+    """
+    Spectrogram analyzer
 
     Parameters
     ----------
@@ -44,15 +45,31 @@ class Spectrogram(Analyzer):
 
     Examples
     --------
-
     >>> import timeside
+    >>> from timeside.core import get_processor
     >>> from timeside.tools.data_samples import samples as ts_samples
     >>> audio_source = ts_samples['sweep.wav']
-    >>> decoder = timeside.decoder.file.FileDecoder(uri=audio_source)
-    >>> spectrogram = timeside.analyzer.spectrogram.Spectrogram(input_blocksize=2048, input_stepsize=1024)
+    >>> decoder = get_processor('gst_dec')(uri=audio_source)
+    >>> spectrogram = get_processor('spectrogram_analyzer')(input_blocksize=2048, input_stepsize=1024)
     >>> pipe = (decoder | spectrogram)
     >>> pipe.run()
 
+
+     .. plot::
+
+      import timeside
+      from timeside.core import get_processor
+      from timeside.tools.data_samples import samples as ts_samples
+      audio_source = ts_samples['sweep.wav']
+      decoder = get_processor('gst_dec')(uri=audio_source)
+      spectrogram = get_processor('spectrogram_analyzer')(input_blocksize=2048,
+                                                          input_stepsize=1024)
+      pipe = (decoder | spectrogram)
+      pipe.run()
+      res = spectrogram.results['spectrogram_analyzer']
+      res.render()
+
+
     """
     implements(IAnalyzer)
 
@@ -122,4 +139,5 @@ class Spectrogram(Analyzer):
 
 if __name__ == "__main__":
     import doctest
-    doctest.testmod()
+    import timeside
+    doctest.testmod(timeside.analyzer.spectrogram, verbose=True)
index 8dd6d780420e6a11e348729056a280590b591880..b8fa80ffb8f45f88c9dc58032ce292cd5d3d7ad7 100644 (file)
@@ -99,5 +99,5 @@ class AudioSink(GstEncoder):
 
 if __name__ == "__main__":
     import doctest
-
-    doctest.testmod()
+    import timeside
+    doctest.testmod(timeside.decoder.live, verbose=True)