comparison pyvamp-main.cpp @ 1:dc88002ce687

some typos corrected
author fazekasgy
date Tue, 11 Mar 2008 20:24:58 +0000
parents e20e214bdfb5
children 211ebe55d521
comparison
equal deleted inserted replaced
0:e20e214bdfb5 1:dc88002ce687
36 36
37 /** 37 /**
38 * This VAMP plugin is a wrapper for Python Scripts. (VamPy) 38 * This VAMP plugin is a wrapper for Python Scripts. (VamPy)
39 * Centre for Digital Music, Queen Mary, University of London. 39 * Centre for Digital Music, Queen Mary, University of London.
40 * Copyright 2008, George Fazekas. 40 * Copyright 2008, George Fazekas.
41
42 TODO: needs more complete error checking
43 needs correct implementation of Python threading
44 more efficient data conversion using the buffering interface or ctypes
45 VAMP 'programs' not implemented
46 support multiple plugins per script in scanner
47 ensure proper cleanup, (host do a good job though)
48
49 COMPILING AND LINKING:
50 (1) include Python.h wherever it is on your machine
51 (2) this plugin needs to be linked against the Python binary:
52
53 example on on MacOSX:
54 g++ -O2 -Wall -I. -fPIC -c -o pyvamp-main.o pyvamp-main.cpp
55 g++ -dynamiclib -o vamp-pyvamp-plugin.dylib ./PyPlugScanner.o ./PyPlugin.o ./pyvamp-main.o sdk/vamp-sdk/libvamp-sdk.a
56 ... -u _PyMac_Error /Library/Frameworks/Python.framework/Versions/2.5/Python
57 */ 41 */
58 42
59 //#include "Python.h" 43 //#include "Python.h"
60 #include "/usr/include/python/Python.h" 44 #include "/usr/include/python/Python.h"
61 #include "vamp/vamp.h" 45 #include "vamp/vamp.h"
139 (string) Py_GetProgramName(); 123 (string) Py_GetProgramName();
140 124
141 void *pylib = 0; 125 void *pylib = 0;
142 126
143 cerr << "Loading Python Interpreter at: " << pythonPath << endl; 127 cerr << "Loading Python Interpreter at: " << pythonPath << endl;
144 //Preloading the binary allows the load of shared libs //dlopen("/Library/Frameworks/Python.framework/Versions/2.5/Python", RTLD_NOW|RTLD_GLOBAL); 128 //Preloading the binary allows the load of shared libs
145 #ifdef _WIN32
146 //TODO: check how to do RTLD_NOW on Windows 129 //TODO: check how to do RTLD_NOW on Windows
147 pylib = LoadLibrary(pythonPath.c_str()); 130 pylib = LoadLibrary(pythonPath.c_str());
148 #else 131 #else
149 pylib = dlopen(pythonPath.c_str(), RTLD_NOW|RTLD_GLOBAL); 132 pylib = dlopen(pythonPath.c_str(), RTLD_NOW|RTLD_GLOBAL);
150 #endif 133 #endif
151 if (!pylib) cerr << "Warning: Could not preload Python." 134 if (!pylib) cerr << "Warning: Could not preload Python."
152 << " Dynamic lodading in scripts will fail." << endl; 135 << " Dynamic loading in scripts will fail." << endl;
153 Py_Initialize(); 136 Py_Initialize();
154 PyEval_InitThreads(); 137 PyEval_InitThreads();
155 } else { 138 } else {
156 //Py_InitializeEx(1); 139 //Py_InitializeEx(1);
157 } 140 }