]> git.donarmstrong.com Git - lilypond.git/blob - scm/translation-functions.scm
* python/convertrules.py (conv): warning on \tempo{}
[lilypond.git] / scm / translation-functions.scm
1 ;;;; translation-functions.scm --
2 ;;;;
3 ;;;;  source file of the GNU LilyPond music typesetter
4 ;;;; 
5 ;;;; (c) 1998--2006 Han-Wen Nienhuys <hanwen@cs.uu.nl>
6 ;;;;                 Jan Nieuwenhuizen <janneke@gnu.org>
7
8 ;; metronome marks
9 (define-public (format-metronome-markup dur count context)
10   (let* ((note-mark (make-smaller-markup
11                      (make-note-by-number-markup (ly:duration-log dur)
12                                                  (ly:duration-dot-count dur)
13                                                  1))))  
14     (make-line-markup
15      (list
16       (make-general-align-markup Y DOWN note-mark)
17       (make-simple-markup  "=")
18       (make-simple-markup (number->string count))))))
19
20 (define-public (format-mark-alphabet mark context)
21   (make-bold-markup (make-markalphabet-markup (1- mark))))
22
23 (define-public (format-mark-box-alphabet mark context)
24   (make-bold-markup (make-box-markup (make-markalphabet-markup (1- mark)))))
25
26 (define-public (format-mark-circle-alphabet mark context)
27   (make-bold-markup (make-circle-markup (make-markalphabet-markup (1- mark)))))
28
29 (define-public (format-mark-letters mark context)
30   (make-bold-markup (make-markletter-markup (1- mark))))
31
32 (define-public (format-mark-numbers mark context)
33   (make-bold-markup (number->string mark)))
34
35 (define-public (format-mark-barnumbers mark context)
36   (make-bold-markup (number->string (ly:context-property context 'currentBarNumber))))
37
38 (define-public (format-mark-box-letters mark context)
39   (make-bold-markup (make-box-markup (make-markletter-markup (1- mark)))))
40
41 (define-public (format-mark-circle-letters mark context)
42   (make-bold-markup (make-circle-markup (make-markletter-markup (1- mark)))))
43
44 (define-public (format-mark-box-numbers mark context)
45   (make-bold-markup (make-box-markup (number->string mark))))
46
47 (define-public (format-mark-circle-numbers mark context)
48   (make-bold-markup (make-circle-markup (number->string mark))))
49
50 (define-public (format-mark-box-barnumbers mark context)
51   (make-bold-markup (make-box-markup
52     (number->string (ly:context-property context 'currentBarNumber)))))
53
54 (define-public (format-mark-circle-barnumbers mark context)
55   (make-bold-markup (make-circle-markup
56     (number->string (ly:context-property context 'currentBarNumber)))))
57
58
59 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
60 ;; Bass figures.
61 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
62
63 (define-public (format-bass-figure figure stream-event context)
64   (let* ((event (ly:event-property stream-event 'music-cause ))
65          (fig (ly:music-property event 'figure))
66          (fig-markup (if (number? figure)
67
68                          ;; this is not very elegant, but center-aligning all digits
69                          ;; is problematic with other markups, and shows problems
70                          ;; in the (lack of) overshoot of feta alphabet glyphs.
71                          
72                          ((if (<= 10 figure)
73                               (lambda (y) (make-translate-scaled-markup (cons -0.7 0) y))
74                               identity)
75
76                           (if (eq? #t (ly:music-property event 'diminished))
77                               (markup #:slashed-digit figure)
78                               (markup #:number (number->string figure 10))))
79                          #f
80                          ))
81          (alt (ly:music-property event 'alteration))
82          (alt-markup
83           (if (number? alt)
84               (markup
85                #:general-align Y DOWN #:fontsize
86                (if (not (= alt DOUBLE-SHARP))
87                    -2 2)
88                (alteration->text-accidental-markup alt))
89               
90               #f))
91          (plus-markup (if (eq? #t (ly:music-property event 'augmented))
92                           (markup #:number "+")
93                           #f))
94
95          (alt-dir (ly:context-property context 'figuredBassAlterationDirection))
96          (plus-dir (ly:context-property context 'figuredBassPlusDirection))
97          )
98
99     (if (and (not fig-markup) alt-markup)
100         (begin
101           (set! fig-markup (markup #:left-align #:pad-around 0.3 alt-markup))
102           (set! alt-markup #f)))
103
104
105     ;; hmm, how to get figures centered between note, and
106     ;; lone accidentals too?
107     
108     ;;    (if (markup? fig-markup)
109     ;;  (set!
110     ;;   fig-markup (markup #:translate (cons 1.0 0)
111     ;;                      #:hcenter fig-markup)))
112
113     (if alt-markup
114         (set! fig-markup
115               (markup #:put-adjacent
116                       fig-markup X
117                       (if (number? alt-dir)
118                           alt-dir
119                           LEFT)
120                       #:pad-x 0.2 alt-markup
121                       )))
122
123     
124     (if plus-markup
125         (set! fig-markup
126               (if fig-markup
127                   (markup #:put-adjacent
128                           fig-markup
129                           X (if (number? plus-dir)
130                                 plus-dir
131                                 LEFT)
132                           #:pad-x 0.2 plus-markup)
133                   plus-markup)))
134     
135     (if (markup? fig-markup)
136         (markup #:fontsize -2 fig-markup)
137         empty-markup)
138
139     ))
140