Hi Lucas, You were absolutely right β your method worked perfectly! I made a mistake on my end earlier, but now itβs running just as expected. Thanks so much for your clear and effective solution!
I might follow up soon with a related question β this time about how to display those MIDI values visually above each note, with some formatting. If you happen to be around, Iβd love to hear your thoughts! Really appreciate your help! π Best, Peter Now, the result is: Parsing... Interpreting music...- Found pitch c1 β MIDI: 60 - Found pitch d1 β MIDI: 62 - Found pitch e1 β MIDI: 64 - Found pitch f1 β MIDI: 65 - Found pitch g1 β MIDI: 67 - Found pitch a1 β MIDI: 69 - Found pitch g1 β MIDI: 67 [image: image.png] On Wed, Apr 23, 2025 at 2:38β―PM Lukas-Fabian Moser <l...@gmx.de> wrote: > Hi Peter, > > Am 23.04.25 um 05:41 schrieb Peter X: > > 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 > > This is actually a nice example for a really simple engraver. > > \version "2.24" > > MIDI_pitch_engraver = > #(lambda (context) > (make-engraver > (listeners > ((note-event engraver event) > (let ((pitch (ly:event-property event 'pitch))) > (format #t "- Found pitch ~a~a β MIDI: ~a\n" > (note-name->string pitch) > (1+ (ly:pitch-octave pitch)) > (+ 60 (ly:pitch-semitones pitch)))))))) > > \layout { > \context { > \Voice > \consists #MIDI_pitch_engraver > } > } > > \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 | > } > } > } > > Lukas > >