Recognizes if input is ogg or not.
[xiph/unicode.git] / ao-python / README
blobd9e25a9b466d66c0adfa73f1be15b9bbbbb07033
1 pyao - a Python wrapper module for the ao library
3 This is a wrapper for libao, an audio device abstraction
4 library. libao is available with ogg/vorbis at http://www.xiph.org.
6 To build you need distutils package from
7 http://www.python.org/sigs/distutils-sig/download.html (it comes with
8 Python 2.0). To install:
10 python config_unix.py
11 python setup.py build
12 [as root] python setup.py install
14 Use the config_unix.py script to configure the build first. You can
15 pass a --prefix argument to tell the script where you have the ao
16 files installed. If you have problems, check the file config.log for
17 specifics. If you have any problems let me know. Access the module by
18 using "import ao" in your Python code.
20 Here's an interactive session of just playing with the module, until I
21 create better documentation (there should be docstrings for
22 everything). Watch as I read some random data and "play" it to a wave
23 file.
25 >>> import ao
27 >>> dev = ao.AudioDevice('wav', filename = 'myoutput.wav')
29 >>> f = open('/dev/urandom', 'r') #that's some good stuff
31 >>> print dev
32 <AudioDevice object at 0x812ac28>
34 >>> print dev.driver_info()
35 {'author': 'Aaron Holtzman <aholtzma@ess.engr.uvic.ca>', 
36  'short_name': 'wav', 
37  'name': 'WAV file output', 
38  'comment': 'Sends output to a .wav file'}
40 >>> print ao.driver_info('oss')
41 {'author': 'Aaron Holtzman <aholtzma@ess.engr.uvic.ca>', 
42  'short_name': 'oss', 
43  'name': 'OSS audio driver output ', 
44  'comment': 'Outputs audio to the Open Sound System driver.'}
46 >>> data = f.read(1024*8)
48 >>> dev.play(data)
50 >>> <control-d>
52 And now I have a file myoutput.wav with random noise in it.
54 A note: Because of the way the AO API works, if you are opening a
55 device that outputs to a file (like raw or wav), then you HAVE to pass
56 the filename as a keyword parameter to the constructor (like
57 above). It can't just be an option (you used to be able to do
58 that). Opening a "live" device (e.g. oss or alsa), you obviously don't
59 have to worry about the filename.
62 Andrew Chatham <andrew.chatham@duke.edu>