I'll point it out below.
I am not sure where to place this new engraver code so I can use it. I tried researching this in the manual, but was still unclear. Where should it appear? Again, thanks for your help
Here an engraver which transforms the default stencil to an empty
stencil under certain conditions (it's not a rewrite of
Chord_name_engraver)
Right here is a new ChordNames context that has everything you need. Put the whole context into your file, replacing the current ChordNames context.
\new ChordNames
\with {
chordChanges = ##t
\consists
#(lambda (ctx)
(let* ((chord #f)
(last-chord #f))
(define (at-line-beginning? grob)
(let* ((col (ly:item-get-column grob))
(ln (ly:grob-object col 'left-neighbor))
(col-to-check (if (ly:grob? ln) ln col)))
(and (eq? #t (ly:grob-property col-to-check 'non-musical))
(= 1 (ly:item-break-dir col-to-check)))))
(make-engraver
(acknowledgers
((chord-name-interface this-engraver grob source-engraver)
(if chord
(begin
(set! last-chord chord)
(set! chord #f)))
(set! chord (ly:grob-property grob 'text))
;; If two subsequent chords are equal and chordChanges is enabled,
;; set 'after-line-breaking to a procedure which sets the stencil
;; to an empty-stencil if the new chord is at line-start.
(if (and (equal? chord last-chord)
(ly:context-property ctx 'chordChanges #f))
(ly:grob-set-property! grob 'after-line-breaking
(lambda (grob)
(if (at-line-beginning? grob)
(ly:grob-set-property! grob 'stencil empty-stencil))
;; keep default
(ly:chord-name::after-line-breaking grob))))))
((finalize this-engraver)
;; house keeping
(set! chord #f)
(set! last-chord #f)))))
}
This is the end of the ChordNames context
\chordmode { d2 c~ \break c d }
The chormode code is then placed in the ChordNames context. You may wish to surround it with{}, although it is not necessary here because the \chordmode {} is a single music expresion.
HTH,
Carl