Table of Contents

Class MidiEvent

Namespace
NAudio.Midi
Assembly
NAudio.Midi.dll

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

absoluteTime long

Absolute time of this event

channel int

MIDI channel number

commandCode MidiCommandCode

MIDI command code

Properties

AbsoluteTime

The absolute time for this event

public long AbsoluteTime { get; set; }

Property Value

long

Channel

The MIDI Channel Number for this event (1-16)

public virtual int Channel { get; set; }

Property Value

int

CommandCode

The command code for this event

public MidiCommandCode CommandCode { get; }

Property Value

MidiCommandCode

DeltaTime

The Delta time for this event

public int DeltaTime { get; }

Property Value

int

Methods

Clone()

Creates a deep clone of this MIDI event.

public virtual MidiEvent Clone()

Returns

MidiEvent

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

absoluteTime long

Absolute time used to calculate delta. Is updated ready for the next delta calculation

writer BinaryWriter

Stream 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

rawMessage int

The 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

midiEvent MidiEvent

Returns

bool

IsNoteOff(MidiEvent)

Whether this is a note off event

public static bool IsNoteOff(MidiEvent midiEvent)

Parameters

midiEvent MidiEvent

Returns

bool

IsNoteOn(MidiEvent)

Whether this is a note on event

public static bool IsNoteOn(MidiEvent midiEvent)

Parameters

midiEvent MidiEvent

Returns

bool

ReadNextEvent(BinaryReader, MidiEvent)

Constructs a MidiEvent from a BinaryStream

public static MidiEvent ReadNextEvent(BinaryReader br, MidiEvent previous)

Parameters

br BinaryReader

The binary stream of MIDI data

previous MidiEvent

The 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

br BinaryReader

The 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

writer BinaryWriter

Binary stream

value int

The value to write