Built-in Module cd

cd This module provides an interface to the Silicon Graphics CD library. It is available only on Silicon Graphics systems. The way the library works is as follows. A program opens the CD-ROM device with cd.open() and creates a parser to parse the data from the CD with cd.createparser(). The object returned by cd.open() can be used to read data from the CD, but also to get status information for the CD-ROM device, and to get information about the CD, such as the table of contents. Data from the CD is passed to the parser, which parses the frames, and calls any callback functions that have previously been added. An audio CD is divided into tracks or programs (the terms are used interchangeably). Tracks can be subdivided into indices. An audio CD contains a table of contents which gives the starts of the tracks on the CD. Index 0 is usually the pause before the start of a track. The start of the track as given by the table of contents is normally the start of index 1. Positions on a CD can be represented in two ways. Either a frame number or a tuple of three values, minutes, seconds and frames. Most functions use the latter representation. Positions can be both relative to the beginning of the CD, and to the beginning of the track. Module cd defines the following functions and constants:
\begin{funcdesc}{createparser}{}
Create and return an opaque parser object. The methods of the parser
object are described below.
\end{funcdesc}

\begin{funcdesc}{msftoframe}{min\, sec\, frame}
Converts a \code{(minutes, secon...
...ime
in absolute time code into the corresponding CD frame number.
\end{funcdesc}

\begin{funcdesc}{open}{\optional{device\optional{\, mode}}}
Open the CD-ROM devi...
... drive. The \code{mode}, if not omited, should be the
string 'r'.
\end{funcdesc}
The module defines the following variables:
\begin{datadesc}{error}
Exception raised on various errors.
\end{datadesc}

\begin{datadesc}{DATASIZE}
The size of one frame's worth of audio data. This is ...
...of the
audio data as passed to the callback of type \code{audio}.
\end{datadesc}

\begin{datadesc}{BLOCKSIZE}
The size of one uninterpreted frame of audio data.
\end{datadesc}
The following variables are states as returned by getstatus:
\begin{datadesc}{READY}
The drive is ready for operation loaded with an audio CD.
\end{datadesc}

\begin{datadesc}{NODISC}
The drive does not have a CD loaded.
\end{datadesc}

\begin{datadesc}{CDROM}
The drive is loaded with a CD-ROM. Subsequent play or read operations
will return I/O errors.
\end{datadesc}

\begin{datadesc}{ERROR}
An error aoocurred while trying to read the disc or its table of
contents.
\end{datadesc}

\begin{datadesc}{PLAYING}
The drive is in CD player mode playing an audio CD through its audio
jacks.
\end{datadesc}

\begin{datadesc}{PAUSED}
The drive is in CD layer mode with play paused.
\end{datadesc}

\begin{datadesc}{STILL}
The equivalent of \code{PAUSED} on older (non 3301) model Toshiba
CD-ROM drives. Such drives have never been shipped by SGI.
\end{datadesc}

\begin{datadesc}{audio}
\dataline{pnum}
\dataline{index}
\dataline{ptime}
\datal...
...the \code{addcallback()} method of CD parser
objects (see below).
\end{datadesc}
Player objects (returned by cd.open()) have the following methods:
\begin{funcdesc}{allowremoval}{}
Unlocks the eject button on the CD-ROM drive permitting the user to
eject the caddy if desired.
\end{funcdesc}

\begin{funcdesc}{bestreadsize}{}
Returns the best value to use for the \code{num...
...lue that permits a
continuous flow of data from the CD-ROM drive.
\end{funcdesc}

\begin{funcdesc}{close}{}
Frees the resources associated with the player object....
...\code{close}, the methods of the object should no longer be used.
\end{funcdesc}

\begin{funcdesc}{eject}{}
Ejects the caddy from the CD-ROM drive.
\end{funcdesc}

\begin{funcdesc}{getstatus}{}
Returns information pertaining to the current stat...
....PLAYING},
\code{cd.PAUSED}, \code{cd.STILL}, or \code{cd.CDROM}.
\end{funcdesc}

\begin{funcdesc}{gettrackinfo}{track}
Returns information about the specified tr...
...ments, the start time of
the track and the duration of the track.
\end{funcdesc}

\begin{funcdesc}{msftoblock}{min\, sec\, frame}
Converts a minutes, seconds, fra...
... the frame number by an offset required by certain CD-ROM
drives.
\end{funcdesc}

\begin{funcdesc}{play}{start\, play}
Starts playback of an audio CD in the CD-RO...
...he method \code{togglepause()} can then be used to commence
play.
\end{funcdesc}

\begin{funcdesc}{playabs}{min\, sec\, frame\, play}
Like \code{play()}, except t...
...t is given in minutes,
seconds, frames instead of a track number.
\end{funcdesc}

\begin{funcdesc}{playtrack}{start\, play}
Like \code{play()}, except that playing stops at the end of the track.
\end{funcdesc}

\begin{funcdesc}{playtrackabs}{track\, min\, sec\, frame\, play}
Like \code{play...
...pcified
absolute time and ends at the end of the specified track.
\end{funcdesc}

\begin{funcdesc}{preventremoval}{}
Locks the eject button on the CD-ROM drive thus preventing the user
from arbitrarily ejecting the caddy.
\end{funcdesc}

\begin{funcdesc}{readda}{num_frames}
Reads the specified number of frames from a...
...d unaltered to the \code{parseframe}
method of the parser object.
\end{funcdesc}

\begin{funcdesc}{seek}{min\, sec\, frame}
Sets the pointer that indicates the st...
...ue is the logical block number to which the pointer has been
set.
\end{funcdesc}

\begin{funcdesc}{seekblock}{block}
Sets the pointer that indicates the starting ...
...ue is the logical block number to
which the pointer has been set.
\end{funcdesc}

\begin{funcdesc}{seektrack}{track}
Sets the pointer that indicates the starting ...
...ue is the logical block number to which the
pointer has been set.
\end{funcdesc}

\begin{funcdesc}{stop}{}
Stops the current playing operation.
\end{funcdesc}

\begin{funcdesc}{togglepause}{}
Pauses the CD if it is playing, and makes it play if it is paused.
\end{funcdesc}
Parser objects (returned by cd.createparser()) have the following methods:
\begin{funcdesc}{addcallback}{type\, func\, arg}
Adds a callback for the parser....
...ving the control bits from the CD subcode
data.
\end{description}
\end{funcdesc}

\begin{funcdesc}{deleteparser}{}
Deletes the parser and frees the memory it was ...
...e automatically
when the last reference to the object is removed.
\end{funcdesc}

\begin{funcdesc}{parseframe}{frame}
Parses one or more frames of digital audio d...
...han one frame of digital audio data can
be passed to this method.
\end{funcdesc}

\begin{funcdesc}{removecallback}{type}
Removes the callback for the given \code{type}.
\end{funcdesc}

\begin{funcdesc}{resetparser}{}
Resets the fields of the parser used for trackin...
...de{resetparser} should be called after the disc has
been changed.
\end{funcdesc}