home

also visit: Theatre of Noise | Soundings

about: this site | me

subscribe: RSS

31 August 2007

Music Control Tools: Python-Based

segno
In the previous part of this series of articles I looked at dedicated programming languages for music creation. But why invent a new language for this one special domain? Surely it makes more sense to use one of the many existing languages, provide libraries for required protocols and interface with the correct hardware?

Well, that is not necessarily true. As we saw in our short look at ChucK, new paradigms of coding ("strictly-timed") may enhance development in a specific domain.

However, the advantages of adopting an existing language are obvious. The developer need not work out their own grammar, syntax and tools, but can rather concentrate on the actual audio part of the problem.

In this article I will look at audio development tools based in my language of choice, Python. These will all have the advantages of that language: clear syntax, pragmatic mix of functional, object-oriented and imperative models, strong OOP implementation, etc.

PyGame, based on the Simple DirectMedia Layer (SDL), has lots of graphics functionality, but also plays back MPG files and accesses devices like CD-ROM drives and joysticks. It can queue and play music streams, and contains sound sample manipulation, but is not robust enough in this regard for our purposes. For instance, it can handle only one audio stream at a time and has no DSP functionality.

pySonic is a wrapper for the FMOD library and provides sound file playback and recording, MIDI, 3D sound and support for many formats (wav, aiff, mp3, ogg, mod, etc.). FMOD is not free or open source, so one would have to abide by their license restrictions.

PyPortMidi provides MIDI I/O, although the latest binary is for only Python 2.4. Likewise here's a module for OpenSoundControl (OSC) client functionality.

PySndObj is a wrapper for the SndObj Sound Object Library which provides realtime audio IO and MIDI input (though not on all platforms). Currently this is too immature to recommend for the task at hand.

PyMedia is a library for sound file playback and recording which supports wav, mp3, ogg, avi, divx, dvd, cdda etc. It also has some DSP functionality, namely resampling and frequency analysis.

athenaCL is an interactive command line program specifically designed for algorithmic composition and pitch models studies. It has a host of tools in this regard, outputting results to Csound, MIDI, audio file, XML and text formats. While not requiring Csound, it is tightly integrated with that programme, containing Csound format instrument. (Without it, results can nonetheless be rendered to MIDI files.) This programme looks excellent within the domain it is targeting.

Finally, MusicKit includes serial and MIDI I/O, scheduling and synchronization, real-time (or non-realtime) synthesis (FM, wavetable, physical modeling etc.) and DSP. It supports quadraphonic sound, MP3 and Ogg/Vorbis plus multiple inputs and outputs. Furthermore, the package comes with high-end tools including a sampler, sequencer and score player.

Of all the packages here, it potentially provides the most robust toolkit for sound creation and manipulation. Unfortunately, not only is the GUI on Windows incomplete, but so is MIDI support and the DSP functions. Critically, MIDI and DSP are also missing from the LINUX version. (MusicKit had its genesis on the NeXT and so works just fine in OpenStep... in case that helps you.) There has been no version since May 2005, so it is fair to say this tool is ripe for salvage.

The conclusion of this article must therefore be that there is no Python-based system that meets our needs at present. And while it would be possible to scrape one together from bits and pieces of the packages listed here, that would be far more work than could be justified.

Reference: The wiki entry PythonInMusic contains tools I have not covered here, such as those for media playback and cataloging.

I thank the Arts Council for their support in this research.

5 comment(s) follow:

  Blogger illume wrote at 31 August, 2007 05:37...

Hi,

in regards to pygame -- pygame is definitely not that geared towards sound.

However you can use Numeric for dsp processing with the soundarray module. You will also be able to use the newer Numpy module more easily with the next pygame release.

You can also play multiple music streams, but not as easily as playing one. You need to do all the file reading/queueing yourself.


Cheers,

  Blogger robin wrote at 31 August, 2007 13:50...

Illume: I do hope that PyGame or another of these solutions evolves into a more robust audio tool. It always seems to be about the "next release"!

  Blogger robin wrote at 31 August, 2007 13:51...

Update: pyliblo is a Python send/receive OSC module. Alternatively, the Wiretap project spawned oggpy. You will see lots of bad links to this around the net. This is the current home.

  Blogger robin wrote at 31 August, 2007 13:52...

Here's another option for all of you into 3D graphics. Use the free, open, cross-platform tour-de-force Blender to create your graphics masterpiece. It is clever enough to incorporate Python as a scripting language. So you can use one of the above-mentioned OSC libraries, or follow the directions here. Talk to your favourite audio application as an OSC server.

  Blogger Roet wrote at 13 January, 2008 00:26...

PySndObj is not at all immature; it
provides great support for lots of
different signal processing tasks,
time and frequency-domain. It is
based on the SndObj library, which
has over 100 classes, so it's
pretty complete.
Furthermore, with just a little
bit of C++, new classes can be
added to it.

Post a Comment or go back to home