I am trying to create a program that takes input from a MIDI-device (a keyboard) and plays various sounds depending on which button that is pressed. Currently I am simply trying to get the program to receive data from the MIDI device, but I can't seem to figure it out and there isn't much documentation at the moment. If I have understood right all I need is built into Godot as of 3.1?

What I am doing currently is this (in reduced form):

OS.open_midi_inputs()
OS.get_connected_midi_inputs()

set_process_unhandled_input(true)

func _unhandled_input(event : InputEvent):
	if (event is InputEventMIDI):
		if (event.get_channel() == midiChannel): //This I have set to channel 1 (0)
			print ("MIDI Action Received")

Am I missing something? The MIDI-interface has a small LED that is usually turned on when it has noticed a connection, but my program does not make it turn on even when the interface is set to listen on the correct channel.

Maybe print the value of OS.get_connected_midi_inputs() to see what it returns?

I tried that, but sadly it returns nothing. I tried both starting the program with the MIDI-interface connected and with plugging it in while the program was running, but nothing got me a result from OS.get_connected_midi_inputs()

I noticed there is a plugin for MIDI: https://github.com/SimonSikstrom/godot-midi-in-module Do I need something like that too perhaps?

Maybe. I have not used nor do I own any MIDI devices.

I would expect that print to output something if it saw a connection so either indeed you need a plugin for midi support or I suspect that for whatever reason godot is not compatible with your device perhaps.

Might be worth making a bug report and actively following it to give any feedback and help analyze the issue, since you are the one with the device.

Will do that, thanks! I'll try the module too and see if it works.

Hey I didn't know this was built in to Godot. I have a midi fighter. I'll see if I can get it to work.

Update: Very excited to report that the Midi Fighter seems to work well. I used your code snippet above and I am receiving events when I push buttons and even get events when I tilt it.

I had a unity project planed for the Midi Fighter but I never got to it because there is no midi built into Unity.

That is cool! :D Do you have the device connected to your computer then? And did you set any special settings to make it work? (Does it need Audio Input On, for example?)

Yep, the device is connected. I did not modify any settings. All I did was plug the midi fighter into my Windows 10 PC. Copy your code snippet above into a new script and attached it to a node in the scene. I added a few print statements so I could see what was going on when I pushed play it all just worked.

update: I should add that I have had the midi fight connected to the machine for other programs, so I know my OS knows how to work midi and the drivers are all working.

Ok, thanks for the info! I'll experiment a bit more and see if I can make it work. Good to at least know the code is correct. :)

3 years later