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>
8 ;(debug-enable 'backtrace)
12 (use-modules (ice-9 regex))
14 ;; do nothing in .scm output
15 (define (comment s) "")
21 (define (cons-map f x)
22 (cons (f (car x)) (f (cdr x))))
24 (define (reduce operator list)
25 (if (null? (cdr list)) (car list)
26 (operator (car list) (reduce operator (cdr list)))
30 (define (glue-2-strings a b)
31 (string-append a " " b))
33 (define (numbers->string l)
34 (reduce glue-2-strings (map number->string l)))
36 (define (chop-decimal x) (if (< (abs x) 0.001) 0.0 x))
38 (define (number->octal-string x)
39 (let* ((n (inexact->exact x))
41 (n8 (quotient (- n (* n64 64)) 8)))
45 (number->string (remainder (- n (+ (* n64 64) (* n8 8))) 8)))))
47 (define (inexact->string x radix)
48 (let ((n (inexact->exact x)))
49 (number->string n radix)))
55 (string-append (number->string (car c)) " ")
56 (string-append (number->string (cdr c)) " ")))
62 (make-string 1 (integer->char (+ (char->integer #\A) i)))
67 (define (scm-scm action-name)
70 (define security-paranoia #f)
73 ;; See documentation of Item::visibility_lambda_
74 (define (begin-of-line-visible d) (if (= d 1) '(#f . #f) '(#t . #t)))
75 (define (spanbar-begin-of-line-invisible d) (if (= d -1) '(#t . #t) '(#f . #f)))
76 (define (all-visible d) '(#f . #f))
77 (define (begin-of-line-invisible d) (if (= d 1) '(#t . #t) '(#f . #f)))
78 (define (end-of-line-invisible d) (if (= d -1) '(#t . #t) '(#f . #f)))
81 ;; Score_span_bars are only visible at start of line
82 ;; i.e. if break_dir == RIGHT == 1
83 (define Span_bar_engraver-visibility begin-of-line-invisible)
84 (define Base_span_bar_engraver-visibility begin-of-line-invisible)
85 (define mark-visibility end-of-line-invisible)
86 (define Span_score_bar_engraver-visibility begin-of-line-visible)
87 (define Piano_bar_engraver-visibility begin-of-line-visible)
88 (define Staff_group_bar_engraver-visibility begin-of-line-visible)
90 ;; Spacing constants for prefatory matter.
92 ;; rules for this spacing are much more complicated than this. See [Wanske] page 126 -- 134, [Ross] pg 143 -- 147
96 ;; (Measured in staff space)
99 (("" "Clef_item") . (minimum-space 1.0))
100 (("" "Staff_bar") . (minimum-space 0.0))
101 (("" "Clef_item") . (minimum-space 1.0))
102 (("" "Key_item") . (minimum-space 0.5))
103 (("" "Span_bar") . (extra-space 0.0))
104 (("" "Time_signature") . (extra-space 0.0))
105 (("" "begin-of-note") . (minimum-space 1.5))
106 (("Clef_item" "Key_item") . (minimum-space 4.0))
107 (("Key_item" "Time_signature") . (extra-space 1.0))
108 (("Clef_item" "Time_signature") . (minimum-space 3.5))
109 (("Staff_bar" "Clef_item") . (minimum-space 1.0))
110 (("Clef_item" "Staff_bar") . (minimum-space 3.7))
111 (("Time_signature" "Staff_bar") . (minimum-space 2.0))
112 (("Key_item" "Staff_bar") . (extra-space 1.0))
113 (("Span_bar" "Clef_item") . (extra-space 1.0))
114 (("Clef_item" "Span_bar") . (minimum-space 3.7))
115 (("Time_signature" "Span_bar") . (minimum-space 2.0))
116 (("Key_item" "Span_bar") . (minimum-space 2.5))
117 (("Staff_bar" "Time_signature") . (minimum-space 1.5)) ;double check this.
118 (("Time_signature" "begin-of-note") . (extra-space 2.0)) ;double check this.
119 (("Key_item" "begin-of-note") . (extra-space 2.5))
120 (("Staff_bar" "begin-of-note") . (extra-space 1.0))
121 (("Clef_item" "begin-of-note") . (minimum-space 5.0))
122 (("" "Breathing_sign") . (minimum-space 0.0))
123 (("Breathing_sign" "Key_item") . (minimum-space 1.5))
124 (("Breathing_sign" "begin-of-note") . (minimum-space 1.0))
125 (("Breathing_sign" "Staff_bar") . (minimum-space 1.5))
126 (("Breathing_sign" "Clef_item") . (minimum-space 2.0))
130 (define (break-align-spacer this next)
131 (let ((entry (assoc `(,this ,next) space-alist)))
134 (begin (ly-warn (string-append "Unknown spacing pair `" this "', `" next "'"))
135 '(minimum-space 0.0)))))
141 ;; this is silly, can't we use something like
142 ;; roman-0, roman-1 roman+1 ?
145 ("brace" . "feta-braces")
146 ("default" . "cmr10")
147 ("dynamic" . "feta-din")
151 ("finger" . "feta-nummer")
152 ("typewriter" . "cmtt")
158 ("mark" . "feta-nummer")
159 ("number" . "feta-nummer")
160 ("volta" . "feta-nummer"))
163 (define (string-encode-integer i)
166 ((< i 0) (string-append "n" (string-encode-integer (- i))))
168 (make-string 1 (integer->char (+ 65 (modulo i 26))))
169 (string-encode-integer (quotient i 26))
176 (cdr (assoc i '((-4 . 482)
189 (define script-alist '())
190 (define (articulation-to-scriptdef a)
191 (assoc a script-alist)
194 ;; Map style names to TeX font names. Return false if
195 ;; no font name found.
196 (define (style-to-cmr s)
202 (define font-name-alist '())
203 (define (font-command name-mag)
205 (string-append "magfont"
206 (string-encode-integer (hashq (car name-mag) 1000000))
208 (string-encode-integer (cdr name-mag)))
212 (define (define-fonts names)
213 (set! font-name-alist (map font-command names))
216 (font-load-command (car x) (cdr x))) font-name-alist)
219 (define (fontify name exp)
220 (string-append (select-font name)
227 ; Make a function that checks score element for being of a specific type.
228 (define (make-type-checker name)
230 (not (not (memq name (ly-get-elt-property elt 'interfaces))))))
241 ;;;;;;;;;;;;;;;;;;; generic output
243 (define (translate-molecule offset)
247 ;;;;;;;;;;;;;;;;;;; TeX output
248 (define (tex-scm action-name)
253 (define (select-font font-name-symbol)
256 (c (assoc font-name-symbol font-name-alist))
261 (ly-warn (string-append
262 "Programming error: No such font known " (car font-name-symbol)))
263 "") ; issue no command
264 (string-append "\\" (cdr c)))
269 (define (beam width slope thick)
270 (embedded-ps ((ps-scm 'beam) width slope thick)))
272 (define (bracket arch_angle arch_width arch_height width height arch_thick thick)
273 (embedded-ps ((ps-scm 'bracket) arch_angle arch_width arch_height width height arch_thick thick)))
275 (define (dashed-slur thick dash l)
276 (embedded-ps ((ps-scm 'dashed-slur) thick dash l)))
278 (define (crescendo thick w h cont)
279 (embedded-ps ((ps-scm 'crescendo) thick w h cont)))
282 (string-append "\\char" (inexact->string i 10) " "))
284 (define (dashed-line thick dash w)
285 (embedded-ps ((ps-scm 'dashed-line) thick dash w)))
287 (define (decrescendo thick w h cont)
288 (embedded-ps ((ps-scm 'decrescendo) thick w h cont)))
290 ;This sets CTM so that you get to the currentpoint
291 ; by executing a 0 0 moveto
296 (define (font-load-command name-mag command)
298 "\\font\\" command "="
299 (symbol->string (car name-mag))
301 (number->string (magstep (cdr name-mag)))
305 (define (embedded-ps s)
306 (string-append "\\embeddedps{" s "}"))
309 (string-append "% " s))
312 "\n\\EndLilyPondOutput")
314 (define (experimental-on)
317 (define (font-switch i)
321 (define (font-def i s)
323 "\\font" (font-switch i) "=" s "\n"))
329 ;(ly-gulp-file "lily.ps")
331 ;; URG: now we can't use scm output without Lily
332 (regexp-substitute/global #f "\n" (ly-gulp-file "lily.ps") 'pre " %\n" 'post)
334 "\\input lilyponddefs \\turnOnPostScript"))
336 (define (header creator generate)
338 "%created by: " creator generate "\n"))
340 (define (invoke-char s i)
342 "\n\\" s "{" (inexact->string i 10) "}" ))
344 (define (invoke-dim1 s d)
346 "\n\\" s "{" (number->dim d) "}"))
351 ;; need to do something to make this really safe.
353 (define (output-tex-string s)
354 (if security-paranoia
355 (regexp-substitute/global #f "\\\\" s 'pre "$\\backslash$" 'post)
358 (define (lily-def key val)
362 (regexp-substitute/global #f "_" (output-tex-string key) 'pre "X" 'post)
363 ;(output-tex-string key)
364 "{" (output-tex-string val) "}\n"))
366 (define (number->dim x)
368 (number->string (chop-decimal x)) " pt "))
370 (define (placebox x y s)
373 (number->dim y) "}{" (number->dim x) "}{" s "}\n"))
375 (define (bezier-sandwich l thick)
376 (embedded-ps ((ps-scm 'bezier-sandwich) l thick)))
378 (define (start-line ht)
379 (string-append"\\vbox to " (number->dim ht) "{\\hbox{%\n"))
382 "}\\vss}\\interscoreline")
383 (define (stop-last-line)
385 (define (filledbox breapth width depth height)
387 "\\kern" (number->dim (- breapth))
388 "\\vrule width " (number->dim (+ breapth width))
389 "depth " (number->dim depth)
390 "height " (number->dim height) " "))
393 (string-append "\\hbox{" (output-tex-string s) "}"))
395 (define (tuplet ht gapx dx dy thick dir)
396 (embedded-ps ((ps-scm 'tuplet) ht gapx dx dy thick dir)))
398 (define (volta h w thick vert_start vert_end)
399 (embedded-ps ((ps-scm 'volta) h w thick vert_start vert_end)))
402 ;; The procedures listed below form the public interface of TeX-scm.
403 ;; (should merge the 2 lists)
404 (cond ((eq? action-name 'all-definitions)
406 (define font-load-command ,font-load-command)
408 (define bezier-sandwich ,bezier-sandwich)
409 (define bracket ,bracket)
411 (define crescendo ,crescendo)
412 (define dashed-line ,dashed-line)
413 (define dashed-slur ,dashed-slur)
414 (define decrescendo ,decrescendo)
415 (define end-output ,end-output)
416 (define experimental-on ,experimental-on)
417 (define filledbox ,filledbox)
418 (define font-def ,font-def)
419 (define font-switch ,font-switch)
420 (define header-end ,header-end)
421 (define lily-def ,lily-def)
422 (define header ,header)
423 (define invoke-char ,invoke-char)
424 (define invoke-dim1 ,invoke-dim1)
425 (define placebox ,placebox)
426 (define select-font ,select-font)
427 (define start-line ,start-line)
428 (define stop-line ,stop-line)
429 (define stop-last-line ,stop-last-line)
431 (define tuplet ,tuplet)
432 (define volta ,volta)
435 ((eq? action-name 'beam) beam)
436 ((eq? action-name 'tuplet) tuplet)
437 ((eq? action-name 'bracket) bracket)
438 ((eq? action-name 'crescendo) crescendo)
439 ((eq? action-name 'dashed-line) dashed-line)
440 ((eq? action-name 'dashed-slur) dashed-slur)
441 ((eq? action-name 'decrescendo) decrescendo)
442 ((eq? action-name 'end-output) end-output)
443 ((eq? action-name 'experimental-on) experimental-on)
444 ((eq? action-name 'font-def) font-def)
445 ((eq? action-name 'font-switch) font-switch)
446 ((eq? action-name 'header-end) header-end)
447 ((eq? action-name 'lily-def) lily-def)
448 ((eq? action-name 'header) header)
449 ((eq? action-name 'invoke-char) invoke-char)
450 ((eq? action-name 'invoke-dim1) invoke-dim1)
451 ((eq? action-name 'placebox) placebox)
452 ((eq? action-name 'bezier-sandwich) bezier-sandwich)
453 ((eq? action-name 'start-line) start-line)
454 ((eq? action-name 'stem) stem)
455 ((eq? action-name 'stop-line) stop-line)
456 ((eq? action-name 'stop-last-line) stop-last-line)
457 ((eq? action-name 'volta) volta)
458 (else (error "unknown tag -- PS-TEX " action-name))
464 (define (ps-scm action-name)
467 ;; alist containing fontname -> fontcommand assoc (both strings)
468 (define font-alist '())
469 (define font-count 0)
470 (define current-font "")
473 (define (cached-fontname i)
476 (make-string 1 (integer->char (+ 65 i)))))
478 (define (mag-to-size m)
479 (number->string (case m
482 (2 14) ; really: 14.400
483 (3 17) ; really: 17.280
484 (4 21) ; really: 20.736
485 (5 24) ; really: 24.888
486 (6 30) ; really: 29.856
490 (define (select-font font-name-symbol)
493 (c (assoc font-name-symbol font-name-alist))
498 (ly-warn (string-append
499 "Programming error: No such font known " (car font-name-symbol)))
500 "") ; issue no command
501 (string-append " " (cdr c) " "))
506 (define (font-load-command name-mag command)
510 (symbol->string (car name-mag))
512 (number->string (magstep (cdr name-mag)))
513 " 1000 div 12 mul scalefont setfont } bind def "
517 (define (beam width slope thick)
519 (numbers->string (list width slope thick)) " draw_beam" ))
522 (string-append "% " s))
524 (define (bracket arch_angle arch_width arch_height width height arch_thick thick)
526 (numbers->string (list arch_angle arch_width arch_height width height arch_thick thick)) " draw_bracket" ))
529 (invoke-char " show" i))
531 (define (crescendo thick w h cont )
533 (numbers->string (list w h (inexact->exact cont) thick))
536 ;; what the heck is this interface ?
537 (define (dashed-slur thick dash l)
539 (apply string-append (map control->string l))
540 (number->string thick)
542 (number->string dash)
544 (number->string (* 10 thick)) ;UGH. 10 ?
545 " ] 0 draw_dashed_slur"))
547 (define (dashed-line thick dash width)
549 (number->string width)
551 (number->string thick)
553 (number->string dash)
555 (number->string dash)
556 " ] 0 draw_dashed_line"))
558 (define (decrescendo thick w h cont)
560 (numbers->string (list w h (inexact->exact cont) thick))
561 " draw_decrescendo"))
567 (define (experimental-on) "")
569 (define (filledbox breapth width depth height)
570 (string-append (numbers->string (list breapth width depth height))
574 (define (font-def i s)
577 (substring s 0 (- (string-length s) 4))
578 " findfont 12 scalefont setfont} bind def \n"))
580 (define (font-switch i)
581 (string-append (font i) " "))
585 ;; URG: now we can't use scm output without Lily
586 (ly-gulp-file "lilyponddefs.ps")
587 " {exch pop //systemdict /run get exec} "
588 (ly-gulp-file "lily.ps")
589 "{ exch pop //systemdict /run get exec } "
592 (define (lily-def key val)
594 (if (string=? (substring key 0 (min (string-length "mudelapaper") (string-length key))) "mudelapaper")
595 (string-append "/" key " {" val "} bind def\n")
596 (string-append "/" key " (" val ") def\n")
600 (define (header creator generate)
603 "%%Creator: " creator generate "\n"))
605 (define (invoke-char s i)
607 "(\\" (inexact->string i 8) ") " s " " ))
609 (define (invoke-dim1 s d)
611 (number->string (* d (/ 72.27 72))) " " s ))
613 (define (placebox x y s)
615 (number->string x) " " (number->string y) " {" s "} placebox "))
617 (define (bezier-sandwich l thick)
619 (apply string-append (map control->string l))
620 (number->string thick)
621 " draw_bezier_sandwich"))
623 (define (start-line height)
626 (define (stem breapth width depth height)
627 (string-append (numbers->string (list breapth width depth height))
634 (string-append "(" s ") show "))
637 (define (volta h w thick vert_start vert_end)
639 (numbers->string (list h w thick (inexact->exact vert_start) (inexact->exact vert_end)))
642 (define (tuplet ht gap dx dy thick dir)
644 (numbers->string (list ht gap dx dy thick (inexact->exact dir)))
653 (cond ((eq? action-name 'all-definitions)
656 (define tuplet ,tuplet)
657 (define bracket ,bracket)
659 (define crescendo ,crescendo)
660 (define volta ,volta)
661 (define bezier-sandwich ,bezier-sandwich)
662 (define dashed-line ,dashed-line)
663 (define dashed-slur ,dashed-slur)
664 (define decrescendo ,decrescendo)
665 (define end-output ,end-output)
666 (define experimental-on ,experimental-on)
667 (define filledbox ,filledbox)
668 (define font-def ,font-def)
669 (define font-switch ,font-switch)
670 (define header-end ,header-end)
671 (define lily-def ,lily-def)
672 (define font-load-command ,font-load-command)
673 (define header ,header)
674 (define invoke-char ,invoke-char)
675 (define invoke-dim1 ,invoke-dim1)
676 (define placebox ,placebox)
677 (define select-font ,select-font)
678 (define start-line ,start-line)
680 (define stop-line ,stop-line)
681 (define stop-last-line ,stop-line)
684 ((eq? action-name 'tuplet) tuplet)
685 ((eq? action-name 'beam) beam)
686 ((eq? action-name 'bezier-sandwich) bezier-sandwich)
687 ((eq? action-name 'bracket) bracket)
688 ((eq? action-name 'char) char)
689 ((eq? action-name 'crescendo) crescendo)
690 ((eq? action-name 'dashed-line) dashed-line)
691 ((eq? action-name 'dashed-slur) dashed-slur)
692 ((eq? action-name 'decrescendo) decrescendo)
693 ((eq? action-name 'experimental-on) experimental-on)
694 ((eq? action-name 'filledbox) filledbox)
695 ((eq? action-name 'select-font) select-font)
696 ((eq? action-name 'volta) volta)
697 (else (error "unknown tag -- PS-SCM " action-name))
702 (define (arg->string arg)
703 (cond ((number? arg) (inexact->string arg 10))
704 ((string? arg) (string-append "\"" arg "\""))
705 ((symbol? arg) (string-append "\"" (symbol->string arg) "\""))))
707 (define (func name . args)
713 (map (lambda (x) (string-append " " (arg->string x))) args)))
719 (inexact->exact (/ x (abs x)))))
722 (define (as-scm action-name)
724 (define (beam width slope thick)
726 (func "set-line-char" "#")
727 (func "rline-to" width (* width slope))
731 (define (bezier-sandwich l thick)
738 (dy (- (cdr c3) (cdr c0)))
740 (c1-dx (- (car c1) x))
741 (c1-line-y (+ (cdr c0) (* c1-dx rc)))
742 (dir (if (< c1-line-y (cdr c1)) 1 -1))
743 (y (+ -1 (* dir (max (* dir (cdr c0)) (* dir (cdr c3)))))))
745 (func "rmove-to" x y)
746 (func "put" (if (< 0 dir) "/" "\\\\"))
747 (func "rmove-to" 1 (if (< 0 dir) 1 0))
748 (func "set-line-char" "_")
749 (func "h-line" (- dx 1))
750 (func "rmove-to" (- dx 1) (if (< 0 dir) -1 0))
751 (func "put" (if (< 0 dir) "\\\\" "/"))))))
753 (define (bracket arch_angle arch_width arch_height width height arch_thick thick)
755 (func "rmove-to" (+ width 1) (- (/ height -2) 1))
757 (func "set-line-char" "|")
758 (func "rmove-to" 0 1)
759 (func "v-line" (+ height 1))
760 (func "rmove-to" 0 (+ height 1))
770 (define (experimental-on)
773 (define (filledbox breapth width depth height)
774 (let ((dx (+ width breapth))
775 (dy (+ depth height)))
777 (func "rmove-to" (* -1 breapth) (* -1 depth))
780 (func "set-line-char"
781 (if (<= dx 1) "|" "#"))
784 (func "set-line-char"
785 (if (<= dy 1) "-" "="))
786 (func "h-line" dx))))))
788 (define (font-load-command name-mag command)
789 (func "load-font" (car name-mag) (magstep (cdr name-mag))))
791 (define (header creator generate)
792 (func "header" creator generate))
797 ;; urg: this is good for half of as2text's execution time
798 (define (xlily-def key val)
799 (string-append "(define " key " " (arg->string val) ")\n"))
801 (define (lily-def key val)
803 (or (equal? key "mudelapaperlinewidth")
804 (equal? key "mudelapaperstaffheight"))
805 (string-append "(define " key " " (arg->string val) ")\n")
808 (define (placebox x y s)
809 (let ((ey (inexact->exact y)))
810 (string-append "(move-to " (number->string (inexact->exact x)) " "
811 (if (= 0.5 (- (abs y) (abs ey)))
816 (define (select-font font-name-symbol)
817 (let* ((c (assoc font-name-symbol font-name-alist)))
822 "Programming error: No such font known "
823 (car font-name-symbol)))
824 "") ; issue no command
825 (func "select-font" (car font-name-symbol)))))
827 (define (start-line height)
828 (func "start-line" height))
836 (define (volta h w thick vert-start vert-end)
839 (func "set-line-char" "|")
840 (func "rmove-to" 0 -4)
841 ;; definition strange-way around
845 (func "rmove-to" 1 h)
846 (func "set-line-char" "_")
847 (func "h-line" (- w 1))
848 (func "set-line-char" "|")
851 (func "rmove-to" (- w 1) (* -1 h))
852 (func "v-line" (* -1 h)))
855 (cond ((eq? action-name 'all-definitions)
858 (define bracket ,bracket)
860 ;;(define crescendo ,crescendo)
861 (define bezier-sandwich ,bezier-sandwich)
862 ;;(define dashed-slur ,dashed-slur)
863 ;;(define decrescendo ,decrescendo)
864 (define end-output ,end-output)
865 (define experimental-on ,experimental-on)
866 (define filledbox ,filledbox)
867 ;;(define font-def ,font-def)
868 (define font-load-command ,font-load-command)
869 ;;(define font-switch ,font-switch)
870 (define header ,header)
871 (define header-end ,header-end)
872 (define lily-def ,lily-def)
873 ;;(define invoke-char ,invoke-char)
874 ;;(define invoke-dim1 ,invoke-dim1)
875 (define placebox ,placebox)
876 (define select-font ,select-font)
877 (define start-line ,start-line)
878 ;;(define stem ,stem)
879 (define stop-line ,stop-line)
880 (define stop-last-line ,stop-line)
882 ;;(define tuplet ,tuplet)
883 (define volta ,volta)
885 ;;((eq? action-name 'tuplet) tuplet)
886 ;;((eq? action-name 'beam) beam)
887 ;;((eq? action-name 'bezier-sandwich) bezier-sandwich)
888 ;;((eq? action-name 'bracket) bracket)
889 ((eq? action-name 'char) char)
890 ;;((eq? action-name 'crescendo) crescendo)
891 ;;((eq? action-name 'dashed-slur) dashed-slur)
892 ;;((eq? action-name 'decrescendo) decrescendo)
893 ;;((eq? action-name 'experimental-on) experimental-on)
894 ((eq? action-name 'filledbox) filledbox)
895 ((eq? action-name 'select-font) select-font)
896 ;;((eq? action-name 'volta) volta)
897 (else (error "unknown tag -- MUSA-SCM " action-name))
902 (define (gulp-file name)
903 (let* ((port (open-file name "r"))
904 (content (let loop ((text ""))
905 (let ((line (read-line port)))
906 (if (or (eof-object? line)
909 (loop (string-append text line "\n")))))))
913 ;; urg: Use when standalone, do:
914 ;; (define (ly-gulp-file name) (scm-gulp-file name))
915 (define (scm-gulp-file name)
917 (cons (string-append (getenv 'LILYPONDPREFIX) "/ly")
918 (cons (string-append (getenv 'LILYPONDPREFIX) "/ps")
920 (let ((path (%search-load-path name)))
925 (define (scm-tex-output)
926 (eval (tex-scm 'all-definitions)))
928 (define (scm-ps-output)
929 (eval (ps-scm 'all-definitions)))
931 (define (scm-as-output)
932 (eval (as-scm 'all-definitions)))
934 ; Russ McManus, <mcmanus@IDT.NET>
936 ; I use the following, which should definitely be provided somewhere
937 ; in guile, but isn't, AFAIK:
941 (define (hash-table-for-each fn ht)
943 ((= i (vector-length ht)))
944 (do ((alist (vector-ref ht i) (cdr alist)))
946 (fn (car (car alist)) (cdr (car alist))))))
948 (define (hash-table-map fn ht)
951 ((= i (vector-length ht)) (reverse ret-ls))
952 (do ((alist (vector-ref ht i) (cdr alist)))
954 (set! ret-ls (cons (fn (car (car alist)) (cdr (car alist))) ret-ls)))))
958 (define (index-cell cell dir)
964 ; How should a bar line behave at a break?
966 (define (break-barline glyph dir)
967 (let ((result (assoc glyph
968 '((":|:" . (":|" . "|:"))
971 ("|:" . ("|" . "|:"))
972 ("|." . ("|." . nil))
973 (":|" . (":|" . nil))
974 ("||" . ("||" . nil))
975 (".|." . (".|." . nil))
976 ("scorebar" . (nil . "scorepostbreak"))
977 ("brace" . (nil . "brace"))
978 ("bracket" . (nil . "bracket"))
982 (if (equal? result #f)
983 (ly-warn (string-append "Unknown bar glyph: `" glyph "'"))
984 (index-cell (cdr result) dir))
989 (define (slur-ugly ind ht)
994 (> ht (+ (* 2 ind) -4))
995 (< ht (+ (* -2 ind) 8)))