Re: conditional parenthesis

Walt North <[email protected]> Sun, 5 Jul 2026 10:04:45 -0700
Newsgroups gmane.comp.gnu.lilypond.general
Message-ID <[email protected]>
I have gotten around my issue by changing from using \relative to using 
\fixed. See below. In the sample below.

In the sample below I took \parenthesize out of the picture to isolate 
it from the issue I was having.

So to recap.

  * My original goal was to have () around certain notes in the score
    that only show up if the music is being printed for a specific
    instrument.
  * I tried other ways to only have \parenthesize used for a given
    instrument but it seemed the only clean way to do it in a general
    way was using tags in a function.
  * But doing seemed to introduce an issue with \relative notes.
    Changing to \fixed notes seems to have resolved that.
  * Using \fixed is reasonable for the song I'm working on.
  * But that leaves the mystery for a later date about using relative
    with tags in a function. I have experimented with
    \resetRelativeOctave but that seems a bit cumbersome.


code:

\version "2.26.0"
\language "english"
par = #(define-music-function (note) (ly:music?)
    #{
    \tag #'(guitar)  { $note }
    \tag #'(piano)  { $note }
    #})
musicRel = \relative c' {cs1 \par cs' |}
\score {
   {
     \keepWithTag #'piano {\musicRel}
   }
}
\score {
   {
     \keepWithTag #'guitar {\musicRel}
   }
}
\void \displayLilyMusic \keepWithTag #'piano {\musicRel}
\void \displayLilyMusic \keepWithTag #'guitar {\musicRel}

musicFix = \fixed c' {cs1 \par cs' |}
\score {
   {
     \keepWithTag #'piano {\musicFix}
   }
}
\score {
   {
     \keepWithTag #'guitar {\musicFix}
   }
}
\void \displayLilyMusic \keepWithTag #'piano {\musicFix}
\void \displayLilyMusic \keepWithTag #'guitar {\musicFix}


log result:


{ \absolute { cs'1 { \tag #'piano { cs'''1 } } |
     } }

{ \absolute { cs'1 { \tag #'guitar { cs''1 } } |
     } }

{ \absolute { cs'1 { \tag #'piano { cs''1 } } |
     } }

{ \absolute { cs'1 { \tag #'guitar { cs''1 } } |
     } }