summaryrefslogtreecommitdiffstats
path: root/Demo/sgi/cd
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1992-04-14 11:04:57 (GMT)
committerGuido van Rossum <guido@python.org>1992-04-14 11:04:57 (GMT)
commitf2759a5c2d881b2c791b5ef42321b15a7d1c8b01 (patch)
treed2d529d79050e963d4e682084a2ed0155a349933 /Demo/sgi/cd
parent9183aaa46391a888f2f992f8697d1289f7cbd288 (diff)
downloadcpython-f2759a5c2d881b2c791b5ef42321b15a7d1c8b01.zip
cpython-f2759a5c2d881b2c791b5ef42321b15a7d1c8b01.tar.gz
cpython-f2759a5c2d881b2c791b5ef42321b15a7d1c8b01.tar.bz2
made it a little nicer; use CDDA_DATASIZE; restore output sampling rate
Diffstat (limited to 'Demo/sgi/cd')
-rwxr-xr-xDemo/sgi/cd/recvcd.py37
1 files changed, 24 insertions, 13 deletions
diff --git a/Demo/sgi/cd/recvcd.py b/Demo/sgi/cd/recvcd.py
index e991aaa..db5cc41 100755
--- a/Demo/sgi/cd/recvcd.py
+++ b/Demo/sgi/cd/recvcd.py
@@ -3,23 +3,34 @@
import al, AL
from socket import *
+from CD import CDDA_DATASIZE
-PORT = 50505 # Must match the port in sendcd.py
+PORT = 50505 # Must match the port in sendcd.py
def main():
s = socket(AF_INET, SOCK_DGRAM)
s.bind('', PORT)
- c = al.newconfig()
- c.setchannels(2)
- c.setwidth(2)
- p = al.openport('Audio from CD', 'w', c)
- al.setparams(AL.DEFAULT_DEVICE, [AL.OUTPUT_RATE, AL.RATE_44100])
+ oldparams = [AL.OUTPUT_RATE, 0]
+ params = oldparams[:]
+ al.getparams(AL.DEFAULT_DEVICE, oldparams)
+ params[1] = AL.RATE_44100
+ try:
+ al.setparams(AL.DEFAULT_DEVICE, params)
+ config = al.newconfig()
+ config.setwidth(AL.SAMPLE_16)
+ config.setchannels(AL.STEREO)
+ port = al.openport('CD Player', 'w', config)
- N = 2352
- while 1:
- data = s.recv(N)
- if not data:
- print 'EOF'
- break
- p.writesamps(data)
+ while 1:
+ data = s.recv(CDDA_DATASIZE)
+ if not data:
+ print 'EOF'
+ break
+ port.writesamps(data)
+ except KeyboardInterrupt:
+ pass
+
+ al.setparams(AL.DEFAULT_DEVICE, oldparams)
+
+main()