symbian-qemu-0.9.1-12/python-2.6.1/Mac/Demo/sound/playaiff.py
author johnathan.white@2718R8BGH51.accenture.com
Mon, 08 Mar 2010 18:45:03 +0000
changeset 46 b6935a90ca64
parent 1 2fb8b9db1c86
permissions -rw-r--r--
Modify framebuffer and NGA framebuffer to read screen size from board model dtb file. Optimise memory usuage of frame buffer Add example minigui application with hooks to profiler (which writes results to S:\). Modified NGA framebuffer to run its own dfc queue at high priority

from Carbon.Sound import *
from Carbon import Snd

import aifc, audioop

fn = 'f:just samples:2ndbeat.aif'
af = aifc.open(fn, 'r')
print af.getparams()
print 'nframes  =', af.getnframes()
print 'nchannels =', af.getnchannels()
print 'framerate =', af.getframerate()
nframes = min(af.getnframes(), 100000)
frames = af.readframes(nframes)
print 'len(frames) =', len(frames)
print repr(frames[:100])
frames = audioop.add(frames, '\x80'*len(frames), 1)
print repr(frames[:100])

import struct

header1 = struct.pack('llhhllbbl',
                      0,
                      af.getnchannels(),
                      af.getframerate(),0,
                      0,
                      0,
                      0xFF,
                      60,
                      nframes)
print repr(header1)
header2 = struct.pack('llhlll', 0, 0, 0, 0, 0, 0)
header3 = struct.pack('hhlll',
                      af.getsampwidth()*8,
                      0,
                      0,
                      0,
                      0)
print repr(header3)
header = header1 + header2 + header3

buffer = header + frames

chan = Snd.SndNewChannel(5,0x00C0)

Snd.SndDoCommand(chan, (bufferCmd, 0, buffer), 0)