From 8e8670e644739261135bfb94c662ad1c93bceb9b Mon Sep 17 00:00:00 2001 From: yomguy Date: Fri, 18 Jun 2010 16:57:22 +0000 Subject: [PATCH] fix many wrong init, fix decoder unknown uri, add dependencies --- README | 5 +++-- setup.py | 1 + timeside/__init__.py | 16 ++++++++++------ timeside/analyzer/__init__.py | 8 +++++--- timeside/decoder/__init__.py | 3 ++- timeside/decoder/core.py | 16 +++++++++------- timeside/encoder/__init__.py | 4 ++-- timeside/grapher/__init__.py | 6 +++--- timeside/tools/waveform_batch | 9 +++------ 9 files changed, 38 insertions(+), 30 deletions(-) diff --git a/README b/README index 5488b2a..14b1351 100644 --- a/README +++ b/README @@ -14,8 +14,9 @@ Dependencies ============ python (>= 2.4), python-xml, python-mutagen, python-imaging (>= 1.1.6), -python-numpy, python-setuptools (>= 0.6b3), libsndfile1 (>= 1.0.17), -python-gst0.10, gstreamer0.10-plugins-base +python-numpy, python-setuptools (>= 0.6b3), libsndfile1 (>= 1.0.17), +python-gst0.10, gstreamer0.10-plugins-base, gstreamer0.10-plugins-fluendo-mp3, +gstreamer0.10-plugins-good License ======= diff --git a/setup.py b/setup.py index a473e1e..7474f0b 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# -*- coding: utf-8 -*- '''The setup and build script for the python-twitter library.''' diff --git a/timeside/__init__.py b/timeside/__init__.py index ff77e57..bc13dd6 100644 --- a/timeside/__init__.py +++ b/timeside/__init__.py @@ -1,8 +1,12 @@ # -*- coding: utf-8 -*- -from core import * -from metadata import Metadata -import decoder -import encoder -import grapher -import analyzer + +import timeside.exceptions +import timeside.core +import timeside.component +import timeside.metadata +import timeside.decoder +import timeside.encoder +import timeside.grapher +import timeside.analyzer + diff --git a/timeside/analyzer/__init__.py b/timeside/analyzer/__init__.py index 0bd2039..6259160 100644 --- a/timeside/analyzer/__init__.py +++ b/timeside/analyzer/__init__.py @@ -1,6 +1,8 @@ # -*- coding: utf-8 -*- -from timeside.analyzer.core import * -from timeside.analyzer.duration import * -from timeside.analyzer.max_level import * + +from core import * +from duration import * +from max_level import * + #from timeside.analyzer.mean_level import * #from timeside.analyzer.dc import * diff --git a/timeside/decoder/__init__.py b/timeside/decoder/__init__.py index 9f37f75..78457b3 100644 --- a/timeside/decoder/__init__.py +++ b/timeside/decoder/__init__.py @@ -1,3 +1,4 @@ # -*- coding: utf-8 -*- -from timeside.decoder.core import * +import timeside.core +from core import * diff --git a/timeside/decoder/core.py b/timeside/decoder/core.py index cdcdf47..0a46757 100644 --- a/timeside/decoder/core.py +++ b/timeside/decoder/core.py @@ -60,7 +60,7 @@ class FileDecoder(Processor): ! audioconvert ! %s ! appsink name=sink sync=False ''' % (self.uri, caps)) - # store a pointer to appsink in our decoder object + # store a pointer to appsink in our decoder object self.sink = pipeline.get_by_name('sink') # adjust length of emitted buffers # self.sink.set_property('blocksize', 0x10000) @@ -73,7 +73,7 @@ class FileDecoder(Processor): @interfacedoc def samplerate(self): - return self.audiorate + return self.audiorate @interfacedoc def nframes(self): @@ -93,7 +93,7 @@ class FileDecoder(Processor): @interfacedoc def release(self): - # nothing to do for now + # nothing to do for now pass ## IDecoder methods @@ -101,7 +101,7 @@ class FileDecoder(Processor): @interfacedoc def __init__(self, uri): - # is this a file? + # is this a file? import os.path if os.path.exists(uri): # get the absolute path @@ -111,6 +111,8 @@ class FileDecoder(Processor): # and make a uri of it from urllib import quote self.uri = 'file://'+quote(uri) + else: + self.uri = uri @interfacedoc def format(self): @@ -125,7 +127,7 @@ class FileDecoder(Processor): @interfacedoc def resolution(self): # TODO check: width or depth? - return self.audiowidth + return self.audiowidth @interfacedoc def metadata(self): @@ -151,7 +153,7 @@ class FileDecoder(Processor): self.mimetype= d.mimetype self.audiochannels = d.audiochannels self.audiowidth = d.audiowidth - # conversion from time in nanoseconds to frames + # conversion from time in nanoseconds to frames from math import ceil duration = d.audiorate * d.audiolength * 1.e-9 self.audionframes = int (ceil ( duration ) ) @@ -165,7 +167,7 @@ class FileDecoder(Processor): def gst_buffer_to_numpy_array(self, buf): """ gstreamer buffer to numpy array conversion """ chan = self.audiochannels - samples = frombuffer(buf.data, dtype=float32) + samples = frombuffer(buf.data, dtype=float32) samples.resize([len(samples)/chan, chan]) return samples diff --git a/timeside/encoder/__init__.py b/timeside/encoder/__init__.py index 7eadf71..8248164 100644 --- a/timeside/encoder/__init__.py +++ b/timeside/encoder/__init__.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- -from timeside.encoder.core import * +from core import * #from timeside.encoder.ogg import * -from timeside.encoder.wav import * +from wav import * #from timeside.encoder.mp3 import * #from timeside.encoder.flac import * diff --git a/timeside/grapher/__init__.py b/timeside/grapher/__init__.py index 616ebf6..ce2ebca 100644 --- a/timeside/grapher/__init__.py +++ b/timeside/grapher/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from timeside.grapher.core import * -from timeside.grapher.waveform import * -from timeside.grapher.spectrogram import * +from core import * +from waveform import * +from spectrogram import * diff --git a/timeside/tools/waveform_batch b/timeside/tools/waveform_batch index dfb6344..b93d659 100644 --- a/timeside/tools/waveform_batch +++ b/timeside/tools/waveform_batch @@ -24,10 +24,7 @@ version = '0.1-beta' import os import sys -from timeside.core import * -from timeside.decoder import * -from timeside.grapher import * - +import timeside class GrapherScheme: @@ -87,8 +84,8 @@ class Media2Waveform(object): if not os.path.exists(image) or self.force: print 'Rendering ', source, ' to ', image, '...' audio = os.path.join(os.path.dirname(__file__), source) - decoder = FileDecoder(audio) - waveform = Waveform(width=self.width, height=self.height, output=image, + decoder = timeside.decoder.FileDecoder(audio) + waveform = timeside.grapher.Waveform(width=self.width, height=self.height, output=image, bg_color=self.bg_color, color_scheme=self.color_scheme) (decoder | waveform).run() print 'frames per pixel = ', waveform.graph.samples_per_pixel -- 2.39.5