jdxi_editor.midi.pattern.compiler ================================= .. py:module:: jdxi_editor.midi.pattern.compiler .. autoapi-nested-parse:: 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. .. rubric:: 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 ---------- .. autoapisummary:: jdxi_editor.midi.pattern.compiler.DEFAULT_TICKS_PER_BEAT jdxi_editor.midi.pattern.compiler.STEPS_PER_BEAT jdxi_editor.midi.pattern.compiler.TIME_SIGNATURE_DENOMINATOR jdxi_editor.midi.pattern.compiler.MIN_VELOCITY jdxi_editor.midi.pattern.compiler.MAX_VELOCITY Classes ------- .. autoapisummary:: jdxi_editor.midi.pattern.compiler.PatternRow jdxi_editor.midi.pattern.compiler.PatternNote jdxi_editor.midi.pattern.compiler.PatternSpec Functions --------- .. autoapisummary:: jdxi_editor.midi.pattern.compiler.compile_pattern jdxi_editor.midi.pattern.compiler._conductor_track jdxi_editor.midi.pattern.compiler._row_track Module Contents --------------- .. py:data:: DEFAULT_TICKS_PER_BEAT :value: 480 .. py:data:: STEPS_PER_BEAT :value: 4 .. py:data:: TIME_SIGNATURE_DENOMINATOR :value: 4 .. py:data:: MIN_VELOCITY :value: 1 .. py:data:: MAX_VELOCITY :value: 127 .. py:class:: PatternRow A sequencer row: its track name and MIDI channel (0-15). .. py:attribute:: name :type: str .. py:attribute:: channel :type: int .. py:class:: PatternNote One active step. .. py:attribute:: bar :type: int .. py:attribute:: step :type: int .. py:attribute:: row :type: int .. py:attribute:: note :type: int .. py:attribute:: velocity :type: int .. py:attribute:: duration_ticks :type: int .. py:class:: PatternSpec Everything needed to compile a pattern. .. py:attribute:: bars :type: int .. py:attribute:: steps_per_bar :type: int .. py:attribute:: bpm :type: float .. py:attribute:: rows :type: list[PatternRow] .. py:attribute:: notes :type: list[PatternNote] :value: [] .. py:attribute:: ticks_per_beat :type: int :value: 480 .. py:property:: ticks_per_step :type: int .. py:property:: ticks_per_bar :type: int .. py:property:: length_ticks :type: int .. py:method:: step_tick(bar: int, step: int) -> int Absolute tick of *step* in *bar*. .. py:function:: compile_pattern(spec: PatternSpec) -> mido.MidiFile 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. .. py:function:: _conductor_track(spec: PatternSpec) -> mido.MidiTrack .. py:function:: _row_track(spec: PatternSpec, row: PatternRow, notes: list[PatternNote]) -> mido.MidiTrack