libmusicbrainz3  3.0.2
MusicBrainz::Disc Class Reference

Represents an Audio CD. More...

Public Types

typedef std::pair< int, int > Track
 
typedef std::vector< Disc::TrackTrackList
 

Public Member Functions

 Disc (const std::string &id=std::string())
 Constructor. More...
 
virtual ~Disc ()
 Destructor. More...
 
std::string getId () const
 Returns the MusicBrainz DiscID. More...
 
void setId (const std::string &value)
 Sets the MusicBrainz DiscId. More...
 
int getSectors () const
 Returns the length of the disc in sectors. More...
 
void setSectors (const int sectors)
 Sets the length of the disc in sectors. More...
 
int getFirstTrackNum () const
 Returns the number of the first track on this disc. More...
 
void setFirstTrackNum (const int trackNum)
 Sets the number of the first track on this disc. More...
 
int getLastTrackNum () const
 Returns the number of the last track on this disc. More...
 
void setLastTrackNum (const int trackNum)
 Sets the number of the last track on this disc. More...
 
Disc::TrackListgetTracks ()
 Returns the sector offset and length of this disc. More...
 
void addTrack (Disc::Track track)
 Adds a track to the list. More...
 

Detailed Description

Represents an Audio CD.

This class represents an Audio CD. A disc can have an ID (the MusicBrainz DiscID), which is calculated from the CD's table of contents (TOC). There may also be data from the TOC like the length of the disc in sectors, as well as position and length of the tracks.

Note that different TOCs, maybe due to different pressings, lead to different DiscIDs. Conversely, if two different discs have the same TOC, they also have the same DiscID (which is unlikely but not impossible). DiscIDs are always 28 characters long and look like this: 'J68I_CDcUFdCRCIbHSEbTBCbooA-'. Sometimes they are also referred to as CDIndex IDs.

The MusicBrainz web service (WebService) only returns the DiscID and the number of sectors. The DiscID calculation function readDisc, however, can retrieve the other attributes of Disc from an Audio CD in the disc drive.

Member Typedef Documentation

◆ Track

typedef std::pair<int, int> MusicBrainz::Disc::Track

◆ TrackList

Constructor & Destructor Documentation

◆ Disc()

MusicBrainz::Disc::Disc ( const std::string &  id = std::string())

Constructor.

Parameters
ida string containing a 28-character DiscID

◆ ~Disc()

virtual MusicBrainz::Disc::~Disc ( )
virtual

Destructor.

Member Function Documentation

◆ addTrack()

void MusicBrainz::Disc::addTrack ( Disc::Track  track)

Adds a track to the list.

This method adds an (offset, length) pair to the list of tracks. The leadout track must not be added. The total length of the disc can be set using setSectors.

Parameters
trackan (offset, length) pair (values are ints)
See also
getTracks

◆ getFirstTrackNum()

int MusicBrainz::Disc::getFirstTrackNum ( ) const

Returns the number of the first track on this disc.

Returns
an int containing the track number

◆ getId()

std::string MusicBrainz::Disc::getId ( ) const

Returns the MusicBrainz DiscID.

Returns
a string containing a 28-character DiscID

◆ getLastTrackNum()

int MusicBrainz::Disc::getLastTrackNum ( ) const

Returns the number of the last track on this disc.

Returns
an int containing the track number

◆ getSectors()

int MusicBrainz::Disc::getSectors ( ) const

Returns the length of the disc in sectors.

Returns
the length in sectors as an integer

◆ getTracks()

Disc::TrackList& MusicBrainz::Disc::getTracks ( )

Returns the sector offset and length of this disc.

This method returns a list of tuples containing the track offset and length in sectors for all tracks on this disc. The track offset is measured from the beginning of the disc, the length is relative to the track's offset. Note that the leadout track is not included.

Returns
a vector of (offset, length) pairs (values are ints)

◆ setFirstTrackNum()

void MusicBrainz::Disc::setFirstTrackNum ( const int  trackNum)

Sets the number of the first track on this disc.

Parameters
trackNuman int containing the track number

◆ setId()

void MusicBrainz::Disc::setId ( const std::string &  value)

Sets the MusicBrainz DiscId.

Parameters
valuea string containing a 28-character DiscID

◆ setLastTrackNum()

void MusicBrainz::Disc::setLastTrackNum ( const int  trackNum)

Sets the number of the last track on this disc.

Parameters
trackNuman int containing the track number

◆ setSectors()

void MusicBrainz::Disc::setSectors ( const int  sectors)

Sets the length of the disc in sectors.

Parameters
sectorsthe length in sectors as an integer