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)))))
152 ;; this is silly, can't we use something like
153 ;; roman-0, roman-1 roman+1 ?
156 ("brace" . "feta-braces")
157 ("default" . "cmr10")
158 ("dynamic" . "feta-din")
162 ("finger" . "feta-nummer")
163 ("typewriter" . "cmtt")
169 ("mark" . "feta-nummer")
170 ("number" . "feta-nummer")
171 ("volta" . "feta-nummer"))
174 (define (string-encode-integer i)
177 ((< i 0) (string-append "n" (string-encode-integer (- i))))
179 (make-string 1 (integer->char (+ 65 (modulo i 26))))
180 (string-encode-integer (quotient i 26))
187 (cdr (assoc i '((-4 . 482)
200 (define script-alist '())
201 (define (articulation-to-scriptdef a)
202 (assoc a script-alist)
205 ;; Map style names to TeX font names. Return false if
206 ;; no font name found.
207 (define (style-to-cmr s)
213 (define font-name-alist '())
214 (define (font-command name-mag)
216 (string-append "magfont"
217 (string-encode-integer (hashq (car name-mag) 1000000))
219 (string-encode-integer (cdr name-mag)))
223 (define (define-fonts names)
224 (set! font-name-alist (map font-command names))
227 (font-load-command (car x) (cdr x))) font-name-alist)
230 (define (fontify name exp)
231 (string-append (select-font name)
238 ; Make a function that checks score element for being of a specific type.
239 (define (make-type-checker name)
241 (not (not (memq name (ly-get-elt-property elt 'interfaces))))))
244 ;;;;;;;;;;;;;;;;;;; TeX output
245 (define (tex-scm action-name)
250 (define (select-font font-name-symbol)
253 (c (assoc font-name-symbol font-name-alist))
258 (ly-warn (string-append
259 "Programming error: No such font known " (car font-name-symbol)))
260 "") ; issue no command
261 (string-append "\\" (cdr c)))
266 (define (beam width slope thick)
267 (embedded-ps ((ps-scm 'beam) width slope thick)))
269 (define (bracket arch_angle arch_width arch_height width height arch_thick thick)
270 (embedded-ps ((ps-scm 'bracket) arch_angle arch_width arch_height width height arch_thick thick)))
272 (define (dashed-slur thick dash l)
273 (embedded-ps ((ps-scm 'dashed-slur) thick dash l)))
275 (define (crescendo thick w h cont)
276 (embedded-ps ((ps-scm 'crescendo) thick w h cont)))
279 (string-append "\\char" (inexact->string i 10) " "))
281 (define (dashed-line thick dash w)
282 (embedded-ps ((ps-scm 'dashed-line) thick dash w)))
284 (define (decrescendo thick w h cont)
285 (embedded-ps ((ps-scm 'decrescendo) thick w h cont)))
287 (define (font-load-command name-mag command)
289 "\\font\\" command "="
290 (symbol->string (car name-mag))
292 (number->string (magstep (cdr name-mag)))
295 (define (embedded-ps s)
296 (string-append "\\embeddedps{" s "}"))
299 (string-append "% " s))
302 "\n\\EndLilyPondOutput")
304 (define (experimental-on)
307 (define (font-switch i)
311 (define (font-def i s)
313 "\\font" (font-switch i) "=" s "\n"))
319 ;; URG: ly-gulp-file: now we can't use scm output without Lily
321 ;; fixed in 1.3.4 for powerpc -- broken on Windows
322 (regexp-substitute/global #f "\n"
323 (ly-gulp-file "lily.ps") 'pre " %\n" 'post)
324 (ly-gulp-file "lily.ps"))
326 "\\input lilyponddefs \\turnOnPostScript"))
328 (define (header creator generate)
330 "%created by: " creator generate "\n"))
332 (define (invoke-char s i)
334 "\n\\" s "{" (inexact->string i 10) "}" ))
336 (define (invoke-dim1 s d)
338 "\n\\" s "{" (number->dim d) "}"))
343 ;; need to do something to make this really safe.
345 (define (output-tex-string s)
346 (if security-paranoia
348 (regexp-substitute/global #f "\\\\" s 'pre "$\\backslash$" 'post)
349 (begin (display "warning: not paranoid") (newline) s))
352 (define (lily-def key val)
356 ;; fixed in 1.3.4 for powerpc -- broken on Windows
357 (regexp-substitute/global #f "_"
358 (output-tex-string key) 'pre "X" 'post)
359 (output-tex-string key))
360 "{" (output-tex-string val) "}\n"))
362 (define (number->dim x)
364 (ly-number->string x) " pt "))
366 (define (placebox x y s)
369 (number->dim y) "}{" (number->dim x) "}{" s "}\n"))
371 (define (bezier-sandwich l thick)
372 (embedded-ps ((ps-scm 'bezier-sandwich) l thick)))
374 (define (start-line ht)
375 (string-append"\\vbox to " (number->dim ht) "{\\hbox{%\n"))
378 "}\\vss}\\interscoreline")
379 (define (stop-last-line)
381 (define (filledbox breapth width depth height)
383 "\\kern" (number->dim (- breapth))
384 "\\vrule width " (number->dim (+ breapth width))
385 "depth " (number->dim depth)
386 "height " (number->dim height) " "))
389 (string-append "\\hbox{" (output-tex-string s) "}"))
391 (define (tuplet ht gapx dx dy thick dir)
392 (embedded-ps ((ps-scm 'tuplet) ht gapx dx dy thick dir)))
394 (define (volta h w thick vert_start vert_end)
395 (embedded-ps ((ps-scm 'volta) h w thick vert_start vert_end)))
398 ;; The procedures listed below form the public interface of TeX-scm.
399 ;; (should merge the 2 lists)
400 (cond ((eq? action-name 'all-definitions)
402 (define font-load-command ,font-load-command)
404 (define bezier-sandwich ,bezier-sandwich)
405 (define bracket ,bracket)
407 (define crescendo ,crescendo)
408 (define dashed-line ,dashed-line)
409 (define dashed-slur ,dashed-slur)
410 (define decrescendo ,decrescendo)
411 (define end-output ,end-output)
412 (define experimental-on ,experimental-on)
413 (define filledbox ,filledbox)
414 (define font-def ,font-def)
415 (define font-switch ,font-switch)
416 (define header-end ,header-end)
417 (define lily-def ,lily-def)
418 (define header ,header)
419 (define invoke-char ,invoke-char)
420 (define invoke-dim1 ,invoke-dim1)
421 (define placebox ,placebox)
422 (define select-font ,select-font)
423 (define start-line ,start-line)
424 (define stop-line ,stop-line)
425 (define stop-last-line ,stop-last-line)
427 (define tuplet ,tuplet)
428 (define volta ,volta)
431 ((eq? action-name 'beam) beam)
432 ((eq? action-name 'tuplet) tuplet)
433 ((eq? action-name 'bracket) bracket)
434 ((eq? action-name 'crescendo) crescendo)
435 ((eq? action-name 'dashed-line) dashed-line)
436 ((eq? action-name 'dashed-slur) dashed-slur)
437 ((eq? action-name 'decrescendo) decrescendo)
438 ((eq? action-name 'end-output) end-output)
439 ((eq? action-name 'experimental-on) experimental-on)
440 ((eq? action-name 'font-def) font-def)
441 ((eq? action-name 'font-switch) font-switch)
442 ((eq? action-name 'header-end) header-end)
443 ((eq? action-name 'lily-def) lily-def)
444 ((eq? action-name 'header) header)
445 ((eq? action-name 'invoke-char) invoke-char)
446 ((eq? action-name 'invoke-dim1) invoke-dim1)
447 ((eq? action-name 'placebox) placebox)
448 ((eq? action-name 'bezier-sandwich) bezier-sandwich)
449 ((eq? action-name 'start-line) start-line)
450 ((eq? action-name 'stem) stem)
451 ((eq? action-name 'stop-line) stop-line)
452 ((eq? action-name 'stop-last-line) stop-last-line)
453 ((eq? action-name 'volta) volta)
454 (else (error "unknown tag -- PS-TEX " action-name))
460 (define (ps-scm action-name)
462 ;; alist containing fontname -> fontcommand assoc (both strings)
463 (define font-alist '())
464 (define font-count 0)
465 (define current-font "")
468 (define (cached-fontname i)
471 (make-string 1 (integer->char (+ 65 i)))))
473 (define (mag-to-size m)
474 (number->string (case m
477 (2 14) ; really: 14.400
478 (3 17) ; really: 17.280
479 (4 21) ; really: 20.736
480 (5 24) ; really: 24.888
481 (6 30) ; really: 29.856
485 (define (select-font font-name-symbol)
488 (c (assoc font-name-symbol font-name-alist))
493 (ly-warn (string-append
494 "Programming error: No such font known " (car font-name-symbol)))
495 "") ; issue no command
496 (string-append " " (cdr c) " "))
501 (define (font-load-command name-mag command)
505 (symbol->string (car name-mag))
507 (number->string (magstep (cdr name-mag)))
508 " 1000 div 12 mul scalefont setfont } bind def "
512 (define (beam width slope thick)
514 (numbers->string (list width slope thick)) " draw_beam" ))
517 (string-append "% " s))
519 (define (bracket arch_angle arch_width arch_height width height arch_thick thick)
521 (numbers->string (list arch_angle arch_width arch_height width height arch_thick thick)) " draw_bracket" ))
524 (invoke-char " show" i))
526 (define (crescendo thick w h cont )
528 (numbers->string (list w h (inexact->exact cont) thick))
531 ;; what the heck is this interface ?
532 (define (dashed-slur thick dash l)
534 (apply string-append (map control->string l))
535 (number->string thick)
537 (number->string dash)
539 (number->string (* 10 thick)) ;UGH. 10 ?
540 " ] 0 draw_dashed_slur"))
542 (define (dashed-line thick dash width)
544 (number->string width)
546 (number->string thick)
548 (number->string dash)
550 (number->string dash)
551 " ] 0 draw_dashed_line"))
553 (define (decrescendo thick w h cont)
555 (numbers->string (list w h (inexact->exact cont) thick))
556 " draw_decrescendo"))
562 (define (experimental-on) "")
564 (define (filledbox breapth width depth height)
565 (string-append (numbers->string (list breapth width depth height))
569 (define (font-def i s)
572 (substring s 0 (- (string-length s) 4))
573 " findfont 12 scalefont setfont} bind def \n"))
575 (define (font-switch i)
576 (string-append (font i) " "))
580 ;; URG: now we can't use scm output without Lily
581 (ly-gulp-file "lilyponddefs.ps")
582 " {exch pop //systemdict /run get exec} "
583 (ly-gulp-file "lily.ps")
584 "{ exch pop //systemdict /run get exec } "
587 (define (lily-def key val)
589 (if (string=? (substring key 0 (min (string-length "mudelapaper") (string-length key))) "mudelapaper")
590 (string-append "/" key " {" val "} bind def\n")
591 (string-append "/" key " (" val ") def\n")
595 (define (header creator generate)
598 "%%Creator: " creator generate "\n"))
600 (define (invoke-char s i)
602 "(\\" (inexact->string i 8) ") " s " " ))
604 (define (invoke-dim1 s d)
606 (number->string (* d (/ 72.27 72))) " " s ))
608 (define (placebox x y s)
610 (number->string x) " " (number->string y) " {" s "} placebox "))
612 (define (bezier-sandwich l thick)
614 (apply string-append (map control->string l))
615 (number->string thick)
616 " draw_bezier_sandwich"))
618 (define (start-line height)
621 (define (stem breapth width depth height)
622 (string-append (numbers->string (list breapth width depth height))
629 (string-append "(" s ") show "))
632 (define (volta h w thick vert_start vert_end)
634 (numbers->string (list h w thick (inexact->exact vert_start) (inexact->exact vert_end)))
637 (define (tuplet ht gap dx dy thick dir)
639 (numbers->string (list ht gap dx dy thick (inexact->exact dir)))
648 (cond ((eq? action-name 'all-definitions)
651 (define tuplet ,tuplet)
652 (define bracket ,bracket)
654 (define crescendo ,crescendo)
655 (define volta ,volta)
656 (define bezier-sandwich ,bezier-sandwich)
657 (define dashed-line ,dashed-line)
658 (define dashed-slur ,dashed-slur)
659 (define decrescendo ,decrescendo)
660 (define end-output ,end-output)
661 (define experimental-on ,experimental-on)
662 (define filledbox ,filledbox)
663 (define font-def ,font-def)
664 (define font-switch ,font-switch)
665 (define header-end ,header-end)
666 (define lily-def ,lily-def)
667 (define font-load-command ,font-load-command)
668 (define header ,header)
669 (define invoke-char ,invoke-char)
670 (define invoke-dim1 ,invoke-dim1)
671 (define placebox ,placebox)
672 (define select-font ,select-font)
673 (define start-line ,start-line)
675 (define stop-line ,stop-line)
676 (define stop-last-line ,stop-line)
679 ((eq? action-name 'tuplet) tuplet)
680 ((eq? action-name 'beam) beam)
681 ((eq? action-name 'bezier-sandwich) bezier-sandwich)
682 ((eq? action-name 'bracket) bracket)
683 ((eq? action-name 'char) char)
684 ((eq? action-name 'crescendo) crescendo)
685 ((eq? action-name 'dashed-line) dashed-line)
686 ((eq? action-name 'dashed-slur) dashed-slur)
687 ((eq? action-name 'decrescendo) decrescendo)
688 ((eq? action-name 'experimental-on) experimental-on)
689 ((eq? action-name 'filledbox) filledbox)
690 ((eq? action-name 'select-font) select-font)
691 ((eq? action-name 'volta) volta)
692 (else (error "unknown tag -- PS-SCM " action-name))
697 (define (arg->string arg)
698 (cond ((number? arg) (inexact->string arg 10))
699 ((string? arg) (string-append "\"" arg "\""))
700 ((symbol? arg) (string-append "\"" (symbol->string arg) "\""))))
702 (define (func name . args)
708 (map (lambda (x) (string-append " " (arg->string x))) args)))
714 (inexact->exact (/ x (abs x)))))
717 (define (as-scm action-name)
719 (define (beam width slope thick)
721 (func "set-line-char" "#")
722 (func "rline-to" width (* width slope))
726 (define (bezier-sandwich l thick)
733 (dy (- (cdr c3) (cdr c0)))
735 (c1-dx (- (car c1) x))
736 (c1-line-y (+ (cdr c0) (* c1-dx rc)))
737 (dir (if (< c1-line-y (cdr c1)) 1 -1))
738 (y (+ -1 (* dir (max (* dir (cdr c0)) (* dir (cdr c3)))))))
740 (func "rmove-to" x y)
741 (func "put" (if (< 0 dir) "/" "\\\\"))
742 (func "rmove-to" 1 (if (< 0 dir) 1 0))
743 (func "set-line-char" "_")
744 (func "h-line" (- dx 1))
745 (func "rmove-to" (- dx 1) (if (< 0 dir) -1 0))
746 (func "put" (if (< 0 dir) "\\\\" "/"))))))
748 (define (bracket arch_angle arch_width arch_height width height arch_thick thick)
750 (func "rmove-to" (+ width 1) (- (/ height -2) 1))
752 (func "set-line-char" "|")
753 (func "rmove-to" 0 1)
754 (func "v-line" (+ height 1))
755 (func "rmove-to" 0 (+ height 1))
765 (define (experimental-on)
768 (define (filledbox breapth width depth height)
769 (let ((dx (+ width breapth))
770 (dy (+ depth height)))
772 (func "rmove-to" (* -1 breapth) (* -1 depth))
775 (func "set-line-char"
776 (if (<= dx 1) "|" "#"))
779 (func "set-line-char"
780 (if (<= dy 1) "-" "="))
781 (func "h-line" dx))))))
783 (define (font-load-command name-mag command)
784 (func "load-font" (car name-mag) (magstep (cdr name-mag))))
786 (define (header creator generate)
787 (func "header" creator generate))
792 ;; urg: this is good for half of as2text's execution time
793 (define (xlily-def key val)
794 (string-append "(define " key " " (arg->string val) ")\n"))
796 (define (lily-def key val)
798 (or (equal? key "mudelapaperlinewidth")
799 (equal? key "mudelapaperstaffheight"))
800 (string-append "(define " key " " (arg->string val) ")\n")
803 (define (placebox x y s)
804 (let ((ey (inexact->exact y)))
805 (string-append "(move-to " (number->string (inexact->exact x)) " "
806 (if (= 0.5 (- (abs y) (abs ey)))
811 (define (select-font font-name-symbol)
812 (let* ((c (assoc font-name-symbol font-name-alist)))
817 "Programming error: No such font known "
818 (car font-name-symbol)))
819 "") ; issue no command
820 (func "select-font" (car font-name-symbol)))))
822 (define (start-line height)
823 (func "start-line" height))
831 (define (volta h w thick vert-start vert-end)
834 (func "set-line-char" "|")
835 (func "rmove-to" 0 -4)
836 ;; definition strange-way around
840 (func "rmove-to" 1 h)
841 (func "set-line-char" "_")
842 (func "h-line" (- w 1))
843 (func "set-line-char" "|")
846 (func "rmove-to" (- w 1) (* -1 h))
847 (func "v-line" (* -1 h)))
850 (cond ((eq? action-name 'all-definitions)
853 (define bracket ,bracket)
855 ;;(define crescendo ,crescendo)
856 (define bezier-sandwich ,bezier-sandwich)
857 ;;(define dashed-slur ,dashed-slur)
858 ;;(define decrescendo ,decrescendo)
859 (define end-output ,end-output)
860 (define experimental-on ,experimental-on)
861 (define filledbox ,filledbox)
862 ;;(define font-def ,font-def)
863 (define font-load-command ,font-load-command)
864 ;;(define font-switch ,font-switch)
865 (define header ,header)
866 (define header-end ,header-end)
867 (define lily-def ,lily-def)
868 ;;(define invoke-char ,invoke-char)
869 ;;(define invoke-dim1 ,invoke-dim1)
870 (define placebox ,placebox)
871 (define select-font ,select-font)
872 (define start-line ,start-line)
873 ;;(define stem ,stem)
874 (define stop-line ,stop-line)
875 (define stop-last-line ,stop-line)
877 ;;(define tuplet ,tuplet)
878 (define volta ,volta)
880 ;;((eq? action-name 'tuplet) tuplet)
881 ;;((eq? action-name 'beam) beam)
882 ;;((eq? action-name 'bezier-sandwich) bezier-sandwich)
883 ;;((eq? action-name 'bracket) bracket)
884 ((eq? action-name 'char) char)
885 ;;((eq? action-name 'crescendo) crescendo)
886 ;;((eq? action-name 'dashed-slur) dashed-slur)
887 ;;((eq? action-name 'decrescendo) decrescendo)
888 ;;((eq? action-name 'experimental-on) experimental-on)
889 ((eq? action-name 'filledbox) filledbox)
890 ((eq? action-name 'select-font) select-font)
891 ;;((eq? action-name 'volta) volta)
892 (else (error "unknown tag -- MUSA-SCM " action-name))
897 (define (gulp-file name)
898 (let* ((port (open-file name "r"))
899 (content (let loop ((text ""))
900 (let ((line (read-line port)))
901 (if (or (eof-object? line)
904 (loop (string-append text line "\n")))))))
908 ;; urg: Use when standalone, do:
909 ;; (define (ly-gulp-file name) (scm-gulp-file name))
910 (define (scm-gulp-file name)
912 (cons (string-append (getenv 'LILYPONDPREFIX) "/ly")
913 (cons (string-append (getenv 'LILYPONDPREFIX) "/ps")
915 (let ((path (%search-load-path name)))
920 (define (scm-tex-output)
921 (eval (tex-scm 'all-definitions)))
923 (define (scm-ps-output)
924 (eval (ps-scm 'all-definitions)))
926 (define (scm-as-output)
927 (eval (as-scm 'all-definitions)))
929 ; Russ McManus, <mcmanus@IDT.NET>
931 ; I use the following, which should definitely be provided somewhere
932 ; in guile, but isn't, AFAIK:
936 (define (hash-table-for-each fn ht)
938 ((= i (vector-length ht)))
939 (do ((alist (vector-ref ht i) (cdr alist)))
941 (fn (car (car alist)) (cdr (car alist))))))
943 (define (hash-table-map fn ht)
946 ((= i (vector-length ht)) (reverse ret-ls))
947 (do ((alist (vector-ref ht i) (cdr alist)))
949 (set! ret-ls (cons (fn (car (car alist)) (cdr (car alist))) ret-ls)))))
953 (define (index-cell cell dir)
959 ; How should a bar line behave at a break?
961 (define (break-barline glyph dir)
962 (let ((result (assoc glyph
963 '((":|:" . (":|" . "|:"))
966 ("|:" . ("|" . "|:"))
967 ("|." . ("|." . nil))
968 (":|" . (":|" . nil))
969 ("||" . ("||" . nil))
970 (".|." . (".|." . nil))
971 ("scorebar" . (nil . "scorepostbreak"))
972 ("brace" . (nil . "brace"))
973 ("bracket" . (nil . "bracket"))
977 (if (equal? result #f)
978 (ly-warn (string-append "Unknown bar glyph: `" glyph "'"))
979 (index-cell (cdr result) dir))
984 (define (slur-ugly ind ht)
989 (> ht (+ (* 2 ind) -4))
990 (< ht (+ (* -2 ind) 8)))