In a score I am working on recently, I need to add brackets to certain notation elements such as rests, accidentals and stems. To achieve this purpose I found a quite useful snippet on LSR. This snippet achives the purpose by calling the bracketify-stencil
Scheme command.
However I am using an SMuFL library called esmuflily
that replaces all the notation elements with their SMuFL equivalences. The command in the snippet modifies the stencil based on Lilypond's default stencil, not my currently using stencil. I want to modify the stencil based on the currently using stencil, no matter whether I am using SMuFL or not. So how can I do it?
In my case of adding bracket to rests, for example, the following code produces a bracketified Lilypond default rest.
brkRest = {
\once\override Voice.Rest.stencil = #(lambda (grob)
(bracketify-stencil (ly:rest::print grob) Y 0.1 0.2 0.1))
}
and I must manually change ly:rest::print
(which is Lilypond's default rest stencil) to my actually using stencil in esmuflily
: ekm-rest
.
brkRest = {
\once\override Voice.Rest.stencil = #(lambda (grob)
(bracketify-stencil (ekm-rest grob) Y 0.1 0.2 0.1))
}
However, what if I am using another SMuFL library or not using SMuFL at all? I need a method to automatically get the currently using stencil and call bracketify-stencil
based on itself. I have tried this, but resulted in a "cyclic dependency" error.
brkRest = {
\once\override Voice.Rest.stencil = #(lambda (grob)
(bracketify-stencil ((ly:grob-property grob 'stencil) grob) Y 0.1 0.2 0.1))
}
So what is the correct method of doing this? I am new to Scheme programming in Lilypond.