From: Thomas Fillon Date: Mon, 28 Apr 2014 05:58:40 +0000 (+0200) Subject: Change modules's init files X-Git-Tag: 0.5.5~1^2~26^2~2^2^2~7 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=13e686e41c014a752e0f34f698760a8c2c6bbe73;p=timeside.git Change modules's init files --- diff --git a/README.rst b/README.rst index e0548af..c1bb59a 100644 --- a/README.rst +++ b/README.rst @@ -114,9 +114,9 @@ News * Encoder : transcoded streams where broken. Now fixed with some smart thread controls. * Analyzer : update VAMP plugin example in sandbox * Analyzer : new *experimental* plugin : Limsi Speech Activity Detection Systems (limsi_sad) - * Decoder : process any media in streaming mode giving its URL + * Decoder : process any media in streaming mode giving its URL * Install : fix some setup requirements - + 0.5.3 * Make Analyzer rendering more generic and easy to implement @@ -129,7 +129,7 @@ News * Grapher : add a generic Class to display Analyzers through their 'render' method. For now, it only support FrameValueResult analyzer * Core : add a condition to catch signal only if a LiveDecoder source is used * Various bugfixes - + 0.5.2 * Add a general launch script "timeside-launch" (see "Shell interface") @@ -242,7 +242,7 @@ Dive in Define some processors:: >>> import timeside - >>> decoder = timeside.decoder.FileDecoder('sweep.wav') + >>> decoder = timeside.decoder.file.FileDecoder('sweep.wav') >>> grapher = timeside.grapher.Waveform() >>> analyzer = timeside.analyzer.Level() >>> encoder = timeside.encoder.VorbisEncoder('sweep.ogg') diff --git a/tests/sandbox/test_lolevel_streaming.py b/tests/sandbox/test_lolevel_streaming.py index ee48d69..e0f6e2b 100644 --- a/tests/sandbox/test_lolevel_streaming.py +++ b/tests/sandbox/test_lolevel_streaming.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- from timeside.core import * -from timeside.decoder import FileDecoder +from timeside.decoder.file import FileDecoder from timeside.encoder import Mp3Encoder import sys diff --git a/tests/sandbox/test_lolevel_streaming_threaded.py b/tests/sandbox/test_lolevel_streaming_threaded.py index c3a97eb..1e19dab 100644 --- a/tests/sandbox/test_lolevel_streaming_threaded.py +++ b/tests/sandbox/test_lolevel_streaming_threaded.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- from timeside.core import * -from timeside.decoder import FileDecoder +from timeside.decoder.file import FileDecoder from timeside.encoder import Mp3Encoder import sys diff --git a/tests/sandbox/test_lolevel_streaming_threaded_ogg.py b/tests/sandbox/test_lolevel_streaming_threaded_ogg.py index 881ddbe..7b41879 100644 --- a/tests/sandbox/test_lolevel_streaming_threaded_ogg.py +++ b/tests/sandbox/test_lolevel_streaming_threaded_ogg.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- from timeside.core import * -from timeside.decoder import FileDecoder +from timeside.decoder.file import FileDecoder from timeside.encoder import Mp3Encoder, VorbisEncoder import sys diff --git a/tests/test_analyzer_dc.py b/tests/test_analyzer_dc.py index 68890cb..69c8a88 100755 --- a/tests/test_analyzer_dc.py +++ b/tests/test_analyzer_dc.py @@ -1,7 +1,7 @@ #! /usr/bin/env python from unit_timeside import * -from timeside.decoder import FileDecoder +from timeside.decoder.file import FileDecoder from timeside.analyzer.dc import MeanDCShift import os diff --git a/tests/test_analyzer_level.py b/tests/test_analyzer_level.py index 97c1f66..6fb00b7 100755 --- a/tests/test_analyzer_level.py +++ b/tests/test_analyzer_level.py @@ -1,7 +1,7 @@ #! /usr/bin/env python from unit_timeside import * -from timeside.decoder import FileDecoder +from timeside.decoder.file import FileDecoder from timeside.analyzer.level import Level import os diff --git a/tests/test_array_decoding.py b/tests/test_array_decoding.py index f68dfef..fd2a56f 100755 --- a/tests/test_array_decoding.py +++ b/tests/test_array_decoding.py @@ -1,7 +1,7 @@ #! /usr/bin/env python from __future__ import division -from timeside.decoder import ArrayDecoder +from timeside.decoder.array import ArrayDecoder from unit_timeside import * import numpy as np diff --git a/tests/test_aubio_melenergy.py b/tests/test_aubio_melenergy.py index 5356001..f5ff1d0 100755 --- a/tests/test_aubio_melenergy.py +++ b/tests/test_aubio_melenergy.py @@ -1,7 +1,7 @@ #! /usr/bin/env python from unit_timeside import * -from timeside.decoder import FileDecoder +from timeside.decoder.file import FileDecoder from timeside.analyzer import WITH_AUBIO if WITH_AUBIO: from timeside.analyzer.aubio_melenergy import AubioMelEnergy diff --git a/tests/test_aubio_mfcc.py b/tests/test_aubio_mfcc.py index 2c40287..d7d5ce7 100755 --- a/tests/test_aubio_mfcc.py +++ b/tests/test_aubio_mfcc.py @@ -1,7 +1,7 @@ #! /usr/bin/env python from unit_timeside import * -from timeside.decoder import FileDecoder +from timeside.decoder.file import FileDecoder from timeside.analyzer import WITH_AUBIO if WITH_AUBIO: from timeside.analyzer.aubio_mfcc import AubioMfcc diff --git a/tests/test_aubio_pitch.py b/tests/test_aubio_pitch.py index cb43bcd..dc6022d 100755 --- a/tests/test_aubio_pitch.py +++ b/tests/test_aubio_pitch.py @@ -1,7 +1,7 @@ #! /usr/bin/env python from unit_timeside import * -from timeside.decoder import * +from timeside.decoder.file import FileDecoder from timeside.analyzer import WITH_AUBIO if WITH_AUBIO: from timeside.analyzer.aubio_pitch import AubioPitch diff --git a/tests/test_aubio_specdesc.py b/tests/test_aubio_specdesc.py index 4e561c6..1fe1255 100755 --- a/tests/test_aubio_specdesc.py +++ b/tests/test_aubio_specdesc.py @@ -1,7 +1,7 @@ #! /usr/bin/env python from unit_timeside import * -from timeside.decoder import FileDecoder +from timeside.decoder.file import FileDecoder from timeside.analyzer import WITH_AUBIO if WITH_AUBIO: from timeside.analyzer.aubio_specdesc import AubioSpecdesc diff --git a/tests/test_aubio_temporal.py b/tests/test_aubio_temporal.py index 7011da6..2dd0801 100755 --- a/tests/test_aubio_temporal.py +++ b/tests/test_aubio_temporal.py @@ -1,7 +1,7 @@ #! /usr/bin/env python from unit_timeside import * -from timeside.decoder import FileDecoder +from timeside.decoder.file import FileDecoder from timeside.analyzer import WITH_AUBIO if WITH_AUBIO: from timeside.analyzer.aubio_temporal import AubioTemporal diff --git a/tests/test_decoding.py b/tests/test_decoding.py index 057af4a..5ce3f82 100755 --- a/tests/test_decoding.py +++ b/tests/test_decoding.py @@ -2,7 +2,7 @@ from __future__ import division -from timeside.decoder import FileDecoder +from timeside.decoder.file import FileDecoder from timeside.core import ProcessPipe from unit_timeside import * @@ -127,7 +127,7 @@ class TestDecoding(unittest.TestCase): expected_totalframes = [self.expected_totalframes, self.expected_totalframes +32] # +32 to handle some issue with ogg self.assertIn(totalframes, expected_totalframes) - + input_duration = decoder.input_totalframes / decoder.input_samplerate output_duration = decoder.totalframes() / decoder.output_samplerate if self.test_exact_duration: diff --git a/tests/test_decoding_stack.py b/tests/test_decoding_stack.py index 0203211..4650a75 100755 --- a/tests/test_decoding_stack.py +++ b/tests/test_decoding_stack.py @@ -2,7 +2,7 @@ from __future__ import division -from timeside.decoder import FileDecoder +from timeside.decoder.file import FileDecoder from timeside.analyzer import Level from timeside.core import ProcessPipe import numpy as np diff --git a/tests/test_encoding.py b/tests/test_encoding.py index 8df16b6..388d062 100755 --- a/tests/test_encoding.py +++ b/tests/test_encoding.py @@ -6,7 +6,7 @@ from math import pi import numpy as np from unit_timeside import * from timeside.decoder.utils import get_uri, get_media_uri_info -from timeside.decoder import ArrayDecoder +from timeside.decoder.array import ArrayDecoder import os from tools import tmp_file_sink diff --git a/tests/test_graphing.py b/tests/test_graphing.py index 5322b6a..51bad4d 100755 --- a/tests/test_graphing.py +++ b/tests/test_graphing.py @@ -1,6 +1,6 @@ #! /usr/bin/env python -from timeside.decoder import FileDecoder +from timeside.decoder.file import FileDecoder from unit_timeside import * import os.path diff --git a/tests/test_transcoding.py b/tests/test_transcoding.py index d345ead..a42aedc 100755 --- a/tests/test_transcoding.py +++ b/tests/test_transcoding.py @@ -3,7 +3,7 @@ from __future__ import division from timeside.core import * -from timeside.decoder import * +from timeside.decoder.file import FileDecoder from timeside.analyzer import * from timeside.encoder import * from timeside.component import * diff --git a/tests/test_transcoding_streaming.py b/tests/test_transcoding_streaming.py index 2ff0f4a..a7655fc 100755 --- a/tests/test_transcoding_streaming.py +++ b/tests/test_transcoding_streaming.py @@ -2,11 +2,11 @@ from __future__ import division -from timeside.core import * -from timeside.decoder import * -from timeside.analyzer import * +#from timeside.core import * +from timeside.decoder.file import FileDecoder +#from timeside.analyzer import * from timeside.encoder import * -from timeside.component import * +#from timeside.component import * from unit_timeside import * from tools import tmp_file_sink diff --git a/tests/test_yaafe.py b/tests/test_yaafe.py index a7ed80a..50b6dfe 100755 --- a/tests/test_yaafe.py +++ b/tests/test_yaafe.py @@ -1,7 +1,7 @@ #! /usr/bin/env python from unit_timeside import * -from timeside.decoder import FileDecoder +from timeside.decoder.file import FileDecoder from timeside.analyzer import WITH_YAAFE if WITH_YAAFE: from timeside.analyzer import Yaafe diff --git a/timeside/__init__.py b/timeside/__init__.py index ce217f4..f1a0bcd 100644 --- a/timeside/__init__.py +++ b/timeside/__init__.py @@ -10,3 +10,28 @@ import encoder __version__ = '0.5.5' __all__ = ['api', 'core', 'decoder', 'analyzer', 'grapher', 'encoder'] + +print __file__ +print __name__ + +def _discover_modules(): + import sys + import pkgutil + import importlib + pkg = 'timeside' + #__import__(pkg) + package = sys.modules[pkg] + prefix = pkg + "." + + for importer, modname, ispkg in pkgutil.iter_modules(package.__path__, + prefix): + #print modname + if modname.split('.')[1] in ['decoder', 'analyzer', 'encoder', 'grapher']: + print modname + mod = importlib.import_module(modname) + + del mod + del modname + + +_discover_modules() diff --git a/timeside/analyzer/core.py b/timeside/analyzer/core.py index f2a2548..fa18941 100644 --- a/timeside/analyzer/core.py +++ b/timeside/analyzer/core.py @@ -869,7 +869,7 @@ class AnalyzerResultContainer(dict): >>> import timeside >>> from timeside.analyzer.core import Analyzer >>> wav_file = 'tests/samples/sweep.mp3' # doctest: +SKIP - >>> d = timeside.decoder.FileDecoder(wav_file) + >>> d = timeside.decoder.file.FileDecoder(wav_file) >>> a = Analyzer() >>> (d|a).run() diff --git a/timeside/decoder/__init__.py b/timeside/decoder/__init__.py index ee59bda..ebd2f39 100644 --- a/timeside/decoder/__init__.py +++ b/timeside/decoder/__init__.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- -from file import FileDecoder -from array import ArrayDecoder -from live import LiveDecoder - -__all__ = ['FileDecoder', 'ArrayDecoder', 'LiveDecoder'] +#from file import FileDecoder +#from array import ArrayDecoder +#from live import LiveDecoder +# +#__all__ = ['FileDecoder', 'ArrayDecoder', 'LiveDecoder'] diff --git a/timeside/decoder/file.py b/timeside/decoder/file.py index 62d8ecf..88bedc1 100644 --- a/timeside/decoder/file.py +++ b/timeside/decoder/file.py @@ -50,7 +50,7 @@ class FileDecoder(Decoder): def id(): return "gst_dec" - def __init__(self, uri, start=0, duration=None, stack=False): + def __init__(self, uri, start=0, duration=None, stack=False, sha1=None): """ Construct a new FileDecoder @@ -71,7 +71,11 @@ class FileDecoder(Decoder): self.stack = stack self.uri = get_uri(uri) - self._sha1 = get_sha1(uri) + + if not sha1: + self._sha1 = get_sha1(uri) + else: + self._sha1 = sha1 self.uri_total_duration = get_media_uri_info(self.uri)['duration'] diff --git a/timeside/decoder/live.py b/timeside/decoder/live.py index ae9b7ba..c8dcb8d 100644 --- a/timeside/decoder/live.py +++ b/timeside/decoder/live.py @@ -63,9 +63,9 @@ class LiveDecoder(Decoder): >>> import timeside - >>> live = timeside.decoder.LiveDecoder(num_buffers=5) + >>> live = timeside.decoder.live.LiveDecoder(num_buffers=5) >>> a = timeside.analyzer.Waveform() - >>> e = timeside.encoder.Mp3Encoder('/tmp/test_live.mp3', + >>> e = timeside.encoder.mp3.Mp3Encoder('/tmp/test_live.mp3', ... overwrite=True) >>> pipe = (live | a | e) >>> pipe.run() # doctest: +SKIP diff --git a/timeside/encoder/__init__.py b/timeside/encoder/__init__.py index 4c6d4ee..f04257d 100644 --- a/timeside/encoder/__init__.py +++ b/timeside/encoder/__init__.py @@ -1,13 +1,13 @@ # -*- coding: utf-8 -*- - -from ogg import VorbisEncoder -from wav import WavEncoder -from mp3 import Mp3Encoder -from flac import FlacEncoder -from m4a import AacEncoder -from webm import WebMEncoder -from audiosink import AudioSink -from opus import OpusEncoder - -__all__ = ['VorbisEncoder', 'WavEncoder', 'Mp3Encoder', 'FlacEncoder', - 'AacEncoder', 'WebMEncoder', 'AudioSink', 'OpusEncoder'] +# +#from ogg import VorbisEncoder +#from wav import WavEncoder +#from mp3 import Mp3Encoder +#from flac import FlacEncoder +#from m4a import AacEncoder +#from webm import WebMEncoder +#from audiosink import AudioSink +#from opus import OpusEncoder +# +#__all__ = ['VorbisEncoder', 'WavEncoder', 'Mp3Encoder', 'FlacEncoder', +# 'AacEncoder', 'WebMEncoder', 'AudioSink', 'OpusEncoder'] diff --git a/timeside/encoder/audiosink.py b/timeside/encoder/audiosink.py index 524d685..5424700 100644 --- a/timeside/encoder/audiosink.py +++ b/timeside/encoder/audiosink.py @@ -35,8 +35,8 @@ class AudioSink(GstEncoder): >>> import timeside >>> wav_file = 'tests/samples/guitar.wav' # doctest: +SKIP - >>> d = timeside.decoder.FileDecoder(wav_file) - >>> e = timeside.encoder.AudioSink() + >>> d = timeside.decoder.file.FileDecoder(wav_file) + >>> e = timeside.encoder.audiosink.AudioSink() >>> (d|e).run() # doctest: +SKIP """