5.6.1 Other uses for tweaks


Tying notes across voices

The following example demonstrates how to connect notes in different voices using ties. Normally, only two notes in the same voice can be connected with ties. By using two voices, with the tied notes in one of them

[image of music]

and blanking the first up-stem in that voice, the tie appears to cross voices:

<<
  {
    \tweak Stem.transparent ##t
    b8~ 8\noBeam
  }
\\
  { b8[ g] }
>>

[image of music]

To make sure that the just-blanked stem doesn’t squeeze the tie too much, we can lengthen the stem by setting the length to 8,

<<
  {
    \tweak Stem.transparent ##t
    \tweak Stem.length #8
    b8~ 8\noBeam
  }
\\
  { b8[ g] }
>>

[image of music]

Now for overriding the transparency of a graphical object, we could have used the shorthand \hide as explained above. Tweaking is a different operation, affecting only properties generated from a single music expression. It turns out that we can convert overrides into tweaks using \single, making it possible to rewrite the above example as

<<
  {
    \single \hide Stem
    \single \hide Flag
    \tweak Stem.length #8
    b8~ 8\noBeam
  }
\\
  { b8[ g] }
>>

[image of music]

In this particular case, the difference to \once \hide is not apparent. It is important when there are several objects at the same point in musical time (like noteheads in a chord). In that case, \once will affect all of those objects while \single will only affect a single one, the one generated by the immediately following music expression.


Simulating a fermata in MIDI

For outside-staff objects it is usually better to override the object’s stencil property rather than its transparent property when you wish to remove it from the printed output. Setting the stencil property of an object to #f will remove that object entirely from the printed output. This means it has no effect on the placement of other objects placed relative to it.

For example, if we wished to change the metronome setting in order to simulate a fermata in the MIDI output we would not want the metronome markings to appear in the printed output, and we would not want it to influence the spacing between the two systems or the positions of adjacent annotations on the staff. So setting its stencil property to #f would be the best way. We show here the effect of the two methods:

\score {
  \relative {
    % Visible tempo marking
    \tempo 4=120
    a'4 a a
    \once \hide Score.MetronomeMark
    % Invisible tempo marking to lengthen fermata in MIDI
    \tempo 4=80
    a4\fermata |
    % New tempo for next section
    \tempo 4=100
    a4 a a a |
  }
  \layout { }
  \midi { }
}

[image of music]

\score {
  \relative {
    % Visible tempo marking
    \tempo 4=120
    a'4 a a
    \once \omit Score.MetronomeMark
    % Invisible tempo marking to lengthen fermata in MIDI
    \tempo 4=80
    a4\fermata |
    % New tempo for next section
    \tempo 4=100
    a4 a a a |
  }
  \layout { }
  \midi { }
}

[image of music]

Both methods remove the metronome mark which lengthens the fermata from the printed output, and both affect the MIDI timing as required, but the transparent metronome mark in the first line forces the following tempo indication too high while the second (with the stencil removed) does not.

Zie ook

Music Glossary: system.


LilyPond – Beginnershandleiding v2.23.82 (ontwikkelingstak).