Vamp Plugins library

In [4]:
%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
In [5]:
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')()

Set-up Vamp plugins

first get the lost of the available plugins (via Vamp Simple Host) and choose which one(s) to run

In [6]:
# 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
In [7]:
# Let's choose #7
my_plugin = plugins_list[7]
print my_plugin
['vamp-example-plugins', 'percussiononsets', 'detectionfunction']

Set-up Timeside Vamp plugin Analyzer

In [9]:
vamp = get_processor('vamp_simple_host')([my_plugin])

Run the pipe

In [10]:
myPipe = (d | vamp | specgram | waveform).run()

Display the result

In [11]:
vamp.results.keys()
Out[11]:
['vamp_simple_host.percussiononsets.detectionfunction']
In [12]:
key = vamp.results.keys()[0]
In [13]:
# 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()
In [ ]:
res_vamp.render();
In [ ]:
 
In [ ]: