Changeset c2803e5
- Timestamp:
- 12/24/08 19:54:06 (4 years ago)
- Branches:
- master, crem, crem2, dev, diadems, forma, generic, instru_search, lam, nlivemulti, production, release/1.4.4, security, social, storage, test, video
- Children:
- 583df3f
- Parents:
- 40f3d09
- git-author:
- olivier <> (12/24/08 19:54:06)
- git-committer:
- olivier <> (12/24/08 19:54:06)
- Location:
- telemeta/visualization
- Files:
-
- 10 edited
-
api.py (modified) (1 diff)
-
spectrogram.py (modified) (1 diff)
-
spectrogram2.py (modified) (1 diff)
-
spectrogram3.py (modified) (3 diffs)
-
spectrogram4.py (modified) (3 diffs)
-
wav2png.py (modified) (9 diffs)
-
waveform.py (modified) (1 diff)
-
waveform2.py (modified) (1 diff)
-
waveform3.py (modified) (3 diffs)
-
waveform4.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
telemeta/visualization/api.py
r6699ec9 rc2803e5 21 21 """ 22 22 23 def set_colors(self, background=None, scheme=None): 24 """Set the colors used for image generation. background is a RGB tuple, 25 and scheme a a predefined color theme name""" 26 pass 27 23 28 def render(media_item, width=None, height=None, options=None): 24 29 """Generator that streams the visualization output as a PNG image""" -
telemeta/visualization/spectrogram.py
re84ac08 rc2803e5 26 26 return "Spectrogram 1" 27 27 28 def set_colors(self, background=None, scheme=None): 29 pass 30 28 31 def render(self, media_item, options=None): 29 32 """Generator that streams the spectral view as a PNG image""" -
telemeta/visualization/spectrogram2.py
r9f20f85 rc2803e5 26 26 def get_name(self): 27 27 return "Spectrogram (octave)" 28 29 def set_colors(self, background=None, scheme=None): 30 pass 28 31 29 def render(self, media_item, options=None):32 def render(self, media_item, width=None, height=None, options=None): 30 33 """Generator that streams the spectral view as a PNG image""" 31 34 -
telemeta/visualization/spectrogram3.py
r1f728bb rc2803e5 19 19 implements(IMediaItemVisualizer) 20 20 21 bg_color = None 22 color_scheme = None 23 21 24 def get_id(self): 22 25 return "spectrogram3" … … 25 28 return "Spectrogram (audiolab)" 26 29 30 def set_colors(self, background=None, scheme=None): 31 self.bg_color = background 32 self.color_scheme = scheme 33 27 34 def render(self, media_item, width=None, height=None, options=None): 28 35 """Generator that streams the spectrogram as a PNG image with a python method""" … … 41 48 42 49 fft_size = 2048 43 args = (wav_file, pngFile.name, image_width, image_height, fft_size) 50 args = (wav_file, pngFile.name, image_width, image_height, fft_size, 51 self.bg_color, self.color_scheme) 44 52 create_spectrogram_png(*args) 45 53 -
telemeta/visualization/spectrogram4.py
r1f728bb rc2803e5 19 19 implements(IMediaItemVisualizer) 20 20 21 bg_color = None 22 color_scheme = None 23 21 24 def get_id(self): 22 25 return "spectrogram4" … … 25 28 return "Spectrogram (audiolab large)" 26 29 30 def set_colors(self, background=None, scheme=None): 31 self.bg_color = background 32 self.color_scheme = scheme 33 27 34 def render(self, media_item, width=None, height=None, options=None): 28 35 """Generator that streams the spectrogram as a PNG image with a python method""" … … 41 48 42 49 fft_size = 2048 43 args = (wav_file, pngFile.name, image_width, image_height, fft_size) 50 args = (wav_file, pngFile.name, image_width, image_height, fft_size, 51 self.bg_color, self.color_scheme) 44 52 create_spectrogram_png(*args) 45 53 -
telemeta/visualization/wav2png.py
r1f728bb rc2803e5 29 29 import scikits.audiolab as audiolab 30 30 31 color_schemes = { 32 'default': { 33 'waveform': [(50,0,200), (0,220,80), (255,224,0), (255,0,0)], 34 'spectrogram': [(0, 0, 0), (58/4,68/4,65/4), (80/2,100/2,153/2), (90,180,100), 35 (224,224,44), (255,60,30), (255,255,255)] 36 }, 37 'purple': { 38 'waveform': [(173,173,173), (147,149,196), (77,80,138), (108,66,0)], 39 'spectrogram': [(0, 0, 0), (58/4,68/4,65/4), (80/2,100/2,153/2), (90,180,100), 40 (224,224,44), (255,60,30), (255,255,255)] 41 } 42 } 43 31 44 class TestAudioFile(object): 32 45 """A class that mimics audiolab.sndfile but generates noise instead of reading … … 245 258 246 259 class WaveformImage(object): 247 def __init__(self, image_width, image_height): 248 self.image = Image.new("RGB", (image_width, image_height)) 260 def __init__(self, image_width, image_height, bg_color = None, color_scheme = None): 261 if not bg_color: 262 bg_color = (0,0,0) 263 if not color_scheme: 264 color_scheme = 'default' 265 266 self.image = Image.new("RGB", (image_width, image_height), bg_color) 249 267 250 268 self.image_width = image_width … … 254 272 self.previous_x, self.previous_y = None, None 255 273 256 colors = [ 257 (50,0,200), 258 (0,220,80), 259 (255,224,0), 260 (255,0,0), 261 ] 274 colors = color_schemes[color_scheme]['waveform'] 262 275 263 276 # this line gets the old "screaming" colors back... … … 328 341 329 342 class SpectrogramImage(object): 330 def __init__(self, image_width, image_height, fft_size): 343 def __init__(self, image_width, image_height, fft_size, bg_color = None, color_scheme = None): 344 345 #FIXME: bg_color is ignored 346 347 if not color_scheme: 348 color_scheme = 'default' 349 331 350 self.image = Image.new("P", (image_height, image_width)) 332 351 … … 335 354 self.fft_size = fft_size 336 355 337 colors = [ 338 (0, 0, 0), 339 (58/4,68/4,65/4), 340 (80/2,100/2,153/2), 341 (90,180,100), 342 (224,224,44), 343 (255,60,30), 344 (255,255,255) 345 ] 356 colors = color_schemes[color_scheme]['spectrogram'] 346 357 347 358 self.image.putpalette(interpolate_colors(colors, True)) … … 379 390 380 391 381 def create_wavform_png(input_filename, output_filename_w, image_width, image_height, fft_size): 392 def create_wavform_png(input_filename, output_filename_w, image_width, image_height, fft_size, 393 bg_color = None, color_scheme = None): 382 394 audio_file = audiolab.sndfile(input_filename, 'read') 383 395 … … 385 397 processor = AudioProcessor(audio_file, fft_size, numpy.hanning) 386 398 387 waveform = WaveformImage(image_width, image_height )399 waveform = WaveformImage(image_width, image_height, bg_color, color_scheme) 388 400 389 401 for x in range(image_width): … … 405 417 print " done" 406 418 407 def create_spectrogram_png(input_filename, output_filename_s, image_width, image_height, fft_size): 419 def create_spectrogram_png(input_filename, output_filename_s, image_width, image_height, fft_size, 420 bg_color = None, color_scheme = None): 408 421 audio_file = audiolab.sndfile(input_filename, 'read') 409 422 … … 411 424 processor = AudioProcessor(audio_file, fft_size, numpy.hanning) 412 425 413 spectrogram = SpectrogramImage(image_width, image_height, fft_size )426 spectrogram = SpectrogramImage(image_width, image_height, fft_size, bg_color, color_scheme) 414 427 415 428 for x in range(image_width): -
telemeta/visualization/waveform.py
r59ecfdd rc2803e5 29 29 return "Waveform" 30 30 31 def set_colors(self, background=None, scheme=None): 32 pass 33 31 34 def render(self, media_item, options=None): 32 35 """Generator that streams the waveform as a PNG image""" -
telemeta/visualization/waveform2.py
r9f20f85 rc2803e5 29 29 return "Waveform (octave)" 30 30 31 def set_colors(self, background=None, scheme=None): 32 pass 33 31 34 def render(self, media_item, options=None): 32 35 """Generator that streams the temporal view as a PNG image""" -
telemeta/visualization/waveform3.py
r1f728bb rc2803e5 19 19 implements(IMediaItemVisualizer) 20 20 21 bg_color = None 22 color_scheme = None 23 21 24 def get_id(self): 22 25 return "waveform3" … … 24 27 def get_name(self): 25 28 return "Waveform (audiolab)" 29 30 def set_colors(self, background=None, scheme=None): 31 self.bg_color = background 32 self.color_scheme = scheme 26 33 27 34 def render(self, media_item, width=None, height=None, options=None): … … 41 48 42 49 fft_size = 2048 43 args = (wav_file, pngFile.name, image_width, image_height, fft_size) 50 args = (wav_file, pngFile.name, image_width, image_height, fft_size, 51 self.bg_color, self.color_scheme) 44 52 create_wavform_png(*args) 45 53 -
telemeta/visualization/waveform4.py
r1f728bb rc2803e5 19 19 implements(IMediaItemVisualizer) 20 20 21 bg_color = None 22 color_scheme = None 23 21 24 def get_id(self): 22 25 return "waveform4" … … 25 28 return "Waveform (audiolab large)" 26 29 27 def render(self, media_item, width=None, height=None, options=None): 30 def set_colors(self, background=None, scheme=None): 31 self.bg_color = background 32 self.color_scheme = scheme 33 34 def render(self, media_item, width=None, height=None, options=None): 28 35 """Generator that streams the waveform as a PNG image with a python method""" 29 36 … … 41 48 42 49 fft_size = 2048 43 args = (wav_file, pngFile.name, image_width, image_height, fft_size )50 args = (wav_file, pngFile.name, image_width, image_height, fft_size, self.bg_color, self.color_scheme) 44 51 create_wavform_png(*args) 45 52
Note: See TracChangeset
for help on using the changeset viewer.
