using System; using System.IO; using System.Text; namespace NAudio.Midi { /// /// Represents a Sequencer Specific event /// public class SequencerSpecificEvent : MetaEvent { private byte[] data; /// /// Reads a new sequencer specific event from a MIDI stream /// /// The MIDI stream /// The data length public SequencerSpecificEvent(BinaryReader br, int length) { this.data = br.ReadBytes(length); } /// /// Creates a new Sequencer Specific event /// /// The sequencer specific data /// Absolute time of this event public SequencerSpecificEvent(byte[] data, long absoluteTime) : base(MetaEventType.SequencerSpecific, data.Length, absoluteTime) { this.data = data; } /// /// Creates a deep clone of this MIDI event. /// public override MidiEvent Clone() => new SequencerSpecificEvent((byte[])data.Clone(), AbsoluteTime); /// /// The contents of this sequencer specific /// public byte[] Data { get { return this.data; } set { this.data = value; this.metaDataLength = this.data.Length; } } /// /// Describes this MIDI text event /// /// A string describing this event public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append(base.ToString()); sb.Append(" "); foreach (var b in data) { sb.AppendFormat("{0:X2} ", b); } sb.Length--; return sb.ToString(); } /// /// Calls base class export first, then exports the data /// specific to this event /// MidiEvent.Export /// public override void Export(ref long absoluteTime, BinaryWriter writer) { base.Export(ref absoluteTime, writer); writer.Write(data); } } }