CINXE.COM

How does the MusicBrainz calculate CD Index Disc Ids?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head><script type="text/javascript" src="/_static/js/bundle-playback.js?v=HxkREWBo" charset="utf-8"></script> <script type="text/javascript" src="/_static/js/wombat.js?v=txqj7nKC" charset="utf-8"></script> <script>window.RufflePlayer=window.RufflePlayer||{};window.RufflePlayer.config={"autoplay":"on","unmuteOverlay":"hidden"};</script> <script type="text/javascript" src="/_static/js/ruffle/ruffle.js"></script> <script type="text/javascript"> __wm.init("https://web.archive.org/web"); __wm.wombat("http://musicbrainz.org:80/disc.html","20030813231654","https://web.archive.org/","web","/_static/", "1060816614"); </script> <link rel="stylesheet" type="text/css" href="/_static/css/banner-styles.css?v=S1zqJCYt" /> <link rel="stylesheet" type="text/css" href="/_static/css/iconochive.css?v=3PDvdIFv" /> <!-- End Wayback Rewrite JS Include --> <title>How does the MusicBrainz calculate CD Index Disc Ids?</title> <link rel="stylesheet" type="text/css" href="/web/20030813231654cs_/http://musicbrainz.org/brainz.css?t=1055963355"> <link rel="shortcut icon" href="/web/20030813231654im_/http://musicbrainz.org/favicon.ico"> <meta http-equiv="expires" content="1"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> </head> <body> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr> <td class="LogoBarCell"><a href="/web/20030813231654/http://musicbrainz.org/"><img src="/web/20030813231654im_/http://musicbrainz.org/images/header_logo_a.gif" width="614" height="67" alt="" border="0"></a></td> </tr> </table> <p style="display: none"> <a href="#maincontent">Skip to main content &gt;&gt;</a> </p> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr> <td class="NavBarCell"><a href="/web/20030813231654/http://musicbrainz.org/"><img src="/web/20030813231654im_/http://musicbrainz.org/images/header_logo_b.gif" width="98" height="21" alt="" border="0"></a></td> <td class="NavBarCell" align="right" valign="middle"> <span class="topmenu"> <a href="/web/20030813231654/http://musicbrainz.org/search.html">Search</a> | <a href="/web/20030813231654/http://musicbrainz.org/login.html">Login</a> | <a href="/web/20030813231654/http://musicbrainz.org/prefs.html">Prefs</a> | <a href="/web/20030813231654/http://musicbrainz.org/moderate.html">Moderate</a> | <a href="/web/20030813231654/http://musicbrainz.org/download.html">Download</a> | <a href="/web/20030813231654/http://musicbrainz.org/faq.html">FAQ</a> | <a href="https://web.archive.org/web/20030813231654/http://wiki.musicbrainz.org/">Wiki</a> </span>&nbsp; </td> </tr> </table> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td width="141" class="SideBarCell" valign="top"> <table width="141" cellpadding="0" cellspacing="0" border="0"> <tr> <td width="131" height="20" bgcolor="#AAAAAA"><img src="/web/20030813231654im_/http://musicbrainz.org/images/pixel.gif" width="5" height="1" alt="" border="0"> <span class="section">Site Menu</span> </td> <td width="10" rowspan="2" bgcolor="#FFFFFF"><img src="/web/20030813231654im_/http://musicbrainz.org/images/sidemenu_end.gif" width="10" height="20" alt="" border="0"></td> </tr> <tr> <td width="131" height="1" bgcolor="#000000"><img src="/web/20030813231654im_/http://musicbrainz.org/images/pixel.gif" width="1" height="1" alt="" border="0"></td> </tr> </table> <table cellpadding="3" cellspacing="0" border="0" width="131px"> <tr> <td> <script type="text/javascript" src="/web/20030813231654js_/http://musicbrainz.org/scripts/sitemenu.js"></script> <div id="sitemenu"> <div class="sitemenu0"> <div class="menuitem" id="sitemenu1item"> <div class="menurow_c" id="sitemenu1row"> <a class="menunocontrol_c" id="sitemenu1control">&nbsp;</a><a class="menulink" href="/web/20030813231654/http://musicbrainz.org/index.html">Home</a></div></div> <div class="menuitem" id="sitemenu2item"> <div class="menurow_c" id="sitemenu2row"> <span class="menucontrol_c" id="sitemenu2control">&nbsp;</span><a class="menulink" href="/web/20030813231654/http://musicbrainz.org/introduction.html">About</a></div></div> <div class="menuitem" id="sitemenu16item"> <div class="menurow_c" id="sitemenu16row"> <span class="menucontrol_c" id="sitemenu16control">&nbsp;</span><a class="menulink" href="/web/20030813231654/http://musicbrainz.org/news/index.html">News</a></div></div> <div class="menuitem" id="sitemenu35item"> <div class="menurow_c" id="sitemenu35row"> <span class="menucontrol_c" id="sitemenu35control">&nbsp;</span><a class="menulink" href="/web/20030813231654/http://musicbrainz.org/download.html">Products</a></div></div> <div class="menuitem" id="sitemenu57item"> <div class="menurow_c" id="sitemenu57row"> <span class="menucontrol_c" id="sitemenu57control">&nbsp;</span><a class="menulink" href="/web/20030813231654/http://musicbrainz.org/search.html">Search/Browse</a></div></div> <div class="menuitem" id="sitemenu63item"> <div class="menurow_c" id="sitemenu63row"> <span class="menucontrol_c" id="sitemenu63control">&nbsp;</span><a class="menulink" href="/web/20030813231654/http://musicbrainz.org/mod_intro.html">Edit the Data</a></div></div> <div class="menuitem" id="sitemenu152item"> <div class="menurow_c" id="sitemenu152row"> <span class="menucontrol_c" id="sitemenu152control">&nbsp;</span><a class="menulink" href="/web/20030813231654/http://musicbrainz.org/contribute.html">Help Us</a></div></div> <div class="menuitem" id="sitemenu169item"> <div class="menurow_o" id="sitemenu169row"> <a class="menucontrol_o" id="sitemenu169control" href="/web/20030813231654/http://musicbrainz.org/information.html" onclick="return smt(&quot;sitemenu169&quot;)">&nbsp;</a><a class="menulink" href="/web/20030813231654/http://musicbrainz.org/information.html">Support</a></div><div class="submenu_o" id="sitemenu169sub"> <div class="sitemenu1"> <div class="menuitem" id="sitemenu170item"> <div class="menurow_c" id="sitemenu170row"> <a class="menunocontrol_c" id="sitemenu170control">&nbsp;</a><a class="menulink" href="/web/20030813231654/http://musicbrainz.org/faq.html">FAQ</a></div></div> <div class="menuitem" id="sitemenu171item"> <div class="menurow_o" id="sitemenu171row"> <a class="menucontrol_o" id="sitemenu171control" href="/web/20030813231654/http://musicbrainz.org/documentation.html" onclick="return smt(&quot;sitemenu171&quot;)">&nbsp;</a><a class="menulink" href="/web/20030813231654/http://musicbrainz.org/documentation.html">Docs</a></div><div class="submenu_o" id="sitemenu171sub"> <div class="sitemenu2"> <div class="menuitem" id="sitemenu172item"> <div class="menurow_c" id="sitemenu172row"> <a class="menunocontrol_c" id="sitemenu172control">&nbsp;</a><a class="menulink" href="/web/20030813231654/http://musicbrainz.org/documentation.html">Introduction</a></div></div> <div class="menuitem" id="sitemenu173item"> <div class="menurow_c" id="sitemenu173row"> <a class="menunocontrol_c" id="sitemenu173control">&nbsp;</a><a class="menulink" href="/web/20030813231654/http://musicbrainz.org/how.html">How</a></div></div> <div class="menuitem" id="sitemenu174item"> <div class="menurow_c" id="sitemenu174row"> <a class="menunocontrol_c" id="sitemenu174control">&nbsp;</a><a class="menulink" href="/web/20030813231654/http://musicbrainz.org/client_howto.html">Client HOWTO</a></div></div> <div class="menuitem" id="sitemenu175item"> <div class="menurow_c" id="sitemenu175row"> <a class="menunocontrol_c" id="sitemenu175control">&nbsp;</a><a class="menulink" href="/web/20030813231654/http://musicbrainz.org/docs/mb_client/">Client Docs</a></div></div> <div class="menuitem" id="sitemenu176item"> <div class="menurow_c" id="sitemenu176row"> <a class="menunocontrol_c" id="sitemenu176control">&nbsp;</a><a class="menulink" href="/web/20030813231654/http://musicbrainz.org/cd_submission.html">CD Submission</a></div></div> <div class="menuitem" id="sitemenu177item"> <div class="menurow_c" id="sitemenu177row"> <a class="menunocontrol_c" id="sitemenu177control">&nbsp;</a><a class="menulink" href="/web/20030813231654/http://musicbrainz.org/tagger/id-intro.html">About MB IDs</a></div></div> <div class="menuitem" id="sitemenu178item"> <div class="menurow_o" id="sitemenu178row"> <a class="menunocontrol_o" id="sitemenu178control">&nbsp;</a><a class="menulink" href="/web/20030813231654/http://musicbrainz.org/disc.html">About Disc IDs</a></div></div> <div class="menuitem" id="sitemenu179item"> <div class="menurow_c" id="sitemenu179row"> <a class="menunocontrol_c" id="sitemenu179control">&nbsp;</a><a class="menulink" href="/web/20030813231654/http://musicbrainz.org/docs/specs/metadata_tags.html">ID3 Tags</a></div></div> <div class="menuitem" id="sitemenu180item"> <div class="menurow_c" id="sitemenu180row"> <a class="menunocontrol_c" id="sitemenu180control">&nbsp;</a><a class="menulink" href="/web/20030813231654/http://musicbrainz.org/db_structure.html">Database</a></div></div> <div class="menuitem" id="sitemenu181item"> <div class="menurow_c" id="sitemenu181row"> <a class="menunocontrol_c" id="sitemenu181control">&nbsp;</a><a class="menulink" href="/web/20030813231654/http://musicbrainz.org/stats.html">Stats</a></div></div> </div> </div> </div> <div class="menuitem" id="sitemenu182item"> <div class="menurow_c" id="sitemenu182row"> <a class="menunocontrol_c" id="sitemenu182control">&nbsp;</a><a class="menulink" href="/web/20030813231654/http://musicbrainz.org/support/contact.html">Contact Us</a></div></div> <div class="menuitem" id="sitemenu183item"> <div class="menurow_c" id="sitemenu183row"> <a class="menunocontrol_c" id="sitemenu183control">&nbsp;</a><a class="menulink" href="/web/20030813231654/http://musicbrainz.org/list.html">Mailing Lists</a></div></div> <div class="menuitem" id="sitemenu184item"> <div class="menurow_c" id="sitemenu184row"> <a class="menunocontrol_c" id="sitemenu184control">&nbsp;</a><a class="menulink" href="https://web.archive.org/web/20030813231654/http://sourceforge.net/tracker/?func=add&amp;group_id=19506&amp;atid=119506">Report a Bug</a></div></div> </div> </div> </div> <div class="menuitem" id="sitemenu185item"> <div class="menurow_c" id="sitemenu185row"> <a class="menunocontrol_c" id="sitemenu185control">&nbsp;</a><a class="menulink" href="https://web.archive.org/web/20030813231654/http://wiki.musicbrainz.org/">Wiki</a></div></div> </div> </div> </td> </tr> </table> <table width="141" cellpadding="0" cellspacing="0" border="0"> <tr> <td width="131" height="1" bgcolor="#000000"><img src="/web/20030813231654im_/http://musicbrainz.org/images/pixel.gif" width="1" height="1" alt="" border="0"></td> <td width="10" rowspan="3" bgcolor="#FFFFFF"><img src="/web/20030813231654im_/http://musicbrainz.org/images/pixel.gif" width="1" height="1" alt="" border="0"><br><img src="/web/20030813231654im_/http://musicbrainz.org/images/sidemenu_end.gif" width="10" height="20" alt="" border="0"></td> </tr> <tr> <td width="131" height="20" bgcolor="#AAAAAA"><img src="/web/20030813231654im_/http://musicbrainz.org/images/pixel.gif" width="5" height="1" alt="" border="0"> <span class="section"> Quick Search </span> </td> </tr> <tr> <td width="131" height="1" bgcolor="#000000"><img src="/web/20030813231654im_/http://musicbrainz.org/images/pixel.gif" width="1" height="1" alt="" border="0"></td> </tr> </table> <div class="SideBarContentArea"> <div class="SideBarContentArea2"> <table class="SidebarSearch"> <tr> <th>Artist</th> <td> <form method="get" action="/web/20030813231654/http://musicbrainz.org/newsearch.html"> <div> <input type="text" name="search" value=""> <input type="hidden" name="table" value="Artist"> </div> </form> </td> </tr> <tr> <th>Album</th> <td> <form method="get" action="/web/20030813231654/http://musicbrainz.org/newsearch.html"> <div> <input type="text" name="search" value=""> <input type="hidden" name="table" value="Album"> </div> </form> </td> </tr> <tr> <th>Track</th> <td> <form method="get" action="/web/20030813231654/http://musicbrainz.org/newsearch.html"> <div> <input type="text" name="search" value=""> <input type="hidden" name="table" value="Track"> </div> </form> </td> </tr> </table> </div> </div> <table width="141" cellpadding="0" cellspacing="0" border="0"> <tr> <td width="131" height="1" bgcolor="#000000"><img src="/web/20030813231654im_/http://musicbrainz.org/images/pixel.gif" width="1" height="1" alt="" border="0"></td> <td width="10" rowspan="3" bgcolor="#FFFFFF"><img src="/web/20030813231654im_/http://musicbrainz.org/images/pixel.gif" width="1" height="1" alt="" border="0"><br><img src="/web/20030813231654im_/http://musicbrainz.org/images/sidemenu_end.gif" width="10" height="20" alt="" border="0"></td> </tr> <tr> <td width="131" height="20" bgcolor="#AAAAAA"><img src="/web/20030813231654im_/http://musicbrainz.org/images/pixel.gif" width="5" height="1" alt="" border="0"> <span class="section"> Top Moderators </span> </td> </tr> <tr> <td width="131" height="1" bgcolor="#000000"><img src="/web/20030813231654im_/http://musicbrainz.org/images/pixel.gif" width="1" height="1" alt="" border="0"></td> </tr> </table> <div class="SideBarContentArea"> <div class="SideBarContentArea2"> <table cellpadding="2" cellspacing="0" border="0" class="statsb" width="110px"> <tr> <td align="right" valign="top" width="50%" class="statsb"> grendel </td> <td align="left" valign="top" width="50%" class="stats"> 1020 </td> </tr><tr> <td align="right" valign="top" width="50%" class="statsb"> zeroGrav... </td> <td align="left" valign="top" width="50%" class="stats"> 706 </td> </tr><tr> <td align="right" valign="top" width="50%" class="statsb"> Singletoned </td> <td align="left" valign="top" width="50%" class="stats"> 637 </td> </tr><tr> <td align="right" valign="top" width="50%" class="statsb"> doctorblah </td> <td align="left" valign="top" width="50%" class="stats"> 393 </td> </tr><tr> <td align="right" valign="top" width="50%" class="statsb"> secretlo... </td> <td align="left" valign="top" width="50%" class="stats"> 370 </td> </tr> </table> <div class="SideBarMoreLink"> <span class="sidemenusmall"> <a href="/web/20030813231654/http://musicbrainz.org/topmods.html">more &gt;&gt;</a> </span> </div> </div> </div> <table width="141" cellpadding="0" cellspacing="0" border="0"> <tr> <td width="131" height="1" bgcolor="#000000"><img src="/web/20030813231654im_/http://musicbrainz.org/images/pixel.gif" width="1" height="1" alt="" border="0"></td> <td width="10" rowspan="3" bgcolor="#FFFFFF"><img src="/web/20030813231654im_/http://musicbrainz.org/images/pixel.gif" width="1" height="1" alt="" border="0"><br><img src="/web/20030813231654im_/http://musicbrainz.org/images/sidemenu_end.gif" width="10" height="20" alt="" border="0"></td> </tr> <tr> <td width="131" height="20" bgcolor="#AAAAAA"><img src="/web/20030813231654im_/http://musicbrainz.org/images/pixel.gif" width="5" height="1" alt="" border="0"> <span class="section"> Server Stats </span> </td> </tr> <tr> <td width="131" height="1" bgcolor="#000000"><img src="/web/20030813231654im_/http://musicbrainz.org/images/pixel.gif" width="1" height="1" alt="" border="0"></td> </tr> </table> <div class="SideBarContentArea"> <div class="SideBarContentArea2"> <table cellpadding="2" cellspacing="0" border="0" class="statsb" width="110px"> <col style="width: 50%"> <col style="width: 50%"> <tr><td valign="top" align="right" class="statsb">Artists</td><td valign="top" class="stats">58935</td></tr><tr><td valign="top" align="right" class="statsb">Albums</td><td valign="top" class="stats">88928</td></tr><tr><td valign="top" align="right" class="statsb">Tracks</td><td valign="top" class="stats">1100379</td></tr><tr><td valign="top" align="right" class="statsb">Discids</td><td valign="top" class="stats">58578</td></tr><tr><td valign="top" align="right" class="statsb">TRM Ids</td><td valign="top" class="stats">767239</td></tr><tr><td valign="top" align="right" class="statsb">Mods</td><td valign="top" class="stats">442961</td></tr><tr><td valign="top" align="right" class="statsb">Users</td><td valign="top" class="stats">16772</td></tr> </table> <div class="SideBarMoreLink"> <span class="sidemenusmall"> <a href="/web/20030813231654/http://musicbrainz.org/stats.html">more &gt;&gt;</a> </span> </div> </div> </div> <table width="141" cellpadding="0" cellspacing="0" border="0"> <tr> <td width="131" height="1" bgcolor="#000000"><img src="/web/20030813231654im_/http://musicbrainz.org/images/pixel.gif" width="1" height="1" alt="" border="0"></td> <td width="10" rowspan="3" bgcolor="#FFFFFF"><img src="/web/20030813231654im_/http://musicbrainz.org/images/pixel.gif" width="1" height="1" alt="" border="0"><br><img src="/web/20030813231654im_/http://musicbrainz.org/images/sidemenu_end.gif" width="10" height="20" alt="" border="0"></td> </tr> <tr> <td width="131" height="20" bgcolor="#AAAAAA"><img src="/web/20030813231654im_/http://musicbrainz.org/images/pixel.gif" width="5" height="1" alt="" border="0"> <span class="section"> Sponsors </span> </td> </tr> <tr> <td width="131" height="1" bgcolor="#000000"><img src="/web/20030813231654im_/http://musicbrainz.org/images/pixel.gif" width="1" height="1" alt="" border="0"></td> </tr> </table> <div class="SideBarContentArea"> <div class="SideBarContentArea2"> <div style="text-align: center; margin: 1em 0"> <a href="https://web.archive.org/web/20030813231654/http://www.relatable.com/"><img src="/web/20030813231654im_/http://musicbrainz.org/images/relatable.gif" border="0" alt="Relatable" title="Relatable"></a> </div> <div style="text-align: center; margin: 1em 0"> Hosting by: <a href="https://web.archive.org/web/20030813231654/http://www.communitycolo.net/"><img src="/web/20030813231654im_/http://musicbrainz.org/images/cccp.png" border="0" alt="CCCP" title="California Community Colocation Project"></a> </div> <div style="text-align: center; margin: 1em 0"> <form action="https://web.archive.org/web/20030813231654/https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_xclick"> <input type="hidden" name="business" value="donations@musicbrainz.org"> <input type="hidden" name="item_name" value="Donation to MusicBrainz"> <input type="image" src="/web/20030813231654im_/http://musicbrainz.org/images/paypal.gif" style="border: 0" name="submit" alt="Donate to MusicBrainz!"> </form> </div> <div class="SideBarMoreLink"> <span class="sidemenusmall"> <a href="/web/20030813231654/http://musicbrainz.org/sponsors.html">more &gt;&gt;</a> </span> </div> </div> </div> </td> <td bgcolor="FFFFFF" align="left" valign="top"> <table cellpadding="15" cellspacing="0" border="0" width="100%"> <tr> <td align="left" valign="top" class="body" width="100%"> <a id="maincontent"></a> <h1>How does the MusicBrainz calculate CD Index Disc Ids?</h1> <p> Let us first have some words about how data is organized on a CD, going top down. </p> <img src="/web/20030813231654im_/http://musicbrainz.org/images/cdhand.gif" align="left" border="0" alt="a compact disc"> <p> A digital audio compact disc (CD-DA) can hold up to 99 audio tracks. </p> <p> Sampling is done at a rate of 44.1 kHz using 16 bits resolution per channel, thus there are 44100 x 2 bytes x 2 channels (Stereo) = 176400 bytes of PCM data stored per second. </p> <p> This audio data is contained in logical blocks of 2352 bytes each on the CD, holding 2352 / 176400 = 1 / 75 seconds of sound. </p> <p> A logical block plus 882 bytes of error correction and control data forms a raw block of 3234 bytes that is spread among 98 frames of 33 bytes each that are all together written on one spiral track among the CD. </p> <p> At present we can stop at the level of logical blocks for our task. The deeper stuff will be needed in case the CD-Text format becomes popular, which stores extra data (like artist and track information) in the above mentioned control data parts. </p> <p> Now let us have a look at a real world CD-DA. Using a tool like <a href="https://web.archive.org/web/20030813231654/ftp://ftp.freebsd.org/pub/FreeBSD/FreeBSD-current/src/usr.sbin/cdcontrol/cdcontrol.c"> <tt>cdcontrol</tt></a> (FreeBSD) on <a href="/web/20030813231654/http://musicbrainz.org/showalbum.html?discid=MUtMmKN402WPj3_VFsgUelxpc8U-&amp;tracks=15&amp;toc=1+15+325882+150+18791+34817+56500+77156+106244+125879+149935+169035+186060+205979+230292+246809+265764+289629">this CD</a> will yield: </p> <center> <table width="95%" cellspacing="0" cellpadding="10" border="0" bgcolor="#efefff" summary="a closer look at a digital audio CD"> <tr> <td> <pre> marc@oranje$ cdcontrol -f /dev/cd0c info Starting track = 1, ending track = 15, TOC size = 4 bytes track start duration block length type ------------------------------------------------- 1 0:02.00 4:10.41 0 18641 audio 2 4:10.41 3:35.51 18641 16026 audio 3 7:44.17 4:51.08 34667 21683 audio 4 12:33.25 4:37.31 56350 20656 audio 5 17:08.56 6:29.63 77006 29088 audio 6 23:36.44 4:23.60 106094 19635 audio 7 27:58.29 5:22.56 125729 24056 audio 8 33:19.10 4:16.50 149785 19100 audio 9 37:33.60 3:49.00 168885 17025 audio 10 41:20.60 4:27.44 185910 19919 audio 11 45:46.29 5:26.13 205829 24313 audio 12 51:10.42 3:42.17 230142 16517 audio 13 54:50.59 4:14.55 246659 18955 audio 14 59:03.39 5:20.15 265614 23865 audio 15 64:21.54 8:05.28 289479 36253 data 170 72:25.07 - 325732 - - </pre> </td> </tr> </table> </center> <p> This is an example of a CD with an extra track of data (what you know as CD-ROM), marketed in this case as CD-Extra, featuring a video and some pictures. (More precise: this is disc with two sessions, audio and data) </p> <p> You should note the special track 170 (<tt>0xaa</tt>), that marks the beginning of the leadout track, consisting of the remaining blocks on the CD. </p> <p> The CD Index algorithm simply takes the following pieces of data and runs them through the <a href="https://web.archive.org/web/20030813231654/http://www.w3.org/TR/1998/REC-DSig-label/SHA1-1_0">SHA-1</a> hash function: </p> <ul> <li> First track (normally one): 1 byte <li> Last track: 1 byte <li> Leadout track: 4 bytes <li> 99 frame offsets: 4 bytes for each track. If there are less than 99 frame offsets (almost certainly), the value 0 will be used instead. </ul> <p> Before the data is fed through the SHA-1 hash, it is converted to ASCII using </p> <center> <table width="95%" cellspacing="0" cellpadding="10" border="0" bgcolor="#efefff" summary="1 byte hex output"> <tr> <td> <tt>printf("%02X", value);</tt> </td> </tr> </table> </center> <p> for byte values and </p> <center> <table width="95%" cellspacing="0" cellpadding="10" border="0" bgcolor="#efefff" summary="4 byte hex output"> <tr> <td> <tt>printf("%08X", value);</tt> </td> </tr> </table> </center> <p> for 32 bit integer values. </p> <p> Code is a better definition than English, so here is the code that calculates the disc Id: </p> <center> <table width="95%" cellspacing="0" cellpadding="10" border="0" bgcolor="#efefff" summary="CD Index Id algorithm"> <tr> <td> <pre> sprintf(temp, "%02X", pCDInfo-&gt;FirstTrack); sha_update(&amp;sha, (unsigned char*) temp, strlen(temp)); sprintf(temp, "%02X", pCDInfo-&gt;LastTrack); sha_update(&amp;sha, (unsigned char*) temp, strlen(temp)); for (i = 0; i&lt;100; i++) { sprintf(temp, "%08X", pCDInfo-&gt;FrameOffset[i]); sha_update(&amp;sha, (unsigned char*) temp, strlen(temp)); } sha_final(digest, &amp;sha); </pre> </td> </tr> </table> </center> <p> Note that the leadout track is stored in <tt>pCDInfo-&gt;FrameOffset[0]</tt>. </p> <p> The resulting 20 byte SHA-1 signature is converted to a base 64 encoded character ASCII string that is the disc Id. </p> <p> One uses base 64 encoding to map arbitrary bytes onto a string of printable ASCII characters. It does this by redistributing the 24 bits of three 8-bit codes each into four 6-bit codes from a table of 64 very common ASCII characters. </p> <p> Thus we end up with an Id string of 28 characters, in the above example with "MUtMmKN402WPj3_VFsgUelxpc8U-". </p> <p> Note: This base 64 string is not the same one specified in RFC822. The RFC822 spec uses <tt>+</tt>, <tt>/</tt>, and <tt>=</tt> characters, all of which are special HTTP/URL characters. To avoid the problems with dealing with that, I (Rob) used <tt>.</tt>, <tt>_</tt>, and <tt>-</tt>. For details on this, please refer to <tt>base64.c</tt> in the source code. </p> <p> This scheme has the advantage of being very simple (simple to understand, simple to implement) and it is not ambiguous. </p> <p> However, two CDs pressings may not have the same Ids. To handle this case, the CD Index system will let a user check to see if the CD already exists in the system under a different Id. If so, the system creates a new association for the different pressing of the same CD. </p> <p> If you'd like to know more about this, please <a href="download.html">download</a> the client source code and check it out. The code is clean and self documenting. If you are interested in creating other CD Index clients and need the SHA-1 source code, you can either dig through the CD Index source, or check the <a href="https://web.archive.org/web/20030813231654/http://www.w3.org/tr/1998/rec-dsig-label/sha1-1_0">W3C page</a> on SHA-1. </p> <p> Note: The use of the MD5 algorithm has been discontinued in favour of public domain SHA-1. </p> <p> <font size="+1">Links</font> </p> <ul> <li> The How Stuff Works site has a very readable <a href="https://web.archive.org/web/20030813231654/http://howstuffworks.com/cd.htm">introduction</a> on CD technology intended for the technically curious. Written by Marshall Brain. <li> A superb coverage of CDs and formats on a scientific level is given by Prof Kelin J Kuhn from University of Washington. Get the basics lecture <a href="https://web.archive.org/web/20030813231654/http://www.ee.washington.edu/conselec/CE/kuhn/cdaudio/95x6.htm">here</a> and the format/encoding stuff lecture <a href="https://web.archive.org/web/20030813231654/http://www.ee.washington.edu/conselec/CE/kuhn/cdaudio2/95x7.htm">here</a>. <li> There is actually a very fine <a href="https://web.archive.org/web/20030813231654/http://www.fadden.com/cdrfaq">FAQ about toasting</a> available that has lots of interesting facts. Written by Andy McFadden. <li> Find out more about how CD-DA and CD-ROM formats have been enhanced through <a href="https://web.archive.org/web/20030813231654/http://www.discmfg.com/PDF/enhanced.pdf">this</a> PDF document provided by Cinram. <li> Another introduction from Kelin Kuhn can be found <a href="https://web.archive.org/web/20030813231654/http://www.ee.washington.edu/class/ConsElec/cd.html">here</a>, again at University of Washington Electrical Engineering. <!--<li> The folks over at Hewlett-Packard have <a href="http://www.hp.com/isgsupport/cdr/devkit/techover.htm">these</a> technical bits for you.--> </ul> <div style="margin-top: 1em">&nbsp;</div> </td> </tr> </table> </td> </tr> </table> <div id="FooterBar"> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td width="10%"> &nbsp; </td> <td width="15%"> <a href="https://web.archive.org/web/20030813231654/http://www.creativecommons.org/">Creative Commons</a> </td> <td width="15%"> <a href="https://web.archive.org/web/20030813231654/http://www.eff.org/"><abbr title="Electronic Frontier Foundation">EFF</abbr></a> </td> <td width="15%"> <a href="https://web.archive.org/web/20030813231654/http://www.gnu.org/copyleft/gpl.html"><abbr title="General Public License">GPL</abbr></a> </td> <td width="15%"> <a href="https://web.archive.org/web/20030813231654/http://www.gnu.org/copyleft/lesser.html"><abbr title="Lesser General Public License">LGPL</abbr></a> </td> <td width="15%"> <a href="https://web.archive.org/web/20030813231654/http://www.freshmeat.net/">Freshmeat</a> </td> <td width="10%"> &nbsp; </td> </tr> </table> </div> <div id="CreditsBar"> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td width="30%" style="text-align: left"> <a href="/web/20030813231654/http://musicbrainz.org/support/contact.html">contact details</a> </td> <td width="40%" style="text-align: center"> original design|<a href="https://web.archive.org/web/20030813231654/http://vacubomb.com/">vacubomb.com</a> </td> <td width="30%" style="text-align: right"> server version: 2003-07-25 </td> </tr> </table> </div> </body> </html> <!-- FILE ARCHIVED ON 23:16:54 Aug 13, 2003 AND RETRIEVED FROM THE INTERNET ARCHIVE ON 08:22:07 Dec 11, 2024. JAVASCRIPT APPENDED BY WAYBACK MACHINE, COPYRIGHT INTERNET ARCHIVE. ALL OTHER CONTENT MAY ALSO BE PROTECTED BY COPYRIGHT (17 U.S.C. SECTION 108(a)(3)). --> <!-- playback timings (ms): captures_list: 0.692 exclusion.robots: 0.052 exclusion.robots.policy: 0.037 esindex: 0.012 cdx.remote: 5.144 LoadShardBlock: 168.495 (3) PetaboxLoader3.datanode: 130.487 (4) PetaboxLoader3.resolve: 204.112 (3) load_resource: 219.309 -->

Pages: 1 2 3 4 5 6 7 8 9 10