/// <summary> /// Parses the binary metadata from the flac file into a CueSheet object. /// </summary> /// <param name="data">The binary data from the flac file.</param> public override void LoadBlockData(byte[] data) { this.mediaCatalog = Encoding.ASCII.GetString(data, 0, 128).Trim(new char[] { '\0' }); this.leadInSampleCount = BinaryDataHelper.GetUInt64(data, 128); this.isCDCueSheet = BinaryDataHelper.GetBoolean(data, 136, 0); // We're skipping 7 bits + 258 bytes which is reserved null data byte trackCount = data[395]; if (trackCount > 100) { // Do we really need to throw an exception here? throw new Exceptions.FlacLibSharpInvalidFormatException(string.Format("CueSheet has invalid track count {0}. Cannot be more than 100.", trackCount)); } int cueSheetTrackOffset = 396; for (int i = 0; i < trackCount; i++) { CueSheetTrack newTrack = new CueSheetTrack(data, cueSheetTrackOffset); cueSheetTrackOffset += 36 + (12 * newTrack.IndexPointCount); // 36 bytes for the cueSheetTrack and 12 bytes per index point ... this.Tracks.Add(newTrack); } }
/// <summary> /// Parses the binary metadata from the flac file into a CueSheet object. /// </summary> /// <param name="data">The binary data from the flac file.</param> public override void LoadBlockData(byte[] data) { this.mediaCatalog = Encoding.ASCII.GetString(data, 0, 128).Trim(new char[]{ '\0' }); this.leadInSampleCount = BinaryDataHelper.GetUInt64(data, 128); this.isCDCueSheet = BinaryDataHelper.GetBoolean(data, 136, 0); // We're skipping 7 bits + 258 bytes which is reserved null data byte trackCount = data[395]; if (trackCount > 100) { // Do we really need to throw an exception here? throw new Exceptions.FlacLibSharpInvalidFormatException(string.Format("CueSheet has invalid track count {0}. Cannot be more than 100.", trackCount)); } int cueSheetTrackOffset = 396; for (int i = 0; i < trackCount; i++) { CueSheetTrack newTrack = new CueSheetTrack(data, cueSheetTrackOffset); cueSheetTrackOffset += 36 + (12 * newTrack.IndexPointCount); // 36 bytes for the cueSheetTrack and 12 bytes per index point ... this.Tracks.Add(newTrack); } }