Dear LilyPond community,

I’m trying to figure out how to print the MIDI number of each note in a
score using a Scheme engraver — for example, I’d like c' to print as 60, d'
as 62, etc., during compilation.

Here is a simplified example of the kind of input I’m working with:

\version "2.24.4"

\score {
  \new Staff {
    \new Voice {
      \clef treble \key c \major \time 4/4
      c'4 d'4 e'4 f'4 |
      g'4 a'4 g'2 |
    }
  }
}

My goal is: When this file compiles, each note’s MIDI number is printed to
the terminal.

🎵 Found pitch c' → MIDI: 60
🎵 Found pitch d' → MIDI: 62
...

⸻

I’ve attempted writing a custom engraver using Scheme (not shown here to
avoid confusion), but even with simplified versions, I consistently get the
following error — even on clean test files:

/opt/homebrew/Cellar/lilypond/2.24.4/share/lilypond/2.24.4/ly/init.ly:65:2:
error: Guile signaled an error for the expression beginning here


⸻

🆘 My question:

What is the proper or recommended way to extract and print the MIDI number
of each note in a LilyPond score?

I’d really appreciate any working examples or pointers. Thank you very much!

Best regards,
Peter

Attachment: test_midi_number.ly
Description: Binary data

Reply via email to