Discussion:
[Python-3000-checkins] r65228 - python/branches/py3k/Lib/test/test_ossaudiodev.py
brett.cannon
2008-07-25 17:56:47 UTC
Permalink
Author: brett.cannon
Date: Fri Jul 25 19:56:47 2008
New Revision: 65228

Log:
Forward-port r65112 so that test_ossaudiodev uses sunau.

Modified:
python/branches/py3k/Lib/test/test_ossaudiodev.py

Modified: python/branches/py3k/Lib/test/test_ossaudiodev.py
==============================================================================
--- python/branches/py3k/Lib/test/test_ossaudiodev.py (original)
+++ python/branches/py3k/Lib/test/test_ossaudiodev.py Fri Jul 25 19:56:47 2008
@@ -6,7 +6,7 @@
import errno
import ossaudiodev
import sys
-import sunaudio
+import sunau
import time
import audioop
import unittest
@@ -22,15 +22,16 @@
AFMT_S16_NE = ossaudiodev.AFMT_S16_BE


-SND_FORMAT_MULAW_8 = 1
-
def read_sound_file(path):
- fp = open(path, 'rb')
- size, enc, rate, nchannels, extra = sunaudio.gethdr(fp)
- data = fp.read()
- fp.close()
+ with open(path, 'rb') as fp:
+ au = sunau.open(fp)
+ rate = au.getframerate()
+ nchannels = au.getnchannels()
+ encoding = au._encoding
+ fp.seek(0)
+ data = fp.read()

- if enc != SND_FORMAT_MULAW_8:
+ if encoding != sunau.AUDIO_FILE_ENCODING_MULAW_8:
raise RuntimeError("Expect .au file with 8-bit mu-law samples")

# Convert the data to 16-bit signed.

Loading...