1 ;;;; output-lib.scm -- implement Scheme output helper functions
3 ;;;; source file of the GNU LilyPond music typesetter
5 ;;;; (c) 1998--2001 Jan Nieuwenhuizen <janneke@gnu.org>
6 ;;;; Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 ; Tablature functions, by Jiba (jiba@tuxfamily.org)
10 ; The TabNoteHead stem attachment function.
11 (define (tablature-stem-attachment-function style duration)
15 ; The TabNoteHead molecule callback.
16 ; Create a text molecule
17 (define (tablature-molecule-callback grob)
18 (let ((molecule (fontify-text
19 (ly-get-default-font grob)
20 (ly-get-grob-property grob 'text)
22 molecule ; return the molecule.
26 ; The TabNoteHead tablatureFormat callback.
27 ; Compute the text grob-property
28 (define (fret-number-tablature-format string tuning pitch)
30 (- (pitch-semitones pitch)
32 (- string 1) ; remove 1 because list index starts at 0 and guitar string at 1.
38 ; end of tablature functions
41 (define (arg->string arg)
42 (cond ((number? arg) (inexact->string arg 10))
43 ((string? arg) (string-append "\"" arg "\""))
44 ((symbol? arg) (string-append "\"" (symbol->string arg) "\""))))
47 (define (func name . args)
53 (map (lambda (x) (string-append " " (arg->string x))) args)))
57 ;;(define (mm-to-pt x)
58 ;; (* (/ 72.27 25.40) x))
60 ;; do nothing in .scm output
61 (define (comment s) "")
63 (define (numbers->string l)
64 (apply string-append (map ly-number->string l)))
66 ; (define (chop-decimal x) (if (< (abs x) 0.001) 0.0 x))
68 (define (number->octal-string x)
69 (let* ((n (inexact->exact x))
71 (n8 (quotient (- n (* n64 64)) 8)))
75 (number->string (remainder (- n (+ (* n64 64) (* n8 8))) 8)))))
77 (define (inexact->string x radix)
78 (let ((n (inexact->exact x)))
79 (number->string n radix)))
82 (define (control->string c)
83 (string-append (number->string (car c)) " "
84 (number->string (cdr c)) " "))
89 (make-string 1 (integer->char (+ (char->integer #\A) i)))))
91 (define (scm-scm action-name)
96 (define (find-notehead-symbol duration style)
98 ((xcircle) (cons "2xcircle" "music"))
99 ((harmonic) (cons "0neo_mensural" "music"))
101 ;; Oops, I actually would not call this "baroque", but, for
102 ;; backwards compatibility to 1.4, this is supposed to take
103 ;; brevis, longa and maxima from the neo-mensural font and all
104 ;; other note heads from the default font. -- jr
106 (cons (string-append (number->string duration) "neo_mensural") "ancient")
107 (cons (number->string duration) "music")))
109 (cons (string-append (number->string duration) (symbol->string style))
112 (cons (string-append (number->string duration) (symbol->string style))
115 ;; The default font in mf/feta-bolletjes.mf defines a brevis, but
116 ;; neither a longa nor a maxima. Hence let us, for the moment,
117 ;; take these from the neo-mensural font. TODO: mf/feta-bolletjes
118 ;; should define at least a longa for the default font. The longa
119 ;; should look exactly like the brevis of the default font, but
120 ;; with a stem exactly like that of the quarter note. -- jr
122 (cons (string-append (number->string duration) "neo_mensural") "ancient")
123 (cons (number->string duration) "music")))
125 (cons (string-append (number->string (max 0 duration)) (symbol->string style))
129 (define (note-head-style->attachment-coordinates style duration)
130 "Return pair (X . Y), containing multipliers for the note head
131 bounding box, where to attach the stem. e.g.: X==0 means horizontally
132 centered, X==1 is at the right, X == -1 is at the left."
137 '(0.0 . 0.6) ;; neo-mensural
138 '(1.0 . 0.5) ;; default
140 ((cross) '(1.0 . 0.75))
141 ((mensural) '(0.0 . 0.6))
142 ((neo_mensural) '(0.0 . 0.6))
143 ((diamond) '(1.0 . 0.8))
144 ((transparent) '(1.0 . 1.0))
145 ((slash) '(1.0 . 1.0))
146 ((harmonic) '(1.0 0.0))
147 ((triangle) '(0.75 . 0.15))
150 '(0.0 . 0.6) ;; neo-mensural
151 '(1.0 . 0.5) ;; default
155 ;; this also works for easy notation.
159 (define (string-encode-integer i)
162 ((< i 0) (string-append "n" (string-encode-integer (- i))))
164 (make-string 1 (integer->char (+ 65 (modulo i 26))))
165 (string-encode-integer (quotient i 26))))))