+++ /dev/null
-# -*- coding: utf-8 -*-
+++ /dev/null
-# -*- coding: utf-8 -*-
-
-from timeside.core import Processor, implements, interfacedoc, FixedSizeInputAdapter
-from timeside.api import *
-import numpy
-
-
-class Gain(Processor):
- implements(IEffect)
-
- @interfacedoc
- def __init__(self, gain=1.0):
- self.gain = gain
-
- @staticmethod
- @interfacedoc
- def id():
- return "test_gain"
-
- @staticmethod
- @interfacedoc
- def name():
- return "Gain test effect"
-
- def process(self, frames, eod=False):
- return numpy.multiply(frames, self.gain), eod
+++ /dev/null
-# -*- coding: utf-8 -*-
-"""
-Created on Fri Oct 11 13:22:37 2013
-
-@author: thomas
-"""
-
-from __future__ import division
-import timeside
-import matplotlib.pyplot as plt
-import numpy as np
-import sys
-
-#wav_file = sys.argv[-1]
-wav_file = '/home/thomas/code/timeside/TimeSide/tests/samples/sweep.wav'
-
-# normal
-d = timeside.decoder.FileDecoder(wav_file)
-
-specgram = timeside.analyzer.Spectrogram()
-waveform = timeside.analyzer.Waveform()
-
-# Get available Vamp plugins list
-from timeside.analyzer.vamp_plugin import VampSimpleHost
-plugins_list = VampSimpleHost.get_plugins_list()
-
-# Display avalaible plugins
-print 'index \t soname \t \t identifier \t output '
-print '------ \t \t ---------- \t ------ '
-for index, line in zip(xrange(len(plugins_list)),plugins_list):
- print '%d : %s \t %s \t %s' % (index,line[0],line[1],line[2])
-
-# Let's choose #7
-my_plugin = plugins_list[7]
-print my_plugin
-
-#
-# Vamp plugin Analyzer
-#vamp = timeside.analyzer.VampSimpleHost([my_plugin])
-vamp = timeside.analyzer.VampSimpleHost()
-
-#
-myPipe = (d | vamp | specgram | waveform).run()
-
-# Get spectrogram result and plot the spectrogram
-spec_res = specgram.results['spectrogram_analyzer']
-N = spec_res.parameters['FFT_SIZE']
-max_freq = (N // 2 + 1) / N * spec_res.frame_metadata.samplerate
-
-
-
-# Get the vamp plugin result and plot it
-for key in vamp.results.keys():
- print vamp.results[key].data
-
-res_vamp = vamp.results['vamp_simple_host.percussiononsets.detectionfunction']
-
-plt.figure(1)
-
-plt.subplot(2,1,1)
-plt.plot(res_vamp.time, res_vamp.data)
-plt.xlabel('time in s')
-plt.grid
-plt.title(res_vamp.name)
-
-plt.subplot(2,1,2)
-plt.imshow(20 * np.log10(spec_res.data.T + 1e-6),
- origin='lower',
- extent=[spec_res.time[0], spec_res.time[-1], 0,
- max_freq],
- aspect='auto')
-
-data = (res_vamp.data - res_vamp.data.mean()).clip(0)
-plt.plot(res_vamp.time, abs(data / data.max() * max_freq))
-
-
-plt.xlabel('time in s')
-plt.show()
\ No newline at end of file
+++ /dev/null
-# -*- coding: utf-8 -*-
-"""
-Created on Tue Jul 16 13:04:49 2013
-
-@author: thomas
-"""
-from __future__ import division
-import timeside
-import matplotlib.pyplot as plt
-import numpy as np
-import sys
-
-if not '.wav' in sys.argv[-1]:
- wav_file = 'toto.wav'
-else:
- wav_file = sys.argv[-1]
-
-# normal
-decoder = timeside.decoder.FileDecoder(wav_file, start=10, duration=15)
-#e = timeside.encoder.VorbisEncoder('output.ogg', overwrite = True)
-aubio_pitch = timeside.analyzer.AubioPitch()
-aubio_temporal = timeside.analyzer.AubioTemporal()
-specgram = timeside.analyzer.Spectrogram()
-waveform = timeside.analyzer.Waveform()
-#g = timeside.grapher.Spectrogram()
-
-pipe = (decoder | aubio_pitch | aubio_temporal | specgram | waveform).run()
-
-pipe.results.keys()
-
-# Display Spectrogram + Aubio Pitch + Aubio Beat
-plt.figure(1)
-
-spec_res = specgram.results['spectrogram_analyzer']
-N = spec_res.parameters['FFT_SIZE']
-plt.imshow(20 * np.log10(spec_res.data.T),
- origin='lower',
- extent=[spec_res.time[0], spec_res.time[-1], 0,
- (N // 2 + 1) / N * spec_res.frame_metadata.samplerate],
- aspect='auto')
-
-res_pitch = aubio_pitch.results['aubio_pitch']
-plt.plot(res_pitch.time, res_pitch.data)
-
-
-res_beats = aubio_temporal.results['aubio_temporal.beat']
-
-for time in res_beats.time:
- plt.axvline(time, color='r')
-
-plt.title('Spectrogram + Aubio pitch + Aubio beat')
-plt.grid()
-
-# Display waveform + Onsets
-plt.figure(2)
-res_wave = waveform.results['waveform_analyzer']
-plt.plot(res_wave.time, res_wave.data)
-res_onsets = aubio_temporal.results['aubio_temporal.onset']
-for time in res_onsets.time:
- plt.axvline(time, color='g')
-plt.grid()
-plt.title('Waveform + Aubio onset')
-plt.show()
+++ /dev/null
-# -*- coding: utf-8 -*-
-
-import os, sys
-import timeside
-
-path = sys.argv[-1]
-filename = path.split(os.sep)[-1]
-result_dir = '../results/'
-
-if not os.path.exists(result_dir):
- os.makedirs(result_dir)
-
-decoder = timeside.decoder.FileDecoder(path)
-graphers = timeside.core.processors(timeside.api.IGrapher)
-encoders = timeside.core.processors(timeside.api.IEncoder)
-analyzers = timeside.core.processors(timeside.api.IAnalyzer)
-
-grapher_list = []
-analyzer_list = []
-encoder_list = []
-
-pipe = decoder
-
-for grapher in graphers:
- proc = grapher()
- grapher_list.append(proc)
- pipe = pipe | proc
-
-for analyzer in analyzers:
- proc = analyzer()
- analyzer_list.append(proc)
- pipe = pipe | proc
-
-for encoder in encoders:
- path = result_dir + os.sep + filename + '.' + encoder.file_extension()
- proc = encoder(path, overwrite=True)
- encoder_list.append(proc)
- pipe = pipe | proc
-
-print pipe
-pipe.run()
-
-for grapher in grapher_list:
- image = result_dir + os.sep + filename + '-' + grapher.id() + '.png'
- grapher.render(image)
-
+++ /dev/null
-# -*- coding: utf-8 -*-
-
-import os, sys
-import timeside
-
-audio_file = sys.argv[-1]
-audio_filename = audio_file.split(os.sep)[-1]
-img_dir = '../results/img'
-
-if not os.path.exists(img_dir):
- os.makedirs(img_dir)
-
-decoder = timeside.decoder.FileDecoder(audio_file)
-graphers = timeside.core.processors(timeside.api.IGrapher)
-pipe = decoder
-proc_list = []
-
-for grapher in graphers:
- proc = grapher()
- proc_list.append(proc)
- print proc.id()
- pipe = pipe | proc
-
-pipe.run()
-
-for grapher in proc_list:
- image = img_dir + os.sep + audio_filename + '-' + grapher.id() + '.png'
- grapher.render(image)
+++ /dev/null
-# -*- coding: utf-8 -*-
-
-import timeside
-from sys import stdout
-import os.path
-import numpy
-
-class TestAnalyzer:
-
- graphers = timeside.get_processors(timeside.api.IGrapher)
- decoders = timeside.get_processors(timeside.api.IDecoder)
- encoders= timeside.get_processors(timeside.api.IEncoder)
- analyzers = timeside.get_processors(timeside.api.IAnalyzer)
-
- def __init__(self, path):
- self.source = os.path.join(os.path.dirname(__file__), path)
- print "Processing %s" % self.source
- self.decoder = timeside.decoder.FileDecoder(self.source)
- print 'format: ', self.decoder.format()
- self.pipe = self.decoder
- self.analyzers_sub_pipe = []
-
- def process(self):
- for analyzer in self.analyzers:
- sub_pipe = analyzer()
- self.analyzers_sub_pipe.append(sub_pipe)
- self.pipe = self.pipe | sub_pipe
- self.pipe.run()
-
- def results(self):
- results = []
- for analyzer in self.analyzers_sub_pipe:
- if hasattr(analyzer, 'results'):
- results.append(analyzer.results())
- else:
- value = analyzer.result()
- results.append([{'name':analyzer.name(),
- 'id':analyzer.id(),
- 'unit':analyzer.unit(),
- 'value':str(value)}])
- print results
-
-
-test = TestAnalyzer('../samples/guitar.wav')
-#test = TestAnalyzer('/home/momo/music/wav/Cellar/Cellar-FinallyMix_01.wav')
-test.process()
-test.results()
-
+++ /dev/null
-# -*- coding: utf-8 -*-
-
-import timeside
-import sys
-import os.path
-import numpy
-import time
-
-
-class TestAnalyzer:
-
- analyzer = timeside.analyzer.Level()
-
- def __init__(self, path):
- self.source = path
- print "Processing %s" % self.source
- self.decoder = timeside.decoder.FileDecoder(self.source)
- print 'format: ', self.decoder.format()
- self.pipe = self.decoder
- self.sub_pipe = self.analyzer
-
- def process(self):
- self.pipe = self.pipe | self.sub_pipe
- self.pipe.run()
-
- def results(self):
- print {'name':self.analyzer.name(),
- 'id':self.analyzer.id(),
- 'unit':self.analyzer.unit(),
- 'value':str(self.analyzer.value)}
-
-test = TestAnalyzer(sys.argv[-1])
-test.process()
-test.results()
+++ /dev/null
-# -*- coding: utf-8 -*-
-
-from timeside.decoder import *
-from timeside.encoder import *
-import os.path
-import sys
-
-source = sys.argv[-1]
-dest = source+'.flac'
-
-decoder = FileDecoder(source)
-encoder = FlacEncoder(dest, overwrite=True)
-
-(decoder | encoder).run()
+++ /dev/null
-# -*- coding: utf-8 -*-
-
-from timeside.decoder import *
-from timeside.encoder import *
-import os.path
-import sys
-
-if len(sys.argv) < 2:
- print 'usage:', sys.argv[0], '<inputfile>'
- sys.exit(1)
-
-source = sys.argv[-1]
-dest = source+'.mp3'
-
-print 'converting', source, 'to', dest
-
-decoder = FileDecoder(source)
-encoder = Mp3Encoder(dest, overwrite=True)
-
-(decoder | encoder).run()
-
-metadata = {'TIT2': 'title', #title2
- 'TCOM': 'composer', #composer
- 'TPE1': 'lead creator', #lead
- 'UFID': 'identifier', #Unique ID...
- 'TALB': 'album', #album
- 'TCON': 'genre', #genre
- 'TDRC': '2011', #year
-# 'COMM': 'blabla', #comment
- }
-
-encoder.set_metadata(metadata)
-encoder.write_metadata()
+++ /dev/null
-from numpy import vstack, zeros
-
-from timeside.decoder import *
-from timeside.encoder import *
-
-import sys, os.path
-
-def transcode(source, target):
- decoder = FileDecoder(source)
- decoder.setup()
-
- channels = decoder.channels()
- samplerate = decoder.samplerate()
-
- print channels, samplerate
-
- encoder = Mp3Encoder(target)
- encoder.setup(channels = channels, samplerate = samplerate)
-
- totalframes = 0
- while True:
- frames, eod = decoder.process()
- encoder.process(frames, eod)
- totalframes += frames.shape[0]
- if eod or encoder.eod:
- break
-
-if __name__ == '__main__':
-
- if len(sys.argv) < 3:
- print 'needs 2 args'
- sys.exit(1)
- transcode(sys.argv[1], sys.argv[2])
+++ /dev/null
-# -*- coding: utf-8 -*-
-
-from timeside.decoder import *
-from timeside.encoder import *
-import os.path
-import sys
-
-if len(sys.argv) < 2:
- print 'usage:', sys.argv[0], '<inputfile>'
- sys.exit(1)
-
-source = sys.argv[-1]
-dest = source+'.ogg'
-
-print 'converting', source, 'to', dest
-
-decoder = FileDecoder(source)
-encoder = VorbisEncoder(dest, overwrite=True)
-
-(decoder | encoder).run()
+++ /dev/null
-# -*- coding: utf-8 -*-
-
-from timeside.decoder import *
-from timeside.encoder import *
-import os.path
-import sys
-
-source = sys.argv[-1]
-dest = source+'.webm'
-
-decoder = FileDecoder(source)
-encoder = WebMEncoder(dest)
-
-(decoder | encoder).run()
+++ /dev/null
-# -*- coding: utf-8 -*-
-
-from timeside.decoder import *
-from timeside.encoder import *
-import os.path
-
-source = os.path.join(os.path.dirname(__file__), "../samples/sweep.wav")
-dest = os.path.join(os.path.dirname(__file__), "../results/sweep_wav.flac")
-
-decoder = FileDecoder(source)
-encoder = FlacEncoder(dest)
-
-(decoder | encoder).run()
+++ /dev/null
-# -*- coding: utf-8 -*-
-
-from timeside.tests.api.examples import Gain
-from timeside.core import *
-from timeside.decoder import *
-from timeside.analyzer import *
-from timeside.encoder import *
-from timeside.api import *
-
-import sys
-if len(sys.argv) > 1:
- source = sys.argv[1]
-else:
- import os.path
- source= os.path.join (os.path.dirname(__file__), "../samples/guitar.wav")
-
-Decoder = FileDecoder
-print "Creating decoder with id=%s for: %s" % (Decoder.id(), source)
-decoder = Decoder(source)
-analyzer = MaxLevel()
-decoder.setup()
-nchannels = decoder.channels()
-samplerate = decoder.samplerate()
-nframes = decoder.nframes()
-analyzer.setup(nchannels, samplerate)
-
-print "Stats: duration=%f, nframes=%d, nchannels=%d, samplerate=%d, resolution=%d" % (
- nframes / float(samplerate), nframes, nchannels, samplerate, decoder.resolution())
-
-while True:
- frames, eod = decoder.process()
- analyzer.process(frames, eod)
- if eod:
- break
-
-max_level = analyzer.result()
-print "Max level: %f" % max_level
-
-destination = "../results/guitar_normalized.wav"
-Encoder = WavEncoder
-print "Creating encoder with id=%s for: %s" % (Encoder.id(), destination)
-encoder = Encoder(destination)
-
-gain = 1
-if max_level > 0:
- gain = 0.9 / max_level
-
-effect = Gain(gain)
-
-decoder.setup()
-effect.setup(decoder.channels(), decoder.samplerate())
-encoder.setup(effect.channels(), effect.samplerate())
-
-print "Applying effect id=%s with gain=%f" % (effect.id(), gain)
-
-while True:
- frames, eod = decoder.process()
- encoder.process(*effect.process(frames, eod))
- if eod:
- break
-
+++ /dev/null
-# -*- coding: utf-8 -*-
-
-from timeside.core import *
-from timeside.decoder import *
-from timeside.analyzer import *
-from timeside.encoder import *
-from timeside.api import *
-
-import sys
-if len(sys.argv) > 1:
- source = sys.argv[1]
-else:
- import os.path
- source= os.path.join (os.path.dirname(__file__), "../samples/sweep.flac")
-
-decoder = FileDecoder(source)
-print "Creating decoder with id=%s for: %s" % (decoder.id(), source)
-decoder.setup()
-channels = decoder.channels()
-print 'channels :', channels
-samplerate = decoder.samplerate()
-nframes = decoder.nframes()
-
-dest1 = "/tmp/test_filesink.mp3"
-dest2 = "/tmp/test_appsink.mp3"
-f = open(dest2,'w')
-
-streaming=True
-encoder = Mp3Encoder(dest1, streaming=True)
-encoder.setup(channels=channels, samplerate=samplerate)
-
-while True:
- encoder.process(*decoder.process())
- if streaming:
- f.write(encoder.chunk)
- if encoder.eod :
- break
-
-f.close()
-print encoder.pipe
+++ /dev/null
-# -*- coding: utf-8 -*-
-
-from timeside.core import *
-from timeside.decoder import *
-from timeside.analyzer import *
-from timeside.encoder import *
-from timeside.api import *
-
-import sys
-if len(sys.argv) > 1:
- source = sys.argv[1]
-else:
- import os.path
- source= os.path.join (os.path.dirname(__file__), "../samples/sweep.wav")
-
-decoder = FileDecoder(source)
-print "Creating decoder with id=%s for: %s" % (decoder.id(), source)
-decoder.setup()
-channels = decoder.channels()
-print 'channels :', channels
-samplerate = decoder.samplerate()
-nframes = decoder.nframes()
-
-dest1 = "/tmp/test_filesink.mp3"
-dest2 = "/tmp/test_appsink.mp3"
-f = open(dest2,'w')
-
-streaming=True
-encoder = Mp3Encoder(dest1, streaming=True)
-encoder.setup(channels=channels, samplerate=samplerate)
-
-print encoder.pipe
-
-while True:
- encoder.process(*decoder.process())
- if streaming:
- f.write(encoder.chunk)
- if encoder.eod :
- break
-
-f.close()
-print encoder.pipe
+++ /dev/null
-# -*- coding: utf-8 -*-
-
-from timeside.core import *
-from timeside.decoder import *
-from timeside.analyzer import *
-from timeside.encoder import *
-from timeside.api import *
-
-import sys
-if len(sys.argv) > 1:
- source = sys.argv[1]
-else:
- import os.path
- source= os.path.join (os.path.dirname(__file__), "../samples/sweep.flac")
-
-decoder = FileDecoder(source)
-print "Creating decoder with id=%s for: %s" % (decoder.id(), source)
-decoder.setup()
-channels = decoder.channels()
-print 'channels :', channels
-samplerate = decoder.samplerate()
-nframes = decoder.nframes()
-
-dest1 = "/tmp/test_filesink.ogg"
-dest2 = "/tmp/test_appsink.ogg"
-f = open(dest2,'w')
-
-streaming=True
-encoder = VorbisEncoder(dest1, streaming=True)
-encoder.setup(channels=channels, samplerate=samplerate)
-
-print encoder.pipe
-
-while True:
- encoder.process(*decoder.process())
- if streaming:
- f.write(encoder.chunk)
- if encoder.eod :
- break
-
-f.close()
-print encoder.pipe
+++ /dev/null
-# -*- coding: utf-8 -*-
-
-from timeside.decoder import *
-from timeside.encoder import *
-import os.path
-
-source = os.path.join(os.path.dirname(__file__), "../samples/sweep.wav")
-dest = os.path.join(os.path.dirname(__file__), "/tmp/sweep_wav.mp3")
-
-decoder = FileDecoder(source)
-encoder = Mp3Encoder(dest)
-
-(decoder | encoder).run()
-
-metadata = {'TIT2': 'title', #title2
- 'TCOM': 'composer', #composer
- 'TPE1': 'lead creator', #lead
- 'UFID': 'identifier', #Unique ID...
- 'TALB': 'album', #album
- 'TCON': 'genre', #genre
- 'TDRC': '2011', #year
-# 'COMM': 'blabla', #comment
- }
-
-encoder.set_metadata(metadata)
-encoder.write_metadata()
-
+++ /dev/null
-# -*- coding: utf-8 -*-
-
-from timeside.tests.api.examples import Gain
-from timeside.core import *
-from timeside.decoder import *
-from timeside.analyzer import *
-from timeside.encoder import *
-from timeside.api import *
-from sys import stdout
-import os.path
-import numpy
-
-source = os.path.join(os.path.dirname(__file__), "../samples/guitar.wav")
-
-print "Normalizing %s" % source
-decoder = FileDecoder(source)
-maxlevel = MaxLevel()
-duration = Duration()
-
-(decoder | maxlevel | duration).run()
-
-gain = 1
-if maxlevel.result() < 0:
- gain = 0.9 / numpy.exp(maxlevel.result()/20)
-
-print "input maxlevel: %f" % maxlevel.result()
-print "gain: %f" % gain
-print "duration: %f %s" % (duration.result(), duration.unit())
-
-gain = Gain(gain)
-encoder = WavEncoder("../results/guitar_normalized.wav")
-
-subpipe = gain | maxlevel
-
-(decoder | subpipe | encoder).run()
-
-print "output maxlevel: %f" % maxlevel.result()
-
-
+++ /dev/null
-# -*- coding: utf-8 -*-
-
-import os
-from timeside.core import *
-from timeside.api import *
-from timeside.decoder import *
-from timeside.grapher import *
-
-sample_dir = '../samples'
-img_dir = '../results/img'
-if not os.path.exists(img_dir):
- os.mkdir(img_dir)
-
-test_dict = {'sweep.wav': 'spec_wav.png',
- 'sweep.flac': 'spec_flac.png',
- 'sweep.ogg': 'spec_ogg.png',
- 'sweep.mp3': 'spec_mp3.png',
- }
-
-for source, image in test_dict.iteritems():
- audio = os.path.join(os.path.dirname(__file__), sample_dir + os.sep + source)
- image = img_dir + os.sep + image
- print 'Test : decoder(%s) | waveform (%s)' % (source, image)
- decoder = FileDecoder(audio)
- spectrogram = Spectrogram()
- (decoder | spectrogram).run()
- print 'frames per pixel = ', spectrogram.samples_per_pixel
- print "render spectrogram to: %s" % image
- spectrogram.render(image)
-
-
-
+++ /dev/null
-# -*- coding: utf-8 -*-
-
-from timeside.decoder import *
-from timeside.encoder import *
-import os.path
-
-source = os.path.join(os.path.dirname(__file__), "../samples/sweep.wav")
-dest = os.path.join(os.path.dirname(__file__), "../results/sweep_wav.ogg")
-
-decoder = FileDecoder(source)
-encoder = VorbisEncoder(dest)
-
-(decoder | encoder).run()
+++ /dev/null
-# -*- coding: utf-8 -*-
-
-from timeside.decoder import *
-from timeside.analyzer import *
-from timeside.encoder import *
-
-import os.path
-source = os.path.join(os.path.dirname(__file__), "../samples/sweep.wav")
-dest = os.path.join(os.path.dirname(__file__), "../results/sweep_wav.wav")
-
-decoder = FileDecoder(source)
-encoder = WavEncoder(dest)
-
-(decoder | encoder).run()
-
+++ /dev/null
-# -*- coding: utf-8 -*-
-
-import os
-from timeside.core import *
-from timeside.api import *
-from timeside.decoder import *
-from timeside.grapher import *
-
-sample_dir = '../samples'
-img_dir = '../results/img'
-if not os.path.exists(img_dir):
- os.makedirs(img_dir)
-
-test_dict = {'sweep.wav': 'waveform_wav.png',
- 'sweep.flac': 'waveform_flac.png',
- 'sweep.ogg': 'waveform_ogg.png',
- 'sweep.mp3': 'waveform_mp3.png',
- }
-
-for source, image in test_dict.iteritems():
- audio = os.path.join(os.path.dirname(__file__), sample_dir + os.sep + source)
- image = img_dir + os.sep + image
- print 'Test : decoder(%s) | waveform (%s)' % (source, image)
- decoder = FileDecoder(audio)
- waveform = Waveform(width=1024, height=256, bg_color=(255,255,255), color_scheme='default')
- (decoder | waveform).run()
- print 'frames per pixel = ', waveform.samples_per_pixel
- print "render waveform to: %s" % image
- waveform.render(image)
--- /dev/null
+# -*- coding: utf-8 -*-
--- /dev/null
+# -*- coding: utf-8 -*-
+
+from timeside.core import Processor, implements, interfacedoc, FixedSizeInputAdapter
+from timeside.api import *
+import numpy
+
+
+class Gain(Processor):
+ implements(IEffect)
+
+ @interfacedoc
+ def __init__(self, gain=1.0):
+ self.gain = gain
+
+ @staticmethod
+ @interfacedoc
+ def id():
+ return "test_gain"
+
+ @staticmethod
+ @interfacedoc
+ def name():
+ return "Gain test effect"
+
+ def process(self, frames, eod=False):
+ return numpy.multiply(frames, self.gain), eod
--- /dev/null
+# -*- coding: utf-8 -*-
+"""
+Created on Fri Oct 11 13:22:37 2013
+
+@author: thomas
+"""
+
+from __future__ import division
+import timeside
+import matplotlib.pyplot as plt
+import numpy as np
+import sys
+
+#wav_file = sys.argv[-1]
+wav_file = '/home/thomas/code/timeside/TimeSide/tests/samples/sweep.wav'
+
+# normal
+d = timeside.decoder.FileDecoder(wav_file)
+
+specgram = timeside.analyzer.Spectrogram()
+waveform = timeside.analyzer.Waveform()
+
+# Get available Vamp plugins list
+from timeside.analyzer.vamp_plugin import VampSimpleHost
+plugins_list = VampSimpleHost.get_plugins_list()
+
+# Display avalaible plugins
+print 'index \t soname \t \t identifier \t output '
+print '------ \t \t ---------- \t ------ '
+for index, line in zip(xrange(len(plugins_list)),plugins_list):
+ print '%d : %s \t %s \t %s' % (index,line[0],line[1],line[2])
+
+# Let's choose #7
+my_plugin = plugins_list[7]
+print my_plugin
+
+#
+# Vamp plugin Analyzer
+#vamp = timeside.analyzer.VampSimpleHost([my_plugin])
+vamp = timeside.analyzer.VampSimpleHost()
+
+#
+myPipe = (d | vamp | specgram | waveform).run()
+
+# Get spectrogram result and plot the spectrogram
+spec_res = specgram.results['spectrogram_analyzer']
+N = spec_res.parameters['FFT_SIZE']
+max_freq = (N // 2 + 1) / N * spec_res.frame_metadata.samplerate
+
+
+
+# Get the vamp plugin result and plot it
+for key in vamp.results.keys():
+ print vamp.results[key].data
+
+res_vamp = vamp.results['vamp_simple_host.percussiononsets.detectionfunction']
+
+plt.figure(1)
+
+plt.subplot(2,1,1)
+plt.plot(res_vamp.time, res_vamp.data)
+plt.xlabel('time in s')
+plt.grid
+plt.title(res_vamp.name)
+
+plt.subplot(2,1,2)
+plt.imshow(20 * np.log10(spec_res.data.T + 1e-6),
+ origin='lower',
+ extent=[spec_res.time[0], spec_res.time[-1], 0,
+ max_freq],
+ aspect='auto')
+
+data = (res_vamp.data - res_vamp.data.mean()).clip(0)
+plt.plot(res_vamp.time, abs(data / data.max() * max_freq))
+
+
+plt.xlabel('time in s')
+plt.show()
\ No newline at end of file
--- /dev/null
+# -*- coding: utf-8 -*-
+"""
+Created on Tue Jul 16 13:04:49 2013
+
+@author: thomas
+"""
+from __future__ import division
+import timeside
+import matplotlib.pyplot as plt
+import numpy as np
+import sys
+
+if not '.wav' in sys.argv[-1]:
+ wav_file = 'toto.wav'
+else:
+ wav_file = sys.argv[-1]
+
+# normal
+decoder = timeside.decoder.FileDecoder(wav_file, start=10, duration=15)
+#e = timeside.encoder.VorbisEncoder('output.ogg', overwrite = True)
+aubio_pitch = timeside.analyzer.AubioPitch()
+aubio_temporal = timeside.analyzer.AubioTemporal()
+specgram = timeside.analyzer.Spectrogram()
+waveform = timeside.analyzer.Waveform()
+#g = timeside.grapher.Spectrogram()
+
+pipe = (decoder | aubio_pitch | aubio_temporal | specgram | waveform).run()
+
+pipe.results.keys()
+
+# Display Spectrogram + Aubio Pitch + Aubio Beat
+plt.figure(1)
+
+spec_res = specgram.results['spectrogram_analyzer']
+N = spec_res.parameters['FFT_SIZE']
+plt.imshow(20 * np.log10(spec_res.data.T),
+ origin='lower',
+ extent=[spec_res.time[0], spec_res.time[-1], 0,
+ (N // 2 + 1) / N * spec_res.frame_metadata.samplerate],
+ aspect='auto')
+
+res_pitch = aubio_pitch.results['aubio_pitch']
+plt.plot(res_pitch.time, res_pitch.data)
+
+
+res_beats = aubio_temporal.results['aubio_temporal.beat']
+
+for time in res_beats.time:
+ plt.axvline(time, color='r')
+
+plt.title('Spectrogram + Aubio pitch + Aubio beat')
+plt.grid()
+
+# Display waveform + Onsets
+plt.figure(2)
+res_wave = waveform.results['waveform_analyzer']
+plt.plot(res_wave.time, res_wave.data)
+res_onsets = aubio_temporal.results['aubio_temporal.onset']
+for time in res_onsets.time:
+ plt.axvline(time, color='g')
+plt.grid()
+plt.title('Waveform + Aubio onset')
+plt.show()
--- /dev/null
+# -*- coding: utf-8 -*-
+
+import os, sys
+import timeside
+
+path = sys.argv[-1]
+filename = path.split(os.sep)[-1]
+result_dir = '../results/'
+
+if not os.path.exists(result_dir):
+ os.makedirs(result_dir)
+
+decoder = timeside.decoder.FileDecoder(path)
+graphers = timeside.core.processors(timeside.api.IGrapher)
+encoders = timeside.core.processors(timeside.api.IEncoder)
+analyzers = timeside.core.processors(timeside.api.IAnalyzer)
+
+grapher_list = []
+analyzer_list = []
+encoder_list = []
+
+pipe = decoder
+
+for grapher in graphers:
+ proc = grapher()
+ grapher_list.append(proc)
+ pipe = pipe | proc
+
+for analyzer in analyzers:
+ proc = analyzer()
+ analyzer_list.append(proc)
+ pipe = pipe | proc
+
+for encoder in encoders:
+ path = result_dir + os.sep + filename + '.' + encoder.file_extension()
+ proc = encoder(path, overwrite=True)
+ encoder_list.append(proc)
+ pipe = pipe | proc
+
+print pipe
+pipe.run()
+
+for grapher in grapher_list:
+ image = result_dir + os.sep + filename + '-' + grapher.id() + '.png'
+ grapher.render(image)
+
--- /dev/null
+# -*- coding: utf-8 -*-
+
+import os, sys
+import timeside
+
+audio_file = sys.argv[-1]
+audio_filename = audio_file.split(os.sep)[-1]
+img_dir = '../results/img'
+
+if not os.path.exists(img_dir):
+ os.makedirs(img_dir)
+
+decoder = timeside.decoder.FileDecoder(audio_file)
+graphers = timeside.core.processors(timeside.api.IGrapher)
+pipe = decoder
+proc_list = []
+
+for grapher in graphers:
+ proc = grapher()
+ proc_list.append(proc)
+ print proc.id()
+ pipe = pipe | proc
+
+pipe.run()
+
+for grapher in proc_list:
+ image = img_dir + os.sep + audio_filename + '-' + grapher.id() + '.png'
+ grapher.render(image)
--- /dev/null
+# -*- coding: utf-8 -*-
+
+import timeside
+from sys import stdout
+import os.path
+import numpy
+
+class TestAnalyzer:
+
+ graphers = timeside.get_processors(timeside.api.IGrapher)
+ decoders = timeside.get_processors(timeside.api.IDecoder)
+ encoders= timeside.get_processors(timeside.api.IEncoder)
+ analyzers = timeside.get_processors(timeside.api.IAnalyzer)
+
+ def __init__(self, path):
+ self.source = os.path.join(os.path.dirname(__file__), path)
+ print "Processing %s" % self.source
+ self.decoder = timeside.decoder.FileDecoder(self.source)
+ print 'format: ', self.decoder.format()
+ self.pipe = self.decoder
+ self.analyzers_sub_pipe = []
+
+ def process(self):
+ for analyzer in self.analyzers:
+ sub_pipe = analyzer()
+ self.analyzers_sub_pipe.append(sub_pipe)
+ self.pipe = self.pipe | sub_pipe
+ self.pipe.run()
+
+ def results(self):
+ results = []
+ for analyzer in self.analyzers_sub_pipe:
+ if hasattr(analyzer, 'results'):
+ results.append(analyzer.results())
+ else:
+ value = analyzer.result()
+ results.append([{'name':analyzer.name(),
+ 'id':analyzer.id(),
+ 'unit':analyzer.unit(),
+ 'value':str(value)}])
+ print results
+
+
+test = TestAnalyzer('../samples/guitar.wav')
+#test = TestAnalyzer('/home/momo/music/wav/Cellar/Cellar-FinallyMix_01.wav')
+test.process()
+test.results()
+
--- /dev/null
+# -*- coding: utf-8 -*-
+
+import timeside
+import sys
+import os.path
+import numpy
+import time
+
+
+class TestAnalyzer:
+
+ analyzer = timeside.analyzer.Level()
+
+ def __init__(self, path):
+ self.source = path
+ print "Processing %s" % self.source
+ self.decoder = timeside.decoder.FileDecoder(self.source)
+ print 'format: ', self.decoder.format()
+ self.pipe = self.decoder
+ self.sub_pipe = self.analyzer
+
+ def process(self):
+ self.pipe = self.pipe | self.sub_pipe
+ self.pipe.run()
+
+ def results(self):
+ print {'name':self.analyzer.name(),
+ 'id':self.analyzer.id(),
+ 'unit':self.analyzer.unit(),
+ 'value':str(self.analyzer.value)}
+
+test = TestAnalyzer(sys.argv[-1])
+test.process()
+test.results()
--- /dev/null
+# -*- coding: utf-8 -*-
+
+import timeside
+import sys
+import os.path
+import numpy
+import time
+
+
+class TestAnalyzer:
+
+ analyzer = timeside.analyzer.Level()
+
+ def __init__(self, path):
+ self.source = path
+ print "Processing %s" % self.source
+ self.decoder = timeside.decoder.FileDecoder(self.source)
+ print 'format: ', self.decoder.format()
+ self.pipe = self.decoder
+ self.sub_pipe = self.analyzer
+
+ def process(self):
+ self.pipe = self.pipe | self.sub_pipe
+ self.pipe.run()
+
+ def results(self):
+ print self.sub_pipe.results()
+
+test = TestAnalyzer(sys.argv[-1])
+test.process()
+test.results()
--- /dev/null
+# -*- coding: utf-8 -*-
+
+import sys
+sys.path.append('/home/momo/dev/aubio/interfaces/python/build/lib.linux-x86_64-2.6/')
+
+import timeside
+
+decoder = timeside.decoder.FileDecoder('/home/momo/music_local/Kavinsky - Nightcall EP/01 Nightcall (Feat. Lovefoxxx).mp3')
+analyzer = timeside.analyzer.AubioBPM()
+(decoder | analyzer).run()
+print analyzer.result()
+
+
--- /dev/null
+# -*- coding: utf-8 -*-
+
+import timeside
+
+decoder = timeside.decoder.FileDecoder('/home/momo/music_local/Kavinsky - Nightcall EP/01 Nightcall (Feat. Lovefoxxx).mp3')
+analyzer = timeside.analyzer.AubioOnsetRate()
+(decoder | analyzer).run()
+print analyzer.result()
+
+
--- /dev/null
+# -*- coding: utf-8 -*-
+
+from timeside.decoder import *
+from timeside.encoder import *
+import os.path
+import sys
+
+source = sys.argv[-1]
+dest = source+'.flac'
+
+decoder = FileDecoder(source)
+encoder = FlacEncoder(dest, overwrite=True)
+
+(decoder | encoder).run()
--- /dev/null
+# -*- coding: utf-8 -*-
+
+from timeside.decoder import *
+from timeside.encoder import *
+import os.path
+import sys
+
+if len(sys.argv) < 2:
+ print 'usage:', sys.argv[0], '<inputfile>'
+ sys.exit(1)
+
+source = sys.argv[-1]
+dest = source+'.mp3'
+
+print 'converting', source, 'to', dest
+
+decoder = FileDecoder(source)
+encoder = Mp3Encoder(dest, overwrite=True)
+
+(decoder | encoder).run()
+
+metadata = {'TIT2': 'title', #title2
+ 'TCOM': 'composer', #composer
+ 'TPE1': 'lead creator', #lead
+ 'UFID': 'identifier', #Unique ID...
+ 'TALB': 'album', #album
+ 'TCON': 'genre', #genre
+ 'TDRC': '2011', #year
+# 'COMM': 'blabla', #comment
+ }
+
+encoder.set_metadata(metadata)
+encoder.write_metadata()
--- /dev/null
+from numpy import vstack, zeros
+
+from timeside.decoder import *
+from timeside.encoder import *
+
+import sys, os.path
+
+def transcode(source, target):
+ decoder = FileDecoder(source)
+ decoder.setup()
+
+ channels = decoder.channels()
+ samplerate = decoder.samplerate()
+
+ print channels, samplerate
+
+ encoder = Mp3Encoder(target)
+ encoder.setup(channels = channels, samplerate = samplerate)
+
+ totalframes = 0
+ while True:
+ frames, eod = decoder.process()
+ encoder.process(frames, eod)
+ totalframes += frames.shape[0]
+ if eod or encoder.eod:
+ break
+
+if __name__ == '__main__':
+
+ if len(sys.argv) < 3:
+ print 'needs 2 args'
+ sys.exit(1)
+ transcode(sys.argv[1], sys.argv[2])
--- /dev/null
+# -*- coding: utf-8 -*-
+
+from timeside.decoder import *
+from timeside.encoder import *
+import os.path
+import sys
+
+if len(sys.argv) < 2:
+ print 'usage:', sys.argv[0], '<inputfile>'
+ sys.exit(1)
+
+source = sys.argv[-1]
+dest = source+'.ogg'
+
+print 'converting', source, 'to', dest
+
+decoder = FileDecoder(source)
+encoder = VorbisEncoder(dest, overwrite=True)
+
+(decoder | encoder).run()
--- /dev/null
+# -*- coding: utf-8 -*-
+
+from timeside.decoder import *
+from timeside.encoder import *
+import os.path
+import sys
+
+source = sys.argv[-1]
+dest = source+'.webm'
+
+decoder = FileDecoder(source)
+encoder = WebMEncoder(dest)
+
+(decoder | encoder).run()
--- /dev/null
+# -*- coding: utf-8 -*-
+
+from timeside.decoder import *
+from timeside.encoder import *
+import os.path
+
+source = os.path.join(os.path.dirname(__file__), "../samples/sweep.wav")
+dest = os.path.join(os.path.dirname(__file__), "../results/sweep_wav.flac")
+
+decoder = FileDecoder(source)
+encoder = FlacEncoder(dest)
+
+(decoder | encoder).run()
--- /dev/null
+# -*- coding: utf-8 -*-
+
+from timeside.tests.api.examples import Gain
+from timeside.core import *
+from timeside.decoder import *
+from timeside.analyzer import *
+from timeside.encoder import *
+from timeside.api import *
+
+import sys
+if len(sys.argv) > 1:
+ source = sys.argv[1]
+else:
+ import os.path
+ source= os.path.join (os.path.dirname(__file__), "../samples/guitar.wav")
+
+Decoder = FileDecoder
+print "Creating decoder with id=%s for: %s" % (Decoder.id(), source)
+decoder = Decoder(source)
+analyzer = MaxLevel()
+decoder.setup()
+nchannels = decoder.channels()
+samplerate = decoder.samplerate()
+nframes = decoder.nframes()
+analyzer.setup(nchannels, samplerate)
+
+print "Stats: duration=%f, nframes=%d, nchannels=%d, samplerate=%d, resolution=%d" % (
+ nframes / float(samplerate), nframes, nchannels, samplerate, decoder.resolution())
+
+while True:
+ frames, eod = decoder.process()
+ analyzer.process(frames, eod)
+ if eod:
+ break
+
+max_level = analyzer.result()
+print "Max level: %f" % max_level
+
+destination = "../results/guitar_normalized.wav"
+Encoder = WavEncoder
+print "Creating encoder with id=%s for: %s" % (Encoder.id(), destination)
+encoder = Encoder(destination)
+
+gain = 1
+if max_level > 0:
+ gain = 0.9 / max_level
+
+effect = Gain(gain)
+
+decoder.setup()
+effect.setup(decoder.channels(), decoder.samplerate())
+encoder.setup(effect.channels(), effect.samplerate())
+
+print "Applying effect id=%s with gain=%f" % (effect.id(), gain)
+
+while True:
+ frames, eod = decoder.process()
+ encoder.process(*effect.process(frames, eod))
+ if eod:
+ break
+
--- /dev/null
+# -*- coding: utf-8 -*-
+
+from timeside.core import *
+from timeside.decoder import *
+from timeside.analyzer import *
+from timeside.encoder import *
+from timeside.api import *
+
+import sys
+if len(sys.argv) > 1:
+ source = sys.argv[1]
+else:
+ import os.path
+ source= os.path.join (os.path.dirname(__file__), "../samples/sweep.flac")
+
+decoder = FileDecoder(source)
+print "Creating decoder with id=%s for: %s" % (decoder.id(), source)
+decoder.setup()
+channels = decoder.channels()
+print 'channels :', channels
+samplerate = decoder.samplerate()
+nframes = decoder.nframes()
+
+dest1 = "/tmp/test_filesink.mp3"
+dest2 = "/tmp/test_appsink.mp3"
+f = open(dest2,'w')
+
+streaming=True
+encoder = Mp3Encoder(dest1, streaming=True)
+encoder.setup(channels=channels, samplerate=samplerate)
+
+while True:
+ encoder.process(*decoder.process())
+ if streaming:
+ f.write(encoder.chunk)
+ if encoder.eod :
+ break
+
+f.close()
+print encoder.pipe
--- /dev/null
+# -*- coding: utf-8 -*-
+
+from timeside.core import *
+from timeside.decoder import *
+from timeside.analyzer import *
+from timeside.encoder import *
+from timeside.api import *
+
+import sys
+if len(sys.argv) > 1:
+ source = sys.argv[1]
+else:
+ import os.path
+ source= os.path.join (os.path.dirname(__file__), "../samples/sweep.wav")
+
+decoder = FileDecoder(source)
+print "Creating decoder with id=%s for: %s" % (decoder.id(), source)
+decoder.setup()
+channels = decoder.channels()
+print 'channels :', channels
+samplerate = decoder.samplerate()
+nframes = decoder.nframes()
+
+dest1 = "/tmp/test_filesink.mp3"
+dest2 = "/tmp/test_appsink.mp3"
+f = open(dest2,'w')
+
+streaming=True
+encoder = Mp3Encoder(dest1, streaming=True)
+encoder.setup(channels=channels, samplerate=samplerate)
+
+print encoder.pipe
+
+while True:
+ encoder.process(*decoder.process())
+ if streaming:
+ f.write(encoder.chunk)
+ if encoder.eod :
+ break
+
+f.close()
+print encoder.pipe
--- /dev/null
+# -*- coding: utf-8 -*-
+
+from timeside.core import *
+from timeside.decoder import *
+from timeside.analyzer import *
+from timeside.encoder import *
+from timeside.api import *
+
+import sys
+if len(sys.argv) > 1:
+ source = sys.argv[1]
+else:
+ import os.path
+ source= os.path.join (os.path.dirname(__file__), "../samples/sweep.flac")
+
+decoder = FileDecoder(source)
+print "Creating decoder with id=%s for: %s" % (decoder.id(), source)
+decoder.setup()
+channels = decoder.channels()
+print 'channels :', channels
+samplerate = decoder.samplerate()
+nframes = decoder.nframes()
+
+dest1 = "/tmp/test_filesink.ogg"
+dest2 = "/tmp/test_appsink.ogg"
+f = open(dest2,'w')
+
+streaming=True
+encoder = VorbisEncoder(dest1, streaming=True)
+encoder.setup(channels=channels, samplerate=samplerate)
+
+print encoder.pipe
+
+while True:
+ encoder.process(*decoder.process())
+ if streaming:
+ f.write(encoder.chunk)
+ if encoder.eod :
+ break
+
+f.close()
+print encoder.pipe
--- /dev/null
+# -*- coding: utf-8 -*-
+
+from timeside.decoder import *
+from timeside.encoder import *
+import os.path
+
+source = os.path.join(os.path.dirname(__file__), "../samples/sweep.wav")
+dest = os.path.join(os.path.dirname(__file__), "/tmp/sweep_wav.mp3")
+
+decoder = FileDecoder(source)
+encoder = Mp3Encoder(dest)
+
+(decoder | encoder).run()
+
+metadata = {'TIT2': 'title', #title2
+ 'TCOM': 'composer', #composer
+ 'TPE1': 'lead creator', #lead
+ 'UFID': 'identifier', #Unique ID...
+ 'TALB': 'album', #album
+ 'TCON': 'genre', #genre
+ 'TDRC': '2011', #year
+# 'COMM': 'blabla', #comment
+ }
+
+encoder.set_metadata(metadata)
+encoder.write_metadata()
+
--- /dev/null
+# -*- coding: utf-8 -*-
+
+from timeside.decoder import *
+from timeside.encoder import *
+import os.path
+
+source = os.path.join(os.path.dirname(__file__), "../samples/sweep.wav")
+dest = os.path.join(os.path.dirname(__file__), "/tmp/sweep_wav.mp3")
+
+decoder = FileDecoder(source)
+encoder = Mp3Encoder(dest)
+
+(decoder | encoder).run()
+
+metadata = {'TIT2': 'title', #title2
+ 'TCOM': 'composer', #composer
+ 'TPE1': 'lead creator', #lead
+ 'UFID': 'identifier', #Unique ID...
+ 'TALB': 'album', #album
+ 'TCON': 'genre', #genre
+ 'TDRC': '2011', #year
+# 'COMM': 'blabla', #comment
+ }
+
+encoder.set_metadata(metadata)
+encoder.write_metadata()
+
--- /dev/null
+# -*- coding: utf-8 -*-
+
+import time
+import timeside
+
+metadata = {'TIT2': 'title', #title2
+ 'TCOM': 'composer', #composer
+ 'TPE1': 'lead creator', #lead
+ 'UFID': 'identifier', #Unique ID...
+ 'TALB': 'album', #album
+ 'TCON': 'genre', #genre
+ 'TDRC': '2011', #year
+# 'COMM': 'blabla', #comment
+ }
+
+decoder = timeside.decoder.FileDecoder('/home/momo/dev/telemeta/sandboxes/sandbox_lam/media/items/2012/09/26/LAM_ETUD_01_01_004.wav')
+
+encoder = timeside.encoder.Mp3Encoder('/tmp/output.mp3')
+encoder.set_metadata(metadata)
+
+(decoder | encoder).run()
+
--- /dev/null
+# -*- coding: utf-8 -*-
+
+import timeside
+import os.path
+
+source = os.path.join(os.path.dirname(__file__), "../samples/sweep.wav")
+
+d = timeside.decoder.FileDecoder(source)
+a = timeside.analyzer.OnsetDetectionFunction()
+
+(d | a).run()
+
+print a.results
\ No newline at end of file
--- /dev/null
+# -*- coding: utf-8 -*-
+
+from timeside.tests.api.examples import Gain
+from timeside.core import *
+from timeside.decoder import *
+from timeside.analyzer import *
+from timeside.encoder import *
+from timeside.api import *
+from sys import stdout
+import os.path
+import numpy
+
+source = os.path.join(os.path.dirname(__file__), "../samples/guitar.wav")
+
+print "Normalizing %s" % source
+decoder = FileDecoder(source)
+maxlevel = MaxLevel()
+duration = Duration()
+
+(decoder | maxlevel | duration).run()
+
+gain = 1
+if maxlevel.result() < 0:
+ gain = 0.9 / numpy.exp(maxlevel.result()/20)
+
+print "input maxlevel: %f" % maxlevel.result()
+print "gain: %f" % gain
+print "duration: %f %s" % (duration.result(), duration.unit())
+
+gain = Gain(gain)
+encoder = WavEncoder("../results/guitar_normalized.wav")
+
+subpipe = gain | maxlevel
+
+(decoder | subpipe | encoder).run()
+
+print "output maxlevel: %f" % maxlevel.result()
+
+
--- /dev/null
+# -*- coding: utf-8 -*-
+
+import timeside.decoder
+import timeside.analyzer
+
+
+decoder = timeside.decoder.FileDecoder('/home/momo/dev/timeside/timeside/tests/samples/sweep.wav')
+analyzer = timeside.analyzer.AubioMelEnergy()
+(decoder | analyzer).run()
+
+print len(analyzer.results())
+print len(analyzer.results())
+print len(analyzer.results())
+
+
+
--- /dev/null
+# -*- coding: utf-8 -*-
+
+import os
+from timeside.core import *
+from timeside.api import *
+from timeside.decoder import *
+from timeside.grapher import *
+
+sample_dir = '../samples'
+img_dir = '../results/img'
+if not os.path.exists(img_dir):
+ os.mkdir(img_dir)
+
+test_dict = {'sweep.wav': 'spec_wav.png',
+ 'sweep.flac': 'spec_flac.png',
+ 'sweep.ogg': 'spec_ogg.png',
+ 'sweep.mp3': 'spec_mp3.png',
+ }
+
+for source, image in test_dict.iteritems():
+ audio = os.path.join(os.path.dirname(__file__), sample_dir + os.sep + source)
+ image = img_dir + os.sep + image
+ print 'Test : decoder(%s) | waveform (%s)' % (source, image)
+ decoder = FileDecoder(audio)
+ spectrogram = Spectrogram()
+ (decoder | spectrogram).run()
+ print 'frames per pixel = ', spectrogram.samples_per_pixel
+ print "render spectrogram to: %s" % image
+ spectrogram.render(image)
+
+
+
--- /dev/null
+# -*- coding: utf-8 -*-
+
+import os
+from timeside.decoder import *
+from timeside.grapher import *
+
+sample_dir = '../samples'
+img_dir = '../results/img'
+if not os.path.exists(img_dir):
+ os.mkdir(img_dir)
+
+test_dict = {'sweep.wav': 'spec_wav.png',}
+
+for source, image in test_dict.iteritems():
+ audio = os.path.join(os.path.dirname(__file__), sample_dir + os.sep + source)
+ image = img_dir + os.sep + image
+ print 'Test : decoder(%s) | waveform (%s)' % (source, image)
+ decoder = FileDecoder(audio)
+ spectrogram = SpectrogramLinear()
+ (decoder | spectrogram).run()
+ print 'frames per pixel = ', spectrogram.samples_per_pixel
+ print "render spectrogram to: %s" % image
+ spectrogram.render(image)
+
+
+
--- /dev/null
+# -*- coding: utf-8 -*-
+
+import os
+import timeside
+
+audio_dir = '/home/momo/music_local/test/aboul/wav/'
+audio_file = 'aboul.wav'
+audio_path = audio_dir + audio_file
+img_dir = '../results/img'
+
+if not os.path.exists(img_dir):
+ os.makedirs(img_dir)
+
+decoder = timeside.decoder.FileDecoder(audio_path)
+analyzers = timeside.core.processors(timeside.api.IAnalyzer)
+pipe = decoder
+
+for analyzer in analyzers:
+ subpipe = analyzer()
+ analyzers_sub.append(subpipe)
+ pipe = pipe | subpipe
+
+image = img_dir + os.sep + source + '.png'
+print 'Test : decoder(%s) | waveform (%s)' % (source, image)
+
+spectrogram = SpectrogramLinear(width=10240, height=512, bg_color=(0,0,0), color_scheme='default')
+(decoder | spectrogram).run()
+print 'frames per pixel = ', spectrogram.samples_per_pixel
+print "render spectrogram to: %s" % image
+spectrogram.render(image)
+
--- /dev/null
+# -*- coding: utf-8 -*-
+
+from timeside.decoder import *
+from timeside.encoder import *
+import os.path
+
+source = os.path.join(os.path.dirname(__file__), "../samples/sweep.wav")
+dest = os.path.join(os.path.dirname(__file__), "../results/sweep_wav.ogg")
+
+decoder = FileDecoder(source)
+encoder = VorbisEncoder(dest)
+
+(decoder | encoder).run()
--- /dev/null
+# -*- coding: utf-8 -*-
+
+from timeside.decoder import *
+from timeside.analyzer import *
+from timeside.encoder import *
+
+import os.path
+source = os.path.join(os.path.dirname(__file__), "../samples/sweep.wav")
+dest = os.path.join(os.path.dirname(__file__), "../results/sweep_wav.wav")
+
+decoder = FileDecoder(source)
+encoder = WavEncoder(dest)
+
+(decoder | encoder).run()
+
--- /dev/null
+# -*- coding: utf-8 -*-
+
+import os
+from timeside.core import *
+from timeside.api import *
+from timeside.decoder import *
+from timeside.grapher import *
+
+sample_dir = '../samples'
+img_dir = '../results/img'
+if not os.path.exists(img_dir):
+ os.makedirs(img_dir)
+
+test_dict = {'sweep.wav': 'waveform_wav.png',
+ 'sweep.flac': 'waveform_flac.png',
+ 'sweep.ogg': 'waveform_ogg.png',
+ 'sweep.mp3': 'waveform_mp3.png',
+ }
+
+for source, image in test_dict.iteritems():
+ audio = os.path.join(os.path.dirname(__file__), sample_dir + os.sep + source)
+ image = img_dir + os.sep + image
+ print 'Test : decoder(%s) | waveform (%s)' % (source, image)
+ decoder = FileDecoder(audio)
+ waveform = Waveform(width=1024, height=256, bg_color=(255,255,255), color_scheme='default')
+ (decoder | waveform).run()
+ print 'frames per pixel = ', waveform.samples_per_pixel
+ print "render waveform to: %s" % image
+ waveform.render(image)
--- /dev/null
+# -*- coding: utf-8 -*-
+
+import os
+from timeside.core import *
+from timeside.api import *
+from timeside.decoder import *
+from timeside.grapher import *
+
+sample_dir = '/home/momo/music_local/Isabelle Aboulker/Mon imagier des instruments/wav/'
+img_dir = '../results/img'
+if not os.path.exists(img_dir):
+ os.mkdir(img_dir)
+
+for source in os.listdir(sample_dir):
+ audio = sample_dir + os.sep + source
+ image = img_dir + os.sep + source + '.png'
+ print 'Test : decoder(%s) | waveform (%s)' % (source, image)
+ decoder = FileDecoder(audio)
+ waveform = Waveform(width=1024, height=256, bg_color=(0,0,0), color_scheme='default')
+ (decoder | waveform).run()
+ print 'frames per pixel = ', waveform.graph.samples_per_pixel
+ print "render waveform to: %s" % image
+ waveform.render(image)
+
+
+
--- /dev/null
+# -*- coding: utf-8 -*-
+
+import os
+from timeside.core import *
+from timeside.api import *
+from timeside.decoder import *
+from timeside.grapher import *
+
+sample = '/home/momo/music_local/Isabelle Aboulker/Mon imagier des instruments/16 - Isabelle Aboulker - 16 instru.flac'
+img_dir = '../results/img'
+if not os.path.exists(img_dir):
+ os.mkdir(img_dir)
+
+audio = sample
+image = img_dir + os.sep + 'toto.png'
+decoder = FileDecoder(audio)
+waveform = Waveform(width=1211, height=170, bg_color=(0,0,0), color_scheme='default')
+(decoder | waveform).run()
+print 'frames per pixel = ', waveform.graph.samples_per_pixel
+print "render waveform to: %s" % image
+waveform.render(image)
+
+
+
--- /dev/null
+# -*- coding: utf-8 -*-
+
+import os
+from timeside.core import *
+from timeside.api import *
+from timeside.decoder import *
+from timeside.grapher import *
+
+sample_dir = '../samples'
+img_dir = '../results/img'
+if not os.path.exists(img_dir):
+ os.makedirs(img_dir)
+
+test_dict = {'sweep.wav': 'waveform_wav.png',
+ 'sweep.flac': 'waveform_flac.png',
+ 'sweep.ogg': 'waveform_ogg.png',
+ 'sweep.mp3': 'waveform_mp3.png',
+ }
+
+for source, image in test_dict.iteritems():
+ audio = os.path.join(os.path.dirname(__file__), sample_dir + os.sep + source)
+ image = img_dir + os.sep + image
+ print 'Test : decoder(%s) | waveform (%s)' % (source, image)
+ decoder = FileDecoder(audio)
+ waveform = WaveformCentroid(width=1024, height=256, bg_color=(0,0,0), color_scheme='default')
+ (decoder | waveform).run()
+ print 'frames per pixel = ', waveform.samples_per_pixel
+ print "render waveform to: %s" % image
+ waveform.render(image)
--- /dev/null
+# -*- coding: utf-8 -*-
+
+import os
+from timeside.core import *
+from timeside.api import *
+from timeside.decoder import *
+from timeside.grapher import *
+
+sample_dir = '../samples'
+img_dir = '../results/img'
+if not os.path.exists(img_dir):
+ os.makedirs(img_dir)
+
+test_dict = {'sweep.wav': 'waveform_wav.png',
+ 'sweep.flac': 'waveform_flac.png',
+ 'sweep.ogg': 'waveform_ogg.png',
+ 'sweep.mp3': 'waveform_mp3.png',
+ }
+
+for source, image in test_dict.iteritems():
+ audio = os.path.join(os.path.dirname(__file__), sample_dir + os.sep + source)
+ image = img_dir + os.sep + image
+ print 'Test : decoder(%s) | waveform (%s)' % (source, image)
+ decoder = FileDecoder(audio)
+ waveform = WaveformContourBlack()
+ (decoder | waveform).run()
+ print 'frames per pixel = ', waveform.samples_per_pixel
+ print "render waveform to: %s" % image
+ waveform.render(image)
--- /dev/null
+# -*- coding: utf-8 -*-
+
+import os
+from timeside.core import *
+from timeside.api import *
+from timeside.decoder import *
+from timeside.grapher import *
+
+sample_dir = '../samples'
+img_dir = '../results/img'
+if not os.path.exists(img_dir):
+ os.makedirs(img_dir)
+
+test_dict = {'sweep.wav': 'waveform_wav.png',
+ 'sweep.flac': 'waveform_flac.png',
+ 'sweep.ogg': 'waveform_ogg.png',
+ 'sweep.mp3': 'waveform_mp3.png',
+ }
+
+for source, image in test_dict.iteritems():
+ audio = os.path.join(os.path.dirname(__file__), sample_dir + os.sep + source)
+ image = img_dir + os.sep + image
+ print 'Test : decoder(%s) | waveform (%s)' % (source, image)
+ decoder = FileDecoder(audio)
+ waveform = Waveform()
+ (decoder | waveform).run()
+ print 'frames per pixel = ', waveform.samples_per_pixel
+ print "render waveform to: %s" % image
+ waveform.render(image)