def read_sound_file(path):
    fp = open(path, 'rb')
    size, enc, rate, nchannels, extra = sunaudio.gethdr(fp)
    data = fp.read()
    fp.close()

    if enc != SND_FORMAT_MULAW_8:
        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)
示例#2
0
def read_sound_file(path):
    fp = open(path, 'rb')
    size, enc, rate, nchannels, extra = sunaudio.gethdr(fp)
    data = fp.read()
    fp.close()

    if enc != SND_FORMAT_MULAW_8:
        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)
示例#3
0
def play_sound_file(path):
    fp = open(path, 'r')
    size, enc, rate, nchannels, extra = sunaudio.gethdr(fp)
    data = fp.read()
    fp.close()

    if enc != SND_FORMAT_MULAW_8:
        print "Expect .au file with 8-bit mu-law samples"
        return

    try:
        a = linuxaudiodev.open('w')
    except linuxaudiodev.error, msg:
        if msg[0] in (errno.EACCES, errno.ENODEV):
            raise TestSkipped, msg
        raise TestFailed, msg
def play_sound_file(path):
    fp = open(path, 'r')
    size, enc, rate, nchannels, extra = sunaudio.gethdr(fp)
    data = fp.read()
    fp.close()

    if enc != SND_FORMAT_MULAW_8:
        print "Expect .au file with 8-bit mu-law samples"
        return

    try:
        a = linuxaudiodev.open('w')
    except linuxaudiodev.error, msg:
        if msg[0] in (errno.EACCES, errno.ENODEV, errno.EBUSY):
            raise TestSkipped, msg
        raise TestFailed, msg
示例#5
0
    def test_play_sound_file(self):
        path = findfile("audiotest.au")
        fp = open(path, 'r')
        size, enc, rate, nchannels, extra = sunaudio.gethdr(fp)
        data = fp.read()
        fp.close()

        if enc != SND_FORMAT_MULAW_8:
            self.fail("Expect .au file with 8-bit mu-law samples")

        # convert the data to 16-bit signed
        data = audioop.ulaw2lin(data, 2)

        # set the data format
        if sys.byteorder == 'little':
            fmt = linuxaudiodev.AFMT_S16_LE
        else:
            fmt = linuxaudiodev.AFMT_S16_BE

        # set parameters based on .au file headers
        self.dev.setparameters(rate, 16, nchannels, fmt)
        self.dev.write(data)
        self.dev.flush()
示例#6
0
    def test_play_sound_file(self):
        path = findfile("audiotest.au")
        fp = open(path, 'r')
        size, enc, rate, nchannels, extra = sunaudio.gethdr(fp)
        data = fp.read()
        fp.close()

        if enc != SND_FORMAT_MULAW_8:
            self.fail("Expect .au file with 8-bit mu-law samples")

        # convert the data to 16-bit signed
        data = audioop.ulaw2lin(data, 2)

        # set the data format
        if sys.byteorder == 'little':
            fmt = linuxaudiodev.AFMT_S16_LE
        else:
            fmt = linuxaudiodev.AFMT_S16_BE

        # set parameters based on .au file headers
        self.dev.setparameters(rate, 16, nchannels, fmt)
        self.dev.write(data)
        self.dev.flush()
示例#7
0
def playfile(name):
	if G.mode <> 'mac':
		tempname = name
	elif cache.has_key(name):
		tempname = cache[name]
	else:
		tempname = G.tempprefix + `rand.rand()`
		cmd = HOME_BIN_SGI + 'macsound2sgi'
		cmd = cmd + ' ' + commands.mkarg(name)
		cmd = cmd + ' >' + tempname
		if G.debug: print cmd
		sts = posix.system(cmd)
		if sts:
			print cmd
			print 'Exit status', sts
			stdwin.fleep()
			return
		cache[name] = tempname
	fp = open(tempname, 'r')
	try:
		hdr = sunaudio.gethdr(fp)
	except sunaudio.error, msg:
		hdr = ()
示例#8
0
def playfile(name):
	if G.mode <> 'mac':
		tempname = name
	elif cache.has_key(name):
		tempname = cache[name]
	else:
		tempname = G.tempprefix + `rand.rand()`
		cmd = HOME_BIN_SGI + 'macsound2sgi'
		cmd = cmd + ' ' + commands.mkarg(name)
		cmd = cmd + ' >' + tempname
		if G.debug: print cmd
		sts = posix.system(cmd)
		if sts:
			print cmd
			print 'Exit status', sts
			stdwin.fleep()
			return
		cache[name] = tempname
	fp = open(tempname, 'r')
	try:
		hdr = sunaudio.gethdr(fp)
	except sunaudio.error, msg:
		hdr = ()
示例#9
0
import sunaudio

file = "samples/sample.au"

print(sunaudio.gethdr(open(file, "rb")))

## (6761, 1, 8012, 1, 'sample.au')
示例#10
0
import sunaudio

file = "samples/sample.au"

print sunaudio.gethdr(open(file, "rb"))

## (6761, 1, 8012, 1, 'sample.au')
示例#11
0
from test_support import verbose, findfile, TestFailed, TestSkipped
示例#12
0
from test_support import verbose, findfile, TestFailed, TestSkipped