2.6.2 Running a function on all layout objects

The most versatile way of tuning an object is \applyOutput which works by inserting an event into the specified context ( ApplyOutputEvent). Its syntax is either

\applyOutput Context proc

or

\applyOutput Context.Grob proc

where proc is a Scheme function, taking three arguments.

When interpreted, the function proc is called for every layout object (with grob name Grob if specified) found in the context Context at the current time step, with the following arguments:

In addition, the cause of the layout object, i.e., the music expression or object that was responsible for creating it, is in the object property cause. For example, for a note head, this is a NoteHead event, and for a stem object, this is a Stem object.

Here is a function to use for \applyOutput; it blanks note-heads on the center-line and next to it:

#(define (blanker grob grob-origin context)
   (if (< (abs (ly:grob-property grob 'staff-position)) 2)
       (set! (ly:grob-property grob 'transparent) #t)))

\relative {
  a'4 e8 <<\applyOutput Voice.NoteHead #blanker a c d>> b2
}

[image of music]

To have function interpreted at the Score or Staff level use these forms

\applyOutput Score…
\applyOutput Staff…

LilyPond — Extending v2.23.82 (development-branch).