jdxi_editor.midi.music.pdf_export

Export a MIDI file to sheet music PDF (music21 + LilyPond) for use by the app menu. Uses the same logic as piano.py for consistent LilyPond behavior.

Functions

short_name(→ str)

Abbreviation for staff label (e.g. 'Piano' -> 'Pno.', long names truncated).

export_midi_to_pdf(→ Optional[str])

Export a MIDI file to a PDF in the same directory (stem.pdf).

cleanup_score(...)

Minimal cleanup with safe quantization.

annotate_staffs(score, track_names)

_ensure_parts_have_measures(→ None)

Ensure every part has at least one Measure so LilyPond export does not hit context bugs.

export_score(→ tuple[pathlib.Path, pathlib.Path])

set_metadata(composer, score, title)

remove_empty_parts(score)

Remove any parts that have no notes, chords, or rests.

Module Contents

jdxi_editor.midi.music.pdf_export.short_name(name: str, max_len: int = 12) str[source]

Abbreviation for staff label (e.g. ‘Piano’ -> ‘Pno.’, long names truncated).

jdxi_editor.midi.music.pdf_export.export_midi_to_pdf(midi_path: str | pathlib.Path) str | None[source]

Export a MIDI file to a PDF in the same directory (stem.pdf). Mirrors piano.main() for consistent LilyPond behavior. Returns the PDF path or None on failure.

jdxi_editor.midi.music.pdf_export.cleanup_score(score: music21.stream.Score | music21.stream.Part | music21.stream.Opus) music21.stream.Stream[music21.Music21Object | Any] | None[source]

Minimal cleanup with safe quantization.

jdxi_editor.midi.music.pdf_export.annotate_staffs(score: music21.stream.Score | music21.stream.Part | music21.stream.Opus, track_names: list[str])[source]
jdxi_editor.midi.music.pdf_export._ensure_parts_have_measures(score: music21.stream.Score) None[source]

Ensure every part has at least one Measure so LilyPond export does not hit context bugs.

jdxi_editor.midi.music.pdf_export.export_score(midi_file: pathlib.Path, midi_file_stem: str, score) tuple[pathlib.Path, pathlib.Path][source]
jdxi_editor.midi.music.pdf_export.set_metadata(composer: str, score: music21.stream.Score | music21.stream.Part | music21.stream.Opus, title: str)[source]
jdxi_editor.midi.music.pdf_export.remove_empty_parts(score: music21.stream.Score)[source]

Remove any parts that have no notes, chords, or rests. Returns a cleaned score.