Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
LilyPond wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Defining a Custom Staff Context
Page
Discussion
English
Read
Edit
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
Edit source
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
Instead of having to type the same customization commands every time you need to use a particular type of staff, you can define a custom staff context and use it instead. For example, instead of: <code>\new Staff \with { ... }</code> You would use: <code>\new MyCustomStaff</code> A custom staff context can have any customizations that you would use in a Staff's \with block. Note that the custom staff's definition can be saved in a file that you <code>\include</code>, so you do not have to re-create it every time it is needed. <lilypond version="2.24.0"> %% http://lsr.di.unimi.it/LSR/Item?id=979 (formerly id=882) % DEFINE A CUSTOM STAFF CONTEXT FOR "LAYOUT" \layout { \context { % make a copy of the standard Staff context \Staff % give this custom context a name of your choice \name MyCustomStaff % tell LilyPond that commands that work in a standard % Staff context should also work in this custom context \alias Staff % add customizations, these are just examples, % they can be anything that can go in a staff's \with block \consists "Pitch_squash_engraver" squashedPosition = #0 \override NoteHead.style = #'slash \override Stem.transparent = ##t \override Flag.transparent = ##t } % define which "parent" contexts will accept this custom context as a "child" \context { \Score \accepts MyCustomStaff } \context { \ChoirStaff \accepts MyCustomStaff } \context { \GrandStaff \accepts MyCustomStaff } \context { \PianoStaff \accepts MyCustomStaff } \context { \StaffGroup \accepts MyCustomStaff } } % DEFINE THE CUSTOM STAFF CONTEXT FOR "MIDI" TOO % to avoid warnings the context has to be defined for each type of output \midi { \context { \Staff \name MyCustomStaff \alias Staff % the customizations are not needed for midi % since they are for visual output only } \context { \Score \accepts MyCustomStaff } \context { \ChoirStaff \accepts MyCustomStaff } \context { \GrandStaff \accepts MyCustomStaff } \context { \PianoStaff \accepts MyCustomStaff } \context { \StaffGroup \accepts MyCustomStaff } } % EXAMPLE \score { << \new Staff { c' d' e' f' } \new MyCustomStaff { c' d' e' f' } >> \layout { } \midi { } } </lilypond> [[Category:Contexts and engravers]] [[Category:Tweaks and overrides]]
Summary:
Please note that all contributions to LilyPond wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Meta:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Defining a Custom Staff Context
Add topic