Using the new MIDI-functions

ImerionImerion Posts: 15Member
edited September 2019 in Audio

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):



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.


  • MegalomaniakMegalomaniak Posts: 2,658Admin

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

  • ImerionImerion Posts: 15Member

    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:
    Do I need something like that too perhaps?

  • MegalomaniakMegalomaniak Posts: 2,658Admin

    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.

  • ImerionImerion Posts: 15Member

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

  • Jay KyburzJay Kyburz Posts: 4Member
    edited September 2019

    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.

  • ImerionImerion Posts: 15Member

    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?)

  • Jay KyburzJay Kyburz Posts: 4Member
    edited September 2019

    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.

  • ImerionImerion Posts: 15Member

    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. :)

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file