1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
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
The config script is new and still pretty weak. 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
>>> myoptions = {'file': 'myoutput.wav'}
>>> dev = ao.AudioDevice('wav', options = myoptions)
>>> f = open('/dev/urandom', 'r') #that's some good stuff
>>> print dev
<AudioDevice object at 0x812ac28>
>>> print dev.get_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.get_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.
Andrew Chatham <andrew.chatham@duke.edu>
|