]> git.donarmstrong.com Git - lilypond.git/blob - scm/output-lib.scm
release: 1.5.35
[lilypond.git] / scm / output-lib.scm
1 ;;;; output-lib.scm -- implement Scheme output helper functions
2 ;;;;
3 ;;;;  source file of the GNU LilyPond music typesetter
4 ;;;; 
5 ;;;; (c) 1998--2001 Jan Nieuwenhuizen <janneke@gnu.org>
6 ;;;; Han-Wen Nienhuys <hanwen@cs.uu.nl>
7
8
9 (define (arg->string arg)
10   (cond ((number? arg) (inexact->string arg 10))
11         ((string? arg) (string-append "\"" arg "\""))
12         ((symbol? arg) (string-append "\"" (symbol->string arg) "\""))))
13
14 ;; ugh: naming.
15 (define (func name . args)
16   (string-append 
17    "(" name 
18    (if (null? args) 
19        ""
20        (apply string-append 
21               (map (lambda (x) (string-append " " (arg->string x))) args)))
22    ")\n"))
23
24
25 ;;(define (mm-to-pt x)
26 ;;  (* (/ 72.27 25.40) x))
27
28 ;; do nothing in .scm output
29 (define (comment s) "")
30
31 (define (numbers->string l)
32   (apply string-append (map ly-number->string l)))
33
34 ; (define (chop-decimal x) (if (< (abs x) 0.001) 0.0 x))
35
36 (define (number->octal-string x)
37   (let* ((n (inexact->exact x))
38          (n64 (quotient n 64))
39          (n8 (quotient (- n (* n64 64)) 8)))
40     (string-append
41      (number->string n64)
42      (number->string n8)
43      (number->string (remainder (- n (+ (* n64 64) (* n8 8))) 8)))))
44
45 (define (inexact->string x radix)
46   (let ((n (inexact->exact x)))
47     (number->string n radix)))
48
49
50 (define (control->string c)
51   (string-append (number->string (car c)) " "
52                  (number->string (cdr c)) " "))
53
54 (define (font i)
55   (string-append
56    "font"
57    (make-string 1 (integer->char (+ (char->integer #\A) i)))))
58
59 (define (scm-scm action-name)
60   1)
61
62
63 ;; silly, use alist? 
64 (define (find-notehead-symbol duration style)
65   (case style
66    ((xcircle) "2xcircle")
67    ((harmonic) "0neo_mensural")
68    ((baroque) 
69     (string-append (number->string duration)
70                    (if (< duration 0) "neo_mensural" "")))
71    ((mensural) (string-append (number->string duration) (symbol->string style)))
72    ((neo_mensural) (string-append (number->string duration) (symbol->string style)))
73    ((default) (number->string duration))
74    (else
75     (string-append (number->string (max 0 duration)) (symbol->string style)))))
76
77
78 (define (note-head-style->attachment-coordinates style)
79   "Return pair (X . Y), containing multipliers for the note head
80 bounding box, where to attach the stem. e.g.: X==0 means horizontally
81 centered, X==1 is at the right, X == -1 is at the left."
82
83   (case style
84     ((default) '(1.0 . 0.5))
85     ((cross) '(1.0 . 0.75))
86     ((mensural) '(0.0 . 0.6))
87     ((neo_mensural) '(0.0 . 0.6))
88     ((diamond) '(1.0 . 0.8))
89     ((transparent) '(1.0 . 1.0))
90     ((slash) '(1.0 . 1.0))
91     ((harmonic) '(1.0 0.0))
92     ((triangle) '(0.75 . 0.15))
93     (else
94      '(1.0 . 0.0)
95      )))
96                      
97 (define (string-encode-integer i)
98   (cond
99    ((= i  0) "o")
100    ((< i 0)   (string-append "n" (string-encode-integer (- i))))
101    (else (string-append
102           (make-string 1 (integer->char (+ 65 (modulo i 26))))
103           (string-encode-integer (quotient i 26))))))
104
105
106
107
108