Revision 6:c4eb7acfb989 Vamp.v3.ipynb

View differences:

Vamp.v3.ipynb
25 25
  {
26 26
   "cells": [
27 27
    {
28
     "cell_type": "code",
29
     "collapsed": true,
30
     "input": [
31
      "import vamp"
32
     ],
33
     "language": "python",
28
     "cell_type": "markdown",
34 29
     "metadata": {},
35
     "outputs": [],
36
     "prompt_number": 1
30
     "source": [
31
      "# Using Vamp plugins from Python\n",
32
      "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.)"
33
     ]
37 34
    },
38 35
    {
39
     "cell_type": "code",
40
     "collapsed": false,
41
     "input": [
42
      "import librosa"
43
     ],
44
     "language": "python",
36
     "cell_type": "markdown",
45 37
     "metadata": {},
46
     "outputs": [
47
      {
48
       "output_type": "stream",
49
       "stream": "stderr",
50
       "text": [
51
        "/usr/lib/python2.7/site-packages/librosa/core/audio.py:33: UserWarning: Could not import scikits.samplerate. Falling back to scipy.signal\n",
52
        "  warnings.warn('Could not import scikits.samplerate. '\n"
53
       ]
54
      }
55
     ],
56
     "prompt_number": 2
38
     "source": [
39
      "### Setup\n",
40
      "\n",
41
      "First import some necessary modules.\n",
42
      "\n",
43
      "The `vamp` module loads and runs Vamp plugins.\n",
44
      "`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",
45
      "`matplotlib` is the plotting library."
46
     ]
57 47
    },
58 48
    {
59 49
     "cell_type": "code",
60 50
     "collapsed": true,
61 51
     "input": [
52
      "import vamp\n",
53
      "import librosa\n",
62 54
      "import matplotlib.pyplot as plt"
63 55
     ],
64 56
     "language": "python",
65 57
     "metadata": {},
66 58
     "outputs": [],
67
     "prompt_number": 3
59
     "prompt_number": 26
60
    },
61
    {
62
     "cell_type": "markdown",
63
     "metadata": {},
64
     "source": [
65
      "This bit of magic ensures that plots show up in the notebook rather than in a separate window:"
66
     ]
68 67
    },
69 68
    {
70 69
     "cell_type": "code",
......
75 74
     "language": "python",
76 75
     "metadata": {},
77 76
     "outputs": [],
78
     "prompt_number": 4
77
     "prompt_number": 27
78
    },
79
    {
80
     "cell_type": "markdown",
81
     "metadata": {},
82
     "source": [
83
      "### Getting started with the Vamp module\n",
84
      "\n",
85
      "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",
86
      "\n",
87
      "You can find plugin descriptions and downloads at http://vamp-plugins.org/download.html."
88
     ]
79 89
    },
80 90
    {
81 91
     "cell_type": "code",
......
84 94
      "vamp.list_plugins()"
85 95
     ],
86 96
     "language": "python",
87
     "metadata": {},
97
     "metadata": {
98
      "scrolled": true
99
     },
88 100
     "outputs": [
89 101
      {
90 102
       "metadata": {},
91 103
       "output_type": "pyout",
92
       "prompt_number": 5,
104
       "prompt_number": 28,
93 105
       "text": [
94 106
        "['bbc-vamp-plugins:bbc-energy',\n",
95 107
        " 'bbc-vamp-plugins:bbc-intensity',\n",
......
190 202
       ]
191 203
      }
192 204
     ],
193
     "prompt_number": 5
205
     "prompt_number": 28
206
    },
207
    {
208
     "cell_type": "markdown",
209
     "metadata": {},
210
     "source": [
211
      "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."
212
     ]
194 213
    },
195 214
    {
196 215
     "cell_type": "code",
......
201 220
     "language": "python",
202 221
     "metadata": {},
203 222
     "outputs": [],
204
     "prompt_number": 6
223
     "prompt_number": 29
224
    },
225
    {
226
     "cell_type": "markdown",
227
     "metadata": {},
228
     "source": [
229
      "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."
230
     ]
205 231
    },
206 232
    {
207 233
     "cell_type": "code",

Also available in: Unified diff