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)
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)
22 (- (pitch-semitones (ly-get-mus-property (ly-get-grob-property grob 'cause) 'pitch))
24 (ly-get-grob-property grob 'string-tunings)
25 (- (ly-get-grob-property grob 'tab-string)
26 1 ; remove 1 because list index starts at 0 and guitar string at 1.
32 molecule ; return the molecule.
36 ; end of tablature functions
39 (define (arg->string arg)
40 (cond ((number? arg) (inexact->string arg 10))
41 ((string? arg) (string-append "\"" arg "\""))
42 ((symbol? arg) (string-append "\"" (symbol->string arg) "\""))))
45 (define (func name . args)
51 (map (lambda (x) (string-append " " (arg->string x))) args)))
55 ;;(define (mm-to-pt x)
56 ;; (* (/ 72.27 25.40) x))
58 ;; do nothing in .scm output
59 (define (comment s) "")
61 (define (numbers->string l)
62 (apply string-append (map ly-number->string l)))
64 ; (define (chop-decimal x) (if (< (abs x) 0.001) 0.0 x))
66 (define (number->octal-string x)
67 (let* ((n (inexact->exact x))
69 (n8 (quotient (- n (* n64 64)) 8)))
73 (number->string (remainder (- n (+ (* n64 64) (* n8 8))) 8)))))
75 (define (inexact->string x radix)
76 (let ((n (inexact->exact x)))
77 (number->string n radix)))
80 (define (control->string c)
81 (string-append (number->string (car c)) " "
82 (number->string (cdr c)) " "))
87 (make-string 1 (integer->char (+ (char->integer #\A) i)))))
89 (define (scm-scm action-name)
94 (define (find-notehead-symbol duration style)
96 ((xcircle) "2xcircle")
97 ((harmonic) "0neo_mensural")
99 (string-append (number->string duration)
100 (if (< duration 0) "neo_mensural" "")))
101 ((mensural) (string-append (number->string duration) (symbol->string style)))
102 ((neo_mensural) (string-append (number->string duration) (symbol->string style)))
103 ((default) (number->string duration))
105 (string-append (number->string (max 0 duration)) (symbol->string style)))))
108 (define (note-head-style->attachment-coordinates style)
109 "Return pair (X . Y), containing multipliers for the note head
110 bounding box, where to attach the stem. e.g.: X==0 means horizontally
111 centered, X==1 is at the right, X == -1 is at the left."
114 ((default) '(1.0 . 0.5))
115 ((cross) '(1.0 . 0.75))
116 ((mensural) '(0.0 . 0.6))
117 ((neo_mensural) '(0.0 . 0.6))
118 ((diamond) '(1.0 . 0.8))
119 ((transparent) '(1.0 . 1.0))
120 ((slash) '(1.0 . 1.0))
121 ((harmonic) '(1.0 0.0))
122 ((triangle) '(0.75 . 0.15))
125 ;; this also works for easy notation.
129 (define (string-encode-integer i)
132 ((< i 0) (string-append "n" (string-encode-integer (- i))))
134 (make-string 1 (integer->char (+ 65 (modulo i 26))))
135 (string-encode-integer (quotient i 26))))))