Hi James (et al).

There seems to still be some confusion about all this… There is certainly no need to "define a context for instrument names", as suggested by James:

You could define a context for instrument names, which is probably way more work than is necessary for most situations

I have attached a little tutorial, which shows various methods of showing or hiding an instrument name, both when that instrument name is defined inside the music variable and when it is not.

Hope this helps!
Kieren.

\version "2.12"
\include "english.ly"
#(set-global-staff-size 18)

\markup \wordwrap { We have defined two music variables: \typewriter "\musicWithName" and \concat { \typewriter "\musicWithoutName" . } }
musicWithName = \relative
{
  \tag #'score \set Staff.instrumentName = "Kazoo"
  c4 d e f | g1 \bar "|."
}
musicWithoutName = \relative
{
  c4 d e f | g1 \bar "|."
}

\markup \wordwrap { First, we show how to display or hide the instrument name using \concat { \typewriter "\musicWithName" . } Here is the default output: }
\score
{
  \musicWithName
}
\markup \wordwrap { Note that trying to override the \typewriter "Staff.instrumentName" property in the \typewriter "\with" block fails, because the \typewriter "\set Staff.instrumentName" command contained inside \typewriter "\musicWithName" “resets” the property \italic after the staff (music) really begins: }
\score
{
  \new Staff \with { instrumentName = "" } \musicWithName
}

\markup \wordwrap { In the \typewriter "\with" block of the Staff context, you \italic { can } eliminate the instrument name entirely, by setting the \typewriter "#'stencil" property to \concat { \typewriter "##f" : } }
\score
{
  \new Staff \with { \override InstrumentName #'stencil = ##f } \musicWithName
}
\markup \wordwrap { The same effect is obtained by completely removing the \typewriter Instrument_name_engraver from the Staff context: }
\score
{
  \new Staff \musicWithName
  \layout { \context { \Staff \remove "Instrument_name_engraver" } }
}

\markup \wordwrap { If you have “tagged” the \typewriter "\set Staff.instrumentName" command inside the musical content (unnecessarily mixing content with presentation), you can use \typewriter "\removeWithTag" to hide the instrument name: }
\score
{
  \new Staff \removeWithTag #'score \musicWithName
}

\markup \wordwrap { Now, we show how to display or hide the instrument name using \concat { \typewriter "\musicWithoutName" . } Here is the default output: }
\score
{
  \musicWithoutName
}

\markup \wordwrap { Of course, you can add the instrument name to the Staff context directly, in the \typewriter "\with" block (and this is probably the best method): }
\score
{
  \new Staff \with { instrumentName = "Kazoo" } \musicWithoutName
}
\markup \wordwrap { Alternatively, you can use a \typewriter "\set Staff.instrumentName" command within the staff music: }
\score
{
  \new Staff { \set Staff.instrumentName = "Kazoo" \musicWithoutName }
}
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to