Wiki » History » Version 17

Mi Tian, 2015-08-11 02:08 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
7 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.
8 1 Mi Tian
9 10 Gyorgy Fazekas
See http://vamp-plugins.org/ for more introduction about Vamp environment and the plugins.
10 1 Mi Tian
11 16 Gyorgy Fazekas
h2. Vampy wrapper plugin (for running plugins written in Python)
12 10 Gyorgy Fazekas
13 11 Gyorgy Fazekas
Vamp plugins are typically written in C++. To use Vamp plugins written in Python you need to install the "Vampy wrapper plugin":http://www.vamp-plugins.org/vampy.html. 
14 11 Gyorgy Fazekas
Then, any python script following some simple conventions will be presented to a vamp host as it was an ordinary Vamp plugin.
15 10 Gyorgy Fazekas
16 10 Gyorgy Fazekas
Download Vampy: http://www.vamp-plugins.org/vampy.html
17 10 Gyorgy Fazekas
Tutorial: http://isophonics.net/content/getting-started-vampy
18 10 Gyorgy Fazekas
19 10 Gyorgy Fazekas
Put the plugins in your Vamp plugin folder or any other designated directory. You may set an environment variable to tell
20 17 Mi Tian
your system where to look for Vamp plugins. On Linux/Unix or OS/X: $ export VAMPY_PATH="/your/vamp/plugin/directory"
21 10 Gyorgy Fazekas
22 10 Gyorgy Fazekas
Optionally, you may need to tell your system where to find Python for Vampy to work correctly:
23 1 Mi Tian
To do this, set the VAMPY_PYLIB environment variable to the location of the python shared library (.dylib / .so).
24 10 Gyorgy Fazekas
25 11 Gyorgy Fazekas
For more information see "this readme file in the Vampy package":https://code.soundsoftware.ac.uk/projects/vampy/repository/entry/README
26 10 Gyorgy Fazekas
27 6 Mi Tian
h2. Host applications
28 1 Mi Tian
29 1 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.
30 1 Mi Tian
31 10 Gyorgy Fazekas
* "Sonic Visualiser":http://www.sonicvisualiser.org/ -- An interactive audio analysis and visualisation tool using Vamp plugins
32 6 Mi Tian
33 10 Gyorgy Fazekas
* "Sonic Annotator":https://code.soundsoftware.ac.uk/projects/sonic-annotator -- A command line tool facilitating facilitating feature extraction, parameter configuration and output manipulation for a large bunch of audio files.
34 6 Mi Tian
35 1 Mi Tian
* "Audacity":http://audacityteam.org/ -- An audio editor which enables recording, labelling and editing the audio.
36 13 Gyorgy Fazekas
37 15 Gyorgy Fazekas
__Note for developers:__ If you are developing new plugins in Python it is customary to use a command line host such as Sonic Annotator or the "Vamp Simple Host":http://vamp-plugins.org/develop.html available in the Vamp Plugin SDK. This will allow you to see error messages printed to the terminal, which would otherwise be invisible. Vampy plugins can be used in any GUI host like Sonic Visualiser, but errors reported by plugin scripts will be more difficult to see.
38 6 Mi Tian
39 6 Mi Tian
40 1 Mi Tian
h2. Plugin installation
41 4 Mi Tian
42 10 Gyorgy Fazekas
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. 
43 1 Mi Tian
44 1 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/mitian/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.
45 10 Gyorgy Fazekas
46 4 Mi Tian
<pre>
47 5 Mi Tian
mitian$ export VAMP_PATH=$VAMP_PATH:/homes/mitian/hg/onset-fusion
48 4 Mi Tian
</pre>
49 4 Mi Tian
50 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@). 
51 4 Mi Tian
52 1 Mi Tian
h2. Parameters and outputs of this plugin set
53 4 Mi Tian
54 4 Mi Tian
h3. Parameters
55 4 Mi Tian
<pre>
56 5 Mi Tian
    **Adjustable parameters**
57 9 Gyorgy Fazekas
	Fusion Type                         Fusion type [0: early fusion, 1: linear fusion, 2: decision fusion]
58 9 Gyorgy Fazekas
	Detection Sensitivity               Sensitivity level for peak detection in the onset likelihood function.
59 9 Gyorgy Fazekas
                                            The higher the sensitivity, the more onsets will (rightly or wrongly) be detected.
60 9 Gyorgy Fazekas
	Delta Threshold                     Constant offset used for adaptive theresholding using the median of the detection function.
61 9 Gyorgy Fazekas
	Backtracking Threshold              Backtracking threshold used determine the stopping condition for backtracking the detected onset location to an earlier 'perceived' location.
62 9 Gyorgy Fazekas
	Tolerance window                    Tolerance window to combine events from different detection functions for decision fusion.
63 9 Gyorgy Fazekas
	Linear combination coefficient      Combination coefficient for linear fusion.
64 9 Gyorgy Fazekas
	Median filter window                Median filter window size.
65 9 Gyorgy Fazekas
	Cutoff frequency                    Cutoff frequency for the low pass filter.
66 8 Mi Tian
	
67 9 Gyorgy Fazekas
	**bool parameters**                 [0: off, 1: on]
68 9 Gyorgy Fazekas
	Polynomial fitting                  Use polynomial fitting to evaluate detection function peaks.
69 9 Gyorgy Fazekas
	Median filtering                    Use median filter based adaptive thresholding.
70 4 Mi Tian
	Low-pass filtering                  Use low pass filtering to smooth onset detection functions.
71 4 Mi Tian
	Adaptive whitening                  Use adaptive whitening. It evens out the temporal and frequency variation in the signal.
72 4 Mi Tian
</pre>
73 4 Mi Tian
74 1 Mi Tian
h3. Outputs
75 6 Mi Tian
76 6 Mi Tian
77 6 Mi Tian
# *Note Onsets* – The detected note onset times, returned as a single feature with timestamp.
78 1 Mi Tian
# *Smoothed Detection Function* – The smoothed onset detection function.
79 1 Mi Tian
# *Note Onsets* – The detected note onset times, returned as a single feature with timestamp.
80 5 Mi Tian
81 1 Mi Tian
82 1 Mi Tian
NOTE: The last two outputs are not available in fusion based onset detectors. Please check individual plugins for specific output types.
83 1 Mi Tian
 
84 1 Mi Tian
h2. Example usages of the onset detectors
85 1 Mi Tian
86 1 Mi Tian
To use these onset detector plugins in Sonic Visualiser and Audacity is quite straightforward. Load your audio file first, then select a feature extractor/plugin from the transform list. You will also find a set of adjustable parameters in the pop-out box associated with each transform. The extracted features, whether it is onset locations or detection functions, will be visualised in the pane on top of the waveform, synchronised with time.
87 5 Mi Tian
 
88 5 Mi Tian
For comprehensive user manuals, see
89 10 Gyorgy Fazekas
http://www.sonicvisualiser.org/doc/reference/2.1/en/index.html
90 10 Gyorgy Fazekas
http://wiki.audacityteam.org/wiki/Category:Tutorial
91 5 Mi Tian
92 5 Mi Tian
Rather than for visualisation purpose, Sonic Annotator lets you to extract and store audio features efficiently. Here we give a quick tutorial of how to detect onset for a given audio file and save the results to local folder using Sonic Annotator.
93 10 Gyorgy Fazekas
94 3 Mi Tian
<pre>
95 3 Mi Tian
mitian$ sonic-annotator -l | grep vampy-onsets
96 3 Mi Tian
vamp:vampy:vampy-onsets-bersf:vampy-onsets-bersf-onsets
97 3 Mi Tian
vamp:vampy:vampy-onsets-cdsf:vampy-onsets-cdsf-onsets
98 3 Mi Tian
vamp:vampy:vampy-onsets-ber:vampy-onsets-ber-df
99 3 Mi Tian
vamp:vampy:vampy-onsets-ber:vampy-onsets-ber-onsets
100 3 Mi Tian
vamp:vampy:vampy-onsets-ber:vampy-onsets-ber-sdf
101 3 Mi Tian
vamp:vampy:vampy-onsets-cd:vampy-onsets-cd-df
102 3 Mi Tian
vamp:vampy:vampy-onsets-cd:vampy-onsets-cd-onsets
103 3 Mi Tian
vamp:vampy:vampy-onsets-cd:vampy-onsets-cd-sdf
104 3 Mi Tian
vamp:vampy:vampy-onsets-hfc:vampy-onsets-hfc-df
105 3 Mi Tian
vamp:vampy:vampy-onsets-hfc:vampy-onsets-hfc-onsets
106 3 Mi Tian
vamp:vampy:vampy-onsets-hfc:vampy-onsets-hfc-sdf
107 3 Mi Tian
vamp:vampy:vampy-onsets-pd:vampy-onsets-pd-df
108 3 Mi Tian
vamp:vampy:vampy-onsets-pd:vampy-onsets-pd-onsets
109 3 Mi Tian
vamp:vampy:vampy-onsets-pd:vampy-onsets-pd-sdf
110 1 Mi Tian
vamp:vampy:vampy-onsets-sd:vampy-onsets-sd-df
111 3 Mi Tian
vamp:vampy:vampy-onsets-sd:vampy-onsets-sd-onsets
112 3 Mi Tian
vamp:vampy:vampy-onsets-sd:vampy-onsets-sd-sdf
113 3 Mi Tian
vamp:vampy:vampy-onsets-sf:vampy-onsets-sf-df
114 3 Mi Tian
vamp:vampy:vampy-onsets-sf:vampy-onsets-sf-onsets
115 3 Mi Tian
vamp:vampy:vampy-onsets-sf:vampy-onsets-sf-sdf
116 1 Mi Tian
mitian$
117 1 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
118 3 Mi Tian
Extracting and writing features... Done
119 4 Mi Tian
120 3 Mi Tian
Vampy::~PyExtensionManager: Extension module cleaned.
121 3 Mi Tian
mitian$
122 1 Mi Tian
mitian$
123 3 Mi Tian
</pre>
124 3 Mi Tian
125 6 Mi Tian
Each line of the output csv file consists of the timestamp (and duration where applicable) for a single feature, the value of that feature and the feature's label (where applicable), separated by comma.
126 1 Mi Tian
127 3 Mi Tian
Sonic Anntator also allows for batch processing in one go. 
128 3 Mi Tian
<pre>
129 11 Gyorgy Fazekas
130 1 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
131 1 Mi Tian
Extracting and writing features... Done
132 3 Mi Tian
133 3 Mi Tian
Vampy::~PyExtensionManager: Extension module cleaned.
134 11 Gyorgy Fazekas
135 11 Gyorgy Fazekas
136 3 Mi Tian
</pre>
137 3 Mi Tian
138 4 Mi Tian
h2. Play around with your vamp plugin feature extractors
139 1 Mi Tian
140 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 
141 3 Mi Tian
142 4 Mi Tian
Firstly, we can check the current parameter configurations in the skeleton transform description using Sonic Annotator's @-s@ command.
143 3 Mi Tian
144 3 Mi Tian
<pre>
145 11 Gyorgy Fazekas
146 3 Mi Tian
mitian$ sonic-annotator -s vamp:vampy:vampy-onsets-cdsf:vampy-onsets-cdsf-onsets
147 3 Mi Tian
@prefix xsd:      <http://www.w3.org/2001/XMLSchema> .
148 3 Mi Tian
  @prefix vamp:     <http://purl.org/ontology/vamp/> .
149 3 Mi Tian
  @prefix :         <#> .
150 3 Mi Tian
151 3 Mi Tian
 
152 3 Mi Tian
:transform_plugin a vamp:Plugin ;
153 3 Mi Tian
    vamp:identifier "vampy-onsets-cdsf" .
154 3 Mi Tian
155 3 Mi Tian
:transform_library a vamp:PluginLibrary ;
156 3 Mi Tian
    vamp:identifier "vampy" ;
157 3 Mi Tian
    vamp:available_plugin :transform_plugin .
158 3 Mi Tian
159 3 Mi Tian
:transform a vamp:Transform ;
160 3 Mi Tian
    vamp:plugin :transform_plugin ;
161 3 Mi Tian
    vamp:step_size "512"^^xsd:int ;
162 3 Mi Tian
    vamp:block_size "1024"^^xsd:int ;
163 3 Mi Tian
    vamp:parameter_binding [
164 3 Mi Tian
        vamp:parameter [ vamp:identifier "bt-threshold" ] ;
165 3 Mi Tian
        vamp:value "0.9"^^xsd:float ;
166 3 Mi Tian
    ] ;
167 3 Mi Tian
    vamp:parameter_binding [
168 3 Mi Tian
        vamp:parameter [ vamp:identifier "cut-off" ] ;
169 3 Mi Tian
        vamp:value "0.34"^^xsd:float ;
170 3 Mi Tian
    ] ;
171 3 Mi Tian
    vamp:parameter_binding [
172 3 Mi Tian
        vamp:parameter [ vamp:identifier "dthreshold" ] ;
173 3 Mi Tian
        vamp:value "0"^^xsd:float ;
174 3 Mi Tian
    ] ;
175 3 Mi Tian
    vamp:parameter_binding [
176 3 Mi Tian
        vamp:parameter [ vamp:identifier "filtfilt" ] ;
177 3 Mi Tian
        vamp:value "1"^^xsd:float ;
178 3 Mi Tian
    ] ;
179 3 Mi Tian
    vamp:parameter_binding [
180 3 Mi Tian
        vamp:parameter [ vamp:identifier "fusion-type" ] ;
181 3 Mi Tian
        vamp:value "2"^^xsd:float ;
182 3 Mi Tian
    ] ;
183 3 Mi Tian
    vamp:parameter_binding [
184 3 Mi Tian
        vamp:parameter [ vamp:identifier "lin-threshold" ] ;
185 3 Mi Tian
        vamp:value "0.5"^^xsd:float ;
186 3 Mi Tian
    ] ;
187 3 Mi Tian
    vamp:parameter_binding [
188 3 Mi Tian
        vamp:parameter [ vamp:identifier "med-threshold" ] ;
189 3 Mi Tian
        vamp:value "7"^^xsd:float ;
190 3 Mi Tian
    ] ;
191 3 Mi Tian
    vamp:parameter_binding [
192 3 Mi Tian
        vamp:parameter [ vamp:identifier "medfilt" ] ;
193 3 Mi Tian
        vamp:value "1"^^xsd:float ;
194 3 Mi Tian
    ] ;
195 3 Mi Tian
    vamp:parameter_binding [
196 3 Mi Tian
        vamp:parameter [ vamp:identifier "polyfit" ] ;
197 3 Mi Tian
        vamp:value "1"^^xsd:float ;
198 3 Mi Tian
    ] ;
199 3 Mi Tian
    vamp:parameter_binding [
200 3 Mi Tian
        vamp:parameter [ vamp:identifier "threshold" ] ;
201 3 Mi Tian
        vamp:value "50"^^xsd:float ;
202 3 Mi Tian
    ] ;
203 3 Mi Tian
    vamp:parameter_binding [
204 1 Mi Tian
        vamp:parameter [ vamp:identifier "tol-threshold" ] ;
205 1 Mi Tian
        vamp:value "0.03"^^xsd:float ;
206 1 Mi Tian
    ] ;
207 1 Mi Tian
    vamp:parameter_binding [
208 1 Mi Tian
        vamp:parameter [ vamp:identifier "whitening" ] ;
209 1 Mi Tian
        vamp:value "0"^^xsd:float ;
210 1 Mi Tian
    ] ;
211 1 Mi Tian
    vamp:output [ vamp:identifier "vampy-onsets-cdsf-onsets" ] .
212 1 Mi Tian
mitian$
213 1 Mi Tian
</pre>
214 1 Mi Tian
215 6 Mi Tian
Transforms are usually described in _RDF_, following the transform part of the [["Vamp plugin ontology":http://www.omras2.org/VampOntology]]. Now, how can be change the parameter settings in the transform specification file? 
216 1 Mi Tian
217 1 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 the @-t@ option. Let's see an example.
218 1 Mi Tian
219 6 Mi Tian
<pre>
220 11 Gyorgy Fazekas
221 4 Mi Tian
mitian$ sonic-annotator -s vamp:vampy:vampy-onsets-cdsf:vampy-onsets-cdsf-onsets >param_config.n3
222 11 Gyorgy Fazekas
223 4 Mi Tian
</pre>
224 11 Gyorgy Fazekas
225 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 lines in the saved n3 file
226 11 Gyorgy Fazekas
227 4 Mi Tian
<pre>
228 4 Mi Tian
        vamp:parameter [ vamp:identifier "threshold" ] ;
229 4 Mi Tian
        vamp:value "50"^^xsd:float ;
230 4 Mi Tian
</pre>
231 1 Mi Tian
into 
232 4 Mi Tian
<pre>
233 4 Mi Tian
        vamp:parameter [ vamp:identifier "threshold" ] ;
234 1 Mi Tian
        vamp:value "70"^^xsd:float ;
235 1 Mi Tian
</pre>
236 1 Mi Tian
and save it.
237 1 Mi Tian
238 1 Mi Tian
Now we can run the same plugin using the modified parameter settings.
239 1 Mi Tian
<pre>
240 11 Gyorgy Fazekas
241 4 Mi Tian
mitian$ sonic-annotator -t param_config.n3 -w csv test.wav --csv-basedir /homes/mitian/hg/workspace/onsetdetection
242 4 Mi Tian
Extracting and writing features... Done
243 4 Mi Tian
244 4 Mi Tian
Vampy::~PyExtensionManager: Extension module cleaned.
245 11 Gyorgy Fazekas
246 4 Mi Tian
</pre>
247 4 Mi Tian
248 6 Mi Tian
This example only involves a couple of operations for Sonic Annotator. You may also want to type
249 6 Mi Tian
@sonic-annotator -h@
250 7 Mi Tian
for a helpbook. Also your working directory should be where Sonic Annotator is installed. 
251 6 Mi Tian
  
252 6 Mi Tian
h2. That's all guys! Happy hacking with Vamp plugins :)