lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Instrument Name Not Appearing


From: Thomas Morley
Subject: Re: Instrument Name Not Appearing
Date: Sat, 2 Dec 2017 21:29:26 +0100

2017-12-02 17:38 GMT+01:00 SoundsFromSound <address@hidden>:
> Hello list,
>
> I am trying to get an instrument name to show beside a staff that begins in
> the middle of a passage, but I'm not having success. I've attached a
> screenshot, here is the code that shows my question:
>
> \version "2.19.80"
>
> \score {
>   <<
>     \new Staff = "Testing"
>     \with { instrumentName = "Top"  }
>     \relative c'' { c1 | c | c | c |  }
>
>     \new StaffGroup
>     \relative c'' {
>       \new Staff \with { instrumentName = "Bottom"  }
>       { c1 | c <<
>       { c1 | d  }
>
>       \new Staff \with { instrumentName = "Violin"
>             alignAboveContext = "Testing" }
>           {  \once \omit Staff.TimeSignature
>              c1 | b }
>                     >>
>       }
>     }
>   >>
> }
>
> Can someone please show me what I am doing wrong, and how I can get the
> "Violin" instrument name to show up next to the topmost staff?

The stencil-procedure for InstrumentName, system-start-text::print,
explecitely disallows printing an InstrumentName in the middle of a
system.
No clue about the reasoning.

You could try:

#(define-public (my-system-start-text::print grob)
  (let* ((orig (ly:grob-original grob))
         (siblings (if (ly:grob? orig)
                       (ly:spanner-broken-into orig) '() ))
         (long-text (ly:grob-property grob 'long-text #f))
         (text (ly:grob-property grob 'text #f)))
    (cond ((and long-text
                (pair? siblings)
                (equal? grob (car siblings)))
             (grob-interpret-markup grob long-text))
          ((and text
                (pair? siblings)
                (member grob (cdr siblings)))
             (grob-interpret-markup grob text))
          (else (ly:grob-suicide! grob)))))

\layout {
  \override Staff.InstrumentName.stencil = #my-system-start-text::print
}

\score {
  <<
    \new Staff = "Testing"
      \with { instrumentName = "Top"  }
      \relative c'' { c1 | c | c | \break c |  }

    \new StaffGroup
    \relative c'' {
      \new Staff \with { instrumentName = "Bottom"  }
      { c1 | c <<
      { c1 | d  }

      \new Staff \with {
        instrumentName = "Violin"
        shortInstrumentName = "Vln"
            alignAboveContext = "Testing"
      }
          {  \once \omit Staff.TimeSignature
             c1 | b }
                    >>
      }
    }
  >>
}

Though, I've also no clue about side-effects.


Cheers,
  Harm



reply via email to

[Prev in Thread] Current Thread [Next in Thread]