Changing stems direction without affecting rests: Difference between revisions
Appearance
No edit summary |
m New category |
||
| Line 36: | Line 36: | ||
[[Category:Scheme]] | [[Category:Scheme]] | ||
[[Category:Tweaks and overrides]][[Category:Snippet]] | [[Category:Tweaks and overrides]] | ||
[[Category:Snippet]] | |||
Latest revision as of 23:32, 21 November 2025
Here is how to change the stems direction without affecting rests.
\version "2.24"
%% http://lsr.di.unimi.it/LSR/Item?id=732
%LSR Contributed by Valentin Villenave http://lists.gnu.org/archive/html/lilypond-user-fr/2010-12/msg00047.html
stemDownRestsUp =
\override Stem.direction =
#(lambda (grob)
(let* ((cause (ly:grob-property grob 'cause))
(parent-cause (ly:grob-property cause 'cause))
(parent-props (ly:prob-immutable-properties parent-cause))
(parent-class (assoc-get 'class parent-props)))
(if (eq? parent-class 'rest-event)
UP
DOWN)))
\layout { ragged-right = ##f }
\new Staff = "example" {
<<
\context Voice = "up" { \voiceOne r4 c''4 r2 }
\context Voice = "down" { \voiceTwo c'1^"normal" }
>>
<<
\context Voice = "up" { \voiceOne \stemDown r4 c''4 r2 }
\context Voice = "down" { \voiceTwo c'1^"stemDown" }
>>
<<
\context Voice = "up" { \voiceOne \stemDownRestsUp r4 c''4 r2 }
\context Voice = "down" { \voiceTwo c'1^"stemDown, rests Up" }
>>
}