comparison README @ 10:8e9fbe4dc94d

more examples and some bug fixes
author fazekasgy
date Fri, 13 Jun 2008 17:28:22 +0000
parents a4c955e9a70b
children
comparison
equal deleted inserted replaced
9:d2d36e7d2276 10:8e9fbe4dc94d
1 1
2 * VamPy is a Vamp plugin wrapper for Python Scripts. 2 * VamPy is a Vamp plugin wrapper for Python Scripts.
3 3
4 WHAT IS IT FOR? 4 WHAT IS IT FOR?
5 5
6 you can write Vamp plugins in Python which can do the same as the native C++ plugins 6 This wrapper is for writing Vamp plugins in Python which can do the same as a native C++ plugin,
7 plus more if you're using advanced Python modules. 7 plus a lot more if you're using advanced Python modules.
8 8
9 you might get into Vamp development more easily this way. 9 This may be an easier way to get into Vamp development.
10 you can use it for prototyping your plugin before writing in C++ 10 You can use it for prototyping your plugin before writing it in C++
11 11
12 12
13 LIMITATIONS: 13 WHY PYTHON?
14 14
15 this is really just a proof of concept. The implementation is not the most efficient. 15 Python is a general purpose high level scripting language.
16 only tested on MacOSX, but in theory should work on other platforms with small fixes 16 It is interpreted, so you don't need to compile your plugins.
17 The Python C/API is not fully thread safe and correct threading is not yet implemented. 17 It has very high level libraries. e.g. you can stream audio from your VamPy plugin (it works for me...)
18 (This can cause problems resulting in nasty crashes.) 18 Supports functional programming.
19
20 Error checking is incomplete.
21 You better not make a mistake in your Python script, although in most cases you can see what
22 the problem is if you start the host (Sonic Visualiser) from the command line.
23 19
24 20
25 HOW DOES IT WORK: 21 HOW DOES IT WORK:
26 22
27 (1) Make sure you have Python installed. 23 (1) Make sure you have Python installed.
28 (2) Compile the C++ source or ask me for a binary (MacOS). 24 (2) Compile the C++ source or ask me for a binary (MacOS).
29 (3) Copy the library in your Vamp plugin directory like any other Vamp plugins: 25 (3) Copy the library in your Vamp plugin directory like any other Vamp plugins:
30 eg. /Library/Audio/Plug-Ins/Vamp 26 eg. /Library/Audio/Plug-Ins/Vamp
31 (4) Write your python plugins and copy them to the same place. 27 (4) Write some python plugins and copy them to the same place.
32 (5) Each plugin must contain a single class with the same name as your script file. 28 (5) Each plugin must contain a single class with the same name as your script file.
33 e.g. PyZeroCrossing.py -> calss PyZeroCrossing 29 e.g. PyZeroCrossing.py -> calss PyZeroCrossing
34 -Scripts with syntax errors in them are ignored. 30 -Scripts with syntax errors in them are ignored.
35 -Scripts not having the same class as the filename are ignored. 31 -Scripts not having the same class as the filename are ignored. (Python is case sensitive!)
36 -Other unknown scripts are likely to cause a nasty crash. 32 -Other unknown scripts are likely to cause a crash. (Don't put other python scripts in your Vamp directory.)
37 (Don't put other python scripts in your Vamp directory.)
38 33
39 34
40 WHY PYTHON? 35 COMPILING AND LINKING:
41 36
42 Python is a general purpose high level scripting language. 37 (1) make sure Python.h is included wherever it is on your machine
43 It is interpreted, so you don't need to compile your plugins 38 (2) the plugin needs to be linked against the Python binary: e.g.: ld -lpython2.5
44 It has very high level libraries. e.g. you can stream audio from your VamPy plugin (it works for me...) 39
45 Supports functional programming 40 example on on MacOSX:
41 g++ -I../vamp-plugin-sdk -O2 -Wall -I/usr/include/python2.5 -c -o PyPlugin.o PyPlugin.cpp
42 g++ -I../vamp-plugin-sdk -O2 -Wall -I/usr/include/python2.5 -c -o PyPlugScanner.o PyPlugScanner.cpp
43 g++ -I../vamp-plugin-sdk -O2 -Wall -I/usr/include/python2.5 -c -o pyvamp-main.o pyvamp-main.cpp
44 g++ -I../vamp-plugin-sdk -O2 -Wall -I/usr/include/python2.5 -c -o Mutex.o Mutex.cpp
45 g++ -shared PyPlugin.o PyPlugScanner.o pyvamp-main.o Mutex.o -o vampy.dylib -L../vamp-plugin-sdk/vamp-sdk -lvamp-sdk -dynamiclib -lpython2.5 -lpthread
46
47
48 (3) There is a Makefile that compiles this plugin by default.
46 49
47 50
48 COMPILING AND LINKING: 51 LIMITATIONS:
49 52
50 (1) include Python.h wherever it is on your machine 53 This is mainly a proof of concept. The implementation is not the most efficient, but using NumPy it's very reasonable.
51 (2) this plugin needs to be linked against the Python binary: 54 Only tested on MacOSX and Linux (by Chris), but in theory should work on other platforms with small fixes.
52 55
53 example on on MacOSX: 56 Error checking is not yet fully complete.
54 g++ -O2 -Wall -I. -fPIC -c -o pyvamp-main.o pyvamp-main.cpp 57 You better not make a mistake in your Python script, although in most cases you can see what the problem is
55 g++ -dynamiclib -o vamp-pyvamp-plugin.dylib ./PyPlugScanner.o ./PyPlugin.o ./pyvamp-main.o sdk/vamp-sdk/libvamp-sdk.a 58 if you start the host (e.g. Sonic Visualiser) from a command line interface.
56 -u _PyMac_Error /Library/Frameworks/Python.framework/Versions/2.5/Python 59 The wrapper plugin is quite verbose and outputs error messages.
57
58 (3) There is a modified Makefile from the Vamp SDK that compiles this plugin by default.
59 60
60 61
61 TODO: needs more complete error checking 62 TODO: * needs more complete error checking (almost done)
62 needs correct implementation of Python threading 63 * needs correct implementation of Python threading (done)
63 more efficient data conversion using the buffering interface or ctypes 64 * more efficient data conversion using the buffering interface or ctypes (done)
64 Vamp 'programs' not implemented 65 * Vamp 'programs' not implemented
65 support multiple classes per script in scanner 66 * support multiple classes per script in scanner
66 ensure proper cleanup, (host do a good job though) 67 * ensure proper cleanup, (host does a good job though)
67 68
69 HISTORY:
70 added support for NumPy arrays in processN()
71 framecount is now passed also to legacy process() and fixed resulting bugs in the PyZeroCrossing plugin
72 added two examples which use Frequency Domain input in processN()
68 73