Initial clef change: Difference between revisions
Import snippet from LSR |
mNo edit summary |
||
| (3 intermediate revisions by 3 users not shown) | |||
| Line 1: | Line 1: | ||
This snippet handles initial clef changes with a custom engraver. This engraver checks whether there is a difference between the initial clef (as given by <code>\with { \clef ... }</code> and the clef at the first timestep. If any difference is encountered a new clef (spaced like a cue clef) is created, while the original clef and any key signatures are modified to look like the initial clef values. | |||
<lilypond version="2.24 | <lilypond version="2.24"> | ||
%%% This engraver records the initial clef properties (e.g. what is set by \with { \clef ... }) | %%% This engraver records the initial clef properties (e.g. what is set by \with { \clef ... }) | ||
%%% If in the first timestep these changed, engrave the original clef, and change formatting and break | %%% If in the first timestep these changed, engrave the original clef, and change formatting and break | ||
| Line 181: | Line 181: | ||
\clef bass | \clef bass | ||
c'1 | c'1 | ||
} | |||
} | |||
% Basic usage: | |||
\score { | |||
<< | |||
% Just the treble clef | |||
\new Staff { | |||
\key bes \major | |||
c''1 | |||
} | |||
% Just the bass clef | |||
\new Staff \with { \clef bass } { | |||
\key bes \major | |||
c1 | |||
} | |||
% Initial treble clef, then bass clef | |||
\new Staff { | |||
\key bes \major | |||
\clef bass | |||
c1 | |||
} | |||
% Initial bass clef, then treble clef | |||
\new Staff \with { \clef bass } { | |||
\key bes \major | |||
\clef treble | |||
c''1 | |||
} | |||
>> | |||
\layout { | |||
\context { | |||
\Staff | |||
\consists #initial-clef-change-engraver | |||
} | |||
} | } | ||
} | } | ||
</lilypond> | </lilypond> | ||
[[Category:Contexts and engravers]] | |||
[[Category:Scheme]] | |||
[[Category:Staff notation]] | |||
[[Category:Snippet]] | |||