Revision 6:c4eb7acfb989 Vamp.ipynb

View differences:

Vamp.ipynb
1 1
{
2 2
 "cells": [
3 3
  {
4
   "cell_type": "markdown",
5
   "metadata": {},
6
   "source": [
7
    "# Using Vamp plugins from Python\n",
8
    "This notebook illustrates processing an audio file using a Vamp plugin, showing the results in a simple plot, and saving to a .csv file. This could be useful when integrating with analysis software written in Python, or for a batch process. (Note that it is also possible to run Vamp plugins in batch using the [Sonic Annotator](http://vamp-plugins.org/sonic-annotator) command-line program.)"
9
   ]
10
  },
11
  {
12
   "cell_type": "markdown",
13
   "metadata": {},
14
   "source": [
15
    "### Setup\n",
16
    "\n",
17
    "First import some necessary modules.\n",
18
    "\n",
19
    "The `vamp` module loads and runs Vamp plugins.\n",
20
    "`librosa` is an audio analysis module from LabROSA at Columbia University. We are using it here only to load audio files, though it can also carry out some basic analysis functions.\n",
21
    "`matplotlib` is the plotting library."
22
   ]
23
  },
24
  {
4 25
   "cell_type": "code",
5
   "execution_count": 1,
26
   "execution_count": 26,
6 27
   "metadata": {
7 28
    "collapsed": true
8 29
   },
9 30
   "outputs": [],
10 31
   "source": [
11
    "import vamp"
32
    "import vamp\n",
33
    "import librosa\n",
34
    "import matplotlib.pyplot as plt"
35
   ]
36
  },
37
  {
38
   "cell_type": "markdown",
39
   "metadata": {},
40
   "source": [
41
    "This bit of magic ensures that plots show up in the notebook rather than in a separate window:"
12 42
   ]
13 43
  },
14 44
  {
15 45
   "cell_type": "code",
16
   "execution_count": 2,
17
   "metadata": {
18
    "collapsed": false
19
   },
20
   "outputs": [
21
    {
22
     "name": "stderr",
23
     "output_type": "stream",
24
     "text": [
25
      "/usr/lib/python2.7/site-packages/librosa/core/audio.py:33: UserWarning: Could not import scikits.samplerate. Falling back to scipy.signal\n",
26
      "  warnings.warn('Could not import scikits.samplerate. '\n"
27
     ]
28
    }
29
   ],
30
   "source": [
31
    "import librosa"
32
   ]
33
  },
34
  {
35
   "cell_type": "code",
36
   "execution_count": 3,
37
   "metadata": {
38
    "collapsed": true
39
   },
40
   "outputs": [],
41
   "source": [
42
    "import matplotlib.pyplot as plt"
43
   ]
44
  },
45
  {
46
   "cell_type": "code",
47
   "execution_count": 4,
46
   "execution_count": 27,
48 47
   "metadata": {
49 48
    "collapsed": true
50 49
   },
......
54 53
   ]
55 54
  },
56 55
  {
56
   "cell_type": "markdown",
57
   "metadata": {},
58
   "source": [
59
    "### Getting started with the Vamp module\n",
60
    "\n",
61
    "List the plugins that are installed. The strings that are returned here are referred to in the module documentation as _plugin keys_ -- each one consists of the name of the library file that contains the plugin, then a colon, then the identifier for the plugin itself. So a set of plugins with the same text before the colon (such as `qm-vamp-plugins:`) were all distributed in the same plugin library file.\n",
62
    "\n",
63
    "You can find plugin descriptions and downloads at http://vamp-plugins.org/download.html."
64
   ]
65
  },
66
  {
57 67
   "cell_type": "code",
58
   "execution_count": 5,
68
   "execution_count": 28,
59 69
   "metadata": {
60
    "collapsed": false
70
    "collapsed": false,
71
    "scrolled": true
61 72
   },
62 73
   "outputs": [
63 74
    {
......
161 172
       " 'vamp-test-plugin:vamp-test-plugin-freq']"
162 173
      ]
163 174
     },
164
     "execution_count": 5,
175
     "execution_count": 28,
165 176
     "metadata": {},
166 177
     "output_type": "execute_result"
167 178
    }
......
171 182
   ]
172 183
  },
173 184
  {
185
   "cell_type": "markdown",
186
   "metadata": {},
187
   "source": [
188
    "We'll be using the `librosa` module's `load` function to load the audio file. IPython will show documentation about a function if you just give its name with a \"?\" at the end."
189
   ]
190
  },
191
  {
174 192
   "cell_type": "code",
175
   "execution_count": 6,
193
   "execution_count": 29,
176 194
   "metadata": {
177 195
    "collapsed": true
178 196
   },
......
182 200
   ]
183 201
  },
184 202
  {
203
   "cell_type": "markdown",
204
   "metadata": {},
205
   "source": [
206
    "And the main high-level Vamp module function to apply a plugin is called `collect`, because it runs a plugin and collects the results into a suitable structure rather than returning them individually."
207
   ]
208
  },
209
  {
185 210
   "cell_type": "code",
186 211
   "execution_count": 7,
187 212
   "metadata": {

Also available in: Unified diff