This project demonstrates a simple Godot script that listens for MIDI events and triggers animations based on the received events. The script uses the MIDIPlayer node to handle MIDI events and a Tween node to animate an icon's position.
- Listens for MIDI 'Note On' events.
- Animates the position of an icon based on the received MIDI events.
extends Node2D
var action = 0
func _ready():
# Connect the midi_event signal to the method using Callable
$MIDIPlayer.connect("midi_event", Callable(self, "_on_midi_player_midi_event"))
func _on_midi_player_midi_event(channel, event):
if event.type == 144: # Note on event
print("Note on event received: ", event.note)
if action == 0:
var tween = create_tween()
tween.tween_property($Icon, "global_position", Vector2(600, 323), 0.2)
action = 1
elif action == 1:
var tween = create_tween()
tween.tween_property($Icon, "global_position", Vector2(217, 323), 0.2)
action = 0
- Add a MIDIPlayer node to your scene.
- Add an Icon (or any other Node2D) that you want to animate.
- Attach the script to a Node2D (such as the root node of your scene).
- Ensure your MIDI device is connected and configured in Godot.
- Run the scene and play some MIDI notes to see the icon animate.
- Godot Engine 3.x or later.
- A MIDI input device.