Thanks Lukas and Jean for your help.
There is an issue with the below solution. When adding << and >> the
visual is correct but while playing the score the first measure notes
all play together. I'm guessing it's because of << >>. Is there a way to
fix this.
Thanks for all the help.
Raj
On 1/14/2022 1:39 AM, Lukas-Fabian Moser wrote:
Hi Rajesh,
Am 14.01.22 um 01:44 schrieb Rajesh Baskar:
I'm tying to display a question mark at the center of the 1st measure
in a 2 measure score.
I have got this working with hard-coding the offset (3 . 4.5) but
this will not work when the number of notes in a measure is larger
than 3. Is there a way to get this to work dynamically where the
question mark moves to the center of the measure irrespective of the
length of a measure.
Please try to remove everything in your examples not actually related
to the problem at hand (here, for example, everything having to do
with MIDI, proportional notation, boxed measure counters etc.).
What comes to mind is that your question mark is exactly in the
position where you would normally expect a whole bar rest. So how about:
\version "2.22.0"
#(define (center-stencil stil)
(ly:stencil-aligned-to
(ly:stencil-aligned-to stil X CENTER)
Y CENTER))
questionMarkMultiMeasureRest = {
\override MultiMeasureRest.stencil =
#(grob-transformer
'stencil
(lambda (grob default)
(ly:stencil-translate-axis
(center-stencil (ly:text-interface::print grob))
(interval-center (ly:stencil-extent default X))
X)))
\override MultiMeasureRest.text = "?"
\override MultiMeasureRest.font-size = 7
\override MultiMeasureRest.color = "#6A00F4"
}
\new Staff {
\clef bass
<<
{ \hideNotes b2 c }
\new Voice {
\questionMarkMultiMeasureRest
R1
}
>>
\unHideNotes a2 c'4 g
}
One could of course wrap the simultaenous addition of the tweaked full
bar rest in a music function.
The reason I'm using such a comparatively complex stencil override is
that the default positioning of the MultiMeasureRest (which is what we
want here) is handled in the default stencil; if we overwrite that
function completely, we don't get the nice centered alignment we want.
Lukas