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