]> git.donarmstrong.com Git - lilypond.git/blob - scm/define-music-callbacks.scm
apply Julian's patch to fix install-info warnings
[lilypond.git] / scm / define-music-callbacks.scm
1 ;;;; This file is part of LilyPond, the GNU music typesetter.
2 ;;;;
3 ;;;; Copyright (C) 1998--2011 Han-Wen Nienhuys <hanwen@xs4all.nl>
4 ;;;;                 Jan Nieuwenhuizen <janneke@gnu.org>
5 ;;;;                 Neil Puttock <n.puttock@gmail.com>
6 ;;;;                 Carl Sorensen <c_sorensen@byu.edu>
7 ;;;;
8 ;;;; LilyPond is free software: you can redistribute it and/or modify
9 ;;;; it under the terms of the GNU General Public License as published by
10 ;;;; the Free Software Foundation, either version 3 of the License, or
11 ;;;; (at your option) any later version.
12 ;;;;
13 ;;;; LilyPond is distributed in the hope that it will be useful,
14 ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 ;;;; GNU General Public License for more details.
17 ;;;;
18 ;;;; You should have received a copy of the GNU General Public License
19 ;;;; along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
20
21 ;; TODO: should link back into user manual.
22
23 (define (mm-rest-child-list music)
24   "Generate events for multimeasure rests,
25 to be used by the sequential-iterator"
26   (let ((location (ly:music-property music 'origin))
27         (duration (ly:music-property music 'duration)))
28     (list (make-music 'BarCheck
29                       'origin location)
30           (make-event-chord (cons (make-music 'MultiMeasureRestEvent
31                                               'origin location
32                                               'duration duration)
33                                   (ly:music-property music 'articulations)))
34           (make-music 'BarCheck
35                       'origin location))))
36
37 (define (make-ottava-set music)
38   "Set context properties for an ottava bracket."
39   (let ((octavation (ly:music-property music 'ottava-number)))
40
41     (list (context-spec-music
42            (make-apply-context
43             (lambda (context)
44               (let ((offset (* -7 octavation))
45                     (string (assoc-get octavation '((2 . "15ma")
46                                                     (1 . "8va")
47                                                     (0 . #f)
48                                                     (-1 . "8vb")
49                                                     (-2 . "15mb")))))
50                 (set! (ly:context-property context 'middleCOffset) offset)
51                 (set! (ly:context-property context 'ottavation) string)
52                 (ly:set-middle-C! context))))
53            'Staff))))
54
55 (define (make-time-signature-set music)
56   "Set context properties for a time signature."
57   (let* ((num (ly:music-property music 'numerator))
58          (den (ly:music-property music 'denominator))
59          (structure (ly:music-property music 'beat-structure))
60          (fraction (cons num den)))
61     (list (descend-to-context
62             (context-spec-music
63               (make-apply-context
64                 (lambda (context)
65                   (let* ((time-signature-settings
66                           (ly:context-property context 'timeSignatureSettings))
67                          (my-base-fraction
68                            (base-fraction fraction time-signature-settings))
69                          (my-beat-structure
70                            (if (null? structure)
71                                (beat-structure my-base-fraction
72                                                fraction
73                                                time-signature-settings)
74                                structure))
75                          (beaming-exception
76                            (beam-exceptions fraction time-signature-settings))
77                          (new-measure-length (ly:make-moment num den)))
78                      (ly:context-set-property!
79                        context 'timeSignatureFraction fraction)
80                      (ly:context-set-property!
81                        context 'baseMoment (fraction->moment my-base-fraction))
82                      (ly:context-set-property!
83                        context 'beatStructure my-beat-structure)
84                      (ly:context-set-property!
85                        context 'beamExceptions beaming-exception)
86                      (ly:context-set-property!
87                        context 'measureLength new-measure-length))))
88                 'Timing)
89             'Score))))