Am Sa., 4. Juli 2026 um 07:50 Uhr schrieb Walt North <[email protected]>:
>
> I have a case where I need to put parenthesis around some notes (not all
> notes) for a given instrument to emphasize a specific thing at certain points.
>
> I thought this might be a case where tags would come in handy.
>
> But the following doesn't add the parenthesis. What am I missing? Is the
> problem related to having tags within a function? Or would there be a better
> way to do this.
>
> \version "2.26.0"
>
> par = #(define-music-function (note) (ly:music?)
> #{
> \tag #'(piano) { #note }
> \tag #'(guitar) { \parenthesize #note }
> #})
>
> music = {c'1}
>
> \score {
> {
> \keepWithTag #'piano {\par \music}
> }
> }
> \score {
> {
> \keepWithTag #'guitar {\par \music}
> }
> }
>
>
Two issues:
a)
\parenthesize works on a single note or event-chord.
Your `music` is sequential music, though.
Thus { \parenthesize { c'1 } } does not work.
b)
In the function you do #note. This _changes_ `note` for all instances
of the function.
Use a copy instead, i.e. $note
As long as you only want to parenthesize single notes below works here:
par = #(define-music-function (note) (ly:music?)
#{
\tag #'(piano) { $note }
\tag #'(guitar) { \parenthesize $note }
#})
music = c'1
\score {
{
\keepWithTag #'piano {\par \music}
}
}
\score {
{
\keepWithTag #'guitar {\par \music}
}
}
Cheers,
Harm