CD(3pm)
β¨ NAME β¨
Audio::CD β a Perl interface to libcdaudio (that's cd + cddb together, the whole package bestie). You're on the CD(3pm) page, from the User Contributed Perl Documentation corner of the world, and it is so much more fun than it sounds πΏβ¨
π SYNOPSIS
use Audio::CD ();
my $cd = Audio::CD->init;
Two lines. That's the whole summoning ritual. Slay.
π DESCRIPTION
Audio::CD gives you a Perl interface to libcdaudio by Tony Arcieri, which you can grab from http://cdcd.undergrid.net/ π
And there's a whole little friend group of classes in here β each one is glue for the libcdaudio functions and data structures. So like, one class to talk to the drive, one for CDDB, one for the disc data, one for tracks, one for status infoβ¦ it's giving organized π
π Audio::CD Class
The main character, obviously.
init
Initialize the Audio::CD object:
my $cd = Audio::CD->init;
stat
Stat the Audio::CD object, and it hands you back an Audio::CD::Info object.
my $info = $cd->stat;
cddb
Returns an Audio::CDDB object.
my $cddb = $cd->cddb;
play
Play the given cd track β and yes, it defaults to 1 if you don't say anything, so no pressure.
$cd->play(1);
stop
Stop the cd.
$cd->stop;
pause
Pause the cd.
$cd->pause;
resume
Resume the cd. (Un-pause, bestie, we're back π«Ά)
$cd->resume;
eject
Eject the cd.
$cd->eject;
close
Close the cd tray.
$cd->close;
play_frames
$cd->play_frames($startframe, $endframe);
The page just hands you the call here β no extra words, so I'm not gonna invent any. Take it verbatim fr fr π
play_track_pos
$cd->play_track_pos($strarttrack, $endtrack, $startpos);
Same deal β that's the exact call, typos and all, don't @ me π
play_track
$cd->play_track($strarttrack, $endtrack);
track_advance
$cd->track_advance($endtrack, $minutes, $seconds);
advance
$cd->advance($minutes, $seconds);
get_volume
Returns an Audio::CD::Volume object.
my $vol = $cd->get_volume;
set_volume
$cd->set_volume($vol);
π Audio::CDDB Class
discid
my $id = $cddb->discid;
lookup
Does a cddb lookup, and returns an Audio::CD::Data object.
my $data = $cddb->lookup;
π¦ Audio::CD::Data Class
artist
my $artist = $data->artist;
title
my $title = $data->title;
genre
my $genre = $data->genre;
tracks
Returns an array reference of Audio::CD::Track objects.
my $foo = $data->tracks($info);
my @tracks = @$foo;
πΈ Audio::CD::Track Class
name
my $name = $track->name;
β Audio::CD::Info Class
mode
Returns the CD mode, one of PLAYING, PAUSED, COMPLETED, NOSTATUS β pick your fighter β¨
my $track = $info->mode;
print "playing" if $info->mode == Audio::CD::PLAYING;
present
Returns true if a disc is present.
$cd->play if $info->present;
current_track
Returns the current track number being played or paused.
my $track = $info->current_track;
first_track
Returns the number of the first track on the CD.
my $track = $info->first_track;
total_tracks
Returns the total number of tracks on the cd.
my $track = $info->total_tracks;
track_time
Returns the current track play time:
my($minutes, $seconds) = $info->track_time;
time
Returns the current disc play time:
my($minutes, $seconds) = $info->time;
length
Returns the disc length time:
my($minutes, $seconds) = $info->length;
tracks
Returns an array reference of Audio::CD::Info::Track objects.
my $foo = $info->tracks;
my @tracks = @$foo;
π§ Audio::CD::Info::Track Class
length
Returns the track length time:
my($minutes, $seconds) = $tinfo->length;
pos
Returns the track position on the CD:
my($minutes, $seconds) = $tinfo->pos;
(Yep, pos is squished onto the same line as its description in the original. We keep it real over here.)
type
Returns the track type β either TRACK_AUDIO or TRACK_DATA:
if ($tinfo->type == Audio::CD::TRACK_AUDIO) {
print "audio track\n";
} elsif ($tinfo->type == Audio::CD::TRACK_DATA) {
print "data track\n";
}
is_audio
Returns true if the track is an audio track; equivalent to the test:
$tinfo->type == Audio::CD::TRACK_AUDIO ? 1 : 0
is_data
Returns true if the track is a data track; equivalent to the test:
$tinfo->type == Audio::CD::TRACK_DATA ? 1 : 0
π SEE ALSO
Xmms(3)
π AUTHOR
- Perl interface by Doug MacEachern
- libcdaudio and
cddb_lookup.cby Tony Arcieri
That's the whole page bestie, every flag and every call, no cap π«Ά
And for the little sign-off at the bottom of the OG: this is perl v5.42.3, dated 2026-08-19, and it lives under CD(3pm). Obsessed. Periodt π
π
π¦ where this page comes from
- ubuntu stonking: libaudio-cd-perl 0.05-13build2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms