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
Piano "Half Sustain Pedal" Indications
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!
When playing the piano, there a quite a few songs that require you to only press the sustain pedal half way (or even a quarter of the way in some cases).<br /> There is currently not a way to show these indications on the generated music in an intuitive way. This snippet provides functions that allow you to easily do this.<br /> The implementation is quite complicated, but basically there are two music functions that get defined, <code>sustainHalfOn</code> and <code>sustainHalfOff</code>. You can use these just like you would normally use <code>sustainOn</code> and <code>sustainOff</code>. You can use any of the sustain pedal styles, and everything will work as expected. You do need to add an explicit call to <code>sustainHalfOff</code> when you want the half pedal to end. Calling <code>sustainOn</code> does not automatically turn off <code>sustainHalfOn</code>. Under the covers, this works by representing sustain half on/half off as Una Corda pedal events. The logic temporarily changes the rendering of Una Corda pedals when you call <code>sustainHalfOn</code>, and changes it back when you call <code>sustainHalfOff</code>. We also temporarily change the value of <code>Staff.unaCordaPedalStyle</code> to match the value of <code>Staff.sustainPedalStyle</code> for the duration of the half sustain event so that the intended sustain pedal style will be used. <lilypond version="2.24.0"> %% This snippet defines functions that enable "1/2" pedal indications %% to be used. Using this is quite easy, just add \sustainHalfOn %% in place of \sustainOn and \sustainHalfOff in place of \sustainOff %% %% This implementation fully supports 'mixed, 'text, and 'bracket pedal modes %% %% The new functions will honor the value of Staff.sustainPedalStyle when %% doing the rendering. %% %% The implementation of these functions is a bit complicated. In order to %% force a new pedal indication when changing from half pedal to full pedal %% or vice versa in mixed or bracket mode, internally this implementation %% represents the half pedal events as UnaCorda pedal events. Basically, %% when \sustainHalfOn is called, we temporarily change the rendering %% of the UnaCorda pedal indications so they look like a half pedal. %% When \sustainHalfOff is called, they are changed back. A side effect of %% this is that having the UnaCorda pedal and 1/2 pedal active at the %% same time is not possible with this implementation. %% Definitions of half-pedal functions. Moving these to a Lilypond include file is recommended. #(define (half-pedal-stencil grob) (grob-interpret-markup grob (markup #:raise 0.1 "Β½" #:hspace -0.5 #:musicglyph "pedal.Ped"))) #(define (add-sustain-on note-event) (set! (ly:music-property note-event 'articulations) (cons (make-music 'UnaCordaEvent 'span-direction -1) (ly:music-property note-event 'articulations))) note-event) #(define (override-una-corda-strings) (context-spec-music (make-sequential-music (list (make-property-set 'pedalUnaCordaStrings (list "Ped." "*Ped." "*")) (make-apply-context (lambda (context) (ly:context-set-property! context 'pedalUnaCordaStyle (ly:context-property context 'pedalSustainStyle)))))) 'Staff)) #(define (revert-una-corda-strings) (context-spec-music (make-sequential-music (list (make-property-unset 'pedalUnaCordaStrings) (make-property-unset 'pedalUnaCordaStyle))) 'Staff)) #(define (add-sustain-off note-event) (set! (ly:music-property note-event 'articulations) (cons (make-music 'UnaCordaEvent 'span-direction 1) (ly:music-property note-event 'articulations))) note-event) #(define (use-half-pedal-stencil) (context-spec-music (make-grob-property-set 'UnaCordaPedal 'stencil half-pedal-stencil) 'Staff)) #(define (revert-pedal-stencil) (context-spec-music (make-grob-property-revert 'UnaCordaPedal 'stencil) 'Staff)) sustainHalfOn = #(define-music-function (note) (ly:music?) (make-sequential-music (list (override-una-corda-strings) (use-half-pedal-stencil) (add-sustain-on note)))) sustainHalfOff = #(define-music-function (note) (ly:music?) (make-sequential-music (list (revert-pedal-stencil) (add-sustain-off note) (revert-una-corda-strings)))) %% Half Pedal Example \new Staff { \set Staff.pedalSustainStyle = #'mixed \sustainHalfOn b'16 c' d' e' \sustainHalfOff f' \sustainOn g' a' a' a' a' a' c' \sustainOff a' a' \sustainOn a' a' \sustainOff\sustainOn a' a' a' a' \sustainOff \set Staff.pedalSustainStyle = #'text a' \sustainHalfOn a' a' a' a' \sustainHalfOff a' \sustainOn a' a' a' a' a' \sustainOff a' } </lilypond> [[Category:Scheme]] [[Category:Contexts and engravers]] [[Category:Expressive marks]] [[Category:Workaround]] [[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
Piano "Half Sustain Pedal" Indications
Add topic