jdxi_editor.midi.pattern.compiler
Pattern compiler
Turns a step pattern into a mido.MidiFile. The same file is played by the shared TransportController and written by Save, so what you hear is what is saved, and a saved pattern sounds the same in the MIDI File Player.
The file is Type 1: - track 0: tempo, time signature - one track per pattern row (named, notes on the row’s channel) Every track ends exactly at the end of the last bar, so looping the file repeats whole bars with no gap.
Example
>>> spec = PatternSpec(bars=1, steps_per_bar=16, bpm=120,
... rows=[PatternRow("Digital Synth 1", channel=0)],
... notes=[PatternNote(bar=0, step=0, row=0, note=60,
... velocity=100, duration_ticks=120)])
>>> compile_pattern(spec).length
2.0
Attributes
Classes
A sequencer row: its track name and MIDI channel (0-15). |
|
One active step. |
|
Everything needed to compile a pattern. |
Functions
|
Compile spec to a Type 1 MIDI file. |
|
|
|
Module Contents
- class jdxi_editor.midi.pattern.compiler.PatternRow[source]
A sequencer row: its track name and MIDI channel (0-15).
- class jdxi_editor.midi.pattern.compiler.PatternSpec[source]
Everything needed to compile a pattern.
- rows: list[PatternRow][source]
- notes: list[PatternNote] = [][source]
- jdxi_editor.midi.pattern.compiler.compile_pattern(spec: PatternSpec) mido.MidiFile[source]
Compile spec to a Type 1 MIDI file.
Velocities are clamped to 1–127.
Notes are clipped at the pattern end, and where the same note on the same row starts again, so a long note never cuts off its successor.
A note-off sorts before a note-on at the same tick.
- jdxi_editor.midi.pattern.compiler._conductor_track(spec: PatternSpec) mido.MidiTrack[source]
- jdxi_editor.midi.pattern.compiler._row_track(spec: PatternSpec, row: PatternRow, notes: list[PatternNote]) mido.MidiTrack[source]