lilypond-learning: The stencil property
The ‘stencil’ property
......................
This property controls the appearance of the bar lines by specifying the
symbol (glyph) which should be printed. In common with many other
properties, it can be set to print nothing by setting its value to ‘#f’.
Let’s try it, as before, omitting the implied Context, ‘Voice’:
{
\time 12/16
\override BarLine.stencil = ##f
c4 b8 c d16 c d8 |
g,8 a16 b8 c d4 e16 |
e8
}
[image src="" alt="[image of music]" text="image of music" ]
The bar lines are still printed. What is wrong? Go back to the IR
and look again at the page giving the properties of BarLine. At the top
of the page it says “Barline objects are created by: Bar_engraver”. Go
to the ‘Bar_engraver’ page. At the bottom it gives a list of Contexts
in which the bar engraver operates. All of them are of the type
‘Staff’, so the reason the ‘\override’ command failed to work as
expected is because ‘Barline’ is not in the default ‘Voice’ context. If
the context is specified incorrectly, the command simply does not work.
No error message is produced, and nothing is logged in the log file.
Let’s try correcting it by adding the correct context:
{
\time 12/16
\override Staff.BarLine.stencil = ##f
c4 b8 c d16 c d8 |
g,8 a16 b8 c d4 e16 |
e8
}
[image src="" alt="[image of music]" text="image of music" ]
Now the bar lines have vanished. Setting the ‘stencil’ property to
‘#f’ is such a frequent operation that there is a shorthand for it
called ‘\omit’:
{
\time 12/16
\omit Staff.BarLine
c4 b8 c d16 c d8 |
g,8 a16 b8 c d4 e16 |
e8
}
[image src="" alt="[image of music]" text="image of music" ]
Note, though, that setting the ‘stencil’ property to ‘#f’ will cause
errors when the dimensions of the object are required for correct
processing. For example, errors will be generated if the ‘stencil’
property of the ‘NoteHead’ object is set to ‘#f’. If this is the case,
you can instead use the ‘point-stencil’ function, which sets the stencil
to an object with zero size:
{
c4 c
\once \override NoteHead.stencil = #point-stencil
c4 c
}
[image src="" alt="[image of music]" text="image of music" ]