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)) " ")))
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 "}"))
173 (tuplet-tex dx dy dir)
174 (embedded-ps-tex (tuplet-ps dx dy dir)))
179 (embedded-ps-tex (volta-ps w last)))
184 (beam-ps width slope thick)
186 (numbers->string (list width slope thick)) " draw_beam " ))
190 (invoke-dim1-ps "draw_bracket" h))
193 (crescendo-ps w h cont)
195 (numbers->string (list w h (inexact->exact cont)))
199 (dashed-slur-ps thick dash l)
201 (apply string-append (map control->string l))
202 (number->string thick)
204 (if (> 1 dash) (number->string (- (* thick dash) thick)) "0") " "
205 (number->string (* 2 thick))
206 " ] 0 draw_dashed_slur"))
209 (decrescendo-ps w h cont)
211 (numbers->string (list w h (inexact->exact cont)))
223 (experimental-on-ps) "")
229 (substring s 0 (- (string-length s) 4))
230 " findfont 12 scalefont setfont} bind def\n"))
234 (string-append (font i) " "))
237 (generalmeter-ps num den)
238 (string-append (number->string (inexact->exact num)) " " (number->string (inexact->exact den)) " generalmeter "))
243 (lily-def-ps key val)
245 "/" key " {" val "} bind def\n"))
248 (header-ps creator generate)
251 "%%Creator: " creator generate "\n"))
256 "(\\" (inexact->string i 8) ") " s " " ))
261 (number->string d) " " s ))
266 (number->string x) " " (number->string y) " {" s "} placebox "))
271 (number->string x) " "
272 (number->string y) " "
278 (apply string-append (map control->string l))
286 (stem-ps kern width height depth)
287 (string-append (numbers->string (list kern width height depth))
296 (string-append "(" s ") set" f " "))
302 (numbers->string (list w (inexact->exact last)))
305 ;;; output definitions
308 (beam o width slope thick)
309 ((invoke-output o "beam") width slope thick))
313 ((invoke-output o "bracket") h))
317 ((invoke-output o "invoke-char") "show" n))
320 (crescendo o w h cont)
321 ((invoke-output o "crescendo") w h cont))
324 (dashed-slur o thick dash l)
325 ((invoke-output o "dashed-slur") thick dash l))
328 (decrescendo o w h cont)
329 ((invoke-output o "decrescendo") w h cont))
333 ((invoke-output o "invoke-dim1") "doublebar" h))
337 ((invoke-output o "empty")))
340 (emptybar o h) (empty o))
344 ((invoke-output o "end-output")))
348 ((invoke-output o "experimental-on")))
352 ((invoke-output o "invoke-dim1") "fatdoublebar" h))
356 ((invoke-output o "invoke-dim1") "finishbar" h))
362 (make-string 1 (integer->char (+ (char->integer #\A) i)))
367 ((invoke-output o "font-def") i s))
371 ((invoke-output o "font-switch") i))
374 (generalmeter o num den)
375 ((invoke-output o "generalmeter") num den))
378 (header o creator generate)
379 ((invoke-output o "header") creator generate))
383 ((invoke-output o "header-end")))
387 (eval-string (string-append s "-" o)))
391 ((invoke-output o "lily-def") key val))
395 ((invoke-output o "invoke-dim1") "maatstreep" h))
399 ((invoke-output o "invoke-char") "pianobrace" i))
403 ((invoke-output o "placebox") x y (b o)))
407 ((invoke-output o "invoke-dim1") "repeatbar" h))
410 (repeatbarstartrepeat o h)
411 ((invoke-output o "invoke-dim1") "repeatbarstartrepeat" h))
415 ((invoke-output o "rulesym") x y))
419 ((invoke-output o "text") "bold" s))
422 (setdynamic o s) (empty o))
426 ((invoke-output o "text") "finger" s))
430 ((invoke-output o "text") "huge" s))
434 ((invoke-output o "text") "italic" s))
438 ((invoke-output o "text") "large" s))
442 ((invoke-output o "text") "Large" s))
446 ((invoke-output o "text") "number" s))
450 ((invoke-output o "text") "text" s))
454 ((invoke-output o "text") "typewriter" s))
458 ((invoke-output o "slur") l))
462 ((invoke-output o "tuplet") dx dy dir))
465 (tuplet-ps dx dy dir)
467 (numbers->string (list dx dy (inexact->exact dir)))
471 (stem o kern width height depth)
472 ((invoke-output o "stem") kern width height depth))
478 ((invoke-output o "start-line")))
482 ((invoke-output o "invoke-dim1") "startbar" h))
486 ((invoke-output o "invoke-dim1") "startrepeat" h))
490 ((invoke-output o "stop-line")))
494 ((invoke-output o "invoke-dim1") "stoprepeat" h))
498 ((invoke-output o "volta") w last))