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))
21 (not (string-match ".*windows.*" (string-downcase (vector-ref (uname) 0)))))
23 ;; do nothing in .scm output
24 (define (comment s) "")
30 (define (cons-map f x)
31 (cons (f (car x)) (f (cdr x))))
33 (define (reduce operator list)
34 (if (null? (cdr list)) (car list)
35 (operator (car list) (reduce operator (cdr list)))
40 (define (numbers->string l)
41 (apply string-append (map ly-number->string l)))
43 ; (define (chop-decimal x) (if (< (abs x) 0.001) 0.0 x))
45 (define (number->octal-string x)
46 (let* ((n (inexact->exact x))
48 (n8 (quotient (- n (* n64 64)) 8)))
52 (number->string (remainder (- n (+ (* n64 64) (* n8 8))) 8)))))
54 (define (inexact->string x radix)
55 (let ((n (inexact->exact x)))
56 (number->string n radix)))
59 (define (control->string c)
60 (string-append (number->string (car c)) " "
61 (number->string (cdr c)) " "))
67 (make-string 1 (integer->char (+ (char->integer #\A) i)))
72 (define (scm-scm action-name)
75 (define security-paranoia #f)
78 ;; See documentation of Item::visibility_lambda_
79 (define (begin-of-line-visible d) (if (= d 1) '(#f . #f) '(#t . #t)))
80 (define (spanbar-begin-of-line-invisible d) (if (= d -1) '(#t . #t) '(#f . #f)))
81 (define (all-visible d) '(#f . #f))
82 (define (begin-of-line-invisible d) (if (= d 1) '(#t . #t) '(#f . #f)))
83 (define (end-of-line-invisible d) (if (= d -1) '(#t . #t) '(#f . #f)))
86 ;; Score_span_bars are only visible at start of line
87 ;; i.e. if break_dir == RIGHT == 1
88 (define Span_bar_engraver-visibility begin-of-line-invisible)
89 (define Base_span_bar_engraver-visibility begin-of-line-invisible)
90 (define mark-visibility end-of-line-invisible)
91 (define Span_score_bar_engraver-visibility begin-of-line-visible)
92 (define Piano_bar_engraver-visibility begin-of-line-visible)
93 (define Staff_group_bar_engraver-visibility begin-of-line-visible)
95 ;; Spacing constants for prefatory matter.
97 ;; rules for this spacing are much more complicated than this. See [Wanske] page 126 -- 134, [Ross] pg 143 -- 147
101 ;; (Measured in staff space)
104 (("" "Left_edge_item") . (extra-space -15.0))
105 (("" "Clef_item") . (minimum-space 1.0))
106 (("" "Staff_bar") . (minimum-space 0.0))
107 (("" "Clef_item") . (minimum-space 1.0))
108 (("" "Key_item") . (minimum-space 0.5))
109 (("" "Span_bar") . (extra-space 0.0))
110 (("" "Time_signature") . (extra-space 0.0))
111 (("" "begin-of-note") . (minimum-space 1.5))
112 (("Clef_item" "Key_item") . (minimum-space 4.0))
113 (("Key_item" "Time_signature") . (extra-space 1.0))
114 (("Clef_item" "Time_signature") . (minimum-space 3.5))
115 (("Staff_bar" "Clef_item") . (minimum-space 1.0))
116 (("Clef_item" "Staff_bar") . (minimum-space 3.7))
117 (("Time_signature" "Staff_bar") . (minimum-space 2.0))
118 (("Key_item" "Staff_bar") . (extra-space 1.0))
119 (("Span_bar" "Clef_item") . (extra-space 1.0))
120 (("Clef_item" "Span_bar") . (minimum-space 3.7))
121 (("Time_signature" "Span_bar") . (minimum-space 2.0))
122 (("Key_item" "Span_bar") . (minimum-space 2.5))
123 (("Staff_bar" "Time_signature") . (minimum-space 1.5)) ;double check this.
124 (("Time_signature" "begin-of-note") . (extra-space 2.0)) ;double check this.
125 (("Key_item" "begin-of-note") . (extra-space 2.5))
126 (("Staff_bar" "begin-of-note") . (extra-space 1.0))
127 (("Clef_item" "begin-of-note") . (minimum-space 5.0))
128 (("" "Breathing_sign") . (minimum-space 0.0))
129 (("Breathing_sign" "Key_item") . (minimum-space 1.5))
130 (("Breathing_sign" "begin-of-note") . (minimum-space 1.0))
131 (("Breathing_sign" "Staff_bar") . (minimum-space 1.5))
132 (("Breathing_sign" "Clef_item") . (minimum-space 2.0))
136 (define (break-align-spacer this next)
137 (let ((entry (assoc `(,this ,next) space-alist)))
140 (begin (ly-warn (string-append "Unknown spacing pair `" this "', `" next "'"))
141 '(minimum-space 0.0)))))
147 ;; this is silly, can't we use something like
148 ;; roman-0, roman-1 roman+1 ?
151 ("brace" . "feta-braces")
152 ("default" . "cmr10")
153 ("dynamic" . "feta-din")
157 ("finger" . "feta-nummer")
158 ("typewriter" . "cmtt")
164 ("mark" . "feta-nummer")
165 ("number" . "feta-nummer")
166 ("volta" . "feta-nummer"))
169 (define (string-encode-integer i)
172 ((< i 0) (string-append "n" (string-encode-integer (- i))))
174 (make-string 1 (integer->char (+ 65 (modulo i 26))))
175 (string-encode-integer (quotient i 26))
182 (cdr (assoc i '((-4 . 482)
195 (define script-alist '())
196 (define (articulation-to-scriptdef a)
197 (assoc a script-alist)
200 ;; Map style names to TeX font names. Return false if
201 ;; no font name found.
202 (define (style-to-cmr s)
208 (define font-name-alist '())
209 (define (font-command name-mag)
211 (string-append "magfont"
212 (string-encode-integer (hashq (car name-mag) 1000000))
214 (string-encode-integer (cdr name-mag)))
218 (define (define-fonts names)
219 (set! font-name-alist (map font-command names))
222 (font-load-command (car x) (cdr x))) font-name-alist)
225 (define (fontify name exp)
226 (string-append (select-font name)
233 ; Make a function that checks score element for being of a specific type.
234 (define (make-type-checker name)
236 (not (not (memq name (ly-get-elt-property elt 'interfaces))))))
239 ;;;;;;;;;;;;;;;;;;; TeX output
240 (define (tex-scm action-name)
245 (define (select-font font-name-symbol)
248 (c (assoc font-name-symbol font-name-alist))
253 (ly-warn (string-append
254 "Programming error: No such font known " (car font-name-symbol)))
255 "") ; issue no command
256 (string-append "\\" (cdr c)))
261 (define (beam width slope thick)
262 (embedded-ps ((ps-scm 'beam) width slope thick)))
264 (define (bracket arch_angle arch_width arch_height width height arch_thick thick)
265 (embedded-ps ((ps-scm 'bracket) arch_angle arch_width arch_height width height arch_thick thick)))
267 (define (dashed-slur thick dash l)
268 (embedded-ps ((ps-scm 'dashed-slur) thick dash l)))
270 (define (crescendo thick w h cont)
271 (embedded-ps ((ps-scm 'crescendo) thick w h cont)))
274 (string-append "\\char" (inexact->string i 10) " "))
276 (define (dashed-line thick dash w)
277 (embedded-ps ((ps-scm 'dashed-line) thick dash w)))
279 (define (decrescendo thick w h cont)
280 (embedded-ps ((ps-scm 'decrescendo) thick w h cont)))
282 (define (font-load-command name-mag command)
284 "\\font\\" command "="
285 (symbol->string (car name-mag))
287 (number->string (magstep (cdr name-mag)))
290 (define (embedded-ps s)
291 (string-append "\\embeddedps{" s "}"))
294 (string-append "% " s))
297 "\n\\EndLilyPondOutput")
299 (define (experimental-on)
302 (define (font-switch i)
306 (define (font-def i s)
308 "\\font" (font-switch i) "=" s "\n"))
314 ;; URG: ly-gulp-file: now we can't use scm output without Lily
316 ;; fixed in 1.3.4 for powerpc -- broken on Windows
317 (regexp-substitute/global #f "\n"
318 (ly-gulp-file "lily.ps") 'pre " %\n" 'post)
319 (ly-gulp-file "lily.ps"))
321 "\\input lilyponddefs \\turnOnPostScript"))
323 (define (header creator generate)
325 "%created by: " creator generate "\n"))
327 (define (invoke-char s i)
329 "\n\\" s "{" (inexact->string i 10) "}" ))
331 (define (invoke-dim1 s d)
333 "\n\\" s "{" (number->dim d) "}"))
338 ;; need to do something to make this really safe.
340 (define (output-tex-string s)
341 (if security-paranoia
343 (regexp-substitute/global #f "\\\\" s 'pre "$\\backslash$" 'post)
344 (begin (display "warning: not paranoid") (newline) s))
347 (define (lily-def key val)
351 ;; fixed in 1.3.4 for powerpc -- broken on Windows
352 (regexp-substitute/global #f "_"
353 (output-tex-string key) 'pre "X" 'post)
354 (output-tex-string key))
355 "{" (output-tex-string val) "}\n"))
357 (define (number->dim x)
359 (ly-number->string x) " pt "))
361 (define (placebox x y s)
364 (number->dim y) "}{" (number->dim x) "}{" s "}\n"))
366 (define (bezier-sandwich l thick)
367 (embedded-ps ((ps-scm 'bezier-sandwich) l thick)))
369 (define (start-line ht)
370 (string-append"\\vbox to " (number->dim ht) "{\\hbox{%\n"))
373 "}\\vss}\\interscoreline")
374 (define (stop-last-line)
376 (define (filledbox breapth width depth height)
378 "\\kern" (number->dim (- breapth))
379 "\\vrule width " (number->dim (+ breapth width))
380 "depth " (number->dim depth)
381 "height " (number->dim height) " "))
384 (string-append "\\hbox{" (output-tex-string s) "}"))
386 (define (tuplet ht gapx dx dy thick dir)
387 (embedded-ps ((ps-scm 'tuplet) ht gapx dx dy thick dir)))
389 (define (volta h w thick vert_start vert_end)
390 (embedded-ps ((ps-scm 'volta) h w thick vert_start vert_end)))
393 ;; The procedures listed below form the public interface of TeX-scm.
394 ;; (should merge the 2 lists)
395 (cond ((eq? action-name 'all-definitions)
397 (define font-load-command ,font-load-command)
399 (define bezier-sandwich ,bezier-sandwich)
400 (define bracket ,bracket)
402 (define crescendo ,crescendo)
403 (define dashed-line ,dashed-line)
404 (define dashed-slur ,dashed-slur)
405 (define decrescendo ,decrescendo)
406 (define end-output ,end-output)
407 (define experimental-on ,experimental-on)
408 (define filledbox ,filledbox)
409 (define font-def ,font-def)
410 (define font-switch ,font-switch)
411 (define header-end ,header-end)
412 (define lily-def ,lily-def)
413 (define header ,header)
414 (define invoke-char ,invoke-char)
415 (define invoke-dim1 ,invoke-dim1)
416 (define placebox ,placebox)
417 (define select-font ,select-font)
418 (define start-line ,start-line)
419 (define stop-line ,stop-line)
420 (define stop-last-line ,stop-last-line)
422 (define tuplet ,tuplet)
423 (define volta ,volta)
426 ((eq? action-name 'beam) beam)
427 ((eq? action-name 'tuplet) tuplet)
428 ((eq? action-name 'bracket) bracket)
429 ((eq? action-name 'crescendo) crescendo)
430 ((eq? action-name 'dashed-line) dashed-line)
431 ((eq? action-name 'dashed-slur) dashed-slur)
432 ((eq? action-name 'decrescendo) decrescendo)
433 ((eq? action-name 'end-output) end-output)
434 ((eq? action-name 'experimental-on) experimental-on)
435 ((eq? action-name 'font-def) font-def)
436 ((eq? action-name 'font-switch) font-switch)
437 ((eq? action-name 'header-end) header-end)
438 ((eq? action-name 'lily-def) lily-def)
439 ((eq? action-name 'header) header)
440 ((eq? action-name 'invoke-char) invoke-char)
441 ((eq? action-name 'invoke-dim1) invoke-dim1)
442 ((eq? action-name 'placebox) placebox)
443 ((eq? action-name 'bezier-sandwich) bezier-sandwich)
444 ((eq? action-name 'start-line) start-line)
445 ((eq? action-name 'stem) stem)
446 ((eq? action-name 'stop-line) stop-line)
447 ((eq? action-name 'stop-last-line) stop-last-line)
448 ((eq? action-name 'volta) volta)
449 (else (error "unknown tag -- PS-TEX " action-name))
455 (define (ps-scm action-name)
457 ;; alist containing fontname -> fontcommand assoc (both strings)
458 (define font-alist '())
459 (define font-count 0)
460 (define current-font "")
463 (define (cached-fontname i)
466 (make-string 1 (integer->char (+ 65 i)))))
468 (define (mag-to-size m)
469 (number->string (case m
472 (2 14) ; really: 14.400
473 (3 17) ; really: 17.280
474 (4 21) ; really: 20.736
475 (5 24) ; really: 24.888
476 (6 30) ; really: 29.856
480 (define (select-font font-name-symbol)
483 (c (assoc font-name-symbol font-name-alist))
488 (ly-warn (string-append
489 "Programming error: No such font known " (car font-name-symbol)))
490 "") ; issue no command
491 (string-append " " (cdr c) " "))
496 (define (font-load-command name-mag command)
500 (symbol->string (car name-mag))
502 (number->string (magstep (cdr name-mag)))
503 " 1000 div 12 mul scalefont setfont } bind def "
507 (define (beam width slope thick)
509 (numbers->string (list width slope thick)) " draw_beam" ))
512 (string-append "% " s))
514 (define (bracket arch_angle arch_width arch_height width height arch_thick thick)
516 (numbers->string (list arch_angle arch_width arch_height width height arch_thick thick)) " draw_bracket" ))
519 (invoke-char " show" i))
521 (define (crescendo thick w h cont )
523 (numbers->string (list w h (inexact->exact cont) thick))
526 ;; what the heck is this interface ?
527 (define (dashed-slur thick dash l)
529 (apply string-append (map control->string l))
530 (number->string thick)
532 (number->string dash)
534 (number->string (* 10 thick)) ;UGH. 10 ?
535 " ] 0 draw_dashed_slur"))
537 (define (dashed-line thick dash width)
539 (number->string width)
541 (number->string thick)
543 (number->string dash)
545 (number->string dash)
546 " ] 0 draw_dashed_line"))
548 (define (decrescendo thick w h cont)
550 (numbers->string (list w h (inexact->exact cont) thick))
551 " draw_decrescendo"))
557 (define (experimental-on) "")
559 (define (filledbox breapth width depth height)
560 (string-append (numbers->string (list breapth width depth height))
564 (define (font-def i s)
567 (substring s 0 (- (string-length s) 4))
568 " findfont 12 scalefont setfont} bind def \n"))
570 (define (font-switch i)
571 (string-append (font i) " "))
575 ;; URG: now we can't use scm output without Lily
576 (ly-gulp-file "lilyponddefs.ps")
577 " {exch pop //systemdict /run get exec} "
578 (ly-gulp-file "lily.ps")
579 "{ exch pop //systemdict /run get exec } "
582 (define (lily-def key val)
584 (if (string=? (substring key 0 (min (string-length "mudelapaper") (string-length key))) "mudelapaper")
585 (string-append "/" key " {" val "} bind def\n")
586 (string-append "/" key " (" val ") def\n")
590 (define (header creator generate)
593 "%%Creator: " creator generate "\n"))
595 (define (invoke-char s i)
597 "(\\" (inexact->string i 8) ") " s " " ))
599 (define (invoke-dim1 s d)
601 (number->string (* d (/ 72.27 72))) " " s ))
603 (define (placebox x y s)
605 (number->string x) " " (number->string y) " {" s "} placebox "))
607 (define (bezier-sandwich l thick)
609 (apply string-append (map control->string l))
610 (number->string thick)
611 " draw_bezier_sandwich"))
613 (define (start-line height)
616 (define (stem breapth width depth height)
617 (string-append (numbers->string (list breapth width depth height))
624 (string-append "(" s ") show "))
627 (define (volta h w thick vert_start vert_end)
629 (numbers->string (list h w thick (inexact->exact vert_start) (inexact->exact vert_end)))
632 (define (tuplet ht gap dx dy thick dir)
634 (numbers->string (list ht gap dx dy thick (inexact->exact dir)))
643 (cond ((eq? action-name 'all-definitions)
646 (define tuplet ,tuplet)
647 (define bracket ,bracket)
649 (define crescendo ,crescendo)
650 (define volta ,volta)
651 (define bezier-sandwich ,bezier-sandwich)
652 (define dashed-line ,dashed-line)
653 (define dashed-slur ,dashed-slur)
654 (define decrescendo ,decrescendo)
655 (define end-output ,end-output)
656 (define experimental-on ,experimental-on)
657 (define filledbox ,filledbox)
658 (define font-def ,font-def)
659 (define font-switch ,font-switch)
660 (define header-end ,header-end)
661 (define lily-def ,lily-def)
662 (define font-load-command ,font-load-command)
663 (define header ,header)
664 (define invoke-char ,invoke-char)
665 (define invoke-dim1 ,invoke-dim1)
666 (define placebox ,placebox)
667 (define select-font ,select-font)
668 (define start-line ,start-line)
670 (define stop-line ,stop-line)
671 (define stop-last-line ,stop-line)
674 ((eq? action-name 'tuplet) tuplet)
675 ((eq? action-name 'beam) beam)
676 ((eq? action-name 'bezier-sandwich) bezier-sandwich)
677 ((eq? action-name 'bracket) bracket)
678 ((eq? action-name 'char) char)
679 ((eq? action-name 'crescendo) crescendo)
680 ((eq? action-name 'dashed-line) dashed-line)
681 ((eq? action-name 'dashed-slur) dashed-slur)
682 ((eq? action-name 'decrescendo) decrescendo)
683 ((eq? action-name 'experimental-on) experimental-on)
684 ((eq? action-name 'filledbox) filledbox)
685 ((eq? action-name 'select-font) select-font)
686 ((eq? action-name 'volta) volta)
687 (else (error "unknown tag -- PS-SCM " action-name))
692 (define (arg->string arg)
693 (cond ((number? arg) (inexact->string arg 10))
694 ((string? arg) (string-append "\"" arg "\""))
695 ((symbol? arg) (string-append "\"" (symbol->string arg) "\""))))
697 (define (func name . args)
703 (map (lambda (x) (string-append " " (arg->string x))) args)))
709 (inexact->exact (/ x (abs x)))))
712 (define (as-scm action-name)
714 (define (beam width slope thick)
716 (func "set-line-char" "#")
717 (func "rline-to" width (* width slope))
721 (define (bezier-sandwich l thick)
728 (dy (- (cdr c3) (cdr c0)))
730 (c1-dx (- (car c1) x))
731 (c1-line-y (+ (cdr c0) (* c1-dx rc)))
732 (dir (if (< c1-line-y (cdr c1)) 1 -1))
733 (y (+ -1 (* dir (max (* dir (cdr c0)) (* dir (cdr c3)))))))
735 (func "rmove-to" x y)
736 (func "put" (if (< 0 dir) "/" "\\\\"))
737 (func "rmove-to" 1 (if (< 0 dir) 1 0))
738 (func "set-line-char" "_")
739 (func "h-line" (- dx 1))
740 (func "rmove-to" (- dx 1) (if (< 0 dir) -1 0))
741 (func "put" (if (< 0 dir) "\\\\" "/"))))))
743 (define (bracket arch_angle arch_width arch_height width height arch_thick thick)
745 (func "rmove-to" (+ width 1) (- (/ height -2) 1))
747 (func "set-line-char" "|")
748 (func "rmove-to" 0 1)
749 (func "v-line" (+ height 1))
750 (func "rmove-to" 0 (+ height 1))
760 (define (experimental-on)
763 (define (filledbox breapth width depth height)
764 (let ((dx (+ width breapth))
765 (dy (+ depth height)))
767 (func "rmove-to" (* -1 breapth) (* -1 depth))
770 (func "set-line-char"
771 (if (<= dx 1) "|" "#"))
774 (func "set-line-char"
775 (if (<= dy 1) "-" "="))
776 (func "h-line" dx))))))
778 (define (font-load-command name-mag command)
779 (func "load-font" (car name-mag) (magstep (cdr name-mag))))
781 (define (header creator generate)
782 (func "header" creator generate))
787 ;; urg: this is good for half of as2text's execution time
788 (define (xlily-def key val)
789 (string-append "(define " key " " (arg->string val) ")\n"))
791 (define (lily-def key val)
793 (or (equal? key "mudelapaperlinewidth")
794 (equal? key "mudelapaperstaffheight"))
795 (string-append "(define " key " " (arg->string val) ")\n")
798 (define (placebox x y s)
799 (let ((ey (inexact->exact y)))
800 (string-append "(move-to " (number->string (inexact->exact x)) " "
801 (if (= 0.5 (- (abs y) (abs ey)))
806 (define (select-font font-name-symbol)
807 (let* ((c (assoc font-name-symbol font-name-alist)))
812 "Programming error: No such font known "
813 (car font-name-symbol)))
814 "") ; issue no command
815 (func "select-font" (car font-name-symbol)))))
817 (define (start-line height)
818 (func "start-line" height))
826 (define (volta h w thick vert-start vert-end)
829 (func "set-line-char" "|")
830 (func "rmove-to" 0 -4)
831 ;; definition strange-way around
835 (func "rmove-to" 1 h)
836 (func "set-line-char" "_")
837 (func "h-line" (- w 1))
838 (func "set-line-char" "|")
841 (func "rmove-to" (- w 1) (* -1 h))
842 (func "v-line" (* -1 h)))
845 (cond ((eq? action-name 'all-definitions)
848 (define bracket ,bracket)
850 ;;(define crescendo ,crescendo)
851 (define bezier-sandwich ,bezier-sandwich)
852 ;;(define dashed-slur ,dashed-slur)
853 ;;(define decrescendo ,decrescendo)
854 (define end-output ,end-output)
855 (define experimental-on ,experimental-on)
856 (define filledbox ,filledbox)
857 ;;(define font-def ,font-def)
858 (define font-load-command ,font-load-command)
859 ;;(define font-switch ,font-switch)
860 (define header ,header)
861 (define header-end ,header-end)
862 (define lily-def ,lily-def)
863 ;;(define invoke-char ,invoke-char)
864 ;;(define invoke-dim1 ,invoke-dim1)
865 (define placebox ,placebox)
866 (define select-font ,select-font)
867 (define start-line ,start-line)
868 ;;(define stem ,stem)
869 (define stop-line ,stop-line)
870 (define stop-last-line ,stop-line)
872 ;;(define tuplet ,tuplet)
873 (define volta ,volta)
875 ;;((eq? action-name 'tuplet) tuplet)
876 ;;((eq? action-name 'beam) beam)
877 ;;((eq? action-name 'bezier-sandwich) bezier-sandwich)
878 ;;((eq? action-name 'bracket) bracket)
879 ((eq? action-name 'char) char)
880 ;;((eq? action-name 'crescendo) crescendo)
881 ;;((eq? action-name 'dashed-slur) dashed-slur)
882 ;;((eq? action-name 'decrescendo) decrescendo)
883 ;;((eq? action-name 'experimental-on) experimental-on)
884 ((eq? action-name 'filledbox) filledbox)
885 ((eq? action-name 'select-font) select-font)
886 ;;((eq? action-name 'volta) volta)
887 (else (error "unknown tag -- MUSA-SCM " action-name))
892 (define (gulp-file name)
893 (let* ((port (open-file name "r"))
894 (content (let loop ((text ""))
895 (let ((line (read-line port)))
896 (if (or (eof-object? line)
899 (loop (string-append text line "\n")))))))
903 ;; urg: Use when standalone, do:
904 ;; (define (ly-gulp-file name) (scm-gulp-file name))
905 (define (scm-gulp-file name)
907 (cons (string-append (getenv 'LILYPONDPREFIX) "/ly")
908 (cons (string-append (getenv 'LILYPONDPREFIX) "/ps")
910 (let ((path (%search-load-path name)))
915 (define (scm-tex-output)
916 (eval (tex-scm 'all-definitions)))
918 (define (scm-ps-output)
919 (eval (ps-scm 'all-definitions)))
921 (define (scm-as-output)
922 (eval (as-scm 'all-definitions)))
924 ; Russ McManus, <mcmanus@IDT.NET>
926 ; I use the following, which should definitely be provided somewhere
927 ; in guile, but isn't, AFAIK:
931 (define (hash-table-for-each fn ht)
933 ((= i (vector-length ht)))
934 (do ((alist (vector-ref ht i) (cdr alist)))
936 (fn (car (car alist)) (cdr (car alist))))))
938 (define (hash-table-map fn ht)
941 ((= i (vector-length ht)) (reverse ret-ls))
942 (do ((alist (vector-ref ht i) (cdr alist)))
944 (set! ret-ls (cons (fn (car (car alist)) (cdr (car alist))) ret-ls)))))
948 (define (index-cell cell dir)
954 ; How should a bar line behave at a break?
956 (define (break-barline glyph dir)
957 (let ((result (assoc glyph
958 '((":|:" . (":|" . "|:"))
961 ("|:" . ("|" . "|:"))
962 ("|." . ("|." . nil))
963 (":|" . (":|" . nil))
964 ("||" . ("||" . nil))
965 (".|." . (".|." . nil))
966 ("scorebar" . (nil . "scorepostbreak"))
967 ("brace" . (nil . "brace"))
968 ("bracket" . (nil . "bracket"))
972 (if (equal? result #f)
973 (ly-warn (string-append "Unknown bar glyph: `" glyph "'"))
974 (index-cell (cdr result) dir))
979 (define (slur-ugly ind ht)
984 (> ht (+ (* 2 ind) -4))
985 (< ht (+ (* -2 ind) 8)))