1 ; lily.scm -- implement Scheme output routines for TeX and PostScript
3 ; source file of the GNU LilyPond music typesetter
5 ; (c) 1998 Jan Nieuwenhuizen <janneke@gnu.org>
9 ; - ready ps code (draw_bracket) vs tex/ps macros/calls (pianobrace),
10 ; all preparations from ps,tex to scm
16 (map (lambda (n) (string-append (number->string n ) " ")) l)))
21 (map (lambda (n) (string-append (number->string n) " ")) l)))
23 (define (chop-decimal x) (if (< (abs x) 0.001) 0.0 x))
25 (define (number->octal-string x)
26 (let* ((n (inexact->exact x))
28 (n8 (quotient (- n (* n64 64)) 8)))
32 (number->string (remainder (- n (+ (* n64 64) (* n8 8))) 8)))))
34 (define (inexact->string x radix)
35 (let ((n (inexact->exact x)))
36 (number->string n radix)))
42 (string-append (number->string (car c)) " ")
43 (string-append (number->string (cadr c)) " ")))
46 ; (define (tex action)
49 (beam-tex width slope thick)
50 (embedded-ps-tex (beam-ps width slope thick)))
54 (embedded-ps-tex (bracket-ps h)))
57 (dashed-slur-tex thick dash l)
58 (embedded-ps-tex (dashed-slur-ps thick dash l)))
61 (crescendo-tex w h cont)
62 (embedded-ps-tex (crescendo-ps w h cont)))
65 (decrescendo-tex w h cont)
66 (embedded-ps-tex (decrescendo-ps w h cont)))
70 (string-append "\\embeddedps{" s "}"))
75 "\n\\EndLilyPondOutput")
82 (experimental-on-tex) "\\turnOnExperimentalFeatures")
86 ((invoke-output o "invoke-dim1") "extender" h))
96 "\\font" (font-switch-tex i) "=" s "\n"))
99 (generalmeter-tex num den)
101 "\\generalmeter{" (number->string (inexact->exact num)) "}{" (number->string (inexact->exact den)) "}"))
104 (header-end-tex) "\\turnOnPostScript")
107 (header-tex creator generate)
109 "%created by: " creator generate "\n"))
112 (invoke-char-tex s i)
114 "\n\\" s "{" (inexact->string i 10) "}" ))
117 (invoke-dim1-tex s d)
119 "\n\\" s "{" (number->dim-tex d) "}"))
122 (lily-def-tex key val)
124 "\\def\\" key "{" val "}\n"))
129 (number->string (chop-decimal x)) "pt "))
135 (number->dim-tex y) "}{" (number->dim-tex x) "}{" s "}"))
140 "\\vrule height " (number->dim-tex (/ h 2))
141 " depth " (number->dim-tex (/ h 2))
142 " width " (number->dim-tex w)
148 (embedded-ps-tex (slur-ps l)))
157 (stem-tex kern width height depth)
159 "\\kern" (number->dim-tex kern)
160 "\\vrule width " (number->dim-tex width)
161 "depth " (number->dim-tex depth)
162 "height " (number->dim-tex height) " "))
170 (string-append "\\set" f "{" s "}"))
177 (beam-ps width slope thick)
179 (numbers->string (list width slope thick)) " draw_beam " ))
183 (invoke-dim1-ps "draw_bracket" h))
186 (crescendo-ps w h cont)
188 (numbers->string (list w h (inexact->exact cont)))
192 (dashed-slur-ps thick dash l)
194 (apply string-append (map control->string l))
195 (number->string thick)
197 (if (> 1 dash) (number->string (- (* thick dash) thick)) "0") " "
198 (number->string (* 2 thick))
199 " ] 0 draw_dashed_slur"))
202 (decrescendo-ps w h cont)
204 (numbers->string (list w h (inexact->exact cont)))
216 (experimental-on-ps) "")
222 (substring s 0 (- (string-length s) 4))
223 " findfont 12 scalefont setfont} bind def\n"))
227 (string-append (font i) " "))
230 (generalmeter-ps num den)
231 (string-append (number->string (inexact->exact num)) " " (number->string (inexact->exact den)) " generalmeter "))
236 (lily-def-ps key val)
238 "/" key " {" val "} bind def\n"))
241 (header-ps creator generate)
244 "%%Creator: " creator generate "\n"))
249 "(\\" (inexact->string i 8) ") " s " " ))
254 (number->string d) " " s ))
259 (number->string x) " " (number->string y) " {" s "} placebox "))
264 (number->string x) " "
265 (number->string y) " "
271 (apply string-append (map control->string l))
279 (stem-ps kern width height depth)
280 (string-append (numbers->string (list kern width height depth))
289 (string-append "(" s ") set" f " "))
292 ;;; output definitions
295 (beam o width slope thick)
296 ((invoke-output o "beam") width slope thick))
300 ((invoke-output o "bracket") h))
304 ((invoke-output o "invoke-char") "show" n))
307 (crescendo o w h cont)
308 ((invoke-output o "crescendo") w h cont))
311 (dashed-slur o thick dash l)
312 ((invoke-output o "dashed-slur") thick dash l))
315 (decrescendo o w h cont)
316 ((invoke-output o "decrescendo") w h cont))
320 ((invoke-output o "invoke-dim1") "doublebar" h))
324 ((invoke-output o "empty")))
327 (emptybar o h) (empty o))
331 ((invoke-output o "end-output")))
335 ((invoke-output o "experimental-on")))
339 ((invoke-output o "invoke-dim1") "fatdoublebar" h))
343 ((invoke-output o "invoke-dim1") "finishbar" h))
349 (make-string 1 (integer->char (+ (char->integer #\A) i)))
354 ((invoke-output o "font-def") i s))
358 ((invoke-output o "font-switch") i))
361 (generalmeter o num den)
362 ((invoke-output o "generalmeter") num den))
365 (header o creator generate)
366 ((invoke-output o "header") creator generate))
370 ((invoke-output o "header-end")))
374 (eval-string (string-append s "-" o)))
378 ((invoke-output o "lily-def") key val))
382 ((invoke-output o "invoke-dim1") "maatstreep" h))
386 ((invoke-output o "invoke-char") "pianobrace" i))
390 ((invoke-output o "placebox") x y (b o)))
394 ((invoke-output o "invoke-dim1") "repeatbar" h))
397 (repeatbarstartrepeat o h)
398 ((invoke-output o "invoke-dim1") "repeatbarstartrepeat" h))
402 ((invoke-output o "rulesym") x y))
406 ((invoke-output o "text") "bold" s))
409 (setdynamic o s) (empty o))
413 ((invoke-output o "text") "finger" s))
417 ((invoke-output o "text") "huge" s))
421 ((invoke-output o "text") "italic" s))
425 ((invoke-output o "text") "large" s))
429 ((invoke-output o "text") "Large" s))
433 ((invoke-output o "text") "number" s))
437 ((invoke-output o "text") "text" s))
441 ((invoke-output o "text") "typewriter" s))
445 ((invoke-output o "slur") l))
449 ((invoke-output o "tuplet") dx dy dir))
452 (tuplet-ps dx dy dir)
454 (numbers->string (list dx dy (inexact->exact dir)))
458 (tuplet-tex dx dy dir)
459 (embedded-ps-tex (tuplet-ps dx dy dir)))
462 (stem o kern width height depth)
463 ((invoke-output o "stem") kern width height depth))
469 ((invoke-output o "start-line")))
473 ((invoke-output o "invoke-dim1") "startbar" h))
477 ((invoke-output o "invoke-dim1") "startrepeat" h))
482 ((invoke-output o "stop-line")))
487 ((invoke-output o "invoke-dim1") "stoprepeat" h))