Hi Gabriel,
This is a good starting point (many thanks, Lukas!), but there are two
issues:
1. Placement. Ideally the hint note would appear closer to the
system-ending barline—ideally, immediately to the left of it.
Yes, that's due to the use of \afterGrace. You can change this by
setting afterGraceFraction, but of course that's not really nice
(actually the note should probably stick to the barline).
1. Accidental. I cannot get a natural sign to show on the D natural;
see my comment within the code below. Here, the accidental is
critical to tell the singer “You are hearing a D sharp from the
sopranos right now, but immediately after you turn the page you
will need to sing a D natural.”
Yes, that was a limitation since the functions I proposed took only
pitches (ly:pitch?), and forced accidentals are not part of pitches but
of NoteEvent's.
Maybe something like this?
\version "2.24.2"
\language "english"
#(define (note? x) (and (ly:music? x)
(music-is-of-type? x 'note-event)))
hintNote =
#(define-music-function (duration-type hint-note) (symbol? note?)
(let ((hint (ly:music-deep-copy hint-note)))
(case duration-type
((explicit-duration)
noop)
((standard-duration)
(ly:music-set-property! hint 'duration #{ 4 #}))
(else
(ly:error "Unknown duration-type in hintNote: ~a" duration-type)))
#{
\single \omit Stem
\tweak Parentheses.font-size -3
\tweak Parentheses.padding 0.1
\parenthesize
#hint
#}))
hint =
#(define-music-function
(duration-type hint-pitch)
((symbol? 'standard-duration) note?)
#{
\grace
\hintNote #duration-type #hint-pitch
#})
afterHint =
#(define-music-function
(main duration-type hint-pitch)
(ly:music? (symbol? 'standard-duration) note?)
#{
\afterGrace
#main
\hintNote #duration-type #hint-pitch
#})
{
\key fs \major
\afterHint as'1 #'explicit-duration bf'2.
\key bf \major
bf'
}
{
\key fs \major
as'1
\key bf \major
\hint as' bf'1
}
\relative c' {
\key g \major
r2 c2 ~ | c4 c c c | c2. a4 | e'1 |
#(define afterGraceFraction 15/16)
\afterHint b1 d!
\break
d?2. d4 | d d d2 ~ | d4 b e2 |
a,4 f'2 f4 | f f f c |
}
%%% SNIPPET ENDS