annotate README.rst @ 129:b8fe675f9c3f

Doc update, & make the plugin key args be called plugin_key rather than just key
author Chris Cannam
date Wed, 24 Jun 2015 16:14:32 +0100
parents a805ab21db33
children f798cda1007f
rev   line source
Chris@117 1
Chris@117 2 Python Vamp plugin host
Chris@117 3 =======================
Chris@117 4
Chris@126 5 This module allows Python code to load and use native-code Vamp
Chris@126 6 plugins (http://vamp-plugins.org) for audio feature analysis.
Chris@117 7
Chris@126 8 The module consists of a native-code extension ("vampyhost") that
Chris@126 9 provides a low-level wrapper for the Vamp plugin SDK, along with a
Chris@126 10 Python wrapper ("vamp") that provides a higher-level abstraction.
Chris@117 11
Chris@126 12 No code for loading audio files is included; you'll need to use some
Chris@126 13 other module for that. This code expects to receive decoded audio data
Chris@126 14 of one or more channels, either as a series of frames or as a single
Chris@126 15 whole buffer.
Chris@117 16
Chris@123 17 Written by Chris Cannam and George Fazekas at the Centre for Digital
Chris@123 18 Music, Queen Mary University of London. Copyright 2008-2015 Queen
Chris@123 19 Mary, University of London. Refer to COPYING.rst for licence details.
Chris@123 20
Chris@123 21 See home page at https://code.soundsoftware.ac.uk/projects/vampy-host
Chris@123 22 for more details.
Chris@123 23
Chris@117 24
Chris@117 25 A simple example
Chris@117 26 ----------------
Chris@117 27
Chris@126 28 Using librosa (http://bmcfee.github.io/librosa/) to read an audio
Chris@126 29 file, and the NNLS Chroma Vamp plugin
Chris@126 30 (https://code.soundsoftware.ac.uk/projects/nnls-chroma/) for
Chris@126 31 analysis::
Chris@117 32
Chris@123 33 $ python
Chris@123 34 >>> import vamp
Chris@123 35 >>> import librosa
Chris@123 36 >>> data, rate = librosa.load("example.wav")
Chris@126 37 >>> chroma = vamp.collect(data, rate, "nnls-chroma:nnls-chroma")
Chris@126 38 >>> chroma
Chris@123 39 {'matrix': ( 0.092879819, array([[ 61.0532608 , 60.27478409, 59.3938446 , ..., 182.13394165,
Chris@123 40 42.40084457, 116.55457306],
Chris@123 41 [ 68.8901825 , 63.98115921, 60.77633667, ..., 245.88218689,
Chris@123 42 68.51251984, 164.70120239],
Chris@123 43 [ 58.59794617, 50.3429184 , 45.44804764, ..., 258.02362061,
Chris@123 44 83.95749664, 179.91200256],
Chris@123 45 ...,
Chris@123 46 [ 0. , 0. , 0. , ..., 0. ,
Chris@123 47 0. , 0. ],
Chris@123 48 [ 0. , 0. , 0. , ..., 0. ,
Chris@123 49 0. , 0. ],
Chris@123 50 [ 0. , 0. , 0. , ..., 0. ,
Chris@123 51 0. , 0. ]], dtype=float32))}
Chris@126 52 >>> stepsize, chromadata = chroma["matrix"]
Chris@123 53 >>> import matplotlib.pyplot as plt
Chris@123 54 >>> plt.imshow(chromadata)
Chris@123 55 <matplotlib.image.AxesImage object at 0x7fe9e0043fd0>
Chris@123 56 >>> plt.show()
Chris@117 57
Chris@126 58 And a pitch-chroma plot appears.
Chris@117 59
Chris@126 60
Chris@126 61 High-level interface (vamp)
Chris@126 62 ---------------------------
Chris@126 63
Chris@126 64 This module contains three sorts of function:
Chris@126 65
Chris@129 66 1. Basic info and lookup functions:
Chris@126 67
Chris@129 68 * ``vamp.list_plugins``
Chris@129 69 * ``vamp.get_outputs_of``
Chris@129 70 * ``vamp.get_category_of``
Chris@126 71
Chris@129 72 These retrieve the installed plugin keys and get basic information
Chris@129 73 about each plugin. (For more detailed information, load a plugin
Chris@129 74 and inspect it using the low-level interface described below.)
Chris@129 75
Chris@129 76 2. Process functions:
Chris@129 77
Chris@129 78 * ``vamp.process_audio``
Chris@129 79 * ``vamp.process_frames``
Chris@129 80 * ``vamp.process_audio_multiple_outputs``
Chris@129 81 * ``vamp.process_frames_multiple_outputs``
Chris@126 82
Chris@126 83 These accept audio input, and produce output in the form of a list
Chris@126 84 of feature sets structured similarly to those in the C++ Vamp
Chris@129 85 plugin SDK. The plugin to be used is specified by its key (the
Chris@129 86 identifier as returned by ``vamp.list_plugins``). A dictionary of
Chris@129 87 plugin parameter settings may optionally be supplied.
Chris@126 88
Chris@126 89 The ``_audio`` versions take a single (presumably long) array of
Chris@126 90 audio samples as input, and chop it into frames according to the
Chris@126 91 plugin's preferred step and block sizes. The ``_frames`` versions
Chris@126 92 instead accept an enumerable sequence of audio frame arrays.
Chris@126 93
Chris@129 94 3. The process-and-collect function:
Chris@129 95
Chris@129 96 * ``vamp.collect``
Chris@126 97
Chris@126 98 This accepts a single array of audio samples as input, and returns
Chris@126 99 an output structure that reflects the underlying structure of the
Chris@126 100 feature output (depending on whether it is a curve, grid, etc). The
Chris@129 101 plugin to be used is specified by its key. A dictionary of plugin
Chris@129 102 parameter settings may optionally be supplied.
Chris@126 103
Chris@126 104 The ``collect`` function processes the whole input before returning
Chris@126 105 anything; if you need to supply a streamed input, or retrieve
Chris@126 106 results as they are calculated, then you must use one of the
Chris@126 107 ``process`` functions (above) or else the low-level interface
Chris@126 108 (below).
Chris@126 109
Chris@126 110
Chris@126 111 Low-level interface (vampyhost)
Chris@126 112 -------------------------------
Chris@126 113
Chris@126 114 This extension contains facilities that operate on Vamp plugins in a
Chris@126 115 way analogous to the existing C++ Vamp Host SDK: ``list_plugins``,
Chris@126 116 ``get_plugin_path``, ``get_category_of``, ``get_library_for``,
Chris@126 117 ``get_outputs_of``, ``load_plugin``, and a utility function
Chris@126 118 ``frame_to_realtime``.
Chris@126 119
Chris@126 120 Calling ``load_plugin`` gets you a ``vampyhost.Plugin`` object, which
Chris@126 121 then exposes all of the methods found in the Vamp SDK Plugin class.
Chris@126 122
Chris@126 123 (Note that methods wrapped directly from the Vamp SDK are named using
Chris@126 124 camelCase, so as to match the names found in the C++ SDK. Elsewhere
Chris@126 125 this module follows Python PEP8 naming.)
Chris@126 126
Chris@126 127 See the individual module and function documentation for further
Chris@126 128 details.
Chris@126 129