How Open CD Index identifies a CD
Audio CDs do not contain a code which can be used to identify them, that's why in CDDB and freedb.org CD data archives were (and still is) used the infamous CDDBID: a 8 hex digits checksum computed from the offset of each track of the CD.
Unfortunately this CDDBID checksum has 2 major problems:
- It happens that 2 different CDs share the same CDDBID
- It happens that some CD readers read the same CD with tracks offset displaced (usually of 75 or 150 frames)
To do that we decided to use a checksum to identify each CD in the index, based on data available in freeddb.org: CD tracks offsets, number of tracks in the CD and total length in seconds of the CD (all those data are available in freedb.org archive).
To overcome the problem of the CD readers which read the same CD reporting different offsets, we decided to use not the absolute offsets but the difference of sequential offsets, basically the length of the tracks. In this way even if one CD reader reports as first track offset 0 and another 150, since all the tracks in the second reader will be displaced of 150 frames, the difference between them will be the same.
Unfortunately freedb.org data reports only tracks beginning offsets, so we are not able to compute last track of the CD length in frames (we could compute it in seconds, but it's not enough accurate), and this means that this method will work only for CDs with at least 2 tracks on.
This is why Open CD Index does NOT accept submissions of CDs with less than 2 tracks.
Other know limits
We also find out that while in music CDs this method works well, there is a cathegory of Audio CDs where more CDs with different contents can have the very same structure: audiobooks.
Many audiobooks with different contents are edited with the same number of tracks of the same exact length. In this case Open CD Index (as well as freedb.org and other CD databases) is unable to distinguish them.
How to compute CD ID
To compute CDID you need the following info from the CD:
- Total number of tracks on the CD
- Length in CD frames of all the tracks but the last one
- Total length of the CD in seconds
A PHP sample
Here follows a PHP snippet where we compute CD ID of a 18 tracks CD knowing number of tracks, tracks offsets and total CD length in seconds.
// Input data
$nTracks=18; // 18 tracks on the CD
$iSeconds=2691; // Total CD length: 2691 seconds = 44 minutes and 51 seconds
echo "CDID: $cdid"
This snippet will output: