1 # Receive UDP packets from sendcd.py and play them on the speaker or
6 from cd
import DATASIZE
8 PORT
= 50505 # Must match the port in sendcd.py
11 s
= socket(AF_INET
, SOCK_DGRAM
)
14 oldparams
= [AL
.OUTPUT_RATE
, 0]
16 al
.getparams(AL
.DEFAULT_DEVICE
, oldparams
)
17 params
[1] = AL
.RATE_44100
19 al
.setparams(AL
.DEFAULT_DEVICE
, params
)
20 config
= al
.newconfig()
21 config
.setwidth(AL
.SAMPLE_16
)
22 config
.setchannels(AL
.STEREO
)
23 port
= al
.openport('CD Player', 'w', config
)
26 data
= s
.recv(DATASIZE
)
31 except KeyboardInterrupt:
34 al
.setparams(AL
.DEFAULT_DEVICE
, oldparams
)