Wiki » History » Version 4

Mi Tian, 2015-08-05 08:36 PM

1 1 Mi Tian
h1. Wiki
2 1 Mi Tian
3 1 Mi Tian
h2. Vamp environment for feature extraction
4 1 Mi Tian
5 4 Mi Tian
_Vamp_ is an audio processing plugin system for plugins that extract descriptive information from audio data — typically referred to as audio analysis plugins or audio feature extraction plugins. The _vamp plugins_ are distributed in shared library files with extension _.dll_, _.so_, or _.dylib_ depending on the platform.  
6 1 Mi Tian
See [[http://vamp-plugins.org/]] for more details about Vamp plugins.
7 1 Mi Tian
8 4 Mi Tian
Several common audio file formats are supported, including MP3, Ogg, and a number of PCM formats such as WAV and AIFF. AAC is supported on OS/X only, and only if not DRM protected. WMA is not supported.
9 4 Mi Tian
10 1 Mi Tian
h2. Host applications
11 1 Mi Tian
12 4 Mi Tian
A vamp plugin cannot be used on its own, but only with a conforming _host_ application which loads the plugin from its shared library and calls functions within the plugin code to configure it, supply it with data, and run it.
13 4 Mi Tian
14 4 Mi Tian
* Sonic Visualiser -- An interactive audio analysis and visualisation tool using Vamp plugins
15 1 Mi Tian
[[http://www.sonicvisualiser.org/]]
16 4 Mi Tian
* Sonic Annotator -- A command line tool facilitating facilitating feature extraction, parameter configuration and output manipulation for a large bunch of audio files.
17 1 Mi Tian
[[https://code.soundsoftware.ac.uk/projects/sonic-annotator]]
18 4 Mi Tian
* Audacity -- An audio editor which enables recording, labelling and editing the audio.
19 1 Mi Tian
[[http://audacityteam.org/]]
20 1 Mi Tian
21 4 Mi Tian
h2. Plugin installation
22 1 Mi Tian
23 4 Mi Tian
The vamp plugins need to be put in a directory where the host can locate, i.e., the _VAMP_PATH_. See [[http://vamp-plugins.org/download.html#install]] for installation instructions. 
24 4 Mi Tian
25 4 Mi Tian
Alternatively, you can set your own VAMP_PATH environment variable to list the locations a host should look in for Vamp plugins. For example, the following command will set @/homes/mtian/hg/onset-fusion@ as an alternative VAMP_PATH. Plugins placed in this directory will also be locatable for the hosts besides those under the system specified vamp directories.
26 4 Mi Tian
<pre>
27 4 Mi Tian
mitian$ export VAMP_PATH=$VAMP_PATH:/homes/mtian/hg/onset-fusion
28 4 Mi Tian
</pre>
29 4 Mi Tian
30 4 Mi Tian
Once the plugins are installed in the Vamp path, they will show themselves under the _Transform_ tab in Sonic Visualiser, or the _Analyze_ tab in Audacity, or in the terminal when you list them using Sonic Annotator (@ sonic-annotator -l@). 
31 4 Mi Tian
32 4 Mi Tian
h2. Parameters and outputs of this plugin set
33 4 Mi Tian
34 4 Mi Tian
h3. Parameters
35 4 Mi Tian
<pre>
36 4 Mi Tian
37 4 Mi Tian
	Fusion Type 					   Fusion type [0: early fusion, 1: linear fusion, 2: decision fusion]
38 4 Mi Tian
	Detection Sensitivity   	    Sensitivity level for peak detection in the onset likelihood function.
39 4 Mi Tian
								       The higher the sensitivity, the more onsets will (rightly or wrongly) be detected.
40 4 Mi Tian
	Delta Threshold  			   Constant offset used for adaptive theresholding using the median of the detection function.
41 4 Mi Tian
	Backtracking Threshold  		   Backtracking threshold used determine the stopping condition for backtracking the detected onset location
42 4 Mi Tian
									to an earlier 'perceived' location.
43 4 Mi Tian
	Tolerance window				   Tolerance window to combine events from different detection functions for decision fusion.
44 4 Mi Tian
	Linear combination coefficient	 Combination coefficient for linear fusion.
45 4 Mi Tian
	Median filter window			   Median filter window size.
46 4 Mi Tian
	Cutoff frequency				   Cutoff frequency for the low pass filter.
47 4 Mi Tian
	
48 4 Mi Tian
	**bool parameters**			    [0: off, 1: on]
49 4 Mi Tian
	Polynomial fitting				 Use polynomial fitting to evaluate detection function peaks.
50 4 Mi Tian
	Median filtering				   Use median filter based adaptive thresholding.
51 4 Mi Tian
	Low-pass filtering				 Use low pass filtering to smooth onset detection functions.
52 4 Mi Tian
	Adaptive whitening				 Use adaptive whitening. It evens out the temporal and frequency variation in the signal.
53 4 Mi Tian
54 4 Mi Tian
</pre>
55 4 Mi Tian
56 4 Mi Tian
h3. Outputs
57 4 Mi Tian
58 4 Mi Tian
59 4 Mi Tian
# Note Onsets – The detected note onset times, returned as a single feature with timestamp.
60 4 Mi Tian
# Smoothed Detection Function – The smoothed onset detection function.
61 4 Mi Tian
# Note Onsets – The detected note onset times, returned as a single feature with timestamp.
62 4 Mi Tian
63 4 Mi Tian
64 4 Mi Tian
NOTE: The last two outputs are not available in fusion based onset detectors.
65 4 Mi Tian
 
66 3 Mi Tian
h2. Example usages of the onset detectors
67 3 Mi Tian
68 3 Mi Tian
<pre>
69 3 Mi Tian
mitian$ sonic-annotator -l | grep vampy-onsets
70 3 Mi Tian
vamp:vampy:vampy-onsets-bersf:vampy-onsets-bersf-onsets
71 3 Mi Tian
vamp:vampy:vampy-onsets-cdsf:vampy-onsets-cdsf-onsets
72 3 Mi Tian
vamp:vampy:vampy-onsets-ber:vampy-onsets-ber-df
73 3 Mi Tian
vamp:vampy:vampy-onsets-ber:vampy-onsets-ber-onsets
74 3 Mi Tian
vamp:vampy:vampy-onsets-ber:vampy-onsets-ber-sdf
75 3 Mi Tian
vamp:vampy:vampy-onsets-cd:vampy-onsets-cd-df
76 3 Mi Tian
vamp:vampy:vampy-onsets-cd:vampy-onsets-cd-onsets
77 3 Mi Tian
vamp:vampy:vampy-onsets-cd:vampy-onsets-cd-sdf
78 3 Mi Tian
vamp:vampy:vampy-onsets-hfc:vampy-onsets-hfc-df
79 3 Mi Tian
vamp:vampy:vampy-onsets-hfc:vampy-onsets-hfc-onsets
80 3 Mi Tian
vamp:vampy:vampy-onsets-hfc:vampy-onsets-hfc-sdf
81 3 Mi Tian
vamp:vampy:vampy-onsets-pd:vampy-onsets-pd-df
82 3 Mi Tian
vamp:vampy:vampy-onsets-pd:vampy-onsets-pd-onsets
83 3 Mi Tian
vamp:vampy:vampy-onsets-pd:vampy-onsets-pd-sdf
84 1 Mi Tian
vamp:vampy:vampy-onsets-sd:vampy-onsets-sd-df
85 3 Mi Tian
vamp:vampy:vampy-onsets-sd:vampy-onsets-sd-onsets
86 3 Mi Tian
vamp:vampy:vampy-onsets-sd:vampy-onsets-sd-sdf
87 3 Mi Tian
vamp:vampy:vampy-onsets-sf:vampy-onsets-sf-df
88 3 Mi Tian
vamp:vampy:vampy-onsets-sf:vampy-onsets-sf-onsets
89 3 Mi Tian
vamp:vampy:vampy-onsets-sf:vampy-onsets-sf-sdf
90 3 Mi Tian
mitian$
91 4 Mi Tian
mitian$ sonic-annotator -d vamp:vampy:vampy-onsets-cdsf:vampy-onsets-cdsf-onsets -w csv test.wav --csv-basedir /homes/mitian/hg/workspace/onsetdetection
92 3 Mi Tian
Extracting and writing features... Done
93 3 Mi Tian
94 1 Mi Tian
Vampy::~PyExtensionManager: Extension module cleaned.
95 3 Mi Tian
mitian$
96 3 Mi Tian
mitian$
97 3 Mi Tian
</pre>
98 3 Mi Tian
99 3 Mi Tian
Sonic Anntator also allows for batch processing in one go. 
100 3 Mi Tian
<pre>
101 1 Mi Tian
mitian$
102 4 Mi Tian
mitian$ sonic-annotator -d vamp:vampy:vampy-onsets-cdsf:vampy-onsets-cdsf-onsets -w csv /homes/mitian/documents/audio/*.wav --csv-basedir /homes/mitian/hg/workspace/onsetdetection
103 1 Mi Tian
Extracting and writing features... Done
104 3 Mi Tian
105 3 Mi Tian
Vampy::~PyExtensionManager: Extension module cleaned.
106 3 Mi Tian
mitian$
107 3 Mi Tian
mitian$
108 3 Mi Tian
</pre>
109 3 Mi Tian
110 4 Mi Tian
h2. Play around with your vamp plugin feature extractors
111 3 Mi Tian
112 4 Mi Tian
We may want use parameter settings other the default. With Sonic Visualiser or Audacity, you can easily access the GUI to modify them. Whiles with Sonic Annotator, you would need to interact with 
113 3 Mi Tian
114 4 Mi Tian
Firstly, we can check the current parameter configurations in the skeleton transform description using Sonic Annotator's @-s@ command.
115 3 Mi Tian
116 3 Mi Tian
<pre>
117 3 Mi Tian
mitian$
118 3 Mi Tian
mitian$ sonic-annotator -s vamp:vampy:vampy-onsets-cdsf:vampy-onsets-cdsf-onsets
119 3 Mi Tian
@prefix xsd:      <http://www.w3.org/2001/XMLSchema> .
120 3 Mi Tian
  @prefix vamp:     <http://purl.org/ontology/vamp/> .
121 3 Mi Tian
  @prefix :         <#> .
122 3 Mi Tian
123 3 Mi Tian
 
124 3 Mi Tian
:transform_plugin a vamp:Plugin ;
125 3 Mi Tian
    vamp:identifier "vampy-onsets-cdsf" .
126 3 Mi Tian
127 3 Mi Tian
:transform_library a vamp:PluginLibrary ;
128 3 Mi Tian
    vamp:identifier "vampy" ;
129 3 Mi Tian
    vamp:available_plugin :transform_plugin .
130 3 Mi Tian
131 3 Mi Tian
:transform a vamp:Transform ;
132 3 Mi Tian
    vamp:plugin :transform_plugin ;
133 3 Mi Tian
    vamp:step_size "512"^^xsd:int ;
134 3 Mi Tian
    vamp:block_size "1024"^^xsd:int ;
135 3 Mi Tian
    vamp:parameter_binding [
136 3 Mi Tian
        vamp:parameter [ vamp:identifier "bt-threshold" ] ;
137 3 Mi Tian
        vamp:value "0.9"^^xsd:float ;
138 3 Mi Tian
    ] ;
139 3 Mi Tian
    vamp:parameter_binding [
140 3 Mi Tian
        vamp:parameter [ vamp:identifier "cut-off" ] ;
141 3 Mi Tian
        vamp:value "0.34"^^xsd:float ;
142 3 Mi Tian
    ] ;
143 3 Mi Tian
    vamp:parameter_binding [
144 3 Mi Tian
        vamp:parameter [ vamp:identifier "dthreshold" ] ;
145 3 Mi Tian
        vamp:value "0"^^xsd:float ;
146 3 Mi Tian
    ] ;
147 3 Mi Tian
    vamp:parameter_binding [
148 3 Mi Tian
        vamp:parameter [ vamp:identifier "filtfilt" ] ;
149 3 Mi Tian
        vamp:value "1"^^xsd:float ;
150 3 Mi Tian
    ] ;
151 3 Mi Tian
    vamp:parameter_binding [
152 3 Mi Tian
        vamp:parameter [ vamp:identifier "fusion-type" ] ;
153 3 Mi Tian
        vamp:value "2"^^xsd:float ;
154 3 Mi Tian
    ] ;
155 3 Mi Tian
    vamp:parameter_binding [
156 3 Mi Tian
        vamp:parameter [ vamp:identifier "lin-threshold" ] ;
157 3 Mi Tian
        vamp:value "0.5"^^xsd:float ;
158 3 Mi Tian
    ] ;
159 3 Mi Tian
    vamp:parameter_binding [
160 3 Mi Tian
        vamp:parameter [ vamp:identifier "med-threshold" ] ;
161 3 Mi Tian
        vamp:value "7"^^xsd:float ;
162 3 Mi Tian
    ] ;
163 3 Mi Tian
    vamp:parameter_binding [
164 3 Mi Tian
        vamp:parameter [ vamp:identifier "medfilt" ] ;
165 3 Mi Tian
        vamp:value "1"^^xsd:float ;
166 3 Mi Tian
    ] ;
167 3 Mi Tian
    vamp:parameter_binding [
168 3 Mi Tian
        vamp:parameter [ vamp:identifier "polyfit" ] ;
169 3 Mi Tian
        vamp:value "1"^^xsd:float ;
170 3 Mi Tian
    ] ;
171 3 Mi Tian
    vamp:parameter_binding [
172 3 Mi Tian
        vamp:parameter [ vamp:identifier "threshold" ] ;
173 3 Mi Tian
        vamp:value "50"^^xsd:float ;
174 3 Mi Tian
    ] ;
175 3 Mi Tian
    vamp:parameter_binding [
176 3 Mi Tian
        vamp:parameter [ vamp:identifier "tol-threshold" ] ;
177 1 Mi Tian
        vamp:value "0.03"^^xsd:float ;
178 1 Mi Tian
    ] ;
179 1 Mi Tian
    vamp:parameter_binding [
180 1 Mi Tian
        vamp:parameter [ vamp:identifier "whitening" ] ;
181 1 Mi Tian
        vamp:value "0"^^xsd:float ;
182 1 Mi Tian
    ] ;
183 1 Mi Tian
    vamp:output [ vamp:identifier "vampy-onsets-cdsf-onsets" ] .
184 1 Mi Tian
mitian$
185 1 Mi Tian
</pre>
186 1 Mi Tian
187 1 Mi Tian
Transforms are usually described in _RDF_, following the transform part of the _Vamp plugin ontology_. Now, how can be change the parameter settings in the transform specification file? 
188 1 Mi Tian
189 4 Mi Tian
The solution is to save this RDF file and modify any content in it as we wish, then to run this transform by specifying the saved file with -t options. Let's see an example.
190 1 Mi Tian
191 4 Mi Tian
<pre>
192 4 Mi Tian
mitian$
193 4 Mi Tian
mitian$ sonic-annotator -s vamp:vampy:vampy-onsets-cdsf:vampy-onsets-cdsf-onsets >param_config.n3
194 4 Mi Tian
mitian$
195 4 Mi Tian
</pre>
196 4 Mi Tian
Now the transform file has been saved to the .n3 (RDF) file. Say, we want to use a higher threshold and change it from 50 to 70. Open an text editor, simple modify the corresponding line
197 4 Mi Tian
<pre>
198 4 Mi Tian
        vamp:parameter [ vamp:identifier "threshold" ] ;
199 4 Mi Tian
        vamp:value "50"^^xsd:float ;
200 4 Mi Tian
</pre>
201 4 Mi Tian
into 
202 4 Mi Tian
<pre>
203 4 Mi Tian
        vamp:parameter [ vamp:identifier "threshold" ] ;
204 4 Mi Tian
        vamp:value "70"^^xsd:float ;
205 4 Mi Tian
</pre>
206 4 Mi Tian
and save it.
207 4 Mi Tian
208 4 Mi Tian
Now we can run the same plugin using the modified parameter settings.
209 4 Mi Tian
<pre>
210 4 Mi Tian
mitian$
211 4 Mi Tian
mitian$ sonic-annotator -t param_config.n3 -w csv test.wav --csv-basedir /homes/mitian/hg/workspace/onsetdetection
212 4 Mi Tian
Extracting and writing features... Done
213 4 Mi Tian
214 4 Mi Tian
Vampy::~PyExtensionManager: Extension module cleaned.
215 4 Mi Tian
mitian$
216 4 Mi Tian
mitian$
217 4 Mi Tian
</pre>
218 4 Mi Tian
219 4 Mi Tian
h2. That's all guys! Let's hack with Vamp plugins :)