PyAudioCD for Linux

1 Introduction

This document describes the Python module cdrom_lnx. This is a thin layer around the basic Linux IOCTL calls to control an audio CD player. Up to now, it has only been tested under Linux 2.0.36 with an IDE-CD player. According to the Linux documentation, it should however work with other CD types, too.

2 Module Content

2.1 class CDRom

represents an open CDRom device. It supports the following methods:
__init__(devicename)
opens the device devicename (for read only access).
pause(), resume(), start(), stop(), eject(), closeTray(), reset()
do what their name tell.
readToc()
reads the CD's table of contents.
The result is a list of TocEntries (more precisely cdrom_tocentry instances). The entries have an additional member duration which represents the duration of the track in frames (i.e. 1/75 s).
playFRAMES(startframes,no)
plays no frames starting with startframes.
playTI(starttrack,startindex,endtrack,endindex)
plays from starttrack,startindex through endtrack,endindex (inclusive).
playMSF(startminute,startsecond,startframe, endminute,endsecond,endframe)
plays from startminute,startsecond,startframe through endminute,endsecond,endframe.
setVolume(channel0,channel1,channel2,channel3)
sets the volume for the 4 channels.
setVolume can be called with a single cdrom_volctrl instance argument, instead.
getVolume()
returns a cdrom_volctrl instance, an object with members channel0,channel1,channel2,channel3.
getSubchnl()
returns a cdrom_subchnl instance describing the current (subchannel) state.

2.2 class cdrom_tocentry

describes a CD track. It supports the following methods:
isDataTrack()
the track contains data rather than audio information.
getLBA()
the LBA (= logical block address, i.e. frame address) address where the track starts.
getMSF()
the MSF (= minute/second/frame) address where the track starts as a cdrom_msf0 instance, an object with members minute, second and frame.
cdrom_tocentry instances returned by CDRom.getToc have an additional member duration that specifies the track's duration in frames.

2.3 class cdrom_subchnl

describes the current (subchannel) state.
It has the following main attributes:
cdsc_audiostatus
current audio state
0x00audio status not supported
0x11audio play in progress
0x12audio play paused
0x13audio play completed
0x14audio play stopped due to error
0x15no current audio state to return
cdsc_trk
current track number
cdsc_ind
current index number
cdsc_absaddr
current absolute address (with respect to the CD start, magically offset by 150)
cdsc_reladdr
current relative address (with respect to the track start, may be negative)
The method getAddr(rel=0) returns the current (absolute or relative) address.

2.4 function lba2msf(lba)

converts from LBA (logical block address) to MSF (minute/second/frame), a cdrom_msf0 instance.

2.5 function msf2lba(minute,second,frame)

converts from MSF (minute/second/frame) to LBA (logical block address).
msf2lba may also be called with a single cdrom_msf0 argument.
Dieter Maurer
Last modified: Sun May 21 15:05:50 CEST 2000