class IAnalyzer(Interface):
"""Media item analyzer driver interface"""
- def get_id():
+ def id():
"""Return a short id alphanumeric, lower-case string."""
- def get_name():
+ def name():
"""Return the analyze name, such as "Mean Level", "Max level",
"Total length, etc..
"""
- def get_unit():
+ def unit():
"""Return the unit of the data such as "dB", "seconds", etc...
"""
- def render(media_item, options=None):
+ def render(media, options=None):
"""Return the result data of the process"""
implements(IAnalyzer)
- def get_id(self):
+ def id(self):
return "nb_channels"
- def get_name(self):
+ def name(self):
return "Channels"
- def get_unit(self):
+ def unit(self):
return ""
def render(self, media_item, options=None):
implements(IAnalyzer)
- def get_id(self):
+ def id(self):
return "dc"
- def get_name(self):
+ def name(self):
return "Mean DC shift"
- def get_unit(self):
+ def unit(self):
return "%"
def render(self, media_item, options=None):
implements(IAnalyzer)
- def get_id(self):
+ def id(self):
return "duration"
- def get_name(self):
+ def name(self):
return "Duration"
- def get_unit(self):
+ def unit(self):
return "h:m:s"
def render(self, media_item, options=None):
implements(IAnalyzer)
- def get_id(self):
+ def id(self):
return "encoding"
- def get_name(self):
+ def name(self):
return "Encoding format"
- def get_unit(self):
+ def unit(self):
return ""
def render(self, media_item, options=None):
implements(IAnalyzer)
- def get_id(self):
+ def id(self):
return "format"
- def get_name(self):
+ def name(self):
return "File format"
- def get_unit(self):
+ def unit(self):
return ""
def render(self, media_item, options=None):
implements(IAnalyzer)
- def get_id(self):
+ def id(self):
return "max_level"
- def get_name(self):
+ def name(self):
return "Maximum peak level"
- def get_unit(self):
+ def unit(self):
return "dB"
def render(self, media_item, options=None):
implements(IAnalyzer)
- def get_id(self):
+ def id(self):
return "mean_level"
- def get_name(self):
+ def name(self):
return "Mean RMS level"
- def get_unit(self):
+ def unit(self):
return "dB"
def render(self, media_item, options=None):
implements(IAnalyzer)
- def get_id(self):
+ def id(self):
return "resolution"
- def get_name(self):
+ def name(self):
return "Resolution"
- def get_unit(self):
+ def unit(self):
return "bits"
def render(self, media_item, options=None):
implements(IAnalyzer)
- def get_id(self):
+ def id(self):
return "samplerate"
- def get_name(self):
+ def name(self):
return "Samplerate"
- def get_unit(self):
+ def unit(self):
return "Hz"
def render(self, media_item, options=None):
self.host = 'vamp-simple-host'
self.buffer_size = 0xFFFF
- def get_id(self):
+ def id(self):
return "vamp_plugins"
- def get_name(self):
+ def name(self):
return "Vamp plugins"
- def get_unit(self):
+ def unit(self):
return ""
def get_plugins_list(self):
implements(IDecoder)
- def __init__(self):
- self.description = self.description()
- self.format = self.format()
- self.mime_type = self.mime_type()
-
def format(self):
return 'FLAC'
implements(IDecoder)
- def __init__(self):
- self.description = self.description()
- self.format = self.format()
- self.mime_type = self.mime_type()
-
def format(self):
return 'MP3'
implements(IDecoder)
def __init__(self):
- self.description = self.description()
- self.format = self.format()
- self.mime_type = self.mime_type()
self.dub2args_dict = {'creator': 'artist',
'relation': 'album'
}
implements(IDecoder)
- def __init__(self):
- self.description = self.description()
- self.format = self.format()
- self.mime_type = self.mime_type()
-
def format(self):
return 'WAV'
def mime_type():
"""Return the mime type corresponding to this encode format"""
- def set_cache_dir(path):
- """Set the directory where cached files should be stored. Does nothing
- if the encodeer doesn't support caching.
-
- The driver shouldn't assume that this method will always get called. A
- temporary directory should be used if that's not the case.
- """
-
def process(source, metadata, options=None):
"""Perform the encoding process and stream the result as a generator.
def __init__(self):
self.quality_default = '-5'
- def get_format(self):
+ def format(self):
return 'FLAC'
- def get_file_extension(self):
+ def file_extension(self):
return 'flac'
- def get_mime_type(self):
+ def mime_type(self):
return 'application/flac'
- def get_description(self):
+ def description(self):
return """
Free Lossless Audio Codec (FLAC) is a file format for lossless audio
data compression. During compression, FLAC does not lose quality from
implements(IEncoder)
def __init__(self):
- self.description = self.description()
- self.format = self.format()
- self.mime_type = self.mime_type()
self.bitrate_default = '192'
self.dub2id3_dict = {'title': 'TIT2', #title2
'creator': 'TCOM', #composer
'publisher': 'tc', #comment
'date': 'ty', #year
}
- def get_format(self):
+ def format(self):
return 'MP3'
- def get_file_extension(self):
+ def file_extension(self):
return 'mp3'
- def get_mime_type(self):
+ def mime_type(self):
return 'audio/mpeg'
- def get_description(self):
+ def description(self):
return """
MPEG-1 Audio Layer 3, more commonly referred to as MP3, is a patented
digital audio encoding format using a form of lossy data compression.
implements(IEncoder)
def __init__(self):
- self.description = self.description()
- self.format = self.format()
- self.mime_type = self.mime_type()
self.bitrate_default = '192'
self.dub2args_dict = {'creator': 'artist',
'relation': 'album'
from timeside.core import *
-class IMediaItemGrapher(Interface):
+class IGrapher(Interface):
"""Media item visualizer driver interface"""
- def get_id():
+ def id():
"""Return a short id alphanumeric, lower-case string."""
- def get_name():
+ def name():
"""Return the graph name, such as "Waveform", "Spectral view",
etc..
"""
def set_colors(self, background=None, scheme=None):
- """Set the colors used for image generation. background is a RGB tuple,
+ """Set the colors used for image generation. background is a RGB tuple,
and scheme a a predefined color theme name"""
pass
# Author: Guillaume Pellerin <yomguy@parisson.com>
from timeside.core import *
-from timeside.graph.api import IMediaItemGrapher
+from timeside.graph.api import IGrapher
from tempfile import NamedTemporaryFile
from timeside.graph.wav2png import *
class SpectrogramGrapherAudiolab(Component):
"""Spectrogram graph driver (python style thanks to wav2png.py and scikits.audiolab)"""
- implements(IMediaItemGrapher)
+ implements(IGrapher)
bg_color = None
color_scheme = None
- def get_id(self):
+ def id(self):
return "spectrogram_audiolab"
- def get_name(self):
+ def name(self):
return "Spectrogram (audiolab)"
-
+
def set_colors(self, background=None, scheme=None):
self.bg_color = background
self.color_scheme = scheme
image_height = height
else:
image_height = 200
-
+
fft_size = 2048
- args = (wav_file, pngFile.name, image_width, image_height, fft_size,
+ args = (wav_file, pngFile.name, image_width, image_height, fft_size,
self.bg_color, self.color_scheme)
create_spectrogram_png(*args)
# Author: Guillaume Pellerin <yomguy@parisson.com>
from timeside.core import *
-from timeside.graph.api import IMediaItemGrapher
+from timeside.graph.api import IGrapher
from tempfile import NamedTemporaryFile
from timeside.graph.wav2png import *
class WaveFormGrapherAudiolab(Component):
"""WaveForm graph driver (python style thanks to wav2png.py and scikits.audiolab)"""
- implements(IMediaItemGrapher)
+ implements(IGrapher)
bg_color = None
color_scheme = None
- def get_id(self):
+ def id(self):
return "waveform_audiolab"
- def get_name(self):
+ def name(self):
return "Waveform (audiolab)"
def set_colors(self, background=None, scheme=None):
image_height = 200
fft_size = 2048
- args = (wav_file, pngFile.name, image_width, image_height, fft_size,
+ args = (wav_file, pngFile.name, image_width, image_height, fft_size,
self.bg_color, self.color_scheme)
create_wavform_png(*args)
--- /dev/null
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+import timeside
+from timeside.core import Component, ExtensionPoint, ComponentManager
+
+class TestAnalyzers(Component):
+ analyzers = ExtensionPoint(timeside.analyze.IAnalyzer)
+
+ def run(self):
+ analyzers = []
+ for analyzer in self.analyzers:
+ analyzers.append({'name':analyzer.name(),
+ 'id':analyzer.id(),
+ 'unit':analyzer.unit(),
+ })
+ print analyzers
+
+class TestDecoders(Component):
+ decoders = ExtensionPoint(timeside.decode.IDecoder)
+
+ def run(self):
+ decoders = []
+ for decoder in self.decoders:
+ decoders.append({'format':decoder.format(),
+ 'mime_type':decoder.mime_type(),
+ })
+ print decoders
+
+
+class TestEncoders(Component):
+ encoders = ExtensionPoint(timeside.encode.IEncoder)
+
+ def run(self):
+ encoders = []
+ for encoder in self.encoders:
+ encoders.append({'format':encoder.format(),
+ 'mime_type':encoder.mime_type(),
+ })
+ print encoders
+
+class TestGraphers(Component):
+ graphers = ExtensionPoint(timeside.graph.IGrapher)
+
+ def run(self):
+ graphers = []
+ for grapher in self.graphers:
+ graphers.append({'id':grapher.id(),
+ 'name':grapher.name(),
+ })
+ print graphers
+
+if __name__ == '__main__':
+ comp_mgr = ComponentManager()
+ a = TestAnalyzers(comp_mgr)
+ d = TestDecoders(comp_mgr)
+ e = TestEncoders(comp_mgr)
+ g = TestGraphers(comp_mgr)
+ a.run()
+ d.run()
+ e.run()
+ g.run()
+