Godot MIDI Input example

An asset by rancidbacon
The page banner background of a mountain and forest
Godot MIDI Input example hero image

Quick Information

0 ratings
Godot MIDI Input example icon image
rancidbacon
Godot MIDI Input example

Example of MIDI Input (e.g keyboard/controller) handling functionality.Lists available MIDI input devices, dumps textual information about the events received and visualises key presses on a 1-octave on screen keyboard.

Supported Engine Version
3.1
Version String
1.0
License Version
MIT
Support Level
community
Modified Date
4 years ago
Git URL
Issue URL

Godot MIDI Input example

Home: https://github.com/follower/godot-midi-input-example

Official Godot docs:

README

The Demo

The enclosed Godot 3.1-compatible project lists available MIDI input devices, dumps textual information about the events received and visualises key presses on a 1-octave on screen keyboard.

Just The Code...

If you just want some example code so you can implement your own MIDI Input-based Godot project...


# The MIDI Input specific parts...

func _ready():
    OS.open_midi_inputs() # Required for cross-platform reliability.

    print(OS.get_connected_midi_inputs()) # List available MIDI input sources (e.g. keyboard, controller).


func _unhandled_input(event : InputEvent):

    if (event is InputEventMIDI): # When we get a MIDI input event...

        var event_dump_rb : String = ""

        # Display the available property values...
        event_dump_rb += "chn: {channel} msg: {message}\n".format({"channel": event.channel, "message": event.message})
        event_dump_rb += "  pitch: {pitch} vel: {velocity}\n".format({"pitch": event.pitch, "velocity": event.velocity})

        event_dump_rb += "\n"

        print(event_dump_rb)


        # Example of converting pitch to a keyboard key (not a musical key) within an octave.
        var key_index = event.pitch % 12


        # Handle the received message type appropriately...
        match event.message:
            MIDI_MESSAGE_NOTE_ON:
                # Do something here...

            MIDI_MESSAGE_NOTE_OFF:
                # Do something here...

Brought to you by follower at http://rancidbacon.com/.

Example of MIDI Input (e.g keyboard/controller) handling functionality.

Lists available MIDI input devices, dumps textual information about the events received and visualises key presses on a 1-octave on screen keyboard.

Reviews

0 ratings

Your Rating

Headline must be at least 3 characters but not more than 50
Review must be at least 5 characters but not more than 500
Please sign in to add a review

Quick Information

0 ratings
Godot MIDI Input example icon image
rancidbacon
Godot MIDI Input example

Example of MIDI Input (e.g keyboard/controller) handling functionality.Lists available MIDI input devices, dumps textual information about the events received and visualises key presses on a 1-octave on screen keyboard.

Supported Engine Version
3.1
Version String
1.0
License Version
MIT
Support Level
community
Modified Date
4 years ago
Git URL
Issue URL

Open Source

Released under the AGPLv3 license

Plug and Play

Browse assets directly from Godot

Community Driven

Created by developers for developers