]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/repeated-music.hh
35a4aaa6e088afa743e39dce30f92f56585e8a6c
[lilypond.git] / lily / include / repeated-music.hh
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 1999--2012 Han-Wen Nienhuys <hanwen@xs4all.nl>
5
6   LilyPond is free software: you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation, either version 3 of the License, or
9   (at your option) any later version.
10
11   LilyPond is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   GNU General Public License for more details.
15
16   You should have received a copy of the GNU General Public License
17   along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #ifndef REPEATED_MUSIC_HH
21 #define REPEATED_MUSIC_HH
22
23 #include "music.hh"
24
25 /**
26    Musical repeats.
27
28    A repeat, when played has the form of BODY A BODY B BODY C.
29
30    In this examples, the list {A B C} is put in ALTERNATIVES_P_.  BODY
31    is put in REPEAT_BODY_P_.  Either the body or the alternative may
32    be omitted.
33
34    There are three modes of representing this  music:
35
36    BODY A
37    B
38    C
39
40    is called "folded". Mostly used for lyrics.
41
42
43    BODY A B C
44
45    is called volta.  This is common notation
46
47    BODY A BODY B BODY C
48
49    is called unfolded.  Useful for MIDI.
50
51    If the number of repeats is smaller than the number of alternatives, then
52    the excess alternatives are ignored for all timing purposes.
53
54    If the number of repeats is bigger than the number of alternatives, then
55    the first alternative is assumed to be repeated.
56 */
57 class Repeated_music
58 {
59 public:
60   static Music *body (Music *);
61   static SCM alternatives (Music *);
62
63   /* How often do we repeat? */
64   static int repeat_count (Music *);
65   DECLARE_SCHEME_CALLBACK (relative_callback, (SCM, SCM));
66
67   static Moment body_get_length (Music *);
68   static Moment alternatives_get_length (Music *, bool fold);
69   static Moment alternatives_volta_get_length (Music *);
70
71   DECLARE_SCHEME_CALLBACK (unfolded_music_length, (SCM));
72   DECLARE_SCHEME_CALLBACK (volta_music_length, (SCM));
73   DECLARE_SCHEME_CALLBACK (folded_music_length, (SCM));
74   DECLARE_SCHEME_CALLBACK (minimum_start, (SCM));
75   DECLARE_SCHEME_CALLBACK (first_start, (SCM));
76 };
77
78 #endif /* REPEATED_MUSIC_HH */