Prefer named constants for MIDI messages.

Issue #65 resolved
Somni created an issue
func receive_raw_midi_message( input_event:InputEventMIDI ) -> void:
    var channel:GodotMIDIPlayerChannelStatus = self.channel_status[input_event.channel]

    match input_event.message:
        MIDI_MESSAGE_NOTE_OFF:
            self._process_track_event_note_off( channel, input_event.pitch )
        MIDI_MESSAGE_NOTE_ON:
            self._process_track_event_note_on( channel, input_event.pitch, input_event.velocity )
        MIDI_MESSAGE_AFTERTOUCH:
            # polyphonic key pressure プレイヤー自体が未実装
            pass
        MIDI_MESSAGE_CONTROL_CHANGE:
            self._process_track_event_control_change( channel, input_event.controller_number, input_event.controller_value )
        MIDI_MESSAGE_PROGRAM_CHANGE:
            channel.program = input_event.instrument
        MIDI_MESSAGE_CHANNEL_PRESSURE:
            # channel pressure プレイヤー自体が未実装
            pass
        MIDI_MESSAGE_PITCH_BEND:
            # 3.1でおかしい値を返す対応。3.2ではvelocityが0のままのハズなので影響はない
            var fixed_pitch = ( input_event.velocity << 7 ) | input_event.pitch
            self._process_pitch_bend( channel, fixed_pitch )
        0x0F:
            # InputEventMIDIはMIDI System Eventを飛ばしてこない!
            pass
        _:
            print( "unknown message %x" % input_event.message )
            breakpoint

For example. It helps to read and write these messages, as opposed to 0x08.

Comments (2)

  1. Log in to comment