Skip to content

InputEvent System Fails to Capture Simultaneous MIDI Events #77035

Closed
@ashih42

Description

@ashih42

Godot version

4.0.2.stable.official [7a0977c]

System information

Apple M1 macOS Ventura 13.3.1

Issue description

There are many common situations where multiple simultaneous MIDI events may occur:

  1. Playing a chord (multiple simultaneous Note On messages).
  2. Releasing a chord (multiple simultaneous Note Off messages).
  3. Some MIDI device may always precede a Note On or Note Off message with a Control Change message for High Resolution Velocity Prefix, so that pressing a single note would send 2 simultaneous messages.
  4. Active Sensing and Clock MIDI messages emitted by MIDI device constantly in the background, happening simultaneously with other MIDI messages triggered by the user.

Godot's InputEvent System may fail to capture some of these multiple simultaneous MIDI input events. In the following report, I have demonstrated examples for situations (1) and (3) and observed Godot failed to process some expected MIDI messages. I have not experimentally confirmed situation (4), but in theory it could happen due similar timing-based mechanism if the user is unlucky.

Steps to reproduce

The following 2 examples uses MIDI Monitor on macOS (a tool to observe received MIDI messages before a program handles them) and the following GDScript to print MIDI events handled by Godot:

extends Node2D

func _ready():
	OS.open_midi_inputs()

func _input(event):
	if (
		event is InputEventMIDI and
		event.message not in [MIDI_MESSAGE_ACTIVE_SENSING, MIDI_MESSAGE_TIMING_CLOCK]
	):
		print(event)

Example 1: Godot failed to process 1 of 3 expected Note On messages when playing a C-major triad chord.

chord

What Midi Monitor observed:

  • Note On
  • Note On
  • Note On
  • Note Off
  • Note Off
  • Note Off

What Godot processed:

  • Note On
  • Note On
  • Note On velocity=0
  • Note On velocity=0
  • Note On velocity=0

(Godot converts Note Off messages to Note On with velocity=0, which is odd but still conforms with MIDI Spec.)


Example 2: Godot failed to process single Note On and Note Off messages which were preceded simultaneously with Control Change for High Resolution Velocity Prefix messages.

pair

What MIDI Monitor observed:

  • Control Change for High Resolution Velocity Prefix
  • Note On
  • Control Change for High Resolution Velocity Prefix
  • Note Off

What Godot processed:

  • Control Change for High Resolution Velocity Prefix
  • Control Change for High Resolution Velocity Prefix

Minimal reproduction project

MidiTest.zip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions