Thanks to visit codestin.com
Credit goes to github.com

Skip to content

note_on and note_off both parsed as note_on #130

@roballsopp

Description

@roballsopp

Mido version: 1.2.8

When looping over events after parsing a file, it seems events I expect to be note_off events, are actually typed as 'note_on' events.

from mido import MidiFile
midi_file = MidiFile('some_file.mid')

events = midi_file.tracks[0]

for evt in events:
	if evt.type == 'note_on':
		# half of these should actually be note_offs
		print(evt)

I have checked in my DAW and with another midi library, and I'm definitely getting about twice as many notes as I expect from mido. I can seemingly work around this by doing:

events = midi_file.tracks[0]

for evt in events:
	if evt.type == 'note_on' and evt.velocity != 0:
		# now they are all note ons
		print(evt)

but this is kinda counter-intuitive, especially since the mido docs make a reference to a note_off type with a non-zero velocity

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions