InputEventMIDI

    Input event for MIDI inputs.

    InputEventMIDI allows receiving input events from MIDI devices such as a piano. MIDI stands for Musical Instrument Digital Interface.

    MIDI signals can be sent 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’s using.

    To receive input events from MIDI devices, you need to call . You can check which devices are detected using OS.get_connected_midi_inputs.

    Note that Godot does not currently support MIDI output, so there is no way to emit MIDI signals from Godot. Only MIDI input works.

    Default

    0

    Setter

    set_channel(value)

    Getter

    get_channel()

    The MIDI channel of this input event. There are 16 channels, so this value ranges from 0 to 15. MIDI channel 9 is reserved for the use with percussion instruments, the rest of the channels are for non-percussion instruments.


    • controller_number

    Default

    0

    Setter

    set_controller_number(value)

    Getter

    get_controller_number()

    If the message is MIDI_MESSAGE_CONTROL_CHANGE, this indicates the controller number, otherwise this is zero. Controllers include devices such as pedals and levers.


    If the message is , this indicates the controller value, otherwise this is zero. Controllers include devices such as pedals and levers.


    • int instrument

    Default

    0

    Setter

    set_instrument(value)

    Getter

    get_instrument()


    • message

    Default

    0

    Setter

    set_message(value)

    Getter

    get_message()

    Returns a value indicating the type of message for this MIDI signal. This is a member of the MidiMessageList enum.

    For MIDI messages between 0x80 and 0xEF, only the left half of the bits are returned as this value, as the other part is the channel (ex: 0x94 becomes 0x9). For MIDI messages from 0xF0 to 0xFF, the value is returned as-is.

    Notes will return MIDI_MESSAGE_NOTE_ON when activated, but they might not always return MIDI_MESSAGE_NOTE_OFF when deactivated, therefore your code should treat the input as stopped if some period of time has passed.

    For more information, see the MIDI message status byte list chart linked above.


    • pitch

    The pitch index number of this MIDI signal. This value ranges from 0 to 127. On a piano, middle C is 60, and A440 is 69, see the “MIDI note” column of the piano key frequency chart on Wikipedia for more information.


    Default

    Setter

    set_pressure(value)

    Getter

    get_pressure()

    The pressure of the MIDI signal. This value ranges from 0 to 127. For many devices, this value is always zero.


    Default

    0

    Setter

    set_velocity(value)

    Getter

    The velocity of the MIDI signal. This value ranges from 0 to 127. For a piano, this corresponds to how quickly the key was pressed, and is rarely above about 110 in practice.