Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
60c225c2
Kaydet (Commit)
60c225c2
authored
Nis 22, 1992
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Rewritten (by Sjoerd again) to use module readcd
üst
daea6c84
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
63 deletions
+58
-63
playcd.py
Demo/sgi/cd/playcd.py
+58
-63
No files found.
Demo/sgi/cd/playcd.py
Dosyayı görüntüle @
60c225c2
# Read CD audio data from the SCSI bus and play it back over the
# built-in speaker or audio jack.
import
sys
import
al
import
AL
import
cd
import
CD
def
playaudio
(
port
,
type
,
audio
):
## print 'playaudio'
port
.
writesamps
(
audio
)
callbacks
=
[
'audio'
,
'pnum'
,
'index'
,
'ptime'
,
'atime'
,
'catalog'
,
'ident'
,
'control'
]
def
callback
(
port
,
type
,
data
):
print
'type'
,
callbacks
[
type
],
'data'
,
`data`
Error
=
'playcd.error'
def
callback
(
arg
,
type
,
data
):
print
`type`
,
`data`
def
triple
((
a
,
b
,
c
)):
return
zfill
(
a
)
+
':'
+
zfill
(
b
)
+
':'
+
zfill
(
c
)
def
zfill
(
n
):
s
=
`n`
return
'0'
*
(
2
-
len
(
s
))
+
s
def
prtrackinfo
(
info
):
for
i
in
range
(
len
(
info
)):
start
,
total
=
info
[
i
]
print
'Track'
,
zfill
(
i
+
1
),
triple
(
start
),
triple
(
total
)
statedict
=
[
'ERROR'
,
'NODISK'
,
'READY'
,
'PLAYING'
,
'PAUSED'
,
'STILL'
]
def
prstatus
(
status
):
state
,
track
,
curtime
,
abstime
,
totaltime
,
first
,
last
,
\
scsi_audio
,
cur_block
,
dummy
=
status
print
'Status:'
,
if
0
<=
state
<
len
(
statedict
):
print
statedict
[
state
]
else
:
print
state
print
'Track: '
,
track
print
'Time: '
,
triple
(
curtime
)
print
'Abs: '
,
triple
(
abstime
)
print
'Total: '
,
triple
(
totaltime
)
print
'First: '
,
first
print
'Last: '
,
last
print
'SCSI: '
,
scsi_audio
print
'Block: '
,
cur_block
print
'Future:'
,
dummy
def
main
():
player
=
cd
.
open
()
parser
=
cd
.
createparser
()
state
,
track
,
(
min
,
sec
,
frame
),
(
abs_min
,
abs_sec
,
abs_frame
),
\
(
total_min
,
total_sec
,
total_frame
),
\
first
,
last
,
scsi_audio
,
\
cur_block
,
(
dum1
,
dum2
,
dum3
)
=
player
.
getstatus
()
print
state
,
track
,
(
min
,
sec
,
frame
),
\
(
abs_min
,
abs_sec
,
abs_frame
),
\
(
total_min
,
total_sec
,
total_frame
),
\
first
,
last
,
scsi_audio
,
\
cur_block
,
(
dum1
,
dum2
,
dum3
)
if
state
<>
CD
.
READY
:
player
.
close
()
raise
Error
,
'CD not ready'
if
not
scsi_audio
:
player
.
close
()
raise
Error
,
'not an audio-capable CD-ROM player'
for
i
in
range
(
first
,
last
+
1
):
trackinfo
=
player
.
gettrackinfo
(
i
)
print
'Track'
,
i
,
trackinfo
if
sys
.
argv
[
1
:]:
print
'Start at track'
,
sys
.
argv
[
1
]
player
.
seektrack
(
eval
(
sys
.
argv
[
1
]))
size
=
player
.
bestreadsize
()
oldparams
=
[
AL
.
OUTPUT_RATE
,
0
]
params
=
oldparams
[:]
al
.
getparams
(
AL
.
DEFAULT_DEVICE
,
oldparams
)
params
[
1
]
=
AL
.
RATE_44100
import
sys
,
readcd
,
al
,
string
,
AL
,
CD
r
=
readcd
.
Readcd
()
.
init
()
prstatus
(
r
.
getstatus
())
prtrackinfo
(
r
.
gettrackinfo
())
l
=
[]
for
arg
in
sys
.
argv
[
1
:]:
x
=
eval
(
arg
)
try
:
l
=
len
(
x
)
r
.
appendstretch
(
x
[
0
],
x
[
1
])
except
TypeError
:
r
.
appendtrack
(
x
)
try
:
oldparams
=
[
AL
.
OUTPUT_RATE
,
0
]
params
=
oldparams
[:]
al
.
getparams
(
AL
.
DEFAULT_DEVICE
,
oldparams
)
params
[
1
]
=
AL
.
RATE_44100
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
)
parser
.
setcallback
(
CD
.
AUDIO
,
playaudio
,
port
)
for
i
in
range
(
1
,
8
):
parser
.
setcallback
(
i
,
callback
,
port
)
parse
r
.
removecallback
(
CD
.
ATIME
)
parser
.
removecallback
(
CD
.
PTIME
)
for
i
in
range
(
8
):
r
.
setcallback
(
i
,
callback
,
None
)
r
.
removecallback
(
CD
.
PTIME
)
r
.
removecallback
(
CD
.
ATIME
)
r
.
setcallback
(
CD
.
AUDIO
,
playaudio
,
port
)
while
1
:
frames
=
player
.
readda
(
size
)
if
frames
==
''
:
break
parser
.
parseframe
(
frames
)
data
=
r
.
play
()
except
KeyboardInterrupt
:
pass
al
.
setparams
(
AL
.
DEFAULT_DEVICE
,
oldparams
)
player
.
close
()
parser
.
deleteparser
()
r
.
player
.
close
()
r
.
parser
.
deleteparser
()
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment