[Python-Dev] Test results of linuxaudiodev.c

Ka-Ping Yee pingster@ilm.com
Thu, 29 Jun 2000 17:44:35 -0700 (PDT)


On 30 Jun 2000, Michael Hudson wrote:
> Yup, that works fine.  Don't understand the details - and as I have my
> graduation ceremony tomorrow I'm going to go to bed and leave learning
> them until some other occasion!

Cool.

Okay, i just discovered sunau.py.  Here's my real shot at
test_linuxaudiodev.py.  Can you give this a try?


---- test_linuxaudiodev.py ----
from test_support import verbose, findfile, TestFailed
import linuxaudiodev
import os, sunau

formats = {("ULAW", 1): linuxaudiodev.AFMT_MU_LAW,
           ("NONE", 1): linuxaudiodev.AFMT_S8,
           ("NONE", 2): linuxaudiodev.AFMT_S16_BE}

def play_au_file(path):
    au = sunau.open(path, "r")
    data = au.readframes(sunau.AUDIO_UNKNOWN_SIZE)
    au.close()

    spec = (au.getcomptype(), au.getsampwidth())
    if not has_key(formats, spec):
        raise "audio format not supported by linuxaudiodev"
        
    dsp = linuxaudiodev.open("w")
    dsp.setparameters(au.getframerate(), au.getsampwidth() * 8,
                      au.getnchannels(), formats[spec])
    dsp.write(data)
    dsp.close()

def test():
    play_au_file(findfile('audiotest.au'))

test()
---- test_linuxaudiodev.py ----



-- ?!ng