InputEventMIDI
Represents an input event from a MIDI device, such as a piano.
InputEventMIDI.swift:18class InputEventMIDI
InputEventMIDI allows receiving input events from MIDI (Musical Instrument Digital Interface) devices such as a piano.
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 openMidiInputs
. You can check which devices are detected using getConnectedMidiInputs
.
Note that Godot does not currently support MIDI output, so there is no way to emit MIDI signals from Godot. Only MIDI input works.
Superclasses
class InputEvent
Abstract base class for input events.
Citizens in SwiftGodot
Conformances
protocol CustomStringConvertible
A type with a customized textual representation.
protocol Equatable
A type that can be compared for value equality.
protocol Hashable
A type that can be hashed into a
Hasher
to produce an integer hash value.protocol Identifiable<ID>
A class of types whose instances hold the value of an entity with stable identity.
protocol VariantRepresentable
Types that conform to VariantRepresentable can be stored directly in
Variant
with no conversion. These include all of the Variant types from Godot (for exampleGString
,Rect
,Plane
), Godot objects (those that subclass SwiftGodot.Object) as well as the built-in Swift types UInt8, Int64 and Double.protocol VariantStorable
Types that conform to VariantStorable can be stored in a Variant and can be extracted back out of a Variant.
Type members
Instance members
var channel: Int32
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.
var controllerNumber: Int32
If the message is
controlChange
, this indicates the controller number, otherwise this is zero. Controllers include devices such as pedals and levers.var controllerValue: Int32
If the message is
controlChange
, this indicates the controller value, otherwise this is zero. Controllers include devices such as pedals and levers.var instrument: Int32
The instrument of this input event. This value ranges from 0 to 127. Refer to the instrument list on the General MIDI wikipedia article to see a list of instruments, except that this value is 0-index, so subtract one from every number on that chart. A standard piano will have an instrument number of 0.
var message: MIDIMessage
Returns a value indicating the type of message for this MIDI signal. This is a member of the
MIDIMessage
enum.var pitch: Int32
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.
var pressure: Int32
The pressure of the MIDI signal. This value ranges from 0 to 127. For many devices, this value is always zero.
var velocity: Int32
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.