Am Donnerstag, 23. Dezember 2010, um 20:25:09 schrieb Reinhold Kainhofer:
> In particular, the problem appears not only with NoteNames, but with any
> other context that is used without a surrounding staff, i.e. FiguredBass,
> ChordNames, etc. The offending code can be found in line 138 of
> scm/parser- clef.scm (function make-clef-set):
> 
>         (context-spec-music seq 'Staff))
> 
> If you use \clef inside a music expression that is not surrounded by a
> staff, lilypond tries to fine the surrounding staff. As that fails,
> apparently, it simply picks up the first Staff context it finds...


Actually, it's even worse: It's not really a bug in the \clef function, but a 
much more general problem with \set and \override!

In particular, if you use \override Staff..... inside a context that does not 
have a Staff parent (like NoteNames, FiguredBass, etc.), then that \override 
will always be applied to the very first staff of the score!

Simple example for this behavior is attached.


Analyzed in more detail: If you set a property for a context that is not a 
parent of the current context, then lilypond will use the first context of 
that name that it finds anywhere in the score and apply the settings there!

The attached example also contains a second example showing this behavior: In 
the voice of the first staff, I set FiguredBass.BassFigure #'color. As 
FiguredBass is no parent of that voice, lilypond searches for a FiguredBass 
context anywhere in the score and applies the setting to the only FiguredBass 
context it finds in the score (although that setting should never have any 
effect on parallel contexts, only on parents or children!).


And a third example of this bug is also contained in the example: If you use 
\set PianoStaff.ShortInstrumentName ... in a normal staff (not inside a 
PianoStaff), the instrument name of an independen PianoStaff will be changed 
instead!

Cheers,
Reinhold

-- 
------------------------------------------------------------------
Reinhold Kainhofer, reinh...@kainhofer.com, http://reinhold.kainhofer.com/
 * Financial & Actuarial Math., Vienna Univ. of Technology, Austria
 * http://www.fam.tuwien.ac.at/, DVR: 0005886
 * LilyPond, Music typesetting, http://www.lilypond.org
\version "2.13.41"


%%%% 1st example: \override in a non-Staff context applies to the first Staff
%                 of the score!
musicI = \relative c' { \clef "treble" c4 dis }
musicII = \relative c { \override Staff.Accidental #'color = #red dis4 \override Voice.Accidental #'color = #blue es }
\score { <<
  \new Staff \new Voice \musicI
  \new Staff \new Voice \musicI
  \new Staff \new Voice \musicII
  % BUG: The \override Staff.... inside the NoteNames changes the very first 
  %      staff of the score!!!
  \new NoteNames \musicII
>>}



%%% 2nd example: \override for a FiguredBass grob in a non-FiguredBass context
%                applies to the FiguredBass context in parallel to the Staff
\score { <<
    % This override will be applied to the FiguredBass that appears later:
    \new Staff \new Voice \relative c' { c4 \override FiguredBass.BassFigure #'color = #green d }
    \new Staff \new Voice \relative c' { c4 d }
    \new FiguredBass \figuremode { <8 3>4 <5> <7 2> }
>>
}


%%% 3rd example: You can change the settings of a PianoStaff from a completely 
%%%% different staff that is not inside a PianoStaff!
\score { <<
    \new Staff \new Voice \relative c' { c1 \break 
      %% The following \set should never apply to the PianoStaff that follows the current staff!
      \set PianoStaff.shortInstrumentName = #"Dummy" d1 
    }
    \new PianoStaff <<
      \new Staff \relative c' { f1 g }
      \new Staff \relative c { \clef "bass" f1 g }
    >>
  >>
}
_______________________________________________
bug-lilypond mailing list
bug-lilypond@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-lilypond

Reply via email to