Autochange music with a different pitch: Difference between revisions
Appearance
Import snippet from LSR |
m Replace version="2.24.0" with version="2.24" now that the LilyWiki extension supports auto-selecting the latest release in a stable series |
||
| Line 1: | Line 1: | ||
The <code>\autochange</code> command usually allows to switch staves when reaching the middle C. However, here is a way to specify a different pitch as the "turning point". | The <code>\autochange</code> command usually allows to switch staves when reaching the middle C. However, here is a way to specify a different pitch as the "turning point". | ||
<lilypond version="2.24 | <lilypond version="2.24"> | ||
%% http://lsr.di.unimi.it/LSR/Item?id=724 | %% http://lsr.di.unimi.it/LSR/Item?id=724 | ||
Revision as of 18:48, 16 November 2025
The \autochange command usually allows to switch staves when reaching the middle C. However, here is a way to specify a different pitch as the "turning point".
\version "2.24"
%% http://lsr.di.unimi.it/LSR/Item?id=724
% by David Kastrup (Feb. 2014)
autoChangeWithPitch =
#(define-music-function (ref music) ((ly:pitch?) ly:music?)
(let ((mus (make-autochange-music
(if ref #{ \transpose $ref c' $music #} music))))
(set! (ly:music-property mus 'element) music)
mus))
\context PianoStaff <<
\context Staff = "up" {
\autoChangeWithPitch a \new Voice << \relative c' {
g4 c e d c r4 a g } >>
}
\context Staff = "down" {
\clef bass
s1*2
}
>>