2012/9/26 Oscar Dub <[email protected]> > > Thanks to both! > > Janek, your information about accessing the internals of Feta and LilyPond > is very useful. As there's no way to add .mf syntax to a LilyPond file (as > far as I know), I'm going to try to follow along Marc's lines. It would be > great to solve the problem without hacking LilyPond's source, but it's good > to know nonetheless. > > On 26 Sep 2012, at 09:44, Marc Hohl <[email protected]> wrote: > > […] create a markup that looks like the shape. > > Once you managed this, you can write a callback for Rest #'stencil that > checks for the duration > of the rest, applies your markup if it is 1 and calls ly:rest::print > otherwise. > > > I've managed to implement both separate parts. > > My markup looks like this: > \markup > { > \combine > \musicglyph #"scripts.ufermata" > \translate #'(-0.01 . 0.19) > \with-color #(x11-color 'white) > \draw-circle #0.28 #0 ##t > } > > The output is attached. > For the scheme function to place in the override, I have cannibalised this > snippet (http://lsr.dsi.unimi.it/LSR/Item?id=548) to make a basic outline: > > #(define (ly:rest-interface::kurtag-rests grob) > (let ((duration (ly:grob-property grob 'duration-log)))) > (if (= duration 0) > ( %{ markup function goes HERE %} ) > (ly:rest::print grob) % else print normal grob > )) > > With the plan being to call this code in via: > \override Rest #'stencil = #ly:rest-interface::kurtag-rests > > My problem now is combining the two stages. I'm not sure how to render the > markup in scheme at the position shown in the code. > > Thanks again, > > Oscar > > _______________________________________________ > lilypond-user mailing list > [email protected] > https://lists.gnu.org/mailman/listinfo/lilypond-user >
Hi Oscar,
you're very close.
Step by step:
1.------------------------------------------
Your definition is wrong with some brackets:
#(define (ly:rest-interface::kurtag-rests grob)
(let ((duration (ly:grob-property grob 'duration-log)))) ;one
closing-bracket too much
(if (= duration 0)
( %{ markup function goes HERE %} )
(ly:rest::print grob) % else print normal grob
)) %the closing-bracket should go here
Please note that scheme is be commented by using the ;-sign
2.------------------------------------------
a)
You want to define a new stencil using a _markup_. So you have to
convert the markup into a stencil via
(grob-interpret-markup grob <what-ever-markup>)
Btw, I would store the markup in a variable.
b)
You want to _use_ this stencil. So you have to set the 'stencil-property via:
(ly:grob-set-property! grob 'stencil (grob-interpret-markup grob
<what-ever-markup>))
3.------------------------------------------
All together:
\version "2.16.0"
mrkp =
\markup
{
\combine
\musicglyph #"scripts.ufermata"
\translate #'(-0.01 . 0.19)
\with-color #(x11-color 'white)
\draw-circle #0.28 #0 ##t
}
#(define (ly:rest-interface::kurtag-rests grob)
(let ((duration (ly:grob-property grob 'duration-log)))
(if (= duration 0)
(ly:grob-set-property! grob 'stencil (grob-interpret-markup grob mrkp))
; else print normal grob
(ly:rest::print grob))))
%--- test
\relative c' {
c1 r r r
d4 r4 r8 r r16 r8.
}
\layout {
\context {
\Voice
\override Rest #'stencil = #ly:rest-interface::kurtag-rests
}
}
4. ------------------------------------------
Regarding the result: not so nice as expected, because of the
white-out on staff-lines.
This problems could be fixed. But instead of fixing a problem that has
its origin in your initial markup-design.
Let's try another markup-construct.
5. ------------------------------------------
I used a markup defined via \path
(you may want change/improve it, I'm not very familiar with postscript commands)
and scaled it a bit.
myPath = #'((curveto 0 0 0.8 0.8 1.6 0))
mrkp =
\markup {
\scale #'(0.9 . 2.2)
\override #'(line-cap-style . round)
\path #0.1 #myPath
}
Also I added a definition to correct/adjust the staff-position:
correctStaffPosition =
\override Rest #'after-line-breaking =
#(lambda (grob)
(let ((staff-pos (ly:grob-property grob 'staff-position 0))
(duration (ly:grob-property grob 'duration-log)))
(if (= duration 0)
(ly:grob-set-property! grob 'staff-position (- staff-pos 2.2 ))
staff-pos)))
6. ------------------------------------------
All together (png attached)
\version "2.16.0"
mrkp =
\markup {
\scale #'(0.9 . 2.2)
\override #'(line-cap-style . round)
\path #0.1 #myPath
}
#(define (ly:rest-interface::kurtag-rests grob)
(let ((duration (ly:grob-property grob 'duration-log)))
(if (= duration 0)
(ly:grob-set-property! grob 'stencil (grob-interpret-markup grob mrkp))
; else print normal grob
(ly:rest::print grob))))
correctStaffPosition =
\override Rest #'after-line-breaking =
#(lambda (grob)
(let ((staff-pos (ly:grob-property grob 'staff-position 0)))
(ly:grob-set-property! grob 'staff-position (- staff-pos 2.2 ))))
\score {
\new Staff
\relative c' {
c1 r r r
d4 r4 r8 r r16 r8.
}
\layout {
\context {
\Voice
\override Rest #'stencil = #ly:rest-interface::kurtag-rests
\correctStaffPosition
}
}
}
7. ------------------------------------------
Limitation:
All above will work for whole rests, but not for a MultiMeasureRest.
MultiMeasureRests are spanner, a stencil-override would be more complex.
HTH,
Harm
<<attachment: atest-15.png>>
_______________________________________________ lilypond-user mailing list [email protected] https://lists.gnu.org/mailman/listinfo/lilypond-user
