Class MidiEvent
Represents an individual MIDI event
public class MidiEvent : ICloneable
- Inheritance
-
MidiEvent
- Implements
- Derived
- Inherited Members
Constructors
MidiEvent()
Default constructor
protected MidiEvent()
MidiEvent(long, int, MidiCommandCode)
Creates a MIDI event with specified parameters
public MidiEvent(long absoluteTime, int channel, MidiCommandCode commandCode)
Parameters
absoluteTimelongAbsolute time of this event
channelintMIDI channel number
commandCodeMidiCommandCodeMIDI command code
Properties
AbsoluteTime
The absolute time for this event
public long AbsoluteTime { get; set; }
Property Value
Channel
The MIDI Channel Number for this event (1-16)
public virtual int Channel { get; set; }
Property Value
CommandCode
The command code for this event
public MidiCommandCode CommandCode { get; }
Property Value
DeltaTime
The Delta time for this event
public int DeltaTime { get; }
Property Value
Methods
Clone()
Creates a deep clone of this MIDI event.
public virtual MidiEvent Clone()
Returns
Export(ref long, BinaryWriter)
Exports this MIDI event's data Overriden in derived classes, but they should call this version
public virtual void Export(ref long absoluteTime, BinaryWriter writer)
Parameters
absoluteTimelongAbsolute time used to calculate delta. Is updated ready for the next delta calculation
writerBinaryWriterStream to write to
FromRawMessage(int)
Creates a MidiEvent from a raw message received using the MME MIDI In APIs
public static MidiEvent FromRawMessage(int rawMessage)
Parameters
rawMessageintThe short MIDI message
Returns
- MidiEvent
A new MIDI Event
GetAsShortMessage()
Converts this MIDI event to a short message (32 bit integer) that can be sent by the Windows MIDI out short message APIs Cannot be implemented for all MIDI messages
public virtual int GetAsShortMessage()
Returns
- int
A short message
IsEndTrack(MidiEvent)
Determines if this is an end track event
public static bool IsEndTrack(MidiEvent midiEvent)
Parameters
midiEventMidiEvent
Returns
IsNoteOff(MidiEvent)
Whether this is a note off event
public static bool IsNoteOff(MidiEvent midiEvent)
Parameters
midiEventMidiEvent
Returns
IsNoteOn(MidiEvent)
Whether this is a note on event
public static bool IsNoteOn(MidiEvent midiEvent)
Parameters
midiEventMidiEvent
Returns
ReadNextEvent(BinaryReader, MidiEvent)
Constructs a MidiEvent from a BinaryStream
public static MidiEvent ReadNextEvent(BinaryReader br, MidiEvent previous)
Parameters
brBinaryReaderThe binary stream of MIDI data
previousMidiEventThe previous channel-voice MIDI event used to resolve running status. Pass null if no channel-voice event has been read yet; meta and sysex events do not update running status and should not be passed here.
Returns
- MidiEvent
A new MidiEvent
ReadVarInt(BinaryReader)
Utility function that can read a variable length integer from a binary stream
public static int ReadVarInt(BinaryReader br)
Parameters
brBinaryReaderThe binary stream
Returns
- int
The integer read
ToString()
Displays a summary of the MIDI event
public override string ToString()
Returns
- string
A string containing a brief description of this MIDI event
WriteVarInt(BinaryWriter, int)
Writes a variable length integer to a binary stream
public static void WriteVarInt(BinaryWriter writer, int value)
Parameters
writerBinaryWriterBinary stream
valueintThe value to write