/// <summary> /// Gets the id for this disc based on the total length of all tracks /// </summary> /// <returns>The disc id as an unsigned long integer</returns> /// <remarks>For backward compatibility this algorithm must not change. /// This algorithm is based on the freedb.org reference at www.freedb.org/.... /// </remarks> public static ulong GetDiscId(CDTableOfContents toc) { int numberOfTracks = toc.NumberOfTracks -1; int index = 0; ulong offset = 0, sum = 0; //int other = 0xff; // = 255 for(index = 0; index < toc.NumberOfTracks; index++) { sum = sum + GetTocSum(Convert.ToUInt64((toc.Minutes[index] * 60) + toc.Seconds[index])); } offset = Convert.ToUInt64( ((toc.Minutes[numberOfTracks] * 60) + toc.Seconds[numberOfTracks]) - ((toc.Minutes[0] * 60) + toc.Seconds[0]) ); return Convert.ToUInt64( ((sum % 0xff) << 24) | (offset << 8) | Convert.ToUInt64(toc.NumberOfTracks) ); //return (ulong)( ((sum % 0xFF) << 24) | (offset << 8) | ((ulong)toc.NumberOfTracks) ); }
public Disc(CDTableOfContents toc) { this.toc = toc; this.id = Disc.GetDiscId(toc); }