Skip to content

Fix MetronomeMark objects silently dropped from Lilypond output - #1993

Merged
mscuthbert merged 2 commits into
cuthbertLab:masterfrom
Emerson936:fix/lily-metronome-mark-1852
Aug 7, 2026
Merged

Fix MetronomeMark objects silently dropped from Lilypond output#1993
mscuthbert merged 2 commits into
cuthbertLab:masterfrom
Emerson936:fix/lily-metronome-mark-1852

Conversation

@Emerson936

Copy link
Copy Markdown
Contributor

Fixes MetronomeMark objects being silently dropped from LilyPond output.

Changes:

  • Added a MetronomeMark dispatch branch to LilypondConverter.appendM21ObjectToContext (previously it fell through unhandled and was dropped).
  • Added lyEmbeddedScmFromMetronomeMark(), which converts a MetronomeMark's referent/number into a LyTempoEvent.
  • Fixed LyTempoEvent.stringOutput(), which ignored a paired stenoDuration when no tempoRange was given, producing invalid syntax.
  • Fixed the LyStenoDuration docstring example, which showed an invalid steno duration ('quarter' instead of '4').

Fixes #1852

AI-assisted with Claude (>10 lines).

The Lilypond translator's element dispatch never recognized
MetronomeMark, so tempo markings were dropped entirely when writing
to lily. Also fixes LyTempoEvent.stringOutput(), which ignored a
paired stenoDuration when no tempoRange was given, and its docstring,
which showed an invalid steno duration ('quarter' instead of '4').

Fixes cuthbertLab#1852

This PR is AI-assisted (>10 lines).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@Emerson936
Emerson936 marked this pull request as draft August 3, 2026 02:33
@mscuthbert

Copy link
Copy Markdown
Member

great PR. fix lint; move the "New in v.11 to the end of the docstring", and I'll be happy to merge. Thanks!

pylint flagged the test-local `from music21 import key` as a reimport of the
module-level import (W0404/W0621); `meter` is not imported at module level, so
that one stays.

AI-assisted (Claude)
@mscuthbert
mscuthbert marked this pull request as ready for review August 7, 2026 02:11
@mscuthbert
mscuthbert merged commit 54e6bb5 into cuthbertLab:master Aug 7, 2026
6 checks passed
@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 93.313% (+0.008%) from 93.305% — Emerson936:fix/lily-metronome-mark-1852 into cuthbertLab:master

@mscuthbert

Copy link
Copy Markdown
Member

Thanks for the good first contribution, @Emerson936 . There are some remaining issues that will be addressed in a followup PR. good luck in your AI contribution class.

mscuthbert added a commit that referenced this pull request Aug 7, 2026
Folds in Emerson936's MetronomeMark work from PR #1993, adapted to the
isinstance dispatch and the annotations on this branch, and finishes the job
that branch started: bringing the emitted syntax up from the v2.14 grammar the
module was written against to LilyPond 2.24 (December 2022).

State the target version.  lilyObjects' module docstring now says output is
written for and checked against 2.24, that constructs from the linked v2.14
grammar are not necessarily still valid, and that convert-ly's convertrules.py
is the authoritative list of what changed.  Policy: support back about four
years from a release, so raise the target when 2.24 falls outside that.

Remaining pre-2.24 syntax, found by running LilyPond's own convert-ly over
generated output declared as \version "2.10.0" and confirmed against a 2.24.4
run:

- \times n/d -> \tuplet d/n (rule 2.17.11).  The fraction inverts: \times 2/3
  is \tuplet 3/2.  setContextForTimeFraction's arguments are correspondingly
  swapped to (actual, normal), which is also the more natural direction for
  music21, whose tuplets already carry tupletActual and tupletNormal.
- OctavateEight -> ClefModifier in the ossia context mods (rule 2.17.18).
  LilyPond does not complain about an \override on an unknown grob name, so
  this had been silently doing nothing.
- Drop \consists "Default_bar_line_engraver" (rule 2.23.8); the engraver no
  longer exists and 2.24 warns twice per ossia staff.
- define-music-function (parser location ...) -> (...) in fictaDef and colorDef
  (rule 2.19.22).  2.24 still accepts the old form, but convert-ly rewrites it.

Not taken: convert-ly's 2.23.11 rule rewrites \bar ".|" and ".|:" to ".|-|" and
".|:-|", restoring the implicit end-of-line "|" those names lost in 2.23.  The
plain names are what 2.24 itself uses for startRepeatBarType and
endRepeatBarType in engraver-init.ly, so the new behavior is the intended one
and the suffixed forms are a compatibility shim for older files.

convert-ly from 2.10 to 2.24 now reports no changes for generated output.

AI-assisted (Claude)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

metronome marks aren't written to lilypond files

3 participants