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 ; This file contains various routines in Scheme that are easier to
10 ; do here than in C++. At present it is a unorganised mess. Sorry.
14 ;(debug-enable 'backtrace)
18 (use-modules (ice-9 regex))
20 ;; The regex module may not be available, or may be broken.
21 ;; If you have trouble with regex, define #f
22 ;;(define use-regex #t)
23 ;;(define use-regex #f)
26 (let ((os (string-downcase (vector-ref (uname) 0))))
27 (not (equal? "cygwin" (substring os 0 (min 6 (string-length os)))))))
29 ;; do nothing in .scm output
30 (define (comment s) "")
36 (define (cons-map f x)
37 (cons (f (car x)) (f (cdr x))))
39 (define (reduce operator list)
40 (if (null? (cdr list)) (car list)
41 (operator (car list) (reduce operator (cdr list)))
46 (define (numbers->string l)
47 (apply string-append (map ly-number->string l)))
49 ; (define (chop-decimal x) (if (< (abs x) 0.001) 0.0 x))
51 (define (number->octal-string x)
52 (let* ((n (inexact->exact x))
54 (n8 (quotient (- n (* n64 64)) 8)))
58 (number->string (remainder (- n (+ (* n64 64) (* n8 8))) 8)))))
60 (define (inexact->string x radix)
61 (let ((n (inexact->exact x)))
62 (number->string n radix)))
65 (define (control->string c)
66 (string-append (number->string (car c)) " "
67 (number->string (cdr c)) " "))
73 (make-string 1 (integer->char (+ (char->integer #\A) i)))
78 (define (scm-scm action-name)
81 (define security-paranoia #f)
84 ;; See documentation of Item::visibility_lambda_
85 (define (begin-of-line-visible d) (if (= d 1) '(#f . #f) '(#t . #t)))
86 (define (spanbar-begin-of-line-invisible d) (if (= d -1) '(#t . #t) '(#f . #f)))
87 (define (all-visible d) '(#f . #f))
88 (define (all-invisible d) '(#t . #t))
89 (define (begin-of-line-invisible d) (if (= d 1) '(#t . #t) '(#f . #f)))
90 (define (end-of-line-invisible d) (if (= d -1) '(#t . #t) '(#f . #f)))
93 ;; Score_span_bars are only visible at start of line
94 ;; i.e. if break_dir == RIGHT == 1
95 (define Span_bar_engraver-visibility begin-of-line-invisible)
96 (define mark-visibility end-of-line-invisible)
98 ;; Spacing constants for prefatory matter.
100 ;; rules for this spacing are much more complicated than this. See [Wanske] page 126 -- 134, [Ross] pg 143 -- 147
104 ;; (Measured in staff space)
107 ((none Instrument_name) . (extra-space 1.0))
108 ((Instrument_name Left_edge_item) . (extra-space 1.0))
109 ((Left_edge_item Clef_item) . (extra-space 1.0))
110 ((none Left_edge_item) . (extra-space 0.0))
111 ((Left_edge_item Staff_bar) . (extra-space 0.0))
112 ; ((none Left_edge_item) . (extra-space -15.0))
113 ; ((none Left_edge_item) . (extra-space -15.0))
114 ((none Clef_item) . (minimum-space 1.0))
115 ((none Staff_bar) . (minimum-space 0.0))
116 ((none Clef_item) . (minimum-space 1.0))
117 ((none Key_item) . (minimum-space 0.5))
118 ((none Time_signature) . (extra-space 0.0))
119 ((none begin-of-note) . (minimum-space 1.5))
120 ((Clef_item Key_item) . (minimum-space 4.0))
121 ((Key_item Time_signature) . (extra-space 1.0))
122 ((Clef_item Time_signature) . (minimum-space 3.5))
123 ((Staff_bar Clef_item) . (minimum-space 1.0))
124 ((Clef_item Staff_bar) . (minimum-space 3.7))
125 ((Time_signature Staff_bar) . (minimum-space 2.0))
126 ((Key_item Staff_bar) . (extra-space 1.0))
127 ((Staff_bar Time_signature) . (minimum-space 1.5)) ;double check this.
128 ((Time_signature begin-of-note) . (extra-space 2.0)) ;double check this.
129 ((Key_item begin-of-note) . (extra-space 2.5))
130 ((Staff_bar begin-of-note) . (extra-space 1.0))
131 ((Clef_item begin-of-note) . (minimum-space 5.0))
132 ((none Breathing_sign) . (minimum-space 0.0))
133 ((Breathing_sign Key_item) . (minimum-space 1.5))
134 ((Breathing_sign begin-of-note) . (minimum-space 1.0))
135 ((Breathing_sign Staff_bar) . (minimum-space 1.5))
136 ((Breathing_sign Clef_item) . (minimum-space 2.0))
140 ;; (define (ly-warn s) (error s))
141 (define (break-align-spacer this next)
142 (let ((entry (assoc (list this next) space-alist)))
145 (begin (ly-warn (string-append "Unknown spacing pair `" this "', `" next "'"))
146 '(minimum-space 0.0)))))
149 (define (find-notehead-symbol duration style)
152 ((harmonic) "0mensural")
154 (string-append (number->string duration)
155 (if (< duration 0) "mensural" "")))
156 ((default) (number->string duration))
158 (string-append (number->string duration) (symbol->string style)))))
163 ;; this is silly, can't we use something like
164 ;; roman-0, roman-1 roman+1 ?
167 ("brace" . "feta-braces")
168 ("default" . "cmr10")
169 ("dynamic" . "feta-din")
173 ("typewriter" . "cmtt")
179 ("mark" . "feta-nummer")
180 ("finger" . "feta-nummer")
181 ("timesig" . "feta-nummer")
182 ("number" . "feta-nummer")
183 ("volta" . "feta-nummer"))
186 (define (string-encode-integer i)
189 ((< i 0) (string-append "n" (string-encode-integer (- i))))
191 (make-string 1 (integer->char (+ 65 (modulo i 26))))
192 (string-encode-integer (quotient i 26))
199 (cdr (assoc i '((-4 . 482)
212 (define script-alist '())
213 (define (articulation-to-scriptdef a)
214 (assoc a script-alist)
217 ;; Map style names to TeX font names. Return false if
218 ;; no font name found.
219 (define (style-to-cmr s)
225 (define font-name-alist '())
226 (define (font-command name-mag)
228 (string-append "magfont"
229 (string-encode-integer (hashq (car name-mag) 1000000))
231 (string-encode-integer (cdr name-mag)))
235 (define (define-fonts names)
236 (set! font-name-alist (map font-command names))
239 (font-load-command (car x) (cdr x))) font-name-alist)
242 (define (fontify name exp)
243 (string-append (select-font name)
250 ; Make a function that checks score element for being of a specific type.
251 (define (make-type-checker name)
253 (not (not (memq name (ly-get-elt-property elt 'interfaces))))))
256 ;;;;;;;;;;;;;;;;;;; TeX output
257 (define (tex-scm action-name)
262 (define (select-font font-name-symbol)
265 (c (assoc font-name-symbol font-name-alist))
270 (ly-warn (string-append
271 "Programming error: No such font known " (car font-name-symbol)))
272 "") ; issue no command
273 (string-append "\\" (cdr c)))
278 (define (beam width slope thick)
279 (embedded-ps ((ps-scm 'beam) width slope thick)))
281 (define (bracket arch_angle arch_width arch_height width height arch_thick thick)
282 (embedded-ps ((ps-scm 'bracket) arch_angle arch_width arch_height width height arch_thick thick)))
284 (define (dashed-slur thick dash l)
285 (embedded-ps ((ps-scm 'dashed-slur) thick dash l)))
287 (define (crescendo thick w h cont)
288 (embedded-ps ((ps-scm 'crescendo) thick w h cont)))
291 (string-append "\\char" (inexact->string i 10) " "))
293 (define (dashed-line thick dash w)
294 (embedded-ps ((ps-scm 'dashed-line) thick dash w)))
296 (define (decrescendo thick w h cont)
297 (embedded-ps ((ps-scm 'decrescendo) thick w h cont)))
299 (define (font-load-command name-mag command)
301 "\\font\\" command "="
302 (symbol->string (car name-mag))
304 (number->string (magstep (cdr name-mag)))
307 (define (embedded-ps s)
308 (string-append "\\embeddedps{" s "}"))
311 (string-append "% " s))
314 "\n\\EndLilyPondOutput")
316 (define (experimental-on)
319 (define (font-switch i)
323 (define (font-def i s)
325 "\\font" (font-switch i) "=" s "\n"))
331 ;; URG: ly-gulp-file: now we can't use scm output without Lily
333 ;; fixed in 1.3.4 for powerpc -- broken on Windows
334 (regexp-substitute/global #f "\n"
335 (ly-gulp-file "lily.ps") 'pre " %\n" 'post)
336 (ly-gulp-file "lily.ps"))
338 "\\input lilyponddefs \\turnOnPostScript"))
340 (define (header creator generate)
342 "%created by: " creator generate "\n"))
344 (define (invoke-char s i)
346 "\n\\" s "{" (inexact->string i 10) "}" ))
348 (define (invoke-dim1 s d)
350 "\n\\" s "{" (number->dim d) "}"))
355 ;; need to do something to make this really safe.
357 (define (output-tex-string s)
358 (if security-paranoia
360 (regexp-substitute/global #f "\\\\" s 'pre "$\\backslash$" 'post)
361 (begin (display "warning: not paranoid") (newline) s))
364 (define (lily-def key val)
368 ;; fixed in 1.3.4 for powerpc -- broken on Windows
369 (regexp-substitute/global #f "_"
370 (output-tex-string key) 'pre "X" 'post)
371 (output-tex-string key))
372 "{" (output-tex-string val) "}\n"))
374 (define (number->dim x)
376 (ly-number->string x) " pt "))
378 (define (placebox x y s)
381 (number->dim y) "}{" (number->dim x) "}{" s "}\n"))
383 (define (bezier-sandwich l thick)
384 (embedded-ps ((ps-scm 'bezier-sandwich) l thick)))
386 (define (start-line ht)
387 (string-append"\\vbox to " (number->dim ht) "{\\hbox{%\n"))
390 "}\\vss}\\interscoreline")
391 (define (stop-last-line)
393 (define (filledbox breapth width depth height)
395 "\\kern" (number->dim (- breapth))
396 "\\vrule width " (number->dim (+ breapth width))
397 "depth " (number->dim depth)
398 "height " (number->dim height) " "))
401 (string-append "\\hbox{" (output-tex-string s) "}"))
403 (define (tuplet ht gapx dx dy thick dir)
404 (embedded-ps ((ps-scm 'tuplet) ht gapx dx dy thick dir)))
406 (define (volta h w thick vert_start vert_end)
407 (embedded-ps ((ps-scm 'volta) h w thick vert_start vert_end)))
410 ;; The procedures listed below form the public interface of TeX-scm.
411 ;; (should merge the 2 lists)
412 (cond ((eq? action-name 'all-definitions)
414 (define font-load-command ,font-load-command)
416 (define bezier-sandwich ,bezier-sandwich)
417 (define bracket ,bracket)
419 (define crescendo ,crescendo)
420 (define dashed-line ,dashed-line)
421 (define dashed-slur ,dashed-slur)
422 (define decrescendo ,decrescendo)
423 (define end-output ,end-output)
424 (define experimental-on ,experimental-on)
425 (define filledbox ,filledbox)
426 (define font-def ,font-def)
427 (define font-switch ,font-switch)
428 (define header-end ,header-end)
429 (define lily-def ,lily-def)
430 (define header ,header)
431 (define invoke-char ,invoke-char)
432 (define invoke-dim1 ,invoke-dim1)
433 (define placebox ,placebox)
434 (define select-font ,select-font)
435 (define start-line ,start-line)
436 (define stop-line ,stop-line)
437 (define stop-last-line ,stop-last-line)
439 (define tuplet ,tuplet)
440 (define volta ,volta)
443 ((eq? action-name 'beam) beam)
444 ((eq? action-name 'tuplet) tuplet)
445 ((eq? action-name 'bracket) bracket)
446 ((eq? action-name 'crescendo) crescendo)
447 ((eq? action-name 'dashed-line) dashed-line)
448 ((eq? action-name 'dashed-slur) dashed-slur)
449 ((eq? action-name 'decrescendo) decrescendo)
450 ((eq? action-name 'end-output) end-output)
451 ((eq? action-name 'experimental-on) experimental-on)
452 ((eq? action-name 'font-def) font-def)
453 ((eq? action-name 'font-switch) font-switch)
454 ((eq? action-name 'header-end) header-end)
455 ((eq? action-name 'lily-def) lily-def)
456 ((eq? action-name 'header) header)
457 ((eq? action-name 'invoke-char) invoke-char)
458 ((eq? action-name 'invoke-dim1) invoke-dim1)
459 ((eq? action-name 'placebox) placebox)
460 ((eq? action-name 'bezier-sandwich) bezier-sandwich)
461 ((eq? action-name 'start-line) start-line)
462 ((eq? action-name 'stem) stem)
463 ((eq? action-name 'stop-line) stop-line)
464 ((eq? action-name 'stop-last-line) stop-last-line)
465 ((eq? action-name 'volta) volta)
466 (else (error "unknown tag -- PS-TEX " action-name))
472 (define (ps-scm action-name)
474 ;; alist containing fontname -> fontcommand assoc (both strings)
475 (define font-alist '())
476 (define font-count 0)
477 (define current-font "")
480 (define (cached-fontname i)
483 (make-string 1 (integer->char (+ 65 i)))))
485 (define (mag-to-size m)
486 (number->string (case m
489 (2 14) ; really: 14.400
490 (3 17) ; really: 17.280
491 (4 21) ; really: 20.736
492 (5 24) ; really: 24.888
493 (6 30) ; really: 29.856
497 (define (select-font font-name-symbol)
500 (c (assoc font-name-symbol font-name-alist))
505 (ly-warn (string-append
506 "Programming error: No such font known " (car font-name-symbol)))
507 "") ; issue no command
508 (string-append " " (cdr c) " "))
513 (define (font-load-command name-mag command)
517 (symbol->string (car name-mag))
519 (number->string (magstep (cdr name-mag)))
520 " 1000 div 12 mul scalefont setfont } bind def "
524 (define (beam width slope thick)
526 (numbers->string (list width slope thick)) " draw_beam" ))
529 (string-append "% " s))
531 (define (bracket arch_angle arch_width arch_height width height arch_thick thick)
533 (numbers->string (list arch_angle arch_width arch_height width height arch_thick thick)) " draw_bracket" ))
536 (invoke-char " show" i))
538 (define (crescendo thick w h cont )
540 (numbers->string (list w h (inexact->exact cont) thick))
543 ;; what the heck is this interface ?
544 (define (dashed-slur thick dash l)
546 (apply string-append (map control->string l))
547 (number->string thick)
549 (number->string dash)
551 (number->string (* 10 thick)) ;UGH. 10 ?
552 " ] 0 draw_dashed_slur"))
554 (define (dashed-line thick dash width)
556 (number->string width)
558 (number->string thick)
560 (number->string dash)
562 (number->string dash)
563 " ] 0 draw_dashed_line"))
565 (define (decrescendo thick w h cont)
567 (numbers->string (list w h (inexact->exact cont) thick))
568 " draw_decrescendo"))
574 (define (experimental-on) "")
576 (define (filledbox breapth width depth height)
577 (string-append (numbers->string (list breapth width depth height))
581 (define (font-def i s)
584 (substring s 0 (- (string-length s) 4))
585 " findfont 12 scalefont setfont} bind def \n"))
587 (define (font-switch i)
588 (string-append (font i) " "))
592 ;; URG: now we can't use scm output without Lily
593 (ly-gulp-file "lilyponddefs.ps")
594 " {exch pop //systemdict /run get exec} "
595 (ly-gulp-file "lily.ps")
596 "{ exch pop //systemdict /run get exec } "
599 (define (lily-def key val)
601 (if (string=? (substring key 0 (min (string-length "mudelapaper") (string-length key))) "mudelapaper")
602 (string-append "/" key " {" val "} bind def\n")
603 (string-append "/" key " (" val ") def\n")
607 (define (header creator generate)
610 "%%Creator: " creator generate "\n"))
612 (define (invoke-char s i)
614 "(\\" (inexact->string i 8) ") " s " " ))
616 (define (invoke-dim1 s d)
618 (number->string (* d (/ 72.27 72))) " " s ))
620 (define (placebox x y s)
622 (number->string x) " " (number->string y) " {" s "} placebox "))
624 (define (bezier-sandwich l thick)
626 (apply string-append (map control->string l))
627 (number->string thick)
628 " draw_bezier_sandwich"))
630 (define (start-line height)
633 (define (stem breapth width depth height)
634 (string-append (numbers->string (list breapth width depth height))
641 (string-append "(" s ") show "))
644 (define (volta h w thick vert_start vert_end)
646 (numbers->string (list h w thick (inexact->exact vert_start) (inexact->exact vert_end)))
649 (define (tuplet ht gap dx dy thick dir)
651 (numbers->string (list ht gap dx dy thick (inexact->exact dir)))
660 (cond ((eq? action-name 'all-definitions)
663 (define tuplet ,tuplet)
664 (define bracket ,bracket)
666 (define crescendo ,crescendo)
667 (define volta ,volta)
668 (define bezier-sandwich ,bezier-sandwich)
669 (define dashed-line ,dashed-line)
670 (define dashed-slur ,dashed-slur)
671 (define decrescendo ,decrescendo)
672 (define end-output ,end-output)
673 (define experimental-on ,experimental-on)
674 (define filledbox ,filledbox)
675 (define font-def ,font-def)
676 (define font-switch ,font-switch)
677 (define header-end ,header-end)
678 (define lily-def ,lily-def)
679 (define font-load-command ,font-load-command)
680 (define header ,header)
681 (define invoke-char ,invoke-char)
682 (define invoke-dim1 ,invoke-dim1)
683 (define placebox ,placebox)
684 (define select-font ,select-font)
685 (define start-line ,start-line)
687 (define stop-line ,stop-line)
688 (define stop-last-line ,stop-line)
691 ((eq? action-name 'tuplet) tuplet)
692 ((eq? action-name 'beam) beam)
693 ((eq? action-name 'bezier-sandwich) bezier-sandwich)
694 ((eq? action-name 'bracket) bracket)
695 ((eq? action-name 'char) char)
696 ((eq? action-name 'crescendo) crescendo)
697 ((eq? action-name 'dashed-line) dashed-line)
698 ((eq? action-name 'dashed-slur) dashed-slur)
699 ((eq? action-name 'decrescendo) decrescendo)
700 ((eq? action-name 'experimental-on) experimental-on)
701 ((eq? action-name 'filledbox) filledbox)
702 ((eq? action-name 'select-font) select-font)
703 ((eq? action-name 'volta) volta)
704 (else (error "unknown tag -- PS-SCM " action-name))
709 (define (arg->string arg)
710 (cond ((number? arg) (inexact->string arg 10))
711 ((string? arg) (string-append "\"" arg "\""))
712 ((symbol? arg) (string-append "\"" (symbol->string arg) "\""))))
714 (define (func name . args)
720 (map (lambda (x) (string-append " " (arg->string x))) args)))
726 (inexact->exact (/ x (abs x)))))
729 (define (as-scm action-name)
731 (define (beam width slope thick)
733 (func "set-line-char" "#")
734 (func "rline-to" width (* width slope))
738 (define (bezier-sandwich l thick)
745 (dy (- (cdr c3) (cdr c0)))
747 (c1-dx (- (car c1) x))
748 (c1-line-y (+ (cdr c0) (* c1-dx rc)))
749 (dir (if (< c1-line-y (cdr c1)) 1 -1))
750 (y (+ -1 (* dir (max (* dir (cdr c0)) (* dir (cdr c3)))))))
752 (func "rmove-to" x y)
753 (func "put" (if (< 0 dir) "/" "\\\\"))
754 (func "rmove-to" 1 (if (< 0 dir) 1 0))
755 (func "set-line-char" "_")
756 (func "h-line" (- dx 1))
757 (func "rmove-to" (- dx 1) (if (< 0 dir) -1 0))
758 (func "put" (if (< 0 dir) "\\\\" "/"))))))
760 (define (bracket arch_angle arch_width arch_height width height arch_thick thick)
762 (func "rmove-to" (+ width 1) (- (/ height -2) 1))
764 (func "set-line-char" "|")
765 (func "rmove-to" 0 1)
766 (func "v-line" (+ height 1))
767 (func "rmove-to" 0 (+ height 1))
777 (define (experimental-on)
780 (define (filledbox breapth width depth height)
781 (let ((dx (+ width breapth))
782 (dy (+ depth height)))
784 (func "rmove-to" (* -1 breapth) (* -1 depth))
787 (func "set-line-char"
788 (if (<= dx 1) "|" "#"))
791 (func "set-line-char"
792 (if (<= dy 1) "-" "="))
793 (func "h-line" dx))))))
795 (define (font-load-command name-mag command)
796 (func "load-font" (car name-mag) (magstep (cdr name-mag))))
798 (define (header creator generate)
799 (func "header" creator generate))
804 ;; urg: this is good for half of as2text's execution time
805 (define (xlily-def key val)
806 (string-append "(define " key " " (arg->string val) ")\n"))
808 (define (lily-def key val)
810 (or (equal? key "mudelapaperlinewidth")
811 (equal? key "mudelapaperstaffheight"))
812 (string-append "(define " key " " (arg->string val) ")\n")
815 (define (placebox x y s)
816 (let ((ey (inexact->exact y)))
817 (string-append "(move-to " (number->string (inexact->exact x)) " "
818 (if (= 0.5 (- (abs y) (abs ey)))
823 (define (select-font font-name-symbol)
824 (let* ((c (assoc font-name-symbol font-name-alist)))
829 "Programming error: No such font known "
830 (car font-name-symbol)))
831 "") ; issue no command
832 (func "select-font" (car font-name-symbol)))))
834 (define (start-line height)
835 (func "start-line" height))
843 (define (volta h w thick vert-start vert-end)
846 (func "set-line-char" "|")
847 (func "rmove-to" 0 -4)
848 ;; definition strange-way around
852 (func "rmove-to" 1 h)
853 (func "set-line-char" "_")
854 (func "h-line" (- w 1))
855 (func "set-line-char" "|")
858 (func "rmove-to" (- w 1) (* -1 h))
859 (func "v-line" (* -1 h)))
862 (cond ((eq? action-name 'all-definitions)
865 (define bracket ,bracket)
867 ;;(define crescendo ,crescendo)
868 (define bezier-sandwich ,bezier-sandwich)
869 ;;(define dashed-slur ,dashed-slur)
870 ;;(define decrescendo ,decrescendo)
871 (define end-output ,end-output)
872 (define experimental-on ,experimental-on)
873 (define filledbox ,filledbox)
874 ;;(define font-def ,font-def)
875 (define font-load-command ,font-load-command)
876 ;;(define font-switch ,font-switch)
877 (define header ,header)
878 (define header-end ,header-end)
879 (define lily-def ,lily-def)
880 ;;(define invoke-char ,invoke-char)
881 ;;(define invoke-dim1 ,invoke-dim1)
882 (define placebox ,placebox)
883 (define select-font ,select-font)
884 (define start-line ,start-line)
885 ;;(define stem ,stem)
886 (define stop-line ,stop-line)
887 (define stop-last-line ,stop-line)
889 ;;(define tuplet ,tuplet)
890 (define volta ,volta)
892 ;;((eq? action-name 'tuplet) tuplet)
893 ;;((eq? action-name 'beam) beam)
894 ;;((eq? action-name 'bezier-sandwich) bezier-sandwich)
895 ;;((eq? action-name 'bracket) bracket)
896 ((eq? action-name 'char) char)
897 ;;((eq? action-name 'crescendo) crescendo)
898 ;;((eq? action-name 'dashed-slur) dashed-slur)
899 ;;((eq? action-name 'decrescendo) decrescendo)
900 ;;((eq? action-name 'experimental-on) experimental-on)
901 ((eq? action-name 'filledbox) filledbox)
902 ((eq? action-name 'select-font) select-font)
903 ;;((eq? action-name 'volta) volta)
904 (else (error "unknown tag -- MUSA-SCM " action-name))
909 (define (gulp-file name)
910 (let* ((port (open-file name "r"))
911 (content (let loop ((text ""))
912 (let ((line (read-line port)))
913 (if (or (eof-object? line)
916 (loop (string-append text line "\n")))))))
920 ;; urg: Use when standalone, do:
921 ;; (define (ly-gulp-file name) (scm-gulp-file name))
922 (define (scm-gulp-file name)
924 (cons (string-append (getenv 'LILYPONDPREFIX) "/ly")
925 (cons (string-append (getenv 'LILYPONDPREFIX) "/ps")
927 (let ((path (%search-load-path name)))
932 (define (scm-tex-output)
933 (eval (tex-scm 'all-definitions)))
935 (define (scm-ps-output)
936 (eval (ps-scm 'all-definitions)))
938 (define (scm-as-output)
939 (eval (as-scm 'all-definitions)))
941 ; Russ McManus, <mcmanus@IDT.NET>
943 ; I use the following, which should definitely be provided somewhere
944 ; in guile, but isn't, AFAIK:
948 (define (hash-table-for-each fn ht)
950 ((= i (vector-length ht)))
951 (do ((alist (vector-ref ht i) (cdr alist)))
953 (fn (car (car alist)) (cdr (car alist))))))
955 (define (hash-table-map fn ht)
958 ((= i (vector-length ht)) (reverse ret-ls))
959 (do ((alist (vector-ref ht i) (cdr alist)))
961 (set! ret-ls (cons (fn (car (car alist)) (cdr (car alist))) ret-ls)))))
965 (define (index-cell cell dir)
971 ; How should a bar line behave at a break?
973 (define (break-barline glyph dir)
974 (let ((result (assoc glyph
975 '((":|:" . (":|" . "|:"))
978 ("|:" . ("|" . "|:"))
979 ("|." . ("|." . nil))
980 (":|" . (":|" . nil))
981 ("||" . ("||" . nil))
982 (".|." . (".|." . nil))
983 ("scorebar" . (nil . "scorepostbreak"))
984 ("brace" . (nil . "brace"))
985 ("bracket" . (nil . "bracket"))
989 (if (equal? result #f)
990 (ly-warn (string-append "Unknown bar glyph: `" glyph "'"))
991 (index-cell (cdr result) dir))
996 (define (slur-ugly ind ht)
1001 (> ht (+ (* 2 ind) -4))
1002 (< ht (+ (* -2 ind) 8)))