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

\applyOutput Context proc

where proc is a Scheme function, taking three arguments.

When interpreted, the function proc is called for every layout object 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 (and (memq 'note-head-interface (ly:grob-interfaces grob))
            (< (abs (ly:grob-property grob 'staff-position)) 2))
       (set! (ly:grob-property grob 'transparent) #t)))

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

[image of music]

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

\applyOutput #'Score #function
\applyOutput #'Staff #function

Other languages: deutsch, español, français.
About automatic language selection.

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