]> git.donarmstrong.com Git - lilypond.git/blob - scm/translation-functions.scm
9c4866a9ac6999eec1dd5eae1f147d8e0d095bfc
[lilypond.git] / scm / translation-functions.scm
1 ;;;; translation-functions.scm --
2 ;;;;
3 ;;;;  source file of the GNU LilyPond music typesetter
4 ;;;; 
5 ;;;; (c) 1998--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
6 ;;;;                 Jan Nieuwenhuizen <janneke@gnu.org>
7
8 (define-public (denominator-tuplet-formatter mus)
9   (number->string (ly:music-property mus 'denominator)))
10
11 (define-public (fraction-tuplet-formatter mus)
12   (string-append
13    (number->string (ly:music-property mus 'denominator))
14    ":"
15    (number->string (ly:music-property mus 'numerator))))
16
17 ;; metronome marks
18 (define-public (format-metronome-markup event context)
19   (let* ((dur (ly:music-property event 'tempo-unit))
20        (count (ly:music-property event 'metronome-count))
21        (note-mark (make-smaller-markup
22                    (make-note-by-number-markup (ly:duration-log dur)
23                                                (ly:duration-dot-count dur)
24                                                1))))  
25     (make-line-markup
26      (list
27       (make-general-align-markup Y DOWN note-mark)
28       (make-simple-markup  "=")
29       (make-simple-markup (number->string count))))))
30
31 (define-public (format-mark-alphabet mark context)
32   (make-bold-markup (make-markalphabet-markup (1- mark))))
33
34 (define-public (format-mark-box-alphabet mark context)
35   (make-bold-markup (make-box-markup (make-markalphabet-markup (1- mark)))))
36
37 (define-public (format-mark-letters mark context)
38   (make-bold-markup (make-markletter-markup (1- mark))))
39
40 (define-public (format-mark-numbers mark context)
41   (make-bold-markup (number->string mark)))
42
43 (define-public (format-mark-barnumbers mark context)
44   (make-bold-markup (number->string (ly:context-property context 'currentBarNumber))))
45
46 (define-public (format-mark-box-letters mark context)
47   (make-bold-markup (make-box-markup (make-markletter-markup (1- mark)))))
48
49 (define-public (format-mark-box-numbers mark context)
50   (make-bold-markup (make-box-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
57 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
58 ;; Bass figures.
59 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
60
61 (define-public (format-bass-figure figure event context)
62   (let* ((fig (ly:music-property event 'figure))
63          (fig-markup (if (number? figure)
64                          (if (eq? #t (ly:music-property event 'diminished))
65                              (markup #:slashed-digit figure)
66                              (markup #:number (number->string figure 10)))
67                          #f
68                          ))
69          (alt (ly:music-property event 'alteration))
70          (alt-markup
71           (if (number? alt)
72               (markup
73                       #:general-align Y DOWN #:fontsize
74                       (if (not (= alt DOUBLE-SHARP))
75                           -2 2)
76                       (alteration->text-accidental-markup alt))
77               
78               #f))
79          (plus-markup (if (eq? #t (ly:music-property event 'augmented))
80                           (markup #:number "+")
81                           #f))
82
83          (alt-dir (ly:context-property context 'figuredBassAlterationDirection))
84          (plus-dir (ly:context-property context 'figuredBassPlusDirection))
85          )
86
87     (if (and (not fig-markup) alt-markup)
88         (begin
89           (set! fig-markup (markup #:left-align #:pad-around 0.3 alt-markup))
90           (set! alt-markup #f)))
91
92
93     ;; hmm, how to get figures centered between note, and
94     ;; lone accidentals too?
95     
96     ;;    (if (markup? fig-markup)
97     ;;  (set!
98     ;;   fig-markup (markup #:translate (cons 1.0 0)
99     ;;                      #:hcenter fig-markup)))
100
101     (if alt-markup
102         (set! fig-markup
103               (markup #:put-adjacent
104                       fig-markup X
105                       (if (number? alt-dir)
106                           alt-dir
107                           LEFT)
108                       #:pad-x 0.2 alt-markup
109                       )))
110
111     
112     (if plus-markup
113         (set! fig-markup
114               (if fig-markup
115                   (markup #:put-adjacent
116                           fig-markup
117                           X (if (number? plus-dir)
118                                 plus-dir
119                                 LEFT)
120                           #:pad-x 0.2 plus-markup)
121                   plus-markup)))
122     
123     (if (markup? fig-markup)
124         (markup #:fontsize -2 fig-markup)
125         empty-markup)
126
127     ))
128