9 nchannels
= c
.getchannels()
11 sampwidth
= c
.getwidth()
12 samprate
= 0.0 # unknown
13 filename
= sys
.argv
[1]
14 f
= open(filename
, 'r')
15 type, totalsize
= aiff
.read_chunk_header(f
)
17 raise aiff
.Error
, 'FORM chunk expected at start of file'
18 aiff
.read_form_chunk(f
)
21 type, size
= aiff
.read_chunk_header(f
)
24 if v
: print 'header:', `
type`
, size
26 nchannels
, nsampframes
, sampwidth
, samprate
= \
27 aiff
.read_comm_chunk(f
)
28 if v
: print nchannels
, nsampframes
, sampwidth
, samprate
30 offset
, blocksize
= aiff
.read_ssnd_chunk(f
)
31 if v
: print offset
, blocksize
33 if size
%2: void
= f
.read(1)
34 p
= makeport(nchannels
, sampwidth
, samprate
)
35 play(p
, data
, offset
, blocksize
)
36 elif type in aiff
.skiplist
:
37 aiff
.skip_chunk(f
, size
)
39 raise aiff
.Error
, 'bad chunk type ' + type
41 def makeport(nchannels
, sampwidth
, samprate
):
43 c
.setchannels(nchannels
)
44 c
.setwidth(sampwidth
/8)
45 # can't set the rate...
46 p
= al
.openport('', 'w', c
)
49 def play(p
, data
, offset
, blocksize
):
52 while p
.getfilled() > 0: time
.sleep(0.01)