jdxi_editor.midi.pattern.importer ================================= .. py:module:: jdxi_editor.midi.pattern.importer .. autoapi-nested-parse:: 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 ---------- .. autoapisummary:: jdxi_editor.midi.pattern.importer.STEPS_PER_BEAT jdxi_editor.midi.pattern.importer.DEFAULT_STEPS_PER_BAR Classes ------- .. autoapisummary:: jdxi_editor.midi.pattern.importer.ImportedNote jdxi_editor.midi.pattern.importer.PatternImport Functions --------- .. autoapisummary:: jdxi_editor.midi.pattern.importer._count jdxi_editor.midi.pattern.importer.import_pattern Module Contents --------------- .. py:data:: STEPS_PER_BEAT :value: 4 .. py:data:: DEFAULT_STEPS_PER_BAR :value: 16 .. py:function:: _count(n: int, noun: str) -> str .. py:class:: ImportedNote A note placed on the step grid. .. 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_steps :type: float .. py:class:: PatternImport Result of reading a MIDI file into the step grid. .. py:attribute:: bars :type: int .. py:attribute:: bpm :type: Optional[float] .. py:attribute:: ticks_per_beat :type: int .. py:attribute:: notes :type: list[ImportedNote] :value: [] .. py:attribute:: dropped_overlapping :type: int :value: 0 .. py:attribute:: dropped_channels :type: dict[int, int] .. py:attribute:: tempo_changes_ignored :type: int :value: 0 .. py:property:: dropped_total :type: int .. py:method:: summary() -> str One line describing what was imported and what was not. .. py:function:: import_pattern(midi_file: mido.MidiFile, channel_to_row: dict[int, int], steps_per_bar: int = DEFAULT_STEPS_PER_BAR) -> PatternImport Place the notes of *midi_file* on the step grid. :param midi_file: File to read :param channel_to_row: 0-based MIDI channel -> sequencer row :param steps_per_bar: Steps per bar (16 for 4/4, 12 for 3/4) :return: PatternImport with notes and a count of what was left out