1 # Compare different audio compression schemes.
3 # This copies mono audio data from the input port to the output port,
4 # and puts up a window with 4 toggle buttons:
6 # uLAW : convert the data to uLAW and back
7 # ADPCM : convert the data to ADPCM and back
8 # Difference : make only the difference between the converted and the
9 # original data audible
10 # Exit : quit from the program
22 parsetree
= flp
.parse_form('cmpaf_form','form')
23 flp
.create_full_form(self
, parsetree
)
25 c
.setchannels(AL
.MONO
)
27 self
.iport
= al
.openport('cmpaf','r', c
)
28 self
.oport
= al
.openport('cmpaf','w', c
)
29 self
.do_adpcm
= self
.do_ulaw
= self
.do_diff
= 0
31 self
.form
.show_form(FL
.PLACE_SIZE
, 1, 'compare audio formats')
36 olddata
= data
= self
.iport
.readsamps(600)
38 data
= audioop
.lin2ulaw(data
, 2)
39 data
= audioop
.ulaw2lin(data
, 2)
41 data
, nacstate
= audioop
.lin2adpcm(data
, 2, \
43 data
, dummy
= audioop
.adpcm2lin(data
, 2, \
45 self
.acstate
= nacstate
47 olddata
= audioop
.mul(olddata
, 2, -1)
48 data
= audioop
.add(olddata
, data
, 2)
49 self
.oport
.writesamps(data
)
52 def cb_exit(self
, *args
):
55 def cb_adpcm(self
, obj
, val
):
56 self
.do_adpcm
= obj
.get_button()
58 def cb_ulaw(self
, obj
, val
):
59 self
.do_ulaw
= obj
.get_button()
61 def cb_diff(self
, obj
, val
):
62 self
.do_diff
= obj
.get_button()
64 cmpaf
= Cmpaf().init()