diff options
author | Walter Bender <walter@walter-laptop.(none)> | 2009-02-20 16:12:44 (GMT) |
---|---|---|
committer | Walter Bender <walter@walter-laptop.(none)> | 2009-02-20 16:12:44 (GMT) |
commit | b0b6de5e6c61fe92452bf057d2f0677a3d1fec9b (patch) | |
tree | 18b7e220d66044df26505c31b0ad68cda5e8d8b0 /arch_src/pyalsaaudio-0.2/playbacktest.py | |
parent | 897de91d58c45e13f6de78818d9805fc78021d75 (diff) |
silbe patch to build alsaaudio on first launch
Diffstat (limited to 'arch_src/pyalsaaudio-0.2/playbacktest.py')
-rw-r--r-- | arch_src/pyalsaaudio-0.2/playbacktest.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/arch_src/pyalsaaudio-0.2/playbacktest.py b/arch_src/pyalsaaudio-0.2/playbacktest.py new file mode 100644 index 0000000..06e0fe9 --- /dev/null +++ b/arch_src/pyalsaaudio-0.2/playbacktest.py @@ -0,0 +1,36 @@ +## recordtest.py +## +## This is an example of a simple sound playback script. +## +## The script opens an ALSA pcm for sound playback. Set +## various attributes of the device. It then reads data +## from stdin and writes it to the device. +## +## To test it out do the following: +## python recordtest.py > out.raw # talk to the microphone +## python playbacktest.py < out.raw +## +## If you have Gnome, you could also just test by doing something like: +## python playbacktest.py < /usr/share/sounds/gnibbles/laughter.wav +import alsaaudio +import sys +import time + +# Open the device in playback mode. +out = alsaaudio.PCM(alsaaudio.PCM_PLAYBACK) + +# Set attributes: Mono, 8000 Hz, 16 bit little endian frames +out.setchannels(1) +out.setrate(8000) +out.setformat(alsaaudio.PCM_FORMAT_S16_LE) + +# The period size controls the internal number of frames per period. +# The significance of this parameter is documented in the ALSA api. +out.setperiodsize(160) + +loops = 10000 +while loops > 0: + loops -= 1 + # Read data from stdin + data = sys.stdin.read(320) + out.write(data) |