jdxi_editor.midi.pattern.importer

Pattern importer

Reads a MIDI file into step-sequencer notes. Used both for “Load Pattern” and for loading the MIDI File Player’s file, so both behave the same:

  • every track is read; notes are mapped to rows by MIDI channel

  • note starts are rounded to the nearest 16th-note step

  • note lengths and velocities are kept (lengths in steps, from the note-offs)

  • notes that start on the same step of a row (chords, simultaneous drum hits) are all kept, in file order; the first is the step’s main note

  • what cannot be represented is counted, not silently lost: notes on other channels, the same note starting twice on one step, and tempo changes after the first

The inverse of jdxi_editor.midi.pattern.compiler.compile_pattern for files it produced.

Attributes

STEPS_PER_BEAT

DEFAULT_STEPS_PER_BAR

Classes

ImportedNote

A note placed on the step grid.

PatternImport

Result of reading a MIDI file into the step grid.

Functions

_count(n, noun) → str

import_pattern(midi_file, channel_to_row[, steps_per_bar]) → PatternImport

Place the notes of midi_file on the step grid.

Module Contents

jdxi_editor.midi.pattern.importer.STEPS_PER_BEAT = 4[source]
jdxi_editor.midi.pattern.importer.DEFAULT_STEPS_PER_BAR = 16[source]
jdxi_editor.midi.pattern.importer._count(n: int, noun: str) → str[source]
class jdxi_editor.midi.pattern.importer.ImportedNote[source]

A note placed on the step grid.

bar: int[source]
step: int[source]
row: int[source]
note: int[source]
velocity: int[source]
duration_steps: float[source]
class jdxi_editor.midi.pattern.importer.PatternImport[source]

Result of reading a MIDI file into the step grid.

bars: int[source]
bpm: float | None[source]
ticks_per_beat: int[source]
notes: list[ImportedNote] = [][source]
dropped_overlapping: int = 0[source]
dropped_channels: dict[int, int][source]
tempo_changes_ignored: int = 0[source]
property dropped_total: int[source]
summary() → str[source]

One line describing what was imported and what was not.

jdxi_editor.midi.pattern.importer.import_pattern(midi_file: mido.MidiFile, channel_to_row: dict[int, int], steps_per_bar: int = DEFAULT_STEPS_PER_BAR) → PatternImport[source]

Place the notes of midi_file on the step grid.

Parameters:
  • midi_file – File to read

  • channel_to_row – 0-based MIDI channel -> sequencer row

  • steps_per_bar – Steps per bar (16 for 4/4, 12 for 3/4)

Returns:

PatternImport with notes and a count of what was left out