7

Using the following adjusted musical example:

enter image description here

I'm hoping to remove all elements except for clefs, key signatures, the staff itself, note heads, and accidentals. All other elements—ties and slurs, articulations, dynamics, stems and beams, etc.—should be removed. The intended output for the above example is:

enter image description here

I expected the following code to do the trick. Can anyone tell me what I'm doing wrong?

\version "2.20.0"
\language "english"

global = {
  \key e \minor
  \time 2/2
  \partial 4
}

right = \relative c' {
  \global
  e8_\mf fs |
  g4 fs8 e ds4 e8 fs |
  b,4\( cs8 ds e4\)
}

left = \relative c {
  \global
  g8( fs |
  e4) a b-> a |
  g fs e
}

\score {
  \new PianoStaff <<
    \new Staff = "upper" \right
    \new Staff = "lower" { \clef bass \left }
  >>
  \layout { 
    \context {
      \PianoStaff
        \remove "Time_signature_engraver"
        \remove "Stem_engraver"
        \remove "Rest_engraver"
        \remove "Phrasing_slur_engraver"
        \remove "Slur_engraver"
        \remove "Tie_engraver"
        \remove "Dynamic_engraver"
    }
  }
}
2
  • Weird. If I change \context { \PianoStaff to \context { \Staff, then the time signature engraver is removed, but none of the others. This is true even if I change the order of the \removes.
    – Aaron
    Commented Aug 20, 2022 at 20:40
  • Interesting. I've tried PianoStaff, Staff, and Score there, all to no avail.
    – Richard
    Commented Aug 20, 2022 at 20:42

2 Answers 2

8

It's very simple. You need to remove the engravers from the proper objects.

PianoStaff is an object whose only job is to grab some Staffs, equip them with a nice brace and a single centered instrument name. So it technically does not know anything about time signature or anything else. It just knows about the staves that it is supposed to hold. If you tell it to stop engraving time signatures, nothing happens because it hasn't been engraving any time signatures in the first place.

Similarly, a Staff is just an object that is supposed to hold some Voices. It needs to keep some context and global stuff (like time signature, key signature or any accidentals that have been used (to handle situations like "one voice contains a C# and another contains a C later in the same bar", in which case some object needs to take note of the accidentals)). So if you tell it to get rid of time signature, it works, because it was its job to engrave it. However, it does not engrave any of the other stuff, so still nothing happens.

So the question is: whose job it is to engrave all the stems, rests etc.? The answer is simple: it's the Voice's job.

All in all, changing your \layout block to

\layout { 
  \context {
    \Staff
    \remove "Time_signature_engraver"
  }
  \context {
    \Voice
    \remove "Stem_engraver"
    \remove "Rest_engraver"
    \remove "Phrasing_slur_engraver"
    \remove "Slur_engraver"
    \remove "Tie_engraver"
    \remove "Dynamic_engraver"
  }
}

will make it work — you just need to tell the objects that actually have the responsibility of drawing the stuff you want to get rid of.

2
  • Oh, how embarassing; I tried everything except Voice! Cheers.
    – Richard
    Commented Aug 20, 2022 at 20:57
  • 1
    @Richard, yeah, chasing the correct object for the job is sometimes a bit annoying :—). And Voice is something you need to specify only in the contexts (pretty much), because most of the time you're "inside" a voice. So normally you need to do e. g. \omit Staff.TimeSignature (to "go up a level" and take it to the Staff) but if it's the Voice's job, you do only e. g. \omit Stem.
    – Ramillies
    Commented Aug 20, 2022 at 21:02
4

In case you want this to affect only certain types of contexts you might also do

\version "2.20.0"
\language "english"

global = {
  \key e \minor
  \time 2/2
  \partial 4
}

right = \relative c' {
  \global
  e8_\mf fs |
  g4 fs8 e ds4 e8 fs |
  b,4\( cs8 ds e4\)
}

left = \relative c {
  \global
  g8( fs |
  e4) a b-> a |
  g fs e
}

\score {
  \new PianoStaff <<
    \new Staff = "upper" \right
    \new Staff = "lower" { \clef bass \left }
  >>
  \layout { 
    \context {
      \PianoStaff
        \override TimeSignature.stencil = ##f
        \override Stem.stencil = ##f
        \override Beam.stencil = ##f
        \override Flag.stencil = ##f
        \override Rest.stencil = ##f
        \override MultiMeasureRest.stencil = ##f
        \override PhrasingSlur.stencil = ##f
        \override Slur.stencil = ##f
        \override Tie.stencil = ##f
        \override DynamicText.stencil = ##f
        \override DynamicLineSpanner.stencil = ##f
        \override DynamicTextSpanner.stencil = ##f
        \override Script.stencil = ##f
        \override TextScript.stencil = ##f
    }
  }
}

which is for example the way TabStaff done.

3
  • 1
    Good point. I would just add that \override Whatever.stencil = ##f can be more conveniently written as \omit Whatever.
    – Ramillies
    Commented Aug 20, 2022 at 22:45
  • @Ramillies That is true. I’m not the biggest fan of using \omit ... for everything, because there is no sort of unomit. Thus it is hard for beginners to grasp what omit does and how it can be reverted. \override ....stencil = ##f and \revert ....stencil are in my opinion less functional is verbosity, but easier to wrap your head around. I would generelly suggest using \omit in situations where you do \once\omit ... though.
    – Lazy
    Commented Aug 21, 2022 at 10:58
  • 2
    You can unomit just fine: \undo\omit Whatever
    – Ramillies
    Commented Aug 21, 2022 at 13:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.