reckfellENGINE

InputEventMidi

Represents a MIDI message from a MIDI device, such as a musical keyboard.

On this page
class InputEventMidiReckfellSharpInherits InputEvent

Represents a MIDI message from a MIDI device, such as a musical keyboard.

InputEventMIDI stores information about messages from MIDI(https://en.wikipedia.org/wiki/MIDI) (Musical Instrument Digital Interface) devices. These may include musical keyboards, synthesizers, and drum machines. MIDI messages can be received over a 5-pin MIDI connector or over USB. If your device supports both be sure to check the settings in the device to see which output it is using. By default, Reckfell does not detect MIDI devices. You need to call OS.OpenMidiInputs, first. You can check which devices are detected with OS.GetConnectedMidiInputs, and close the connection with OS.CloseMidiInputs.

C#
public override void _Ready()
{
    OS.OpenMidiInputs();
    ReckfellApi.Print(OS.GetConnectedMidiInputs());
}

public override void _Input(InputEvent inputEvent)
{
    if (inputEvent is InputEventMidi midiEvent)
    {
        PrintMIDIInfo(midiEvent);
    }
}

private void PrintMIDIInfo(InputEventMidi midiEvent)
{
    ReckfellApi.Print(midiEvent);
    ReckfellApi.Print($"Channel {midiEvent.Channel}");
    ReckfellApi.Print($"Message {midiEvent.Message}");
    ReckfellApi.Print($"Pitch {midiEvent.Pitch}");
    ReckfellApi.Print($"Velocity {midiEvent.Velocity}");
    ReckfellApi.Print($"Instrument {midiEvent.Instrument}");
    ReckfellApi.Print($"Pressure {midiEvent.Pressure}");
    ReckfellApi.Print($"Controller number: {midiEvent.ControllerNumber}");
    ReckfellApi.Print($"Controller value: {midiEvent.ControllerValue}");
}

Note: Reckfell does not support MIDI output, so there is no way to emit MIDI messages from Reckfell. Only MIDI input is supported. Note: On the Web platform, using MIDI input requires a browser permission to be granted first. This permission request is performed when calling OS.OpenMidiInputs. MIDI input will not work until the user accepts the permission request.

Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.

Constructors1

InputEventMidiConstructor
# InputEventMidi
C#
public InputEventMidi();

Properties8

ChannelProperty
# Channel
C#
public int Channel { get; set; }

The MIDI channel of this message, ranging from 0 to 15. MIDI channel 9 is reserved for percussion instruments.

ControllerNumberProperty
# ControllerNumber
C#
public int ControllerNumber { get; set; }

The unique number of the controller, if InputEventMidi.Message is MIDI_MESSAGE_CONTROL_CHANGE, otherwise this is 0. This value can be used to identify sliders for volume, balance, and panning, as well as switches and pedals on the MIDI device. See the General MIDI specification for a small list.

ControllerValueProperty
# ControllerValue
C#
public int ControllerValue { get; set; }

The value applied to the controller. If InputEventMidi.Message is MIDI_MESSAGE_CONTROL_CHANGE, this value ranges from 0 to 127, otherwise it is 0. See also InputEventMidi.ControllerValue.

InstrumentProperty
# Instrument
C#
public int Instrument { get; set; }

The instrument (also called program or preset) used on this MIDI message. This value ranges from 0 to 127. To see what each value means, refer to the General MIDI's instrument list. Keep in mind that the list is off by 1 because it does not begin from 0. A value of 0 corresponds to the acoustic grand piano.

MessageProperty
# Message
C#
public MidiMessage Message { get; set; }

Represents the type of MIDI message (see the MIDIMessage enum). For more information, see the MIDI message status byte list chart.

PitchProperty
# Pitch
C#
public int Pitch { get; set; }

The pitch index number of this MIDI message. This value ranges from 0 to 127. On a piano, the middle C is 60, followed by a C-sharp (61), then a D (62), and so on. Each octave is split in offsets of 12. See the "MIDI note number" column of the piano key frequency chart a full list.

PressureProperty
# Pressure
C#
public int Pressure { get; set; }

The strength of the key being pressed. This value ranges from 0 to 127. Note: For many devices, this value is always 0. Other devices such as musical keyboards may simulate pressure by changing the InputEventMidi.Velocity, instead.

VelocityProperty
# Velocity
C#
public int Velocity { get; set; }

The velocity of the MIDI message. This value ranges from 0 to 127. For a musical keyboard, this corresponds to how quickly the key was pressed, and is rarely above 110 in practice. Note: Some MIDI devices may send a MIDI_MESSAGE_NOTE_ON message with 0 velocity and expect it to be treated the same as a MIDI_MESSAGE_NOTE_OFF message. If necessary, this can be handled with a few lines of code:

Methods16

GetChannelint
# GetChannel
C#
public int GetChannel();
Returns int
GetControllerNumberint
# GetControllerNumber
C#
public int GetControllerNumber();
Returns int
GetControllerValueint
# GetControllerValue
C#
public int GetControllerValue();
Returns int
GetInstrumentint
# GetInstrument
C#
public int GetInstrument();
Returns int
GetMessageMidiMessage
# GetMessage
C#
public MidiMessage GetMessage();
Returns MidiMessage
GetPitchint
# GetPitch
C#
public int GetPitch();
Returns int
GetPressureint
# GetPressure
C#
public int GetPressure();
Returns int
GetVelocityint
# GetVelocity
C#
public int GetVelocity();
Returns int
SetChannelvoid
# SetChannel
C#
public void SetChannel(int channel);
Parameters
NameTypeDefault
channelint—
SetControllerNumbervoid
# SetControllerNumber
C#
public void SetControllerNumber(int controllerNumber);
Parameters
NameTypeDefault
controllerNumberint—
SetControllerValuevoid
# SetControllerValue
C#
public void SetControllerValue(int controllerValue);
Parameters
NameTypeDefault
controllerValueint—
SetInstrumentvoid
# SetInstrument
C#
public void SetInstrument(int instrument);
Parameters
NameTypeDefault
instrumentint—
SetMessagevoid
# SetMessage
C#
public void SetMessage(MidiMessage message);
Parameters
NameTypeDefault
messageMidiMessage—
SetPitchvoid
# SetPitch
C#
public void SetPitch(int pitch);
Parameters
NameTypeDefault
pitchint—
SetPressurevoid
# SetPressure
C#
public void SetPressure(int pressure);
Parameters
NameTypeDefault
pressureint—
SetVelocityvoid
# SetVelocity
C#
public void SetVelocity(int velocity);
Parameters
NameTypeDefault
velocityint—
Reckfell Engine documentationBack to top ↑
QUICK LINKSGetting startedEntity hierarchyC# & .NET 10Scenes and prefabs
Reckfell guides and full API K
reckfellENGINE
RECKFELL ACCOUNT

Sign in

Sign in to your Reckfell account.

One account for the entire Reckfell platform.