using System.IO;
using System.Text;
namespace NAudio.Midi
{
///
/// Represents a MIDI meta event with raw data
///
public class RawMetaEvent : MetaEvent
{
///
/// Raw data contained in the meta event
///
public byte[] Data { get; set; }
///
/// Creates a meta event with raw data
///
public RawMetaEvent(MetaEventType metaEventType, long absoluteTime, byte[] data) : base(metaEventType, data?.Length ?? 0, absoluteTime)
{
Data = data;
}
///
/// Creates a deep clone of this MIDI event.
///
public override MidiEvent Clone() => new RawMetaEvent(MetaEventType, AbsoluteTime, (byte[])Data?.Clone());
///
/// Describes this meta event
///
public override string ToString()
{
var sb = new StringBuilder().Append(base.ToString());
foreach (var b in Data)
sb.AppendFormat(" {0:X2}", b);
return sb.ToString();
}
///
///
///
public override void Export(ref long absoluteTime, BinaryWriter writer)
{
base.Export(ref absoluteTime, writer);
if (Data == null) return;
writer.Write(Data, 0, Data.Length);
}
}
}