%% Generated by lilypond-book.py
%% Options: [exampleindent=10.16\mm,indent=0\mm,line-width=160\mm]
\include "lilypond-book-preamble.ly"


% ****************************************************************
% Start cut-&-pastable-section
% ****************************************************************



\paper {
  indent = 0\mm
  line-width = 160\mm
  % offset the left padding, also add 1mm as lilypond creates cropped
  % images with a little space on the right
  line-width = #(- line-width (* mm  3.000000) (* mm 1))
}

\layout {
  
}





% ****************************************************************
% ly snippet:
% ****************************************************************
\sourcefilename "extending-glissandi-across-repeats.ly"
\sourcefileline 0
% DO NOT EDIT this file manually; it is automatically
% generated from Documentation/snippets/new
% Make any changes in Documentation/snippets/new/
% and then run scripts/auxiliar/makelsr.py
%
% This file is in the public domain.
%% Note: this file works from version 2.17.6
\version "2.17.6"

\header {
%% Translation of GIT committish: f8e7ac6dcdc5255d0c409ca68407f04dc8b98b99

  texidocfr = "
Un glissando qui se prolonge sur plusieurs sections @code{\\alternative}
peut se rappeler à l'aide d'une note d'ornement supplémentaire et
masquée, à laquelle sera attaché le départ du glissando, ce dans chaque
bloc @code{\\alternative}.  Cette note d'ornement devrait avoir la même
hauteur que la note où commençait le glissando originel.  Ceci est géré
par une fonction musicale qui prendra en argument la hauteur de la note
d'ornement.

Dans le cadre d'un musicque polyphonique, il ne faudra pas oublier
d'ajouter une note d'ornement dans toutes les autres voix afin de
préserver la synchronisation.

"
  doctitlefr = "Rappel du glissando à l'occasion d'une alternative"

  lsrtags = "staff-notation, tweaks-and-overrides"
  texidoc = "
A glissando which extends into several @code{\\alternative} blocks
can be simulated by adding a hidden grace note with a glissando
at the start of each @code{\\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 which
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.
"
  doctitle = "Extending glissandi across repeats"
} % begin verbatim


repeatGliss = #(define-music-function (parser location 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 e1 }
  }
}

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


% ****************************************************************
% end ly snippet
% ****************************************************************
