Пример #1
0
        /// <summary>
        /// Writes the data representing this CueSheet track to the given stream.
        /// </summary>
        /// <param name="targetStream"></param>
        public void WriteBlockData(Stream targetStream)
        {
            targetStream.Write(BinaryDataHelper.GetBytesUInt64(this.trackOffset), 0, 8);
            targetStream.WriteByte(this.TrackNumber);
            targetStream.Write(BinaryDataHelper.GetPaddedAsciiBytes(this.isrc, ISRC_LENGTH), 0, ISRC_LENGTH);

            byte trackAndEmphasis = 0;

            if (this.IsAudioTrack)
            {
                trackAndEmphasis += 0x80; // Most significant bit to 1
            }
            if (this.IsPreEmphasis)
            {
                trackAndEmphasis += 0x40; // Second most significant bit to 1
            }
            targetStream.WriteByte(trackAndEmphasis);

            byte[] nullData = new byte[RESERVED_NULLDATA_LENGTH];
            targetStream.Write(nullData, 0, nullData.Length);

            targetStream.WriteByte(this.IndexPointCount);

            foreach (var indexPoint in this.IndexPoints)
            {
                indexPoint.WriteBlockData(targetStream);
            }
        }
Пример #2
0
        /// <summary>
        /// Will write the data representing this CueSheet track index point to the given stream.
        /// </summary>
        /// <param name="targetStream"></param>
        public void WriteBlockData(Stream targetStream)
        {
            targetStream.Write(BinaryDataHelper.GetBytesUInt64(this.offset), 0, 8);
            targetStream.WriteByte(this.indexPointNumber);

            byte[] nullData = new byte[RESERVED_NULLDATA_LENGTH];
            targetStream.Write(nullData, 0, nullData.Length);
        }
Пример #3
0
        /// <summary>
        /// Will write the data describing this metadata block to the given stream.
        /// </summary>
        /// <param name="targetStream">Stream to write the data to.</param>
        public override void WriteBlockData(Stream targetStream)
        {
            if (this.Tracks.Count > 0)
            {
                var lastTrack = this.Tracks[this.Tracks.Count - 1];
                if (!lastTrack.IsLeadOut)
                {
                    throw new FlacLibSharp.Exceptions.FlacLibSharpInvalidFormatException(string.Format("CueSheet is invalid, last track (nr {0}) is not the lead-out track.", lastTrack.TrackNumber));
                }
            }
            else
            {
                throw new FlacLibSharp.Exceptions.FlacLibSharpInvalidFormatException("CueSheet is invalid as it has no tracks, it must have at least one track (the lead-out track).");
            }

            // TODO: this value in the header should also update when someone add/removes tracks or track index points ...
            this.Header.MetaDataBlockLength = CalculateMetaDataBlockLength();
            this.Header.WriteHeaderData(targetStream);

            targetStream.Write(BinaryDataHelper.GetPaddedAsciiBytes(this.MediaCatalog, MEDIACATALOG_MAX_LENGTH), 0, MEDIACATALOG_MAX_LENGTH);
            targetStream.Write(BinaryDataHelper.GetBytesUInt64(this.LeadInSampleCount), 0, 8);

            byte isCDCueSheet = 0;

            if (this.isCDCueSheet)
            {
                isCDCueSheet = 0x80; // Most significant bit should be 1
            }
            targetStream.WriteByte(isCDCueSheet);

            // Now we need to write 258 bytes of 0 data ("reserved")
            byte[] nullData = new byte[RESERVED_NULLDATA_LENGTH];
            targetStream.Write(nullData, 0, nullData.Length);

            // The number of tracks i 1 byte in size ...
            targetStream.WriteByte(this.TrackCount);

            foreach (var track in Tracks)
            {
                track.WriteBlockData(targetStream);
            }
        }
Пример #4
0
 /// <summary>
 /// Writes the data representing this SeekPoint to the given stream.
 /// </summary>
 /// <param name="targetStream"></param>
 public void WriteData(Stream targetStream)
 {
     targetStream.Write(BinaryDataHelper.GetBytesUInt64(this.firstSampleNumber), 0, 8);
     targetStream.Write(BinaryDataHelper.GetBytesUInt64(this.byteOffset), 0, 8);
     targetStream.Write(BinaryDataHelper.GetBytesUInt16(this.numberOfSamples), 0, 2);
 }