(Unix only) The audiodev module provides sound playing support for Sun and SGI computers. Example 9-8 demonstrates this module.
Example 9-8. Using the audiodev Module
File: audiodev-example-1.py import audiodev import aifc sound = aifc.open("samples/sample.aiff", "r") player = audiodev.AudioDev() player.setoutrate(sound.getframerate()) player.setsampwidth(sound.getsampwidth()) player.setnchannels(sound.getnchannels()) bytes_per_frame = sound.getsampwidth() * sound.getnchannels() bytes_per_second = sound.getframerate() * bytes_per_frame while 1: data = sound.readframes(bytes_per_second) if not data: break player.writeframes(data) player.wait()
Core Modules
More Standard Modules
Threads and Processes
Data Representation
File Formats
Mail and News Message Processing
Network Protocols
Internationalization
Multimedia Modules
Data Storage
Tools and Utilities
Platform-Specific Modules
Implementation Support Modules
Other Modules