jdxi_editor.midi.file.trim
Trim a MIDI file, or one of its tracks, to a range of ticks.
trim_midi_file: keep [start, end) of every track and move it to the start of the file. The tempo, time signature, programs, controllers and SysEx in force at start are kept at tick 0, so the excerpt sounds as it did in place.
trim_track: remove a track’s notes outside [start, end) and leave its timing and other events as they were, so it stays in step with the other tracks.
Notes that begin before start are dropped; notes still sounding at end are released there.
Attributes
Functions
|
|
|
|
|
|
|
|
|
A track of events (stable-sorted by tick), ending at end_tick. |
|
The note-ons of events in [start, end) with their note-offs, a note-off |
|
What msg sets, if it is state to carry over a cut: a later message with |
|
|
|
track with only the notes that begin in [start, end) (ticks), at the |
|
A new file holding [start, end) (ticks) of midi_file, moved to tick 0. |
Module Contents
- jdxi_editor.midi.file.trim._to_track(events: Iterable[Event], end_tick: int) mido.MidiTrack[source]
A track of events (stable-sorted by tick), ending at end_tick.
- jdxi_editor.midi.file.trim._notes_in_range(events: list[Event], start: int, end: int) list[Event][source]
The note-ons of events in [start, end) with their note-offs, a note-off after end moved to end. Other events are left out.
- jdxi_editor.midi.file.trim._state_key(index: int, msg: mido.Message) tuple | None[source]
What msg sets, if it is state to carry over a cut: a later message with the same key replaces it. None for events that only matter where they are.