SND_FORMAT_MULAW_8 = 1
-def play_sound_file(path):
+def read_sound_file(path):
fp = open(path, 'r')
size, enc, rate, nchannels, extra = sunaudio.gethdr(fp)
data = fp.read()
print "Expect .au file with 8-bit mu-law samples"
return
+ # Convert the data to 16-bit signed.
+ data = audioop.ulaw2lin(data, 2)
+ return (data, rate, 16, nchannels)
+
+
+def play_sound_file(data, rate, ssize, nchannels):
try:
a = ossaudiodev.open('w')
except ossaudiodev.error, msg:
raise TestSkipped, msg
raise TestFailed, msg
- # convert the data to 16-bit signed
- data = audioop.ulaw2lin(data, 2)
-
# set the data format
if sys.byteorder == 'little':
fmt = ossaudiodev.AFMT_S16_LE
print msg
def test():
- play_sound_file(findfile('audiotest.au'))
+ (data, rate, ssize, nchannels) = read_sound_file(findfile('audiotest.au'))
+ play_sound_file(data, rate, ssize, nchannels)
test_errors()
test()