jdxi_editor.midi.music.pdf_export ================================= .. py:module:: jdxi_editor.midi.music.pdf_export .. autoapi-nested-parse:: 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 --------- .. autoapisummary:: jdxi_editor.midi.music.pdf_export.short_name jdxi_editor.midi.music.pdf_export.export_midi_to_pdf jdxi_editor.midi.music.pdf_export.cleanup_score jdxi_editor.midi.music.pdf_export.annotate_staffs jdxi_editor.midi.music.pdf_export._ensure_parts_have_measures jdxi_editor.midi.music.pdf_export.export_score jdxi_editor.midi.music.pdf_export.set_metadata jdxi_editor.midi.music.pdf_export.remove_empty_parts Module Contents --------------- .. py:function:: short_name(name: str, max_len: int = 12) -> str Abbreviation for staff label (e.g. 'Piano' -> 'Pno.', long names truncated). .. py:function:: export_midi_to_pdf(midi_path: str | pathlib.Path) -> Optional[str] 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. .. py:function:: cleanup_score(score: music21.stream.Score | music21.stream.Part | music21.stream.Opus) -> music21.stream.Stream[music21.Music21Object | Any] | None Minimal cleanup with safe quantization. .. py:function:: annotate_staffs(score: music21.stream.Score | music21.stream.Part | music21.stream.Opus, track_names: list[str]) .. py:function:: _ensure_parts_have_measures(score: music21.stream.Score) -> None Ensure every part has at least one Measure so LilyPond export does not hit context bugs. .. py:function:: export_score(midi_file: pathlib.Path, midi_file_stem: str, score) -> tuple[pathlib.Path, pathlib.Path] .. py:function:: set_metadata(composer: str, score: music21.stream.Score | music21.stream.Part | music21.stream.Opus, title: str) .. py:function:: remove_empty_parts(score: music21.stream.Score) Remove any parts that have no notes, chords, or rests. Returns a cleaned score.