I'm trying to create a function to display harmonics as shown in the attached images.
harmonic1.png is in the alto clef with the sounded pitches written in the treble clef
harmonic4.png is an acciaccatura all in the alto clef
This is where I got to:
harmonicFingered =
#(define-music-function
(parser location note) (ly:music?)
#{
\stemNeutral #note
#})
harmonicActual =
#(define-music-function
(parser location note) (ly:music?)
#{
\once \override Accidental #'font-size = #-4
\once \override Accidental #'extra-offset = #'(2 . 0)
\tweak Stem #'stencil ##f
\tweak Flag #'stencil ##f
\tweak #'font-size #-4
\tweak #'X-offset #1.75
#note
#})
harmonicActualGrace =
#(define-music-function
(parser location note) (ly:music?)
#{
\once \override Accidental #'font-size = #-4
\tweak Stem #'stencil ##f
\tweak Flag #'stencil ##f
\tweak #'font-size #-4
#note
#})
harmonicBoth =
#(define-music-function (parser location fingered actual) (ly:music? ly:music?)
#{
<<{\harmonicFingered $fingered } \new Voice {\harmonicActual $actual }>> \oneVoice
#})
harmonicGrace =
#(define-music-function (parser location fingered actual) (ly:music? ly:music?)
#{
<<{\harmonicFingered $fingered } \new Voice {\harmonicActualGrace $actual }>> \oneVoice
#})
(for everything except acciaccaturas/grace notes I am putting the sounded pitch after the fingered pitch to be consistent (the original score has some before and some after) - for acciaccaturas I am aligning them vertically).
Which gets things more or less right for most situations - e.g. \harmonicBoth <e\harmonic>4_\flageolet e'}
However, I would be very grateful if someone could help me to
a) clean up the function a bit to be more Lilypondian - I don't think I have done things in the correct/logical way here (I am quite new to this!)
b) if possible allow adding a treble clef or ottava to the sounded pitch
c) make slurs/tuplet brackets etc. avoid the notehead in the same way as they do normal noteheads.
As an aside, why do \flageolets always appear above the note unless specified with a _?
Many thanks!