Skip to content

Conversation

@mscuthbert
Copy link
Member

Followup from #1769 gave me an opportunity to find places to improve midi translate. Pinging @oxygen-dioxide since some changes took place since then

  • Change getNotesFromEvents() from potentially O(n^2) to O(n) while retaining sort order.

  • Pass encoding to parsing of instrument names in addition to lyrics (renamed "encoding_type" to "encoding" -- missed in prior review)

  • create TimingNoteEvent which is a typed NamedTuple that keeps track of when a MidiEvent NoteOn started, stopped, and what the NoteOn event was. Replaced the old tuple of tuples.

  • Faster gathering of Chords (remove potential O(n^2) search).

  • Remove unused special case for single-note streams.

  • opFrac many offsets and durations in MIDI for absolutely correct tuplets, etc.

  • Misc: Update braille.translate SegmentKey to typing.NamedTuple

  • Misc: Search code for places where we were still casting to float for Python 2 division!

  • Misc: Add typing to text/Trigram and some layout things

This is part of the non-backwards compatible MIDI.translate guts rewrite discussed on the music21 list.

Coverage % is expected to drop because the amount of code has been reduced a lot.

@coveralls
Copy link

coveralls commented May 16, 2025

Coverage Status

coverage: 93.011% (-0.001%) from 93.012%
when pulling 15df42c on midi_translate_type_simplify
into cbdd142 on master.

@mscuthbert mscuthbert merged commit 52fc784 into master May 16, 2025
8 checks passed
@mscuthbert
Copy link
Member Author

Coverage didn't drop -- I guess some of the code was not well tested!

@mscuthbert mscuthbert deleted the midi_translate_type_simplify branch May 16, 2025 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants