Author drj
Recipients drj, gpolo
Date 2009-02-12.09:00:09
SpamBayes Score 4.90435e-09
Marked as misclassified No
Message-id <>
The following program does a very basic do-i-get-back-what-i-wrote test.  
sunau can't cope; I am investigating.

#!/usr/bin/env python
# $Id$
# Audio File Tests

import aifc
import sunau
import wave

import struct
import sys
from StringIO import StringIO

frames = struct.pack('256B', *range(256))
log = sys.stderr

# Basic test of reproducability.
# We test that a set of frames (an entirely artifical set, see `frames`, 
# above) can be written to an audio file and read back again to get the 
# same set of frames.
# We test mono/stereo, 8-bit/16-bit, and a few framerates.    
# As of 2009-02-12 sunau does not pass these tests, so I recommend that 
# you remove it.
for af in (aifc, sunau, wave):
  for nchannels in (1, 2):
    for sampwidth in (1, 2):
      for framerate in (11000, 44100, 96000):
        print >> log, "%s %d/%d/%d" % (af.__name__,
          nchannels, sampwidth, framerate)
        f = StringIO()
        w =, 'w')
        s = f.getvalue()
        f = StringIO(s)
        w =
        assert w.getnchannels() == nchannels
        assert w.getsampwidth() == sampwidth
        assert w.getframerate() == framerate
        assert w.readframes(len(frames)//nchannels//sampwidth) == frames
        assert w.readframes(1) == ''
Date User Action Args
2009-02-12 09:00:11drjsetrecipients: + drj, gpolo
2009-02-12 09:00:11drjsetmessageid: <>
2009-02-12 09:00:10drjlinkissue5202 messages
2009-02-12 09:00:09drjcreate