From: yomguy <> Date: Wed, 31 Dec 2008 17:01:27 +0000 (+0000) Subject: rename and reorganize visualizers X-Git-Tag: 1.1~752 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=5f9d77c9a04cb6201c165c7922d529a588f6e8ce;p=telemeta.git rename and reorganize visualizers --- diff --git a/telemeta/visualization/__init__.py b/telemeta/visualization/__init__.py index 06d036b3..7b46c19a 100644 --- a/telemeta/visualization/__init__.py +++ b/telemeta/visualization/__init__.py @@ -1,9 +1,4 @@ from telemeta.visualization.api import * -#from telemeta.visualization.waveform import * -#from telemeta.visualization.waveform2 import * -from telemeta.visualization.waveform3 import * -#from telemeta.visualization.spectrogram import * -from telemeta.visualization.spectrogram2 import * -from telemeta.visualization.spectrogram3 import * -from telemeta.visualization.waveform4 import * -from telemeta.visualization.spectrogram4 import * \ No newline at end of file +from telemeta.visualization.waveform_audiolab import * +from telemeta.visualization.spectrogram_audiolab import * +from telemeta.visualization.spectrogram_octave import * diff --git a/telemeta/visualization/octave_core.py b/telemeta/visualization/octave_core.py index 9109d43d..13fc15e6 100644 --- a/telemeta/visualization/octave_core.py +++ b/telemeta/visualization/octave_core.py @@ -60,7 +60,7 @@ class OctaveCoreVisualizer(Component): ' -scale x250 ' + self.pngFile.name) # Stream - while True : + while True: buffer = self.pngFile.read(self.buffer_size) if len(buffer) == 0: break diff --git a/telemeta/visualization/old/spectrogram.py b/telemeta/visualization/old/spectrogram.py new file mode 100644 index 00000000..f4f0bfc3 --- /dev/null +++ b/telemeta/visualization/old/spectrogram.py @@ -0,0 +1,50 @@ +# Copyright (C) 2007 Samalyse SARL +# All rights reserved. +# +# This software is licensed as described in the file COPYING, which +# you should have received as part of this distribution. The terms +# are also available at http://svn.parisson.org/telemeta/TelemetaLicense. +# +# Author: Olivier Guilyardi + +from telemeta.core import * +from telemeta.visualization.api import IMediaItemVisualizer +from telemeta.visualization.snack_core import SnackCoreVisualizer + +class SpectrogramVisualizer(SnackCoreVisualizer): + """Spectral view visualization driver""" + + implements(IMediaItemVisualizer) + + # possible alternative: + # http://jokosher.python-hosting.com/file/jokosher-extra/Waveform.py + + def get_id(self): + return "spectrogram" + + def get_name(self): + return "Spectrogram 1" + + def set_colors(self, background=None, scheme=None): + pass + + def render(self, media_item, options=None): + """Generator that streams the spectral view as a PNG image""" + + canvas = self.get_snack_canvas() + snd = self.get_snack_sound(media_item) + + canvas.create_spectrogram(0, 10, sound=snd, height=180, width=300 , + windowtype="hamming", fftlength=1024, topfrequency=5000, channel="all", winlength=64) + + stream = self.canvas_to_png_stream(canvas) + + return stream + + + + + + + + diff --git a/telemeta/visualization/old/spectrogram3.py b/telemeta/visualization/old/spectrogram3.py new file mode 100644 index 00000000..f970e470 --- /dev/null +++ b/telemeta/visualization/old/spectrogram3.py @@ -0,0 +1,59 @@ +# Copyright (C) 2008 Parisson SARL +# All rights reserved. +# +# This software is licensed as described in the file COPYING, which +# you should have received as part of this distribution. The terms +# are also available at http://svn.parisson.org/telemeta/TelemetaLicense. +# +# Author: Guillaume Pellerin + +from telemeta.core import * +from telemeta.visualization.api import IMediaItemVisualizer +from django.conf import settings +from tempfile import NamedTemporaryFile +from telemeta.visualization.wav2png import * + +class SpectrogramVisualizer3(Component): + """Spectrogram visualization driver (python style)""" + + implements(IMediaItemVisualizer) + + bg_color = None + color_scheme = None + + def get_id(self): + return "spectrogram3" + + def get_name(self): + return "Spectrogram (audiolab)" + + def set_colors(self, background=None, scheme=None): + self.bg_color = background + self.color_scheme = scheme + + def render(self, media_item, width=None, height=None, options=None): + """Generator that streams the spectrogram as a PNG image with a python method""" + + wav_file = media_item.file.path + pngFile = NamedTemporaryFile(suffix='.png') + + if not width == None: + image_width = width + else: + image_width = 305 + if not height == None: + image_height = height + else: + image_height = 150 + + fft_size = 2048 + args = (wav_file, pngFile.name, image_width, image_height, fft_size, + self.bg_color, self.color_scheme) + create_spectrogram_png(*args) + + buffer = pngFile.read(0xFFFF) + while buffer: + yield buffer + buffer = pngFile.read(0xFFFF) + + pngFile.close() diff --git a/telemeta/visualization/old/waveform.py b/telemeta/visualization/old/waveform.py new file mode 100644 index 00000000..c645c5ef --- /dev/null +++ b/telemeta/visualization/old/waveform.py @@ -0,0 +1,55 @@ +# Copyright (C) 2007 Samalyse SARL +# All rights reserved. +# +# This software is licensed as described in the file COPYING, which +# you should have received as part of this distribution. The terms +# are also available at http://svn.parisson.org/telemeta/TelemetaLicense. +# +# Author: Olivier Guilyardi + +from telemeta.core import * +from telemeta.visualization.api import IMediaItemVisualizer +from django.conf import settings +from tempfile import NamedTemporaryFile +import os +import os.path + +class WaveFormVisualizer(Component): + """WaveForm visualization driver""" + + implements(IMediaItemVisualizer) + + # possible alternative: + # http://jokosher.python-hosting.com/file/jokosher-extra/Waveform.py + + def get_id(self): + return "waveform_first" + + def get_name(self): + return "Waveform (wav2png.c)" + + def set_colors(self, background=None, scheme=None): + pass + + def render(self, media_item, options=None): + """Generator that streams the waveform as a PNG image""" + + pngFile = NamedTemporaryFile(suffix='.png') + wav2png = os.path.dirname(__file__) + '/wav2png/wav2png' + args = "-i " + media_item.file.path + " " + args += "-o " + pngFile.name + " " + args += "-b ffffff " + args += "-l 000088 " + args += "-z 990000 " + args += "-w 300 " + args += "-h 151 " + + os.system(wav2png + " " + args) + + buffer = pngFile.read(0xFFFF) + while buffer: + yield buffer + buffer = pngFile.read(0xFFFF) + + pngFile.close() + diff --git a/telemeta/visualization/old/waveform2.py b/telemeta/visualization/old/waveform2.py new file mode 100644 index 00000000..83a67aa6 --- /dev/null +++ b/telemeta/visualization/old/waveform2.py @@ -0,0 +1,41 @@ +# Copyright (C) 2007 Samalyse SARL +# All rights reserved. +# +# This software is licensed as described in the file COPYING, which +# you should have received as part of this distribution. The terms +# are also available at http://svn.parisson.org/telemeta/TelemetaLicense. +# +# Authors: Olivier Guilyardi +# Guillaume Pellerin + +from telemeta.core import * +from telemeta.visualization.api import IMediaItemVisualizer +from telemeta.visualization.octave_core import OctaveCoreVisualizer + +class WaveformVisualizer2(OctaveCoreVisualizer): + """Octave temporal view visualization driver""" + + implements(IMediaItemVisualizer) + + def __init__(self): + self.set_m_file('waveform2img.m') + self.buffer_size = 0xFFFF + self.trans_type = 'png' + + def get_id(self): + return "waveform_octave" + + def get_name(self): + return "Waveform (octave)" + + def set_colors(self, background=None, scheme=None): + pass + + def render(self, media_item, options=None): + """Generator that streams the temporal view as a PNG image""" + + stream = self.octave_to_png_stream(media_item) + for chunk in stream: + yield chunk + + diff --git a/telemeta/visualization/old/waveform4.py b/telemeta/visualization/old/waveform4.py new file mode 100644 index 00000000..93d9b57f --- /dev/null +++ b/telemeta/visualization/old/waveform4.py @@ -0,0 +1,59 @@ +# Copyright (C) 2008 Parisson SARL +# All rights reserved. +# +# This software is licensed as described in the file COPYING, which +# you should have received as part of this distribution. The terms +# are also available at http://svn.parisson.org/telemeta/TelemetaLicense. +# +# Author: Guillaume Pellerin + +from telemeta.core import * +from telemeta.visualization.api import IMediaItemVisualizer +from django.conf import settings +from tempfile import NamedTemporaryFile +from telemeta.visualization.wav2png import * + +class WaveFormVisualizer(Component): + """WaveForm visualization driver (python style)""" + + implements(IMediaItemVisualizer) + + bg_color = None + color_scheme = None + + def get_id(self): + return "waveform4" + + def get_name(self): + return "Waveform (audiolab large)" + + def set_colors(self, background=None, scheme=None): + self.bg_color = background + self.color_scheme = scheme + + def render(self, media_item, width=None, height=None, options=None): + """Generator that streams the waveform as a PNG image with a python method""" + + wav_file = media_item.file.path + pngFile = NamedTemporaryFile(suffix='.png') + + if not width == None: + image_width = width + else: + image_width = 1800 + if not height == None: + image_height = height + else: + image_height = 300 + + fft_size = 2048 + args = (wav_file, pngFile.name, image_width, image_height, fft_size, self.bg_color, self.color_scheme) + create_wavform_png(*args) + + buffer = pngFile.read(0xFFFF) + while buffer: + yield buffer + buffer = pngFile.read(0xFFFF) + + pngFile.close() + diff --git a/telemeta/visualization/spectrogram.py b/telemeta/visualization/spectrogram.py deleted file mode 100644 index f4f0bfc3..00000000 --- a/telemeta/visualization/spectrogram.py +++ /dev/null @@ -1,50 +0,0 @@ -# Copyright (C) 2007 Samalyse SARL -# All rights reserved. -# -# This software is licensed as described in the file COPYING, which -# you should have received as part of this distribution. The terms -# are also available at http://svn.parisson.org/telemeta/TelemetaLicense. -# -# Author: Olivier Guilyardi - -from telemeta.core import * -from telemeta.visualization.api import IMediaItemVisualizer -from telemeta.visualization.snack_core import SnackCoreVisualizer - -class SpectrogramVisualizer(SnackCoreVisualizer): - """Spectral view visualization driver""" - - implements(IMediaItemVisualizer) - - # possible alternative: - # http://jokosher.python-hosting.com/file/jokosher-extra/Waveform.py - - def get_id(self): - return "spectrogram" - - def get_name(self): - return "Spectrogram 1" - - def set_colors(self, background=None, scheme=None): - pass - - def render(self, media_item, options=None): - """Generator that streams the spectral view as a PNG image""" - - canvas = self.get_snack_canvas() - snd = self.get_snack_sound(media_item) - - canvas.create_spectrogram(0, 10, sound=snd, height=180, width=300 , - windowtype="hamming", fftlength=1024, topfrequency=5000, channel="all", winlength=64) - - stream = self.canvas_to_png_stream(canvas) - - return stream - - - - - - - - diff --git a/telemeta/visualization/spectrogram2.py b/telemeta/visualization/spectrogram2.py deleted file mode 100644 index d4c41e98..00000000 --- a/telemeta/visualization/spectrogram2.py +++ /dev/null @@ -1,37 +0,0 @@ -# Copyright (C) 2007 Samalyse SARL -# All rights reserved. -# -# This software is licensed as described in the file COPYING, which -# you should have received as part of this distribution. The terms -# are also available at http://svn.parisson.org/telemeta/TelemetaLicense. -# -# Authors: Olivier Guilyardi -# Guillaume Pellerin - -from telemeta.core import * -from telemeta.visualization.api import IMediaItemVisualizer -from telemeta.visualization.octave_core import OctaveCoreVisualizer - -class SpectrogramVisualizer2(OctaveCoreVisualizer): - """Octave spectral view visualization driver""" - - implements(IMediaItemVisualizer) - - def __init__(self): - self.set_m_file('spectrogram2img.m') - - def get_id(self): - return "spectrogram2" - - def get_name(self): - return "Spectrogram (octave)" - - def set_colors(self, background=None, scheme=None): - pass - - def render(self, media_item, width=None, height=None, options=None): - """Generator that streams the spectral view as a PNG image""" - - stream = self.octave_to_png_stream(media_item) - return stream - diff --git a/telemeta/visualization/spectrogram3.py b/telemeta/visualization/spectrogram3.py deleted file mode 100644 index f970e470..00000000 --- a/telemeta/visualization/spectrogram3.py +++ /dev/null @@ -1,59 +0,0 @@ -# Copyright (C) 2008 Parisson SARL -# All rights reserved. -# -# This software is licensed as described in the file COPYING, which -# you should have received as part of this distribution. The terms -# are also available at http://svn.parisson.org/telemeta/TelemetaLicense. -# -# Author: Guillaume Pellerin - -from telemeta.core import * -from telemeta.visualization.api import IMediaItemVisualizer -from django.conf import settings -from tempfile import NamedTemporaryFile -from telemeta.visualization.wav2png import * - -class SpectrogramVisualizer3(Component): - """Spectrogram visualization driver (python style)""" - - implements(IMediaItemVisualizer) - - bg_color = None - color_scheme = None - - def get_id(self): - return "spectrogram3" - - def get_name(self): - return "Spectrogram (audiolab)" - - def set_colors(self, background=None, scheme=None): - self.bg_color = background - self.color_scheme = scheme - - def render(self, media_item, width=None, height=None, options=None): - """Generator that streams the spectrogram as a PNG image with a python method""" - - wav_file = media_item.file.path - pngFile = NamedTemporaryFile(suffix='.png') - - if not width == None: - image_width = width - else: - image_width = 305 - if not height == None: - image_height = height - else: - image_height = 150 - - fft_size = 2048 - args = (wav_file, pngFile.name, image_width, image_height, fft_size, - self.bg_color, self.color_scheme) - create_spectrogram_png(*args) - - buffer = pngFile.read(0xFFFF) - while buffer: - yield buffer - buffer = pngFile.read(0xFFFF) - - pngFile.close() diff --git a/telemeta/visualization/spectrogram4.py b/telemeta/visualization/spectrogram4.py deleted file mode 100644 index 87e68740..00000000 --- a/telemeta/visualization/spectrogram4.py +++ /dev/null @@ -1,59 +0,0 @@ -# Copyright (C) 2008 Parisson SARL -# All rights reserved. -# -# This software is licensed as described in the file COPYING, which -# you should have received as part of this distribution. The terms -# are also available at http://svn.parisson.org/telemeta/TelemetaLicense. -# -# Author: Guillaume Pellerin - -from telemeta.core import * -from telemeta.visualization.api import IMediaItemVisualizer -from django.conf import settings -from tempfile import NamedTemporaryFile -from telemeta.visualization.wav2png import * - -class SpectrogramVisualizer3(Component): - """Spectrogram visualization driver (python style)""" - - implements(IMediaItemVisualizer) - - bg_color = None - color_scheme = None - - def get_id(self): - return "spectrogram4" - - def get_name(self): - return "Spectrogram (audiolab large)" - - def set_colors(self, background=None, scheme=None): - self.bg_color = background - self.color_scheme = scheme - - def render(self, media_item, width=None, height=None, options=None): - """Generator that streams the spectrogram as a PNG image with a python method""" - - wav_file = media_item.file.path - pngFile = NamedTemporaryFile(suffix='.png') - - if not width == None: - image_width = width - else: - image_width = 1800 - if not height == None: - image_height = height - else: - image_height = 300 - - fft_size = 2048 - args = (wav_file, pngFile.name, image_width, image_height, fft_size, - self.bg_color, self.color_scheme) - create_spectrogram_png(*args) - - buffer = pngFile.read(0xFFFF) - while buffer: - yield buffer - buffer = pngFile.read(0xFFFF) - - pngFile.close() diff --git a/telemeta/visualization/spectrogram_audiolab.py b/telemeta/visualization/spectrogram_audiolab.py new file mode 100644 index 00000000..c86106d3 --- /dev/null +++ b/telemeta/visualization/spectrogram_audiolab.py @@ -0,0 +1,59 @@ +# Copyright (C) 2008 Parisson SARL +# All rights reserved. +# +# This software is licensed as described in the file COPYING, which +# you should have received as part of this distribution. The terms +# are also available at http://svn.parisson.org/telemeta/TelemetaLicense. +# +# Author: Guillaume Pellerin + +from telemeta.core import * +from telemeta.visualization.api import IMediaItemVisualizer +from django.conf import settings +from tempfile import NamedTemporaryFile +from telemeta.visualization.wav2png import * + +class SpectrogramVisualizerAudiolab(Component): + """Spectrogram visualization driver (python style thanks to wav2png.py and scikits.audiolab)""" + + implements(IMediaItemVisualizer) + + bg_color = None + color_scheme = None + + def get_id(self): + return "spectrogram_audiolab" + + def get_name(self): + return "Spectrogram (audiolab)" + + def set_colors(self, background=None, scheme=None): + self.bg_color = background + self.color_scheme = scheme + + def render(self, media_item, width=None, height=None, options=None): + """Generator that streams the spectrogram as a PNG image with a python method""" + + wav_file = media_item.file.path + pngFile = NamedTemporaryFile(suffix='.png') + + if not width == None: + image_width = width + else: + image_width = 1500 + if not height == None: + image_height = height + else: + image_height = 200 + + fft_size = 2048 + args = (wav_file, pngFile.name, image_width, image_height, fft_size, + self.bg_color, self.color_scheme) + create_spectrogram_png(*args) + + buffer = pngFile.read(0xFFFF) + while buffer: + yield buffer + buffer = pngFile.read(0xFFFF) + + pngFile.close() diff --git a/telemeta/visualization/spectrogram_octave.py b/telemeta/visualization/spectrogram_octave.py new file mode 100644 index 00000000..b130e01f --- /dev/null +++ b/telemeta/visualization/spectrogram_octave.py @@ -0,0 +1,38 @@ +# Copyright (C) 2007 Samalyse SARL +# All rights reserved. +# +# This software is licensed as described in the file COPYING, which +# you should have received as part of this distribution. The terms +# are also available at http://svn.parisson.org/telemeta/TelemetaLicense. +# +# Authors: Olivier Guilyardi +# Guillaume Pellerin + +from telemeta.core import * +from telemeta.visualization.api import IMediaItemVisualizer +from telemeta.visualization.octave_core import OctaveCoreVisualizer + +class SpectrogramVisualizer2(OctaveCoreVisualizer): + """Octave spectral view visualization driver""" + + implements(IMediaItemVisualizer) + + def __init__(self): + self.set_m_file('spectrogram2img.m') + + def get_id(self): + return "spectrogram_octave" + + def get_name(self): + return "Spectrogram (octave)" + + def set_colors(self, background=None, scheme=None): + pass + + def render(self, media_item, width=None, height=None, options=None): + """Generator that streams the spectral view as a PNG image""" + + stream = self.octave_to_png_stream(media_item) + for chunk in stream: + yield chunk + diff --git a/telemeta/visualization/waveform.py b/telemeta/visualization/waveform.py deleted file mode 100644 index 5868c23c..00000000 --- a/telemeta/visualization/waveform.py +++ /dev/null @@ -1,55 +0,0 @@ -# Copyright (C) 2007 Samalyse SARL -# All rights reserved. -# -# This software is licensed as described in the file COPYING, which -# you should have received as part of this distribution. The terms -# are also available at http://svn.parisson.org/telemeta/TelemetaLicense. -# -# Author: Olivier Guilyardi - -from telemeta.core import * -from telemeta.visualization.api import IMediaItemVisualizer -from django.conf import settings -from tempfile import NamedTemporaryFile -import os -import os.path - -class WaveFormVisualizer(Component): - """WaveForm visualization driver""" - - implements(IMediaItemVisualizer) - - # possible alternative: - # http://jokosher.python-hosting.com/file/jokosher-extra/Waveform.py - - def get_id(self): - return "waveform" - - def get_name(self): - return "Waveform" - - def set_colors(self, background=None, scheme=None): - pass - - def render(self, media_item, options=None): - """Generator that streams the waveform as a PNG image""" - - pngFile = NamedTemporaryFile(suffix='.png') - wav2png = os.path.dirname(__file__) + '/wav2png/wav2png' - args = "-i " + media_item.file.path + " " - args += "-o " + pngFile.name + " " - args += "-b ffffff " - args += "-l 000088 " - args += "-z 990000 " - args += "-w 300 " - args += "-h 151 " - - os.system(wav2png + " " + args) - - buffer = pngFile.read(0xFFFF) - while buffer: - yield buffer - buffer = pngFile.read(0xFFFF) - - pngFile.close() - diff --git a/telemeta/visualization/waveform2.py b/telemeta/visualization/waveform2.py deleted file mode 100644 index 5c4ff9a1..00000000 --- a/telemeta/visualization/waveform2.py +++ /dev/null @@ -1,39 +0,0 @@ -# Copyright (C) 2007 Samalyse SARL -# All rights reserved. -# -# This software is licensed as described in the file COPYING, which -# you should have received as part of this distribution. The terms -# are also available at http://svn.parisson.org/telemeta/TelemetaLicense. -# -# Authors: Olivier Guilyardi -# Guillaume Pellerin - -from telemeta.core import * -from telemeta.visualization.api import IMediaItemVisualizer -from telemeta.visualization.octave_core import OctaveCoreVisualizer - -class WaveformVisualizer2(OctaveCoreVisualizer): - """Octave temporal view visualization driver""" - - implements(IMediaItemVisualizer) - - def __init__(self): - self.set_m_file('waveform2img.m') - self.buffer_size = 0xFFFF - self.trans_type = 'png' - - def get_id(self): - return "waveform2" - - def get_name(self): - return "Waveform (octave)" - - def set_colors(self, background=None, scheme=None): - pass - - def render(self, media_item, options=None): - """Generator that streams the temporal view as a PNG image""" - - stream = self.octave_to_png_stream(media_item) - return stream - diff --git a/telemeta/visualization/waveform3.py b/telemeta/visualization/waveform3.py deleted file mode 100644 index f6a111e6..00000000 --- a/telemeta/visualization/waveform3.py +++ /dev/null @@ -1,60 +0,0 @@ -# Copyright (C) 2008 Parisson SARL -# All rights reserved. -# -# This software is licensed as described in the file COPYING, which -# you should have received as part of this distribution. The terms -# are also available at http://svn.parisson.org/telemeta/TelemetaLicense. -# -# Author: Guillaume Pellerin - -from telemeta.core import * -from telemeta.visualization.api import IMediaItemVisualizer -from django.conf import settings -from tempfile import NamedTemporaryFile -from telemeta.visualization.wav2png import * - -class WaveFormVisualizer(Component): - """WaveForm visualization driver (python style)""" - - implements(IMediaItemVisualizer) - - bg_color = None - color_scheme = None - - def get_id(self): - return "waveform3" - - def get_name(self): - return "Waveform (audiolab)" - - def set_colors(self, background=None, scheme=None): - self.bg_color = background - self.color_scheme = scheme - - def render(self, media_item, width=None, height=None, options=None): - """Generator that streams the waveform as a PNG image with a python method""" - - wav_file = media_item.file.path - pngFile = NamedTemporaryFile(suffix='.png') - - if not width == None: - image_width = width - else: - image_width = 305 - if not height == None: - image_height = height - else: - image_height = 150 - - fft_size = 2048 - args = (wav_file, pngFile.name, image_width, image_height, fft_size, - self.bg_color, self.color_scheme) - create_wavform_png(*args) - - buffer = pngFile.read(0xFFFF) - while buffer: - yield buffer - buffer = pngFile.read(0xFFFF) - - pngFile.close() - diff --git a/telemeta/visualization/waveform4.py b/telemeta/visualization/waveform4.py deleted file mode 100644 index 93d9b57f..00000000 --- a/telemeta/visualization/waveform4.py +++ /dev/null @@ -1,59 +0,0 @@ -# Copyright (C) 2008 Parisson SARL -# All rights reserved. -# -# This software is licensed as described in the file COPYING, which -# you should have received as part of this distribution. The terms -# are also available at http://svn.parisson.org/telemeta/TelemetaLicense. -# -# Author: Guillaume Pellerin - -from telemeta.core import * -from telemeta.visualization.api import IMediaItemVisualizer -from django.conf import settings -from tempfile import NamedTemporaryFile -from telemeta.visualization.wav2png import * - -class WaveFormVisualizer(Component): - """WaveForm visualization driver (python style)""" - - implements(IMediaItemVisualizer) - - bg_color = None - color_scheme = None - - def get_id(self): - return "waveform4" - - def get_name(self): - return "Waveform (audiolab large)" - - def set_colors(self, background=None, scheme=None): - self.bg_color = background - self.color_scheme = scheme - - def render(self, media_item, width=None, height=None, options=None): - """Generator that streams the waveform as a PNG image with a python method""" - - wav_file = media_item.file.path - pngFile = NamedTemporaryFile(suffix='.png') - - if not width == None: - image_width = width - else: - image_width = 1800 - if not height == None: - image_height = height - else: - image_height = 300 - - fft_size = 2048 - args = (wav_file, pngFile.name, image_width, image_height, fft_size, self.bg_color, self.color_scheme) - create_wavform_png(*args) - - buffer = pngFile.read(0xFFFF) - while buffer: - yield buffer - buffer = pngFile.read(0xFFFF) - - pngFile.close() - diff --git a/telemeta/visualization/waveform_audiolab.py b/telemeta/visualization/waveform_audiolab.py new file mode 100644 index 00000000..91320022 --- /dev/null +++ b/telemeta/visualization/waveform_audiolab.py @@ -0,0 +1,60 @@ +# Copyright (C) 2008 Parisson SARL +# All rights reserved. +# +# This software is licensed as described in the file COPYING, which +# you should have received as part of this distribution. The terms +# are also available at http://svn.parisson.org/telemeta/TelemetaLicense. +# +# Author: Guillaume Pellerin + +from telemeta.core import * +from telemeta.visualization.api import IMediaItemVisualizer +from django.conf import settings +from tempfile import NamedTemporaryFile +from telemeta.visualization.wav2png import * + +class WaveFormVisualizer(Component): + """WaveForm visualization driver (python style thanks to wav2png.py and scikits.audiolab)""" + + implements(IMediaItemVisualizer) + + bg_color = None + color_scheme = None + + def get_id(self): + return "waveform_audiolab" + + def get_name(self): + return "Waveform (audiolab)" + + def set_colors(self, background=None, scheme=None): + self.bg_color = background + self.color_scheme = scheme + + def render(self, media_item, width=None, height=None, options=None): + """Generator that streams the waveform as a PNG image with a python method""" + + wav_file = media_item.file.path + pngFile = NamedTemporaryFile(suffix='.png') + + if not width == None: + image_width = width + else: + image_width = 1500 + if not height == None: + image_height = height + else: + image_height = 200 + + fft_size = 2048 + args = (wav_file, pngFile.name, image_width, image_height, fft_size, + self.bg_color, self.color_scheme) + create_wavform_png(*args) + + buffer = pngFile.read(0xFFFF) + while buffer: + yield buffer + buffer = pngFile.read(0xFFFF) + + pngFile.close() + diff --git a/telemeta/web/base.py b/telemeta/web/base.py index 9aa2604f..bfbeb92a 100644 --- a/telemeta/web/base.py +++ b/telemeta/web/base.py @@ -57,7 +57,7 @@ class WebView(Component): if request.REQUEST.has_key('visualizer_id'): visualizer_id = request.REQUEST['visualizer_id'] else: - visualizer_id = 'waveform3' + visualizer_id = 'waveform_audiolab' analyzers = [] for analyzer in self.analyzers: