Combining the Marsyas python bindings with the matplotlib library for plotting in Python creates a great environment for prototyping. In the past few months I have done a lot of Marsyas work using this approach and really enjoy it. It gives a lot of the expressive power and prototyping of MATLAB while retaining the data-flow model and efficient processing of Marsyas. Unfortunately getting everything installed and setup for the first time takes some effort.
I recently did an installation on a fresh copy of Ubuntu 11.04 - Natty Narwhal - 32 bits and in this blog post I will share the steps I had to take. As usual the exact details change over time so the instructions are slightly different from previous versions of Ubuntu. These instructions can also be found in the Marsyas User Manual as part of the installation instructions for specific systems.
The first step is to get subversion and cmake installed. I did all the package installation directly using apt-get but you can also use the Synaptic package manager for that purpose. Lines that start with $ are to be typed in the terminal. The others are simply comments describing the steps.
$ sudo apt-get install subversion
$ sudo apt-get install cmake
$ sudo apt-get install cmake-curses-gui
$ sudo apt-get install libasound2-dev
Now we are ready to get the latest Marsyas from svn, configure and compile.
$ svn co https://svn.code.sf.net/p/marsyas/code
$ cd marsyas
$ mkdir build
$ cd build
$ ccmake ../src
(Press [c] to continue and [g] to generate the Makefile)
$ make -j 3 (or higher if you have more cores)
When the compilation is finished you can check that the command-line Marsyas tools were compiled.
$ cd bin
(Press ctrl-c to stop the sine wave from playing)
$ cd ..
If everything worked you will hear a sine wave playing on your speakers.
Now we are ready to get the Python/SWIG bindings going.
$ sudo apt-get install swig
$ sudo apt-get install python-dev
(the python headers)
$ sudo apt-get install python-matplotlib
$ sudo apt-get install ipython
Now we need to reconfigure/compile Marsyas to use Swig to create the python bindings.
$ ccmake ../src
(enable the WITH_SWIG option)
$ make -j 3
$ sudo make install
(install the Marsyas python bindings so that Python can find them)
$ sudo ldconfig /usr/local/lib
(add /usr/local/lib to the path searched for libraries)
If everything has worked you can now combine Marsyas and matplotlib. To check try:
$ cd src/marsyas_python
$ python windowing.py
$ ipython --pylab windowing.py
After running these commands you should be able to see a nice generated figure looking like the image above this paragraph. If you look at the code of windowing.py you will see that the comlputation of the figure data is done through Marsyas. All you need to do is import marsyas at the top of your Python source code. In a future post I will show some utilities that making plotting data from Marsyas networks easy and save you time.