BASS_CD_GetID


Retrieves identification info from the CD in a drive.

char *BASS_CD_GetID(
    DWORD drive,
    DWORD id
);

Parameters

driveThe drive... 0 = the first drive.
idThe identification to retrieve, one of the following.
BASS_CDID_UPCReturns the catalog number of the CD. The number uses UPC/EAN-code (BAR coding). This might not be available for all CDs.
BASS_CDID_CDDBProduces a CDDB identifier. This can be used to get details on the CD's contents from a CDDB server.
BASS_CDID_CDDB_QUERYSends a "query" command to the configured CDDB server (see BASS_CONFIG_CD_CDDB_SERVER) to get a list of matching entries for the CD's CDDB identifier. The contents of each entry can be retrieved via the BASS_CDID_CDDB_READ option.
BASS_CDID_CDDB_READ + entrySends a "read" command to the configured CDDB server (see BASS_CONFIG_CD_CDDB_SERVER) to get a database entry for the CD's CDDB identifier... 0 = first entry.
BASS_CDID_CDDB_READ_CACHEReturns the cached CDDB "read" command response, if there is one.
BASS_CDID_CDDB2Produces a CDDB2 identifier. This can be used to get details on the CD's contents from a CDDB2 server.
BASS_CDID_TEXTRetrieves the CD-TEXT information from the CD (see below for details). CD-TEXT is not available on the majority of CDs.
BASS_CDID_CDPLAYERProduces an identifier that can be used to lookup CD details in the CDPLAYER.INI file, located in the Windows directory.
BASS_CDID_MUSICBRAINZProduces an identifier that can be used to get details on the CD's contents from MusicBrainz.
BASS_CDID_ISRC + trackReturns the International Standard Recording Code of the track... 0 = first track. This might not be available for all CDs.

Return value

If an error occurs, NULL is returned, use BASS_ErrorGetCode to get the error code. If successful, the identification info is returned.

Error codes

BASS_ERROR_DEVICEdrive is invalid.
BASS_ERROR_NOCDThere is no CD in the drive.
BASS_ERROR_ILLPARAMid is invalid.
BASS_ERROR_FILEOPENCould not send command to CDDB server.
BASS_ERROR_NOTAVAILThe CD does not have a UPC, ISRC or CD-TEXT info, or the BASS_CDID_CDDB_READ entry number is not valid.
BASS_ERROR_UNKNOWNSome other mystery problem!

CD-TEXT tags

When requesting CD-TEXT, a series of null-terminated strings is returned (the final string ending in a double null), in the form of "tag=text". The following is a list of all the possible tags. Where <t> is shown, that represents the track number, with "0" being the whole disc/album. For example, "TITLE0" is the album title, while "TITLE1" is the title of the first track.

TITLE<t>The track (or album) title.
PERFORMER<t>The performer(s).
SONGWRITER<t>The song writer(s).
COMPOSER<t>The composer(s).
ARRANGER<t>The arranger(s).
MESSAGE<t>Message.
GENRE<t>Genre.
ISRC<t>International Standard Recording Code (ISRC) of the track... <t> is never 0.
UPCUPC/EAN code of the album.
DISCIDDisc identification information.

Remarks

The returned identification string will remain in memory until the next call to this function, when it will be overwritten by the next result. If you need to keep the contents of an identification string, you should copy it before calling this function again. Exceptions to that are BASS_CDID_CDDB_QUERY and BASS_CDID_CDDB_READ responses, which are cached separately per-drive. A BASS_CDID_CDDB_QUERY response remains cached while the same CD is in the drive, and a BASS_CDID_CDDB_READ response is cached until a different database entry is requested. The CDDB caches are also cleared whenever the CDDB server is changed via the BASS_CONFIG_CD_CDDB_SERVER config option.

When requesting CDDB identification (BASS_CDID_CDDB), the string returned is what should be used in a CDDB query. The command sent to the CDDB server would be "cddb query <the returned string>". If successful, that results in a list of matching CDs, the contents of which can be retrieved using the "cddb read" command. That is what the BASS_CDID_CDDB_QUERY and BASS_CDID_CDDB_READ options do. Details on the format of CDDB requests and responses can be found here: ftp.freedb.org/pub/freedb/latest/CDDBPROTO.

When commands are sent to a CDDB server via the BASS_CDID_CDDB_QUERY and BASS_CDID_CDDB_READ options, CDDB protocol level 6 is used, which means that the responses are (or should be) in UTF-8 form.

Example

List the CD-TEXT info from the CD in the first drive.
char *text=BASS_CD_GetID(0, BASS_CDID_TEXT); // request the CD-TEXT
if (text) // we have got text, display it...
    while (*text) {
        printf("%s\n", text); // display the CD-TEXT entry
        text+=strlen(text)+1; // move on to next entry
    }

See also

BASS_CD_IsReady