pymad is a Python module that allows Python programs to use the MPEG Audio Decoder library. pymad provides a high-level API, similar to the pyogg module, which makes reading PCM data from MPEG audio streams a piece of cake.

Using pymad is as easy as:

#!/usr/bin/env python
import mad, ao, sys

mf = mad.MadFile(sys.argv[1]) dev = ao.AudioDevice(‘oss’, rate=mf.samplerate()) while 1: buf = if buf is None: break, len(buf))

pymad uses the Python distutils tool. To build and install pymad, install python and libmad development files, and then:

 # python –prefix /usr/local
 # python build
 # python install –prefix /usr/local

Remember to make sure /usr/local/python/site-packages/ is in your Python search path.

pymad is licensed under the GNU General Public License.

The latest stable release of pymad can be downloaded from here.

The latest version of the source code is kept in arch:

baz register-archive

baz get
see here for details.

Send any patches or suggestions to Jamie Wilkinson