I hacked this together after discovering that the MIDI support in Godot is not available on iOS. This plugin uses the CoreMIDI framework to receive MIDI events.
- Install
uvfrom https://docs.astral.sh/uv/ - Install
xcodeand command line tools - Build godot headers by running
make godot-headers - Run
make - Copy
bin/godot_ios_midi.aandsrc/godot_ios_midi.gdipto your Godot project'sios/pluginsdirectory - Enable plugin on export
public override void _Ready()
{
if (Engine.HasSingleton("MidiIOS"))
{
var plugin = Engine.GetSingleton("MidiIOS");
plugin.Connect(
"midi_event",
Callable.From(
(Godot.Collections.Dictionary eventData) => OnMidiEvent(eventData)
)
);
}
}
public void OnMidiEvent(Godot.Collections.Dictionary eventData)
{
byte[] midiBytes = (byte[])eventData["data"];
var timestamp = (double)eventData["timestamp"];
GD.Print(
$"MIDI Event Received - Timestamp: {timestamp}, Data: {BitConverter.ToString(midiBytes)}
);
}