/// <summary> /// Queries the AccurateRip database for the CRCs of the tracks on the specified CD /// </summary> /// <param name="totalLengthSeconds"> /// Total length of the CD (from the beginning of the first track to the end of the /// last track) in seconds /// </param> /// <param name="trackOffsetsSeconds"> /// Offsets of the individual tracks on the CD in seconds /// </param> /// <returns></returns> public static Request <CdInfo[]> QueryDatabase( int totalLengthSeconds, int[] trackOffsetsSeconds ) { try { // Calculate the three IDs required by a query to the AccurateRip database. AccurateRip // improves (marginally) on the flawed CDDB disc id by providing two additional ids, // however, this doesn't hurt AccurateRip nearly as much as it would a CDDB service. int discId1 = CalculateDiscId1(trackOffsetsSeconds); int discId2 = CalculateDiscId2(trackOffsetsSeconds); int cddbDiscId = Cddb.CalculateDiscId(totalLengthSeconds, trackOffsetsSeconds); int trackCount = trackOffsetsSeconds.Length; return(QueryDatabase(discId1, discId2, cddbDiscId, trackCount)); } catch (Exception exception) { return(Request <CdInfo[]> .CreateFailedDummy(exception)); } }
/// <summary>Sends the query to the CDDB server</summary> private void sendQuery() { StringBuilder builder = new StringBuilder(192); // Build the initial query string consisting of the command, CDDB disc id // and the number of tracks on the CD builder.AppendFormat( "cddb query {0:x8} {1} ", Cddb.CalculateDiscId(this.discLengthSeconds, this.trackOffsetsSeconds), this.trackOffsetsSeconds.Length ); // Append the start offsets for(int index = 0; index < this.trackOffsetsSeconds.Length; ++index) { builder.AppendFormat("{0} ", this.trackOffsetsSeconds[index] * 75); } builder.Append(this.discLengthSeconds); this.protocol.SendLine(builder.ToString(), 5000); }