pyxiph: python bindings for xiph libraries
pyxiph is a collection of python
bindings for various xiph
libraries. Currently, pyxiph has extensions for:
- ao: a
cross platform audio library
- ogg: a
multimedia container format, and the native file
and stream format for the Xiph.org multimedia codecs
- vorbis:
an open, compressed audio format
- FLAC:
a free, lossless audio codec
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:
- High-level abstraction: there is less translation from the
native API -> python's C-api -> the API you want for python programmers
- Safety: boost.python makes it easier to manage references
- Maintainability: the directness of boost.python's approach
means that the code is easier to understand, modify, and maintain
- Coolness: boost.python is extremely cool, providing a
very-low-cost-of-entry yet powerful means to export C++ code to python
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
- 2007-03-29: pyxiph-0.5 released
- 2006-07-05: pyxiph-0.3 released
- 2006-07-02: pyxiph-0.2 released
Requirements
You will need several other pieces of software installed before you can
build or use pyxiph:
- python: Make sure you've got the development headers
installed (using a devel RPM or whatever).
- libao, libogg, libFLAC++, and libvorbis: Again, make sure you have the
development headers installed.
- boost.python: In general, just install the latest version
of boost and make sure you enable boost.python.
- scons: This is the build control system that pyxiph uses
(a.k.a. its make replacement).
- A C++ compiler: as of now, pyxiph has only been tested with
g++ on linux, but there's no real technical barrier that I know of that
will prevent it from working in other environments.
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!
- pita: a command-line,
client-server music player designed to stay out of your way. This
project was actually the reason pyxiph was started.
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.
Copyright (c) 2006 Austin Bingham