Update: Things are moving on nicely with my first main attempt at wrapping the AGain demo included in the VST sdk to python using nothing but the standard python C API. So far I have everything implemented but the main process, for which I’ll need to do a bit more reading on the numpy C API. Most of this was possible thanks to an easy tutorial by Jun Du over at codeproject.com.
More updates (and source code of course) to follow soon.
This post is more a note to myself than a post of general interest. It is also to let people know that I’m still fiddling with pyVST now and then. I’ve been looking at how to build C extensions to python when using numpy using the following link. I’ve got these extensions working in windows by downloading the tarball and compiling the examples using codeblocks.
The examples are C extensions for a python script but what I’m aiming to do with pyVST, is get the plugin dll to start up the python engine and then pass each frame of the data buffer to a python script for processing. The C extension code will make a useful starting point for passing the data between the plugin dll and python. The aim is to make the plugin aware of its file name and then call a python script with the same filename to do the processing. This will eventually alow a user to make plugins without having to touch any C code. I’ve got a bit of time off at the end of this month, so maybe pyVST will get moving a bit more.
There is no documentation on the numpy extensions page for building on a Windows platform, so here is what I did:
- Download the tarball and extract
- Include the C source and header in your poject
- Include the numpy headers directory
- Link to the python library
- Add this missing line to the header file “static PyObject *rowx2_v2(PyObject *self, PyObject *args);”
- In the main source file, ptrvector() allocates n*sizeof(double), but should really allocate pointers to double; so: n*sizeof(double *)
- Set your compiler to build a dll
- Name the output file “_C_arraytest.pyd
- Put the output file in the same dir as C_arraytest.py and run
Hope this helps anyone googling C extensions for numpy under Windows 🙂
Interpreted languages are an awsome way of realising ideas very quickly, even if you eventually want to hard code your projects in C. I’ve been looking into python more and more recently (since using SCons as my C++ build tool), and have been having some luck with the numPy package for efficient matrix and array mathematics (gives MATLAB type functionality, but for free). Python is also very easy to integrate with C code.
I’ll try to get something up and running in the near future where you have a pre-compiled dll (and eventually the equivalents on other os) which acts as the gateway between your vst host and Python. This is intended to be a very similar project to jVST, enabling python programmers to achieve similar ease of development. I’m sure it is much better to worry about the DSP and sound quality of your plugin at first without the faff involved with the C++ language and constant compile, recompile cycles.
Keep watching this space and I’ll keep reading up in my spare time and eventually start a source forge project or something similar. Should be fun!