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 (begin-of-line-invisible d) (if (= d 1) '(#t . #t) '(#f . #f)))
89 (define (end-of-line-invisible d) (if (= d -1) '(#t . #t) '(#f . #f)))
92 ;; Score_span_bars are only visible at start of line
93 ;; i.e. if break_dir == RIGHT == 1
94 (define Span_bar_engraver-visibility begin-of-line-invisible)
95 (define Base_span_bar_engraver-visibility begin-of-line-invisible)
96 (define mark-visibility end-of-line-invisible)
97 (define Span_score_bar_engraver-visibility begin-of-line-visible)
98 (define Piano_bar_engraver-visibility begin-of-line-visible)
99 (define Staff_group_bar_engraver-visibility begin-of-line-visible)
101 ;; Spacing constants for prefatory matter.
103 ;; rules for this spacing are much more complicated than this. See [Wanske] page 126 -- 134, [Ross] pg 143 -- 147
107 ;; (Measured in staff space)
110 (("" "Left_edge_item") . (extra-space -15.0))
111 (("" "Clef_item") . (minimum-space 1.0))
112 (("" "Staff_bar") . (minimum-space 0.0))
113 (("" "Clef_item") . (minimum-space 1.0))
114 (("" "Key_item") . (minimum-space 0.5))
115 (("" "Span_bar") . (extra-space 0.0))
116 (("" "Time_signature") . (extra-space 0.0))
117 (("" "begin-of-note") . (minimum-space 1.5))
118 (("Clef_item" "Key_item") . (minimum-space 4.0))
119 (("Key_item" "Time_signature") . (extra-space 1.0))
120 (("Clef_item" "Time_signature") . (minimum-space 3.5))
121 (("Staff_bar" "Clef_item") . (minimum-space 1.0))
122 (("Clef_item" "Staff_bar") . (minimum-space 3.7))
123 (("Time_signature" "Staff_bar") . (minimum-space 2.0))
124 (("Key_item" "Staff_bar") . (extra-space 1.0))
125 (("Span_bar" "Clef_item") . (extra-space 1.0))
126 (("Clef_item" "Span_bar") . (minimum-space 3.7))
127 (("Time_signature" "Span_bar") . (minimum-space 2.0))
128 (("Key_item" "Span_bar") . (minimum-space 2.5))
129 (("Staff_bar" "Time_signature") . (minimum-space 1.5)) ;double check this.
130 (("Time_signature" "begin-of-note") . (extra-space 2.0)) ;double check this.
131 (("Key_item" "begin-of-note") . (extra-space 2.5))
132 (("Staff_bar" "begin-of-note") . (extra-space 1.0))
133 (("Clef_item" "begin-of-note") . (minimum-space 5.0))
134 (("" "Breathing_sign") . (minimum-space 0.0))
135 (("Breathing_sign" "Key_item") . (minimum-space 1.5))
136 (("Breathing_sign" "begin-of-note") . (minimum-space 1.0))
137 (("Breathing_sign" "Staff_bar") . (minimum-space 1.5))
138 (("Breathing_sign" "Clef_item") . (minimum-space 2.0))
142 (define (break-align-spacer this next)
143 (let ((entry (assoc `(,this ,next) space-alist)))
146 (begin (ly-warn (string-append "Unknown spacing pair `" this "', `" next "'"))
147 '(minimum-space 0.0)))))
153 ;; this is silly, can't we use something like
154 ;; roman-0, roman-1 roman+1 ?
157 ("brace" . "feta-braces")
158 ("default" . "cmr10")
159 ("dynamic" . "feta-din")
163 ("finger" . "feta-nummer")
164 ("typewriter" . "cmtt")
170 ("mark" . "feta-nummer")
171 ("number" . "feta-nummer")
172 ("volta" . "feta-nummer"))
175 (define (string-encode-integer i)
178 ((< i 0) (string-append "n" (string-encode-integer (- i))))
180 (make-string 1 (integer->char (+ 65 (modulo i 26))))
181 (string-encode-integer (quotient i 26))
188 (cdr (assoc i '((-4 . 482)
201 (define script-alist '())
202 (define (articulation-to-scriptdef a)
203 (assoc a script-alist)
206 ;; Map style names to TeX font names. Return false if
207 ;; no font name found.
208 (define (style-to-cmr s)
214 (define font-name-alist '())
215 (define (font-command name-mag)
217 (string-append "magfont"
218 (string-encode-integer (hashq (car name-mag) 1000000))
220 (string-encode-integer (cdr name-mag)))
224 (define (define-fonts names)
225 (set! font-name-alist (map font-command names))
228 (font-load-command (car x) (cdr x))) font-name-alist)
231 (define (fontify name exp)
232 (string-append (select-font name)
239 ; Make a function that checks score element for being of a specific type.
240 (define (make-type-checker name)
242 (not (not (memq name (ly-get-elt-property elt 'interfaces))))))
245 ;;;;;;;;;;;;;;;;;;; TeX output
246 (define (tex-scm action-name)
251 (define (select-font font-name-symbol)
254 (c (assoc font-name-symbol font-name-alist))
259 (ly-warn (string-append
260 "Programming error: No such font known " (car font-name-symbol)))
261 "") ; issue no command
262 (string-append "\\" (cdr c)))
267 (define (beam width slope thick)
268 (embedded-ps ((ps-scm 'beam) width slope thick)))
270 (define (bracket arch_angle arch_width arch_height width height arch_thick thick)
271 (embedded-ps ((ps-scm 'bracket) arch_angle arch_width arch_height width height arch_thick thick)))
273 (define (dashed-slur thick dash l)
274 (embedded-ps ((ps-scm 'dashed-slur) thick dash l)))
276 (define (crescendo thick w h cont)
277 (embedded-ps ((ps-scm 'crescendo) thick w h cont)))
280 (string-append "\\char" (inexact->string i 10) " "))
282 (define (dashed-line thick dash w)
283 (embedded-ps ((ps-scm 'dashed-line) thick dash w)))
285 (define (decrescendo thick w h cont)
286 (embedded-ps ((ps-scm 'decrescendo) thick w h cont)))
288 (define (font-load-command name-mag command)
290 "\\font\\" command "="
291 (symbol->string (car name-mag))
293 (number->string (magstep (cdr name-mag)))
296 (define (embedded-ps s)
297 (string-append "\\embeddedps{" s "}"))
300 (string-append "% " s))
303 "\n\\EndLilyPondOutput")
305 (define (experimental-on)
308 (define (font-switch i)
312 (define (font-def i s)
314 "\\font" (font-switch i) "=" s "\n"))
320 ;; URG: ly-gulp-file: now we can't use scm output without Lily
322 ;; fixed in 1.3.4 for powerpc -- broken on Windows
323 (regexp-substitute/global #f "\n"
324 (ly-gulp-file "lily.ps") 'pre " %\n" 'post)
325 (ly-gulp-file "lily.ps"))
327 "\\input lilyponddefs \\turnOnPostScript"))
329 (define (header creator generate)
331 "%created by: " creator generate "\n"))
333 (define (invoke-char s i)
335 "\n\\" s "{" (inexact->string i 10) "}" ))
337 (define (invoke-dim1 s d)
339 "\n\\" s "{" (number->dim d) "}"))
344 ;; need to do something to make this really safe.
346 (define (output-tex-string s)
347 (if security-paranoia
349 (regexp-substitute/global #f "\\\\" s 'pre "$\\backslash$" 'post)
350 (begin (display "warning: not paranoid") (newline) s))
353 (define (lily-def key val)
357 ;; fixed in 1.3.4 for powerpc -- broken on Windows
358 (regexp-substitute/global #f "_"
359 (output-tex-string key) 'pre "X" 'post)
360 (output-tex-string key))
361 "{" (output-tex-string val) "}\n"))
363 (define (number->dim x)
365 (ly-number->string x) " pt "))
367 (define (placebox x y s)
370 (number->dim y) "}{" (number->dim x) "}{" s "}\n"))
372 (define (bezier-sandwich l thick)
373 (embedded-ps ((ps-scm 'bezier-sandwich) l thick)))
375 (define (start-line ht)
376 (string-append"\\vbox to " (number->dim ht) "{\\hbox{%\n"))
379 "}\\vss}\\interscoreline")
380 (define (stop-last-line)
382 (define (filledbox breapth width depth height)
384 "\\kern" (number->dim (- breapth))
385 "\\vrule width " (number->dim (+ breapth width))
386 "depth " (number->dim depth)
387 "height " (number->dim height) " "))
390 (string-append "\\hbox{" (output-tex-string s) "}"))
392 (define (tuplet ht gapx dx dy thick dir)
393 (embedded-ps ((ps-scm 'tuplet) ht gapx dx dy thick dir)))
395 (define (volta h w thick vert_start vert_end)
396 (embedded-ps ((ps-scm 'volta) h w thick vert_start vert_end)))
399 ;; The procedures listed below form the public interface of TeX-scm.
400 ;; (should merge the 2 lists)
401 (cond ((eq? action-name 'all-definitions)
403 (define font-load-command ,font-load-command)
405 (define bezier-sandwich ,bezier-sandwich)
406 (define bracket ,bracket)
408 (define crescendo ,crescendo)
409 (define dashed-line ,dashed-line)
410 (define dashed-slur ,dashed-slur)
411 (define decrescendo ,decrescendo)
412 (define end-output ,end-output)
413 (define experimental-on ,experimental-on)
414 (define filledbox ,filledbox)
415 (define font-def ,font-def)
416 (define font-switch ,font-switch)
417 (define header-end ,header-end)
418 (define lily-def ,lily-def)
419 (define header ,header)
420 (define invoke-char ,invoke-char)
421 (define invoke-dim1 ,invoke-dim1)
422 (define placebox ,placebox)
423 (define select-font ,select-font)
424 (define start-line ,start-line)
425 (define stop-line ,stop-line)
426 (define stop-last-line ,stop-last-line)
428 (define tuplet ,tuplet)
429 (define volta ,volta)
432 ((eq? action-name 'beam) beam)
433 ((eq? action-name 'tuplet) tuplet)
434 ((eq? action-name 'bracket) bracket)
435 ((eq? action-name 'crescendo) crescendo)
436 ((eq? action-name 'dashed-line) dashed-line)
437 ((eq? action-name 'dashed-slur) dashed-slur)
438 ((eq? action-name 'decrescendo) decrescendo)
439 ((eq? action-name 'end-output) end-output)
440 ((eq? action-name 'experimental-on) experimental-on)
441 ((eq? action-name 'font-def) font-def)
442 ((eq? action-name 'font-switch) font-switch)
443 ((eq? action-name 'header-end) header-end)
444 ((eq? action-name 'lily-def) lily-def)
445 ((eq? action-name 'header) header)
446 ((eq? action-name 'invoke-char) invoke-char)
447 ((eq? action-name 'invoke-dim1) invoke-dim1)
448 ((eq? action-name 'placebox) placebox)
449 ((eq? action-name 'bezier-sandwich) bezier-sandwich)
450 ((eq? action-name 'start-line) start-line)
451 ((eq? action-name 'stem) stem)
452 ((eq? action-name 'stop-line) stop-line)
453 ((eq? action-name 'stop-last-line) stop-last-line)
454 ((eq? action-name 'volta) volta)
455 (else (error "unknown tag -- PS-TEX " action-name))
461 (define (ps-scm action-name)
463 ;; alist containing fontname -> fontcommand assoc (both strings)
464 (define font-alist '())
465 (define font-count 0)
466 (define current-font "")
469 (define (cached-fontname i)
472 (make-string 1 (integer->char (+ 65 i)))))
474 (define (mag-to-size m)
475 (number->string (case m
478 (2 14) ; really: 14.400
479 (3 17) ; really: 17.280
480 (4 21) ; really: 20.736
481 (5 24) ; really: 24.888
482 (6 30) ; really: 29.856
486 (define (select-font font-name-symbol)
489 (c (assoc font-name-symbol font-name-alist))
494 (ly-warn (string-append
495 "Programming error: No such font known " (car font-name-symbol)))
496 "") ; issue no command
497 (string-append " " (cdr c) " "))
502 (define (font-load-command name-mag command)
506 (symbol->string (car name-mag))
508 (number->string (magstep (cdr name-mag)))
509 " 1000 div 12 mul scalefont setfont } bind def "
513 (define (beam width slope thick)
515 (numbers->string (list width slope thick)) " draw_beam" ))
518 (string-append "% " s))
520 (define (bracket arch_angle arch_width arch_height width height arch_thick thick)
522 (numbers->string (list arch_angle arch_width arch_height width height arch_thick thick)) " draw_bracket" ))
525 (invoke-char " show" i))
527 (define (crescendo thick w h cont )
529 (numbers->string (list w h (inexact->exact cont) thick))
532 ;; what the heck is this interface ?
533 (define (dashed-slur thick dash l)
535 (apply string-append (map control->string l))
536 (number->string thick)
538 (number->string dash)
540 (number->string (* 10 thick)) ;UGH. 10 ?
541 " ] 0 draw_dashed_slur"))
543 (define (dashed-line thick dash width)
545 (number->string width)
547 (number->string thick)
549 (number->string dash)
551 (number->string dash)
552 " ] 0 draw_dashed_line"))
554 (define (decrescendo thick w h cont)
556 (numbers->string (list w h (inexact->exact cont) thick))
557 " draw_decrescendo"))
563 (define (experimental-on) "")
565 (define (filledbox breapth width depth height)
566 (string-append (numbers->string (list breapth width depth height))
570 (define (font-def i s)
573 (substring s 0 (- (string-length s) 4))
574 " findfont 12 scalefont setfont} bind def \n"))
576 (define (font-switch i)
577 (string-append (font i) " "))
581 ;; URG: now we can't use scm output without Lily
582 (ly-gulp-file "lilyponddefs.ps")
583 " {exch pop //systemdict /run get exec} "
584 (ly-gulp-file "lily.ps")
585 "{ exch pop //systemdict /run get exec } "
588 (define (lily-def key val)
590 (if (string=? (substring key 0 (min (string-length "mudelapaper") (string-length key))) "mudelapaper")
591 (string-append "/" key " {" val "} bind def\n")
592 (string-append "/" key " (" val ") def\n")
596 (define (header creator generate)
599 "%%Creator: " creator generate "\n"))
601 (define (invoke-char s i)
603 "(\\" (inexact->string i 8) ") " s " " ))
605 (define (invoke-dim1 s d)
607 (number->string (* d (/ 72.27 72))) " " s ))
609 (define (placebox x y s)
611 (number->string x) " " (number->string y) " {" s "} placebox "))
613 (define (bezier-sandwich l thick)
615 (apply string-append (map control->string l))
616 (number->string thick)
617 " draw_bezier_sandwich"))
619 (define (start-line height)
622 (define (stem breapth width depth height)
623 (string-append (numbers->string (list breapth width depth height))
630 (string-append "(" s ") show "))
633 (define (volta h w thick vert_start vert_end)
635 (numbers->string (list h w thick (inexact->exact vert_start) (inexact->exact vert_end)))
638 (define (tuplet ht gap dx dy thick dir)
640 (numbers->string (list ht gap dx dy thick (inexact->exact dir)))
649 (cond ((eq? action-name 'all-definitions)
652 (define tuplet ,tuplet)
653 (define bracket ,bracket)
655 (define crescendo ,crescendo)
656 (define volta ,volta)
657 (define bezier-sandwich ,bezier-sandwich)
658 (define dashed-line ,dashed-line)
659 (define dashed-slur ,dashed-slur)
660 (define decrescendo ,decrescendo)
661 (define end-output ,end-output)
662 (define experimental-on ,experimental-on)
663 (define filledbox ,filledbox)
664 (define font-def ,font-def)
665 (define font-switch ,font-switch)
666 (define header-end ,header-end)
667 (define lily-def ,lily-def)
668 (define font-load-command ,font-load-command)
669 (define header ,header)
670 (define invoke-char ,invoke-char)
671 (define invoke-dim1 ,invoke-dim1)
672 (define placebox ,placebox)
673 (define select-font ,select-font)
674 (define start-line ,start-line)
676 (define stop-line ,stop-line)
677 (define stop-last-line ,stop-line)
680 ((eq? action-name 'tuplet) tuplet)
681 ((eq? action-name 'beam) beam)
682 ((eq? action-name 'bezier-sandwich) bezier-sandwich)
683 ((eq? action-name 'bracket) bracket)
684 ((eq? action-name 'char) char)
685 ((eq? action-name 'crescendo) crescendo)
686 ((eq? action-name 'dashed-line) dashed-line)
687 ((eq? action-name 'dashed-slur) dashed-slur)
688 ((eq? action-name 'decrescendo) decrescendo)
689 ((eq? action-name 'experimental-on) experimental-on)
690 ((eq? action-name 'filledbox) filledbox)
691 ((eq? action-name 'select-font) select-font)
692 ((eq? action-name 'volta) volta)
693 (else (error "unknown tag -- PS-SCM " action-name))
698 (define (arg->string arg)
699 (cond ((number? arg) (inexact->string arg 10))
700 ((string? arg) (string-append "\"" arg "\""))
701 ((symbol? arg) (string-append "\"" (symbol->string arg) "\""))))
703 (define (func name . args)
709 (map (lambda (x) (string-append " " (arg->string x))) args)))
715 (inexact->exact (/ x (abs x)))))
718 (define (as-scm action-name)
720 (define (beam width slope thick)
722 (func "set-line-char" "#")
723 (func "rline-to" width (* width slope))
727 (define (bezier-sandwich l thick)
734 (dy (- (cdr c3) (cdr c0)))
736 (c1-dx (- (car c1) x))
737 (c1-line-y (+ (cdr c0) (* c1-dx rc)))
738 (dir (if (< c1-line-y (cdr c1)) 1 -1))
739 (y (+ -1 (* dir (max (* dir (cdr c0)) (* dir (cdr c3)))))))
741 (func "rmove-to" x y)
742 (func "put" (if (< 0 dir) "/" "\\\\"))
743 (func "rmove-to" 1 (if (< 0 dir) 1 0))
744 (func "set-line-char" "_")
745 (func "h-line" (- dx 1))
746 (func "rmove-to" (- dx 1) (if (< 0 dir) -1 0))
747 (func "put" (if (< 0 dir) "\\\\" "/"))))))
749 (define (bracket arch_angle arch_width arch_height width height arch_thick thick)
751 (func "rmove-to" (+ width 1) (- (/ height -2) 1))
753 (func "set-line-char" "|")
754 (func "rmove-to" 0 1)
755 (func "v-line" (+ height 1))
756 (func "rmove-to" 0 (+ height 1))
766 (define (experimental-on)
769 (define (filledbox breapth width depth height)
770 (let ((dx (+ width breapth))
771 (dy (+ depth height)))
773 (func "rmove-to" (* -1 breapth) (* -1 depth))
776 (func "set-line-char"
777 (if (<= dx 1) "|" "#"))
780 (func "set-line-char"
781 (if (<= dy 1) "-" "="))
782 (func "h-line" dx))))))
784 (define (font-load-command name-mag command)
785 (func "load-font" (car name-mag) (magstep (cdr name-mag))))
787 (define (header creator generate)
788 (func "header" creator generate))
793 ;; urg: this is good for half of as2text's execution time
794 (define (xlily-def key val)
795 (string-append "(define " key " " (arg->string val) ")\n"))
797 (define (lily-def key val)
799 (or (equal? key "mudelapaperlinewidth")
800 (equal? key "mudelapaperstaffheight"))
801 (string-append "(define " key " " (arg->string val) ")\n")
804 (define (placebox x y s)
805 (let ((ey (inexact->exact y)))
806 (string-append "(move-to " (number->string (inexact->exact x)) " "
807 (if (= 0.5 (- (abs y) (abs ey)))
812 (define (select-font font-name-symbol)
813 (let* ((c (assoc font-name-symbol font-name-alist)))
818 "Programming error: No such font known "
819 (car font-name-symbol)))
820 "") ; issue no command
821 (func "select-font" (car font-name-symbol)))))
823 (define (start-line height)
824 (func "start-line" height))
832 (define (volta h w thick vert-start vert-end)
835 (func "set-line-char" "|")
836 (func "rmove-to" 0 -4)
837 ;; definition strange-way around
841 (func "rmove-to" 1 h)
842 (func "set-line-char" "_")
843 (func "h-line" (- w 1))
844 (func "set-line-char" "|")
847 (func "rmove-to" (- w 1) (* -1 h))
848 (func "v-line" (* -1 h)))
851 (cond ((eq? action-name 'all-definitions)
854 (define bracket ,bracket)
856 ;;(define crescendo ,crescendo)
857 (define bezier-sandwich ,bezier-sandwich)
858 ;;(define dashed-slur ,dashed-slur)
859 ;;(define decrescendo ,decrescendo)
860 (define end-output ,end-output)
861 (define experimental-on ,experimental-on)
862 (define filledbox ,filledbox)
863 ;;(define font-def ,font-def)
864 (define font-load-command ,font-load-command)
865 ;;(define font-switch ,font-switch)
866 (define header ,header)
867 (define header-end ,header-end)
868 (define lily-def ,lily-def)
869 ;;(define invoke-char ,invoke-char)
870 ;;(define invoke-dim1 ,invoke-dim1)
871 (define placebox ,placebox)
872 (define select-font ,select-font)
873 (define start-line ,start-line)
874 ;;(define stem ,stem)
875 (define stop-line ,stop-line)
876 (define stop-last-line ,stop-line)
878 ;;(define tuplet ,tuplet)
879 (define volta ,volta)
881 ;;((eq? action-name 'tuplet) tuplet)
882 ;;((eq? action-name 'beam) beam)
883 ;;((eq? action-name 'bezier-sandwich) bezier-sandwich)
884 ;;((eq? action-name 'bracket) bracket)
885 ((eq? action-name 'char) char)
886 ;;((eq? action-name 'crescendo) crescendo)
887 ;;((eq? action-name 'dashed-slur) dashed-slur)
888 ;;((eq? action-name 'decrescendo) decrescendo)
889 ;;((eq? action-name 'experimental-on) experimental-on)
890 ((eq? action-name 'filledbox) filledbox)
891 ((eq? action-name 'select-font) select-font)
892 ;;((eq? action-name 'volta) volta)
893 (else (error "unknown tag -- MUSA-SCM " action-name))
898 (define (gulp-file name)
899 (let* ((port (open-file name "r"))
900 (content (let loop ((text ""))
901 (let ((line (read-line port)))
902 (if (or (eof-object? line)
905 (loop (string-append text line "\n")))))))
909 ;; urg: Use when standalone, do:
910 ;; (define (ly-gulp-file name) (scm-gulp-file name))
911 (define (scm-gulp-file name)
913 (cons (string-append (getenv 'LILYPONDPREFIX) "/ly")
914 (cons (string-append (getenv 'LILYPONDPREFIX) "/ps")
916 (let ((path (%search-load-path name)))
921 (define (scm-tex-output)
922 (eval (tex-scm 'all-definitions)))
924 (define (scm-ps-output)
925 (eval (ps-scm 'all-definitions)))
927 (define (scm-as-output)
928 (eval (as-scm 'all-definitions)))
930 ; Russ McManus, <mcmanus@IDT.NET>
932 ; I use the following, which should definitely be provided somewhere
933 ; in guile, but isn't, AFAIK:
937 (define (hash-table-for-each fn ht)
939 ((= i (vector-length ht)))
940 (do ((alist (vector-ref ht i) (cdr alist)))
942 (fn (car (car alist)) (cdr (car alist))))))
944 (define (hash-table-map fn ht)
947 ((= i (vector-length ht)) (reverse ret-ls))
948 (do ((alist (vector-ref ht i) (cdr alist)))
950 (set! ret-ls (cons (fn (car (car alist)) (cdr (car alist))) ret-ls)))))
954 (define (index-cell cell dir)
960 ; How should a bar line behave at a break?
962 (define (break-barline glyph dir)
963 (let ((result (assoc glyph
964 '((":|:" . (":|" . "|:"))
965 (";|;" . ("|." . ".|"))
968 ("|:" . ("|" . "|:"))
969 (".|" . ("|" . ".|"))
970 ("|." . ("|." . nil))
971 (":|" . (":|" . nil))
972 ("||" . ("||" . nil))
973 (".|." . (".|." . nil))
974 ("scorebar" . (nil . "scorepostbreak"))
975 ("brace" . (nil . "brace"))
976 ("bracket" . (nil . "bracket"))
980 (if (equal? result #f)
981 (ly-warn (string-append "Unknown bar glyph: `" glyph "'"))
982 (index-cell (cdr result) dir))
987 (define (slur-ugly ind ht)
992 (> ht (+ (* 2 ind) -4))
993 (< ht (+ (* -2 ind) 8)))