summaryrefslogtreecommitdiff
path: root/Documentation/snippets/extending-glissandi-across-repeats.ly
blob: 4656fac4430b740aa164f4e84ffe36158e7fe49e (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
% 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 {
  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 }
    >>
  >>
}