pyxiph: python bindings for xiph libraries

pyxiph is a collection of python bindings for various xiph libraries. Currently, pyxiph has extensions for:
Time permitting, there will be more to follow (speex, theora, etc.). 

pyxiph is being developed using the excellent boost.python (part of the boost project), a framework for reflecting C/C++ constructs into python. boost.python provides several benefits over the native python C-api:
AO, OGG, and VORBIS EXPERTS! If you're interested in helping define useful object-oriented interfaces to xiph libraries, let me know.  pyxiph would like to offer superior interfaces to the standard C API's when possible, but it's not always clear what the best approach is. Any help would be great.

If you're interested in helping define interfaces for other xiph libraries, we can discuss that too. I can't promise that I'll get to them any time soon, but it's definitely in the long-range plans.

News

Requirements

You will need several other pieces of software installed before you can build or use pyxiph:

Downloading

pyxiph is packaged in two forms. The first simply bundles all pyxiph code into a single package, and is the simpler of the two forms. If you want the entire pyxiph codebase, all you need to download is a file of the form pyxiph-<version>.tar.gz.

The other distribution form provides each extension module as a separate package. In this form, for example, you can get the ao and vorbis modules without getting the ogg module. No matter which libraries you want, you'll need to get the file pyxiph-common-<version>.tar.gz. Then, get the package for each other module you want. So, for instance, if you want only ao, you need to download both pyxiph-common-<version>.tar.gz and pyxiph-ao-<version>.tar.gz.

You can download pyxiph from our SourceForge site.

Building

After you've downloaded the source, unpack all of it into the same place. If you're using the complete distribution packaging, you only unpack one file:

tar zxvf pyxiph-<version>.tar.gz

If you're using the distribution packaging that separates the libraries, you need to unpack the individual modules. For instance, if you're installing ao and vorbis only, you'll need to do this:

tar zxvf pyxiph-common-<version>.tar.gz
tar zxvf pyxiph-ao-<version>.tar.gz
tar zxvf pyxiph-vorbis-<version>.tar.gz

In all cases, this will create a directory called pyxiph-<version>. Go to the src directory under that directory:

cd pyxiph-<version>/src

Edit the file custom.py in that directory to match your system. It may need no changes. Once you've done that, run scons:

scons

Finally, install the libraries. Note that you'll probably need root privileges to do this:

scons install

Viola! You should now have a working installation of pyxiph.

Example

Here's a small example demonstrating how to open and play a single ogg/vorbis file (also available in the 'examples' directory of the source download).

import pyxiph.ao, pyxiph.vorbis
import sys
# Create a device using the default driver
device = pyxiph.ao.Device()

# Open up a a file specified on the command line
vfile = pyxiph.vorbis.File(sys.argv[1])

# read data chunks from the file until you reach the end
while True:
    (buff, bytes, stream) = vfile.read(4096)
    if bytes == 0: break
    device.play(buff, bytes)

If you save this as play_ogg.py, you can run it like this:

python play_ogg.py somefile.ogg

Projects using pyxiph

There is only one project I know of that uses pyxiph, and that's because I wrote it!
If you have a project using pyxiph, let us know and we'll post it here :)

Support

If you have questions, patches, or whatever, you can get in touch with the developers through the SourceForge site.

SourceForge.net Logo

Copyright (c) 2006 Austin Bingham