|
static MidiEvent | FromRawMessage (int rawMessage) |
| Converts a raw MIDI message to a MidiEvent object.
|
|
static MidiEvent | ReadNextEvent (BinaryReader br, MidiEvent previous) |
| Reads the next MIDI event from the BinaryReader and returns the corresponding MidiEvent.
|
|
static bool | IsNoteOff (MidiEvent midiEvent) |
| Checks if the given MIDI event represents a Note Off message.
|
|
static bool | IsNoteOn (MidiEvent midiEvent) |
| Checks if the provided MIDI event is a Note On event and returns true if the velocity is greater than 0.
|
|
static bool | IsEndTrack (MidiEvent midiEvent) |
| Checks if the provided MIDI event is an end track event.
|
|
static int | ReadVarInt (BinaryReader br) |
| Reads a variable-length encoded integer from the provided BinaryReader and returns the result.
|
|
static void | WriteVarInt (BinaryWriter writer, int value) |
| Writes a variable-length encoded integer to the specified BinaryWriter.
|
|
Represents an individual MIDI event.
virtual void NAudio.Midi.MidiEvent.Export |
( |
ref long | absoluteTime, |
|
|
BinaryWriter | writer ) |
|
inlinevirtual |
Exports the MIDI event and updates the absolute time.
- Parameters
-
absoluteTime | The absolute time of the event. |
writer | The BinaryWriter to write the event to. |
- Exceptions
-
FormatException | Thrown when the event is unsorted. |
This method exports the MIDI event to the specified BinaryWriter and updates the absolute time. If the event's absolute time is less than the specified absolute time, a FormatException is thrown with the message "Can't export unsorted MIDI events". The method then writes the variable-length quantity representing the time difference to the writer, updates the absolute time, and writes the event data to the writer.
Reimplemented in NAudio.Midi.ChannelAfterTouchEvent, NAudio.Midi.ControlChangeEvent, NAudio.Midi.KeySignatureEvent, NAudio.Midi.MetaEvent, NAudio.Midi.NoteEvent, NAudio.Midi.PatchChangeEvent, NAudio.Midi.PitchWheelChangeEvent, NAudio.Midi.RawMetaEvent, NAudio.Midi.SequencerSpecificEvent, NAudio.Midi.SmpteOffsetEvent, NAudio.Midi.SysexEvent, NAudio.Midi.TempoEvent, NAudio.Midi.TextEvent, NAudio.Midi.TimeSignatureEvent, and NAudio.Midi.TrackSequenceNumberEvent.
static MidiEvent NAudio.Midi.MidiEvent.FromRawMessage |
( |
int | rawMessage | ) |
|
|
inlinestatic |
Converts a raw MIDI message to a MidiEvent object.
- Parameters
-
rawMessage | The raw MIDI message to be converted. |
- Returns
- A MidiEvent object representing the raw MIDI message.
This method parses the raw MIDI message and constructs a corresponding MidiEvent object. It extracts the command code, channel, and data bytes from the raw message and creates the appropriate MidiEvent based on the command code. If the command code is NoteOn, NoteOff, or KeyAfterTouch and the data2 value is greater than 0, it creates a NoteOnEvent; otherwise, it creates a NoteEvent. For ControlChange, PatchChange, ChannelAfterTouch, and PitchWheelChange command codes, it creates the corresponding events with the extracted data values. For other command codes, it throws a FormatException indicating an unsupported MIDI Command Code for the raw message.
- Exceptions
-
FormatException | Thrown when the raw message contains an unsupported MIDI Command Code. |
static bool NAudio.Midi.MidiEvent.IsNoteOff |
( |
MidiEvent | midiEvent | ) |
|
|
inlinestatic |
Checks if the given MIDI event represents a Note Off message.
- Parameters
-
midiEvent | The MIDI event to be checked. |
- Returns
- True if the MIDI event represents a Note Off message; otherwise, false.
This method checks if the provided midiEvent is not null and if its command code is NoteOn. If the command code is NoteOn, it further checks if the velocity of the NoteEvent is 0 and returns true. If the command code is not NoteOn, it directly checks if the command code is NoteOff and returns the result. If the provided midiEvent is null, it returns false.
static MidiEvent NAudio.Midi.MidiEvent.ReadNextEvent |
( |
BinaryReader | br, |
|
|
MidiEvent | previous ) |
|
inlinestatic |
Reads the next MIDI event from the BinaryReader and returns the corresponding MidiEvent.
- Parameters
-
br | The BinaryReader used to read the MIDI data. |
previous | The previous MidiEvent, used to determine running status. |
- Returns
- The MidiEvent read from the BinaryReader.
This method reads the next MIDI event from the BinaryReader and returns the corresponding MidiEvent. It first reads the delta time using the ReadVarInt method, then determines the command code and channel based on the MIDI data. Depending on the command code, it creates a specific type of MidiEvent (e.g., NoteOnEvent, NoteOffEvent, ControlChangeEvent) using the BinaryReader. If the command code is not supported, it throws a FormatException with a message indicating the unsupported MIDI Command Code. The created MidiEvent is then populated with the channel, delta time, and command code before being returned.
- Exceptions
-
FormatException | Thrown when the MIDI Command Code is not supported. |
override string NAudio.Midi.MidiEvent.ToString |
( |
| ) |
|
|
inline |
Returns a string representation of the current Midi event.
- Returns
- A string representing the Midi event. If the commandCode is greater than or equal to MidiCommandCode.Sysex, the string contains the absoluteTime and the commandCode. Otherwise, the string contains the absoluteTime, the commandCode, and the channel.
This method returns a string representation of the current Midi event. If the commandCode is greater than or equal to MidiCommandCode.Sysex, the string contains the absoluteTime and the commandCode. Otherwise, the string contains the absoluteTime, the commandCode, and the channel.