Piano “half sustain pedal” indications: Difference between revisions

Import snippet from LSR
 
m Formatting
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
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 />
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).
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 />
 
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.
 
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>.
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.
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">
<lilypond version="2.24">
%% This snippet defines functions that enable "1/2" pedal indications
%% This snippet defines functions that enable "1/2" pedal indications
%% to be used.  Using this is quite easy, just add \sustainHalfOn
%% to be used.  Using this is quite easy, just add \sustainHalfOn
Line 106: Line 108:


\new Staff {
\new Staff {
   \set Staff.pedalSustainStyle = #'mixed
   \set Staff.pedalSustainStyle = #'mixed
   \sustainHalfOn
   \sustainHalfOn
   b'16 c' d' e'
   b'16 c' d' e'
Line 118: Line 118:
   a' a'
   a' a'
   \sustainOn
   \sustainOn
   a'
   a' a'
  a'
   \sustainOff\sustainOn
   \sustainOff\sustainOn
   a' a' a' a'
   a' a' a' a'
   \sustainOff
   \sustainOff
Line 142: Line 140:
[[Category:Workaround]]
[[Category:Workaround]]
[[Category:Tweaks and overrides]]
[[Category:Tweaks and overrides]]
[[Category:Snippet]]