pyao - a Python wrapper module for the ao library

This is a wrapper for libao, an audio device abstraction
library. libao is available with ogg/vorbis at http://www.xiph.org.

To build you need distutils package from
http://www.python.org/sigs/distutils-sig/download.html (it comes with
Python 2.0). To install:

python config_unix.py
python setup.py build
[as root] python setup.py install

Use the config_unix.py script to configure the build first. You can
pass a --prefix argument to tell the script where you have the ao
files installed. If you have problems, check the file config.log for
specifics. If you have any problems let me know. Access the module by
using "import ao" in your Python code.

Here's an interactive session of just playing with the module, until I
create better documentation (there should be docstrings for
everything). Watch as I read some random data and "play" it to a wave
file.

>>> import ao

>>> dev = ao.AudioDevice('wav', filename = 'myoutput.wav')

>>> f = open('/dev/urandom', 'r') #that's some good stuff

>>> print dev
<AudioDevice object at 0x812ac28>

>>> print dev.driver_info()
{'author': 'Aaron Holtzman <aholtzma@ess.engr.uvic.ca>', 
 'short_name': 'wav', 
 'name': 'WAV file output', 
 'comment': 'Sends output to a .wav file'}

>>> print ao.driver_info('oss')
{'author': 'Aaron Holtzman <aholtzma@ess.engr.uvic.ca>', 
 'short_name': 'oss', 
 'name': 'OSS audio driver output ', 
 'comment': 'Outputs audio to the Open Sound System driver.'}

>>> data = f.read(1024*8)

>>> dev.play(data)

>>> <control-d>

And now I have a file myoutput.wav with random noise in it.

A note: Because of the way the AO API works, if you are opening a
device that outputs to a file (like raw or wav), then you HAVE to pass
the filename as a keyword parameter to the constructor (like
above). It can't just be an option (you used to be able to do
that). Opening a "live" device (e.g. oss or alsa), you obviously don't
have to worry about the filename.


Andrew Chatham <andrew.chatham@duke.edu>