\version "2.19.15"
%{
Thanks to everyone who suggested looking at LSR-753 for the "Jazz style" multi-measure rest.
That is substantially what I want.
In attempts to add parenthesis in the staff around the number within the staff, I ran into several problems.
I first tried adding parenthesis as text to the multi-measure rest, as described in
since it claims to center text. Which it does:
%}
#(define (white-under grob) (grob-interpret-markup grob
(markup #:vcenter #:whiteout #:pad-x 1 (ly:grob-property grob 'text))))
setInlineMMRN = {
\set Score.skipBars = ##t
\override Score.MultiMeasureRest.expand-limit = 1
\override Score.MultiMeasureRest.minimum-length = #30
}
inlineMMRN = {
\once \override MultiMeasureRest.layer = #-2
\once \override MultiMeasureRestNumber.layer = #-1
\once \override MultiMeasureRestNumber.Y-offset = #0
\once \override MultiMeasureRestNumber.stencil = #white-under
}
timeParens = \markup { \huge "(" \magnify #1.4 " " \huge ")" }
{
\setInlineMMRN
\inlineMMRN R1*4^\markup { \timeParens }
}
%{
But I could not get it to move down onto the staff. As described in
"Vertical alignment is a bit more complex. As stated above, markup objects can be moved as a whole;
however, it is also possible to move specific elements inside a markup block."
It took me a while to realize this meant that the techniques using
raise, lower, translate, general-align and translate-scaled
will NOT affect the "markup object moved as a whole",
but rather affect the relative position of objects within the markup object.
I also learned that these techniques, in addition to never placing text on the staff,
will not place text to the left of the anchor point.
Perhaps this section should include a comment to the effect of:
"The commands raise, lower, translate, general-align and translate-scaled
used within a markup block are limited to printing text
outside the staff and to the right of the anchor point."
%}
{
%
% An example of a failed attempt to translate text within a markup block
%
% The translated object will not move to the left, even if it does not collide with anything:
d'1^\markup {
Acte I
\translate #'(-30 . 4) "Scène 1"
}
1 1
% It seems the translated object is positioned relative to the first text object
% and the entire markup is positioned above the staff.
% Here, the lowered second object has the effect of pushing the first object higher up.
1^\markup {
Acte I
\translate #'(0 . -4) "Scène 1"
}
1 1
d'1^\markup {
Acte I
\translate #'(0 . 4) "Scène 1"
}
% The documentation for moving objects suggests using extra-offset.
% Likewise, this does not work on the multi-measure rest.
\setInlineMMRN
\inlineMMRN
\once \override TextScript #'extra-offset = #'(0 . -3.7)
R1*8^\timeParens
}
% What did allow me to place text in the staff was attaching it to an empty chord.
wideTimeParens = \markup { \magnify #11.5 " " \huge "(" \magnify #1.4 " " \huge ")" }
inlineMMRN = {
\once \override MultiMeasureRest.layer = #-2
\once \override MultiMeasureRestNumber.layer = #-1
\once \override MultiMeasureRestNumber.Y-offset = #0
\once \override MultiMeasureRestNumber.stencil = #white-under
\once \override TextScript #'extra-offset = #'(0 . -3.7)
<>^\wideTimeParens
}
{
\setInlineMMRN
\inlineMMRN
R1*4
}
% But then I lost the auto-centered-ness of attaching it to the multi-measure rest.
{
\setInlineMMRN
\inlineMMRN
R1*44
\inlineMMRN
R1*8
\inlineMMRN
R1*12
}
% So I can tweak these into submission.
inlineMMRN = {
\once \override MultiMeasureRest.layer = #-2
\once \override MultiMeasureRestNumber.layer = #-1
\once \override MultiMeasureRestNumber.Y-offset = #0
\once \override MultiMeasureRestNumber.stencil = #white-under
\once \override TextScript #'extra-offset = #'(0 . -3.7)
}
{
\setInlineMMRN
\inlineMMRN
<>^\markup { \magnify #10.4 " " \huge "(" \magnify #4 " " \huge ")" }
R1*44
\inlineMMRN
<>^\markup { \magnify #13.1 " " \huge "(" \magnify #1.9 " " \huge ")" }
R1*8
\inlineMMRN
<>^\markup { \magnify #12 " " \huge "(" \magnify #3.9 " " \huge ")" }
R1*12
}
%{
Finally, here is the real point of my post:
It would be nice to have a function that could take these arguments: duration, number of measures, X-tweak, Y-tweak.
I've done music functions before music and text, but not with numbers.
My template for a music function that takes numbers comes from
padText = #(define-music-function
(parser location padding)
(number?)
#{
\once \override TextScript.padding = #padding
#})
\relative c'' {
c4^"piu mosso" b a b
\padText #1.8
c4^"piu mosso" b a b
\padText #2.6
c4^"piu mosso" b a b
}
So, here is my attempt.
Does anyone have any hints for how to get such a function to work?
It especially doesn't like the expressions ##xTweak, ##yTweak and R$measureLength*#howManyMeasures,
but I don't understand how this syntax works.
%}
playTime = #(define-music-function
(parser location measureLength howManyMeasures xTweak yTweak)
(ly:duration? number? number? number?)
#{
<>^\markup { \magnify ##xTweak " " \huge "(" \magnify ##yTweak " " \huge ")" }
R$measureLength*#howManyMeasures
#})
{
\setInlineMMRN
\playTime 1 #44 #10.4 #4
\playTime 1 #8 #13.1 #1.9
\playTime 1 #12 #12.0 #3.9
}
% Thanks for any advice!