Class MidiUtils
- Namespace
- SpessaSharp.MIDI.Utils
- Assembly
- SpessaSharp.dll
A general purpose class for handling MIDI messages.
public static class MidiUtils
- Inheritance
-
MidiUtils
- Inherited Members
Fields
GsDataMinLen
public const int GsDataMinLen = 9
Field Value
XgDataMinLen
public const int XgDataMinLen = 7
Field Value
Methods
AnalyzeNRPN(int, int, int)
Analyzes a MIDI Non-Registered Parameter Number and returns an identification and data for it.
public static MidiUtils.AnalyzedParameter AnalyzeNRPN(int channel, int nrpn, int value)
Parameters
channelintThe MIDI channel number.
nrpnintThe 14-bit NRPN number.
valueintThe 14-bit value for that number.
Returns
AnalyzeRPN(int, int, int)
Analyzes a MIDI Registered Parameter Number and returns an identification and data for it.
public static MidiUtils.AnalyzedParameter AnalyzeRPN(int channel, int rpn, int value)
Parameters
channelintThe MIDI channel number.
rpnintThe 14-bit RPN number.
valueintThe 14-bit value for that number.
Returns
AnalyzeSysEx(MidiMessage)
Analyzes a MIDI System Exclusive message and returns an identification and data for it.
public static MidiUtils.AnalyzedMessage AnalyzeSysEx(MidiMessage e)
Parameters
eMidiMessageThe message to analyze
Returns
AnalyzeSysEx(ReadOnlySpan<byte>)
Analyzes a MIDI System Exclusive message and returns an identification and data for it.
public static MidiUtils.AnalyzedMessage AnalyzeSysEx(ReadOnlySpan<byte> syx)
Parameters
syxReadOnlySpan<byte>The System Exclusive message, WITHOUT the first 0xF0 System Exclusive byte!
Returns
ChannelToSyx(int)
Channel number to GS/XG "part number"
public static int ChannelToSyx(int chan)
Parameters
chanint
Returns
DeviceControl(int, ReadOnlySpan<byte>)
Gets a raw Device Control System Exclusive message bytes, without the 0xF0 status byte.
public static byte[] DeviceControl(int subID, ReadOnlySpan<byte> data)
Parameters
subIDintThe sub ID.
dataReadOnlySpan<byte>Data, can be multiple bytes.
Returns
- byte[]
DeviceControlMessage(int, int, ReadOnlySpan<byte>)
Gets a Device Control System Exclusive MIDI message.
public static MidiMessage DeviceControlMessage(int ticks, int subID, ReadOnlySpan<byte> data)
Parameters
ticksintThe tick time of the message.
subIDintThe sub ID.
dataReadOnlySpan<byte>Data, can be multiple bytes.
Returns
Gs(int, int, int, byte)
public static byte[] Gs(int a1, int a2, int a3, byte data)
Parameters
Returns
- byte[]
Gs(int, int, int, byte, byte)
public static byte[] Gs(int a1, int a2, int a3, byte data1, byte data2)
Parameters
Returns
- byte[]
Gs(int, int, int, ReadOnlySpan<byte>, Span<byte>)
Gets raw GS System Exclusive message, without the 0xF0 status byte.
public static ReadOnlySpan<byte> Gs(int a1, int a2, int a3, ReadOnlySpan<byte> data, Span<byte> result)
Parameters
a1intAddress 1
a2intAddress 2
a3intAddress 3
dataReadOnlySpan<byte>Data, can be multiple bytes.
resultSpan<byte>The final output, whose len must be GsDataMinLen + data.Length
Returns
- ReadOnlySpan<byte>
The same result provided for convenience
Exceptions
GsMessage(int, int, int, int, ReadOnlySpan<byte>)
Sends a GS System Exclusive address
public static MidiMessage GsMessage(int ticks, int a1, int a2, int a3, ReadOnlySpan<byte> data)
Parameters
ticksinta1intAddress 1
a2intAddress 2
a3intAddress 3
dataReadOnlySpan<byte>Data, can be multiple bytes
Returns
Reset(int, System)
Gets a selected reset System Exclusive MIDI message.
public static MidiMessage Reset(int ticks, Midi.System system)
Parameters
Returns
Set(int, System, GlobalMidiParameter)
Returns a list of MIDI events needed to set the given parameter.
public static MidiMessage[] Set(int ticks, Midi.System system, GlobalMidiParameter parameter)
Parameters
ticksintThe ticks for all events.
systemMidi.SystemIf the message has multiple ways of setting it, this selects the preferred way. Otherwise, it prefers Universal (GM).
parameterGlobalMidiParameterThe parameter and value to set.
Returns
- MidiMessage[]
The list of MIDIMessages that set the parameter.
Set(int, int, System, ChannelMidiParameter)
Returns a list of MIDI events needed to set the given parameter.
public static MidiMessage[] Set(int ticks, int channel, Midi.System system, ChannelMidiParameter parameter)
Parameters
ticksintThe ticks for all events.
channelintThe channel number.
systemMidi.SystemIf the message has multiple ways of setting it, this selects the preferred way. Otherwise, it prefers Universal (GM).
parameterChannelMidiParameterThe parameter and value to set.
Returns
- MidiMessage[]
The list of MIDIMessages that set the parameter.
Syx(int, ReadOnlySpan<byte>)
Turns raw SysEx bytes (without the 0xF0 status byte) into a MIDIMessage.
public static MidiMessage Syx(int ticks, ReadOnlySpan<byte> data)
Parameters
ticksintThe tick time of the message.
dataReadOnlySpan<byte>The data for the message, without the 0xF0 status byte.
Returns
SyxToChannel(int)
GS/XG "part number" to channel number.
public static int SyxToChannel(int part)
Parameters
partint
Returns
Xg(int, int, int, ReadOnlySpan<byte>, Span<byte>)
Gets raw XG System Exclusive message bytes, without the 0xF0 status byte.
public static Span<byte> Xg(int a1, int a2, int a3, ReadOnlySpan<byte> data, Span<byte> result)
Parameters
a1intAddress 1
a2intAddress 2
a3intAddress 3
dataReadOnlySpan<byte>Data, can be multiple bytes.
resultSpan<byte>
Returns
XgMessage(int, int, int, int, ReadOnlySpan<byte>)
Gets a XG System Exclusive MIDI message
public static MidiMessage XgMessage(int ticks, int a1, int a2, int a3, ReadOnlySpan<byte> data)
Parameters
ticksintThe tick time of the message.
a1intAddress 1
a2intAddress 2
a3intAddress 3
dataReadOnlySpan<byte>Data, can be multiple bytes