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
23 ;;(define use-regex #f)
25 ;; (not (equal? "Windows" (substring (vector-ref (uname) 0) 0 7))))
27 ;; do nothing in .scm output
28 (define (comment s) "")
34 (define (cons-map f x)
35 (cons (f (car x)) (f (cdr x))))
37 (define (reduce operator list)
38 (if (null? (cdr list)) (car list)
39 (operator (car list) (reduce operator (cdr list)))
44 (define (numbers->string l)
45 (apply string-append (map ly-number->string l)))
47 ; (define (chop-decimal x) (if (< (abs x) 0.001) 0.0 x))
49 (define (number->octal-string x)
50 (let* ((n (inexact->exact x))
52 (n8 (quotient (- n (* n64 64)) 8)))
56 (number->string (remainder (- n (+ (* n64 64) (* n8 8))) 8)))))
58 (define (inexact->string x radix)
59 (let ((n (inexact->exact x)))
60 (number->string n radix)))
63 (define (control->string c)
64 (string-append (number->string (car c)) " "
65 (number->string (cdr c)) " "))
71 (make-string 1 (integer->char (+ (char->integer #\A) i)))
76 (define (scm-scm action-name)
79 (define security-paranoia #f)
82 ;; See documentation of Item::visibility_lambda_
83 (define (begin-of-line-visible d) (if (= d 1) '(#f . #f) '(#t . #t)))
84 (define (spanbar-begin-of-line-invisible d) (if (= d -1) '(#t . #t) '(#f . #f)))
85 (define (all-visible d) '(#f . #f))
86 (define (begin-of-line-invisible d) (if (= d 1) '(#t . #t) '(#f . #f)))
87 (define (end-of-line-invisible d) (if (= d -1) '(#t . #t) '(#f . #f)))
90 ;; Score_span_bars are only visible at start of line
91 ;; i.e. if break_dir == RIGHT == 1
92 (define Span_bar_engraver-visibility begin-of-line-invisible)
93 (define Base_span_bar_engraver-visibility begin-of-line-invisible)
94 (define mark-visibility end-of-line-invisible)
95 (define Span_score_bar_engraver-visibility begin-of-line-visible)
96 (define Piano_bar_engraver-visibility begin-of-line-visible)
97 (define Staff_group_bar_engraver-visibility begin-of-line-visible)
99 ;; Spacing constants for prefatory matter.
101 ;; rules for this spacing are much more complicated than this. See [Wanske] page 126 -- 134, [Ross] pg 143 -- 147
105 ;; (Measured in staff space)
108 (("" "Left_edge_item") . (extra-space -15.0))
109 (("" "Clef_item") . (minimum-space 1.0))
110 (("" "Staff_bar") . (minimum-space 0.0))
111 (("" "Clef_item") . (minimum-space 1.0))
112 (("" "Key_item") . (minimum-space 0.5))
113 (("" "Span_bar") . (extra-space 0.0))
114 (("" "Time_signature") . (extra-space 0.0))
115 (("" "begin-of-note") . (minimum-space 1.5))
116 (("Clef_item" "Key_item") . (minimum-space 4.0))
117 (("Key_item" "Time_signature") . (extra-space 1.0))
118 (("Clef_item" "Time_signature") . (minimum-space 3.5))
119 (("Staff_bar" "Clef_item") . (minimum-space 1.0))
120 (("Clef_item" "Staff_bar") . (minimum-space 3.7))
121 (("Time_signature" "Staff_bar") . (minimum-space 2.0))
122 (("Key_item" "Staff_bar") . (extra-space 1.0))
123 (("Span_bar" "Clef_item") . (extra-space 1.0))
124 (("Clef_item" "Span_bar") . (minimum-space 3.7))
125 (("Time_signature" "Span_bar") . (minimum-space 2.0))
126 (("Key_item" "Span_bar") . (minimum-space 2.5))
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 (("" "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 (break-align-spacer this next)
141 (let ((entry (assoc `(,this ,next) space-alist)))
144 (begin (ly-warn (string-append "Unknown spacing pair `" this "', `" next "'"))
145 '(minimum-space 0.0)))))
151 ;; this is silly, can't we use something like
152 ;; roman-0, roman-1 roman+1 ?
155 ("brace" . "feta-braces")
156 ("default" . "cmr10")
157 ("dynamic" . "feta-din")
161 ("finger" . "feta-nummer")
162 ("typewriter" . "cmtt")
168 ("mark" . "feta-nummer")
169 ("number" . "feta-nummer")
170 ("volta" . "feta-nummer"))
173 (define (string-encode-integer i)
176 ((< i 0) (string-append "n" (string-encode-integer (- i))))
178 (make-string 1 (integer->char (+ 65 (modulo i 26))))
179 (string-encode-integer (quotient i 26))
186 (cdr (assoc i '((-4 . 482)
199 (define script-alist '())
200 (define (articulation-to-scriptdef a)
201 (assoc a script-alist)
204 ;; Map style names to TeX font names. Return false if
205 ;; no font name found.
206 (define (style-to-cmr s)
212 (define font-name-alist '())
213 (define (font-command name-mag)
215 (string-append "magfont"
216 (string-encode-integer (hashq (car name-mag) 1000000))
218 (string-encode-integer (cdr name-mag)))
222 (define (define-fonts names)
223 (set! font-name-alist (map font-command names))
226 (font-load-command (car x) (cdr x))) font-name-alist)
229 (define (fontify name exp)
230 (string-append (select-font name)
237 ; Make a function that checks score element for being of a specific type.
238 (define (make-type-checker name)
240 (not (not (memq name (ly-get-elt-property elt 'interfaces))))))
243 ;;;;;;;;;;;;;;;;;;; TeX output
244 (define (tex-scm action-name)
249 (define (select-font font-name-symbol)
252 (c (assoc font-name-symbol font-name-alist))
257 (ly-warn (string-append
258 "Programming error: No such font known " (car font-name-symbol)))
259 "") ; issue no command
260 (string-append "\\" (cdr c)))
265 (define (beam width slope thick)
266 (embedded-ps ((ps-scm 'beam) width slope thick)))
268 (define (bracket arch_angle arch_width arch_height width height arch_thick thick)
269 (embedded-ps ((ps-scm 'bracket) arch_angle arch_width arch_height width height arch_thick thick)))
271 (define (dashed-slur thick dash l)
272 (embedded-ps ((ps-scm 'dashed-slur) thick dash l)))
274 (define (crescendo thick w h cont)
275 (embedded-ps ((ps-scm 'crescendo) thick w h cont)))
278 (string-append "\\char" (inexact->string i 10) " "))
280 (define (dashed-line thick dash w)
281 (embedded-ps ((ps-scm 'dashed-line) thick dash w)))
283 (define (decrescendo thick w h cont)
284 (embedded-ps ((ps-scm 'decrescendo) thick w h cont)))
286 (define (font-load-command name-mag command)
288 "\\font\\" command "="
289 (symbol->string (car name-mag))
291 (number->string (magstep (cdr name-mag)))
294 (define (embedded-ps s)
295 (string-append "\\embeddedps{" s "}"))
298 (string-append "% " s))
301 "\n\\EndLilyPondOutput")
303 (define (experimental-on)
306 (define (font-switch i)
310 (define (font-def i s)
312 "\\font" (font-switch i) "=" s "\n"))
318 ;; URG: ly-gulp-file: now we can't use scm output without Lily
320 ;; fixed in 1.3.4 for powerpc -- broken on Windows
321 (regexp-substitute/global #f "\n"
322 (ly-gulp-file "lily.ps") 'pre " %\n" 'post)
323 (ly-gulp-file "lily.ps"))
325 "\\input lilyponddefs \\turnOnPostScript"))
327 (define (header creator generate)
329 "%created by: " creator generate "\n"))
331 (define (invoke-char s i)
333 "\n\\" s "{" (inexact->string i 10) "}" ))
335 (define (invoke-dim1 s d)
337 "\n\\" s "{" (number->dim d) "}"))
342 ;; need to do something to make this really safe.
344 (define (output-tex-string s)
345 (if security-paranoia
347 (regexp-substitute/global #f "\\\\" s 'pre "$\\backslash$" 'post)
348 (begin (display "warning: not paranoid") (newline) s))
351 (define (lily-def key val)
355 ;; fixed in 1.3.4 for powerpc -- broken on Windows
356 (regexp-substitute/global #f "_"
357 (output-tex-string key) 'pre "X" 'post)
358 (output-tex-string key))
359 "{" (output-tex-string val) "}\n"))
361 (define (number->dim x)
363 (ly-number->string x) " pt "))
365 (define (placebox x y s)
368 (number->dim y) "}{" (number->dim x) "}{" s "}\n"))
370 (define (bezier-sandwich l thick)
371 (embedded-ps ((ps-scm 'bezier-sandwich) l thick)))
373 (define (start-line ht)
374 (string-append"\\vbox to " (number->dim ht) "{\\hbox{%\n"))
377 "}\\vss}\\interscoreline")
378 (define (stop-last-line)
380 (define (filledbox breapth width depth height)
382 "\\kern" (number->dim (- breapth))
383 "\\vrule width " (number->dim (+ breapth width))
384 "depth " (number->dim depth)
385 "height " (number->dim height) " "))
388 (string-append "\\hbox{" (output-tex-string s) "}"))
390 (define (tuplet ht gapx dx dy thick dir)
391 (embedded-ps ((ps-scm 'tuplet) ht gapx dx dy thick dir)))
393 (define (volta h w thick vert_start vert_end)
394 (embedded-ps ((ps-scm 'volta) h w thick vert_start vert_end)))
397 ;; The procedures listed below form the public interface of TeX-scm.
398 ;; (should merge the 2 lists)
399 (cond ((eq? action-name 'all-definitions)
401 (define font-load-command ,font-load-command)
403 (define bezier-sandwich ,bezier-sandwich)
404 (define bracket ,bracket)
406 (define crescendo ,crescendo)
407 (define dashed-line ,dashed-line)
408 (define dashed-slur ,dashed-slur)
409 (define decrescendo ,decrescendo)
410 (define end-output ,end-output)
411 (define experimental-on ,experimental-on)
412 (define filledbox ,filledbox)
413 (define font-def ,font-def)
414 (define font-switch ,font-switch)
415 (define header-end ,header-end)
416 (define lily-def ,lily-def)
417 (define header ,header)
418 (define invoke-char ,invoke-char)
419 (define invoke-dim1 ,invoke-dim1)
420 (define placebox ,placebox)
421 (define select-font ,select-font)
422 (define start-line ,start-line)
423 (define stop-line ,stop-line)
424 (define stop-last-line ,stop-last-line)
426 (define tuplet ,tuplet)
427 (define volta ,volta)
430 ((eq? action-name 'beam) beam)
431 ((eq? action-name 'tuplet) tuplet)
432 ((eq? action-name 'bracket) bracket)
433 ((eq? action-name 'crescendo) crescendo)
434 ((eq? action-name 'dashed-line) dashed-line)
435 ((eq? action-name 'dashed-slur) dashed-slur)
436 ((eq? action-name 'decrescendo) decrescendo)
437 ((eq? action-name 'end-output) end-output)
438 ((eq? action-name 'experimental-on) experimental-on)
439 ((eq? action-name 'font-def) font-def)
440 ((eq? action-name 'font-switch) font-switch)
441 ((eq? action-name 'header-end) header-end)
442 ((eq? action-name 'lily-def) lily-def)
443 ((eq? action-name 'header) header)
444 ((eq? action-name 'invoke-char) invoke-char)
445 ((eq? action-name 'invoke-dim1) invoke-dim1)
446 ((eq? action-name 'placebox) placebox)
447 ((eq? action-name 'bezier-sandwich) bezier-sandwich)
448 ((eq? action-name 'start-line) start-line)
449 ((eq? action-name 'stem) stem)
450 ((eq? action-name 'stop-line) stop-line)
451 ((eq? action-name 'stop-last-line) stop-last-line)
452 ((eq? action-name 'volta) volta)
453 (else (error "unknown tag -- PS-TEX " action-name))
459 (define (ps-scm action-name)
461 ;; alist containing fontname -> fontcommand assoc (both strings)
462 (define font-alist '())
463 (define font-count 0)
464 (define current-font "")
467 (define (cached-fontname i)
470 (make-string 1 (integer->char (+ 65 i)))))
472 (define (mag-to-size m)
473 (number->string (case m
476 (2 14) ; really: 14.400
477 (3 17) ; really: 17.280
478 (4 21) ; really: 20.736
479 (5 24) ; really: 24.888
480 (6 30) ; really: 29.856
484 (define (select-font font-name-symbol)
487 (c (assoc font-name-symbol font-name-alist))
492 (ly-warn (string-append
493 "Programming error: No such font known " (car font-name-symbol)))
494 "") ; issue no command
495 (string-append " " (cdr c) " "))
500 (define (font-load-command name-mag command)
504 (symbol->string (car name-mag))
506 (number->string (magstep (cdr name-mag)))
507 " 1000 div 12 mul scalefont setfont } bind def "
511 (define (beam width slope thick)
513 (numbers->string (list width slope thick)) " draw_beam" ))
516 (string-append "% " s))
518 (define (bracket arch_angle arch_width arch_height width height arch_thick thick)
520 (numbers->string (list arch_angle arch_width arch_height width height arch_thick thick)) " draw_bracket" ))
523 (invoke-char " show" i))
525 (define (crescendo thick w h cont )
527 (numbers->string (list w h (inexact->exact cont) thick))
530 ;; what the heck is this interface ?
531 (define (dashed-slur thick dash l)
533 (apply string-append (map control->string l))
534 (number->string thick)
536 (number->string dash)
538 (number->string (* 10 thick)) ;UGH. 10 ?
539 " ] 0 draw_dashed_slur"))
541 (define (dashed-line thick dash width)
543 (number->string width)
545 (number->string thick)
547 (number->string dash)
549 (number->string dash)
550 " ] 0 draw_dashed_line"))
552 (define (decrescendo thick w h cont)
554 (numbers->string (list w h (inexact->exact cont) thick))
555 " draw_decrescendo"))
561 (define (experimental-on) "")
563 (define (filledbox breapth width depth height)
564 (string-append (numbers->string (list breapth width depth height))
568 (define (font-def i s)
571 (substring s 0 (- (string-length s) 4))
572 " findfont 12 scalefont setfont} bind def \n"))
574 (define (font-switch i)
575 (string-append (font i) " "))
579 ;; URG: now we can't use scm output without Lily
580 (ly-gulp-file "lilyponddefs.ps")
581 " {exch pop //systemdict /run get exec} "
582 (ly-gulp-file "lily.ps")
583 "{ exch pop //systemdict /run get exec } "
586 (define (lily-def key val)
588 (if (string=? (substring key 0 (min (string-length "mudelapaper") (string-length key))) "mudelapaper")
589 (string-append "/" key " {" val "} bind def\n")
590 (string-append "/" key " (" val ") def\n")
594 (define (header creator generate)
597 "%%Creator: " creator generate "\n"))
599 (define (invoke-char s i)
601 "(\\" (inexact->string i 8) ") " s " " ))
603 (define (invoke-dim1 s d)
605 (number->string (* d (/ 72.27 72))) " " s ))
607 (define (placebox x y s)
609 (number->string x) " " (number->string y) " {" s "} placebox "))
611 (define (bezier-sandwich l thick)
613 (apply string-append (map control->string l))
614 (number->string thick)
615 " draw_bezier_sandwich"))
617 (define (start-line height)
620 (define (stem breapth width depth height)
621 (string-append (numbers->string (list breapth width depth height))
628 (string-append "(" s ") show "))
631 (define (volta h w thick vert_start vert_end)
633 (numbers->string (list h w thick (inexact->exact vert_start) (inexact->exact vert_end)))
636 (define (tuplet ht gap dx dy thick dir)
638 (numbers->string (list ht gap dx dy thick (inexact->exact dir)))
647 (cond ((eq? action-name 'all-definitions)
650 (define tuplet ,tuplet)
651 (define bracket ,bracket)
653 (define crescendo ,crescendo)
654 (define volta ,volta)
655 (define bezier-sandwich ,bezier-sandwich)
656 (define dashed-line ,dashed-line)
657 (define dashed-slur ,dashed-slur)
658 (define decrescendo ,decrescendo)
659 (define end-output ,end-output)
660 (define experimental-on ,experimental-on)
661 (define filledbox ,filledbox)
662 (define font-def ,font-def)
663 (define font-switch ,font-switch)
664 (define header-end ,header-end)
665 (define lily-def ,lily-def)
666 (define font-load-command ,font-load-command)
667 (define header ,header)
668 (define invoke-char ,invoke-char)
669 (define invoke-dim1 ,invoke-dim1)
670 (define placebox ,placebox)
671 (define select-font ,select-font)
672 (define start-line ,start-line)
674 (define stop-line ,stop-line)
675 (define stop-last-line ,stop-line)
678 ((eq? action-name 'tuplet) tuplet)
679 ((eq? action-name 'beam) beam)
680 ((eq? action-name 'bezier-sandwich) bezier-sandwich)
681 ((eq? action-name 'bracket) bracket)
682 ((eq? action-name 'char) char)
683 ((eq? action-name 'crescendo) crescendo)
684 ((eq? action-name 'dashed-line) dashed-line)
685 ((eq? action-name 'dashed-slur) dashed-slur)
686 ((eq? action-name 'decrescendo) decrescendo)
687 ((eq? action-name 'experimental-on) experimental-on)
688 ((eq? action-name 'filledbox) filledbox)
689 ((eq? action-name 'select-font) select-font)
690 ((eq? action-name 'volta) volta)
691 (else (error "unknown tag -- PS-SCM " action-name))
696 (define (arg->string arg)
697 (cond ((number? arg) (inexact->string arg 10))
698 ((string? arg) (string-append "\"" arg "\""))
699 ((symbol? arg) (string-append "\"" (symbol->string arg) "\""))))
701 (define (func name . args)
707 (map (lambda (x) (string-append " " (arg->string x))) args)))
713 (inexact->exact (/ x (abs x)))))
716 (define (as-scm action-name)
718 (define (beam width slope thick)
720 (func "set-line-char" "#")
721 (func "rline-to" width (* width slope))
725 (define (bezier-sandwich l thick)
732 (dy (- (cdr c3) (cdr c0)))
734 (c1-dx (- (car c1) x))
735 (c1-line-y (+ (cdr c0) (* c1-dx rc)))
736 (dir (if (< c1-line-y (cdr c1)) 1 -1))
737 (y (+ -1 (* dir (max (* dir (cdr c0)) (* dir (cdr c3)))))))
739 (func "rmove-to" x y)
740 (func "put" (if (< 0 dir) "/" "\\\\"))
741 (func "rmove-to" 1 (if (< 0 dir) 1 0))
742 (func "set-line-char" "_")
743 (func "h-line" (- dx 1))
744 (func "rmove-to" (- dx 1) (if (< 0 dir) -1 0))
745 (func "put" (if (< 0 dir) "\\\\" "/"))))))
747 (define (bracket arch_angle arch_width arch_height width height arch_thick thick)
749 (func "rmove-to" (+ width 1) (- (/ height -2) 1))
751 (func "set-line-char" "|")
752 (func "rmove-to" 0 1)
753 (func "v-line" (+ height 1))
754 (func "rmove-to" 0 (+ height 1))
764 (define (experimental-on)
767 (define (filledbox breapth width depth height)
768 (let ((dx (+ width breapth))
769 (dy (+ depth height)))
771 (func "rmove-to" (* -1 breapth) (* -1 depth))
774 (func "set-line-char"
775 (if (<= dx 1) "|" "#"))
778 (func "set-line-char"
779 (if (<= dy 1) "-" "="))
780 (func "h-line" dx))))))
782 (define (font-load-command name-mag command)
783 (func "load-font" (car name-mag) (magstep (cdr name-mag))))
785 (define (header creator generate)
786 (func "header" creator generate))
791 ;; urg: this is good for half of as2text's execution time
792 (define (xlily-def key val)
793 (string-append "(define " key " " (arg->string val) ")\n"))
795 (define (lily-def key val)
797 (or (equal? key "mudelapaperlinewidth")
798 (equal? key "mudelapaperstaffheight"))
799 (string-append "(define " key " " (arg->string val) ")\n")
802 (define (placebox x y s)
803 (let ((ey (inexact->exact y)))
804 (string-append "(move-to " (number->string (inexact->exact x)) " "
805 (if (= 0.5 (- (abs y) (abs ey)))
810 (define (select-font font-name-symbol)
811 (let* ((c (assoc font-name-symbol font-name-alist)))
816 "Programming error: No such font known "
817 (car font-name-symbol)))
818 "") ; issue no command
819 (func "select-font" (car font-name-symbol)))))
821 (define (start-line height)
822 (func "start-line" height))
830 (define (volta h w thick vert-start vert-end)
833 (func "set-line-char" "|")
834 (func "rmove-to" 0 -4)
835 ;; definition strange-way around
839 (func "rmove-to" 1 h)
840 (func "set-line-char" "_")
841 (func "h-line" (- w 1))
842 (func "set-line-char" "|")
845 (func "rmove-to" (- w 1) (* -1 h))
846 (func "v-line" (* -1 h)))
849 (cond ((eq? action-name 'all-definitions)
852 (define bracket ,bracket)
854 ;;(define crescendo ,crescendo)
855 (define bezier-sandwich ,bezier-sandwich)
856 ;;(define dashed-slur ,dashed-slur)
857 ;;(define decrescendo ,decrescendo)
858 (define end-output ,end-output)
859 (define experimental-on ,experimental-on)
860 (define filledbox ,filledbox)
861 ;;(define font-def ,font-def)
862 (define font-load-command ,font-load-command)
863 ;;(define font-switch ,font-switch)
864 (define header ,header)
865 (define header-end ,header-end)
866 (define lily-def ,lily-def)
867 ;;(define invoke-char ,invoke-char)
868 ;;(define invoke-dim1 ,invoke-dim1)
869 (define placebox ,placebox)
870 (define select-font ,select-font)
871 (define start-line ,start-line)
872 ;;(define stem ,stem)
873 (define stop-line ,stop-line)
874 (define stop-last-line ,stop-line)
876 ;;(define tuplet ,tuplet)
877 (define volta ,volta)
879 ;;((eq? action-name 'tuplet) tuplet)
880 ;;((eq? action-name 'beam) beam)
881 ;;((eq? action-name 'bezier-sandwich) bezier-sandwich)
882 ;;((eq? action-name 'bracket) bracket)
883 ((eq? action-name 'char) char)
884 ;;((eq? action-name 'crescendo) crescendo)
885 ;;((eq? action-name 'dashed-slur) dashed-slur)
886 ;;((eq? action-name 'decrescendo) decrescendo)
887 ;;((eq? action-name 'experimental-on) experimental-on)
888 ((eq? action-name 'filledbox) filledbox)
889 ((eq? action-name 'select-font) select-font)
890 ;;((eq? action-name 'volta) volta)
891 (else (error "unknown tag -- MUSA-SCM " action-name))
896 (define (gulp-file name)
897 (let* ((port (open-file name "r"))
898 (content (let loop ((text ""))
899 (let ((line (read-line port)))
900 (if (or (eof-object? line)
903 (loop (string-append text line "\n")))))))
907 ;; urg: Use when standalone, do:
908 ;; (define (ly-gulp-file name) (scm-gulp-file name))
909 (define (scm-gulp-file name)
911 (cons (string-append (getenv 'LILYPONDPREFIX) "/ly")
912 (cons (string-append (getenv 'LILYPONDPREFIX) "/ps")
914 (let ((path (%search-load-path name)))
919 (define (scm-tex-output)
920 (eval (tex-scm 'all-definitions)))
922 (define (scm-ps-output)
923 (eval (ps-scm 'all-definitions)))
925 (define (scm-as-output)
926 (eval (as-scm 'all-definitions)))
928 ; Russ McManus, <mcmanus@IDT.NET>
930 ; I use the following, which should definitely be provided somewhere
931 ; in guile, but isn't, AFAIK:
935 (define (hash-table-for-each fn ht)
937 ((= i (vector-length ht)))
938 (do ((alist (vector-ref ht i) (cdr alist)))
940 (fn (car (car alist)) (cdr (car alist))))))
942 (define (hash-table-map fn ht)
945 ((= i (vector-length ht)) (reverse ret-ls))
946 (do ((alist (vector-ref ht i) (cdr alist)))
948 (set! ret-ls (cons (fn (car (car alist)) (cdr (car alist))) ret-ls)))))
952 (define (index-cell cell dir)
958 ; How should a bar line behave at a break?
960 (define (break-barline glyph dir)
961 (let ((result (assoc glyph
962 '((":|:" . (":|" . "|:"))
965 ("|:" . ("|" . "|:"))
966 ("|." . ("|." . nil))
967 (":|" . (":|" . nil))
968 ("||" . ("||" . nil))
969 (".|." . (".|." . nil))
970 ("scorebar" . (nil . "scorepostbreak"))
971 ("brace" . (nil . "brace"))
972 ("bracket" . (nil . "bracket"))
976 (if (equal? result #f)
977 (ly-warn (string-append "Unknown bar glyph: `" glyph "'"))
978 (index-cell (cdr result) dir))
983 (define (slur-ugly ind ht)
988 (> ht (+ (* 2 ind) -4))
989 (< ht (+ (* -2 ind) 8)))