%pylab inline
from __future__ import division
import timeside
from timeside.core import get_processor
import matplotlib.pyplot as plt
import numpy as np
import sys
Populating the interactive namespace from numpy and matplotlib
wav_file = '/home/thomas/data/CNRSMH_E_1985_001_001_001_04_30s.wav'
d = get_processor('gst_dec')(wav_file)
specgram = get_processor('spectrogram_analyzer')()
waveform = get_processor('waveform_simple')()
first get the lost of the available plugins (via Vamp Simple Host) and choose which one(s) to run
# 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])
index soname identifier output ------ ---------- ------ 0 : vamp-example-plugins amplitudefollower amplitude 1 : vamp-example-plugins fixedtempo tempo 2 : vamp-example-plugins fixedtempo candidates 3 : vamp-example-plugins fixedtempo detectionfunction 4 : vamp-example-plugins fixedtempo acf 5 : vamp-example-plugins fixedtempo filtered_acf 6 : vamp-example-plugins percussiononsets onsets 7 : vamp-example-plugins percussiononsets detectionfunction 8 : vamp-example-plugins powerspectrum powerspectrum 9 : vamp-example-plugins spectralcentroid logcentroid 10 : vamp-example-plugins spectralcentroid linearcentroid 11 : vamp-example-plugins zerocrossing counts 12 : vamp-example-plugins zerocrossing zerocrossings
# Let's choose #7
my_plugin = plugins_list[7]
print my_plugin
['vamp-example-plugins', 'percussiononsets', 'detectionfunction']
vamp = get_processor('vamp_simple_host')([my_plugin])
myPipe = (d | vamp | specgram | waveform).run()
vamp.results.keys()
['vamp_simple_host.percussiononsets.detectionfunction']
key = vamp.results.keys()[0]
# 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
res_vamp = vamp.results[key]
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()
res_vamp.render();