Jump to content

Extending glissandi across repeats: Difference between revisions

From LilyPond wiki
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
mNo edit summary
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
A glissando which extends into several <code>\alternative</code> blocks can be simulated by adding a hidden grace note with a glissando at the start of each <code>\alternative</code> block. The grace note should be at the same pitch as the note which starts the initial glissando. This is implemented here with a music function which takes the pitch of the grace note as its argument.
A glissando that extends into several <code>\alternative</code> blocks can be simulated by adding a hidden grace note with a glissando at the start of each <code>\alternative</code> block. The grace note should be at the same pitch as the note which starts the initial glissando. This is implemented here with a music function that takes the pitch of the grace note as its argument.


Note that in polyphonic music the grace note must be matched with corresponding grace notes in all other voices.
Note that in polyphonic music the grace note must be matched with corresponding grace notes in all other voices.


<lilypond version="2.24" full>
<lilypond version="2.24">
repeatGliss = #(define-music-function (grace)
repeatGliss = #(define-music-function (grace)
   (ly:pitch?)
   (ly:pitch?)
Line 48: Line 48:
   >>
   >>
}
}
\paper { tagline = ##f }
</lilypond>
</lilypond>


[[Category:Included in the official documentation]]
[[Category:Scheme]]
[[Category:Staff notation]]
[[Category:Staff notation]]
[[Category:Tweaks and overrides]]
[[Category:Tweaks and overrides]]
[[Category:Workaround]]
[[Category:Included in the official documentation]]
[[Category:Snippet]]

Latest revision as of 10:00, 10 December 2025

A glissando that extends into several \alternative blocks can be simulated by adding a hidden grace note with a glissando at the start of each \alternative block. The grace note should be at the same pitch as the note which starts the initial glissando. This is implemented here with a music function that takes the pitch of the grace note as its argument.

Note that in polyphonic music the grace note must be matched with corresponding grace notes in all other voices.

\version "2.24"

repeatGliss = #(define-music-function (grace)
  (ly:pitch?)
  #{
    % the next two lines ensure the glissando is long enough
    % to be visible
    \once \override Glissando.springs-and-rods
      = #ly:spanner::set-spacing-rods
    \once \override Glissando.minimum-length = 3.5
    \once \hideNotes
    \grace $grace \glissando
  #})

\score {
  \relative c'' {
    \repeat volta 3 { c4 d e f\glissando }
    \alternative {
      { g2 d }
      { \repeatGliss f g2 e }
      { \repeatGliss f e2 d }
    }
  }
}

music =  \relative c' {
  \voiceOne
  \repeat volta 2 {
    g a b c\glissando
  }
  \alternative {
    { d1 }
    { \repeatGliss c \once \omit StringNumber e1\2 }
  }
}

\score {
  \new StaffGroup <<
    \new Staff <<
      \new Voice { \clef "G_8" \music }
    >>
    \new TabStaff  <<
      \new TabVoice { \clef "moderntab" \music }
    >>
  >>
}