]> git.donarmstrong.com Git - lilypond.git/blobdiff - init/lily.scm
release: 1.1.6
[lilypond.git] / init / lily.scm
index 4d29ce239fe852a9203e6fcf297ff6304e103832..e045426a26641b52d6c02ca385740e0ae3a04cc3 100644 (file)
 ;     all preparations from ps,tex to scm
 
 ;;; library funtions
+(define
+  (xnumbers->string l)
+  (string-append 
+   (map (lambda (n) (string-append (number->string n ) " ")) l)))
+
 (define
   (numbers->string l)
   (apply string-append 
   (let ((n (inexact->exact x)))
        (number->string n radix)))
 
-(define 
-  (number->dim-tex x)
-  (string-append 
-   (number->string (chop-decimal x)) "pt "))
 
 (define
   (control->string c)
     (string-append (number->string (car c)) " ")
     (string-append (number->string (cadr c)) " ")))
 
+;;;;;;;; TeX
+; (define (tex action)
+
+(define 
+  (beam-tex width slope thick)
+  (embedded-ps-tex (beam-ps width slope thick)))
+
+(define 
+  (bracket-tex h)
+  (embedded-ps-tex (bracket-ps h)))
+
+(define 
+  (dashed-slur-tex thick dash l)
+  (embedded-ps-tex (dashed-slur-ps thick dash l)))
+
+(define 
+  (crescendo-tex w h cont)
+  (embedded-ps-tex (crescendo-ps w h cont)))
+
+(define 
+  (decrescendo-tex w h cont)
+  (embedded-ps-tex (decrescendo-ps w h cont)))
+
 (define 
   (embedded-ps-tex s)
   (string-append "\\embeddedps{" s "}"))
 
+
 (define 
-  (invoke-char-ps s i)
-  (string-append 
-   "(\\" (inexact->string i 8) ") " s " " ))
+  (end-output-tex) 
+  "\n\\EndLilyPondOutput")
 
 (define 
-  (invoke-char-tex s i)
-  (string-append 
-   "\n\\" s "{" (inexact->string i 10) "}" ))
+  (empty-tex) 
+  "%\n\\empty%\n")
+
+(define
+  (experimental-on-tex) "\\turnOnExperimentalFeatures")
 
 (define 
-  (invoke-dim1-ps s d) 
+  (extender o h)
+  ((invoke-output o "invoke-dim1") "extender" h))
+
+(define 
+  (font-switch-tex i)
   (string-append
-   (number->string d) " " s ))
+   "\\" (font i) "\n"))
 
 (define 
-  (invoke-dim1-tex s d)
+  (font-def-tex i s)
   (string-append
-   "\n\\" s "{" (number->dim-tex d) "}"))
+   "\\font" (font-switch-tex i) "=" s "\n"))
+
+(define 
+  (generalmeter-tex num den)
+  (string-append 
+   "\\generalmeter{" (number->string (inexact->exact num)) "}{" (number->string (inexact->exact den)) "}"))
 
 (define
-  (invoke-output o s)
-   (eval-string (string-append s "-" o)))
+  (header-end-tex) "\\turnOnPostScript")
 
-;;; output definitions
+(define 
+  (header-tex creator generate) 
+  (string-append
+   "%created by: " creator generate "\n"))
 
 (define 
-  (beam o width slope thick) 
-  ((invoke-output o "beam") width slope thick))
+  (invoke-char-tex s i)
+  (string-append 
+   "\n\\" s "{" (inexact->string i 10) "}" ))
 
 (define 
-  (beam-ps width slope thick)
+  (invoke-dim1-tex s d)
   (string-append
-   (numbers->string (list width slope thick)) " draw_beam " ))
+   "\n\\" s "{" (number->dim-tex d) "}"))
 
-(define 
-  (beam-tex width slope thick)
-  (embedded-ps-tex (beam-ps width slope thick)))
+(define
+  (lily-def-tex key val)
+  (string-append
+   "\\def\\" key "{" val "}\n"))
 
 (define 
-  (bracket o h)
-  ((invoke-output o "bracket") h))
+  (number->dim-tex x)
+  (string-append 
+   (number->string (chop-decimal x)) "pt "))
 
 (define 
-  (bracket-ps h)
-  (invoke-dim1-ps "draw_bracket" h))
+  (placebox-tex x y s) 
+  (string-append 
+   "\\placebox{"
+   (number->dim-tex y) "}{" (number->dim-tex x) "}{" s "}"))
 
 (define 
-  (bracket-tex h)
-  (embedded-ps-tex (bracket-ps h)))
+  (rulesym-tex h w) 
+  (string-append 
+   "\\vrule height " (number->dim-tex (/ h 2))
+   " depth " (number->dim-tex (/ h 2))
+   " width " (number->dim-tex w)
+   )
+  )
 
 (define 
-  (char o n) 
-  ((invoke-output o "invoke-char") "show" n))
+  (slur-tex l)
+  (embedded-ps-tex (slur-ps l)))
 
 (define 
-  (crescendo o w h cont)
-  ((invoke-output o "crescendo") w h cont))
+  (start-line-tex) 
+  (string-append 
+   "\\hbox{%\n")
+  )
 
 (define 
-  (crescendo-ps w h cont)
+  (stem-tex kern width height depth) 
   (string-append 
-   (numbers->string (list w h (inexact->exact cont)))
-   "draw_crescendo"))
+   "\\kern" (number->dim-tex kern)
+   "\\vrule width " (number->dim-tex width)
+   "depth " (number->dim-tex depth)
+   "height " (number->dim-tex height) " "))
 
 (define 
-  (crescendo-tex w h cont)
-  (embedded-ps-tex (crescendo-ps w h cont)))
+  (stop-line-tex) 
+  "}\\interscoreline")
+
+(define
+  (text-tex f s)
+  (string-append "\\set" f "{" s "}"))
+
+
+
+;;;;;;;;;;;; PS
 
 (define 
-  (dashed-slur o thick dash l) 
-  ((invoke-output o "dashed-slur") thick dash l))
+  (beam-ps width slope thick)
+  (string-append
+   (numbers->string (list width slope thick)) " draw_beam " ))
 
 (define 
-  (decrescendo o w h cont)
-  ((invoke-output o "decrescendo") w h cont))
+  (bracket-ps h)
+  (invoke-dim1-ps "draw_bracket" h))
 
 (define 
-  (decrescendo-ps w h cont)
+  (crescendo-ps w h cont)
   (string-append 
    (numbers->string (list w h (inexact->exact cont)))
-   "draw_decrescendo"))
-
-(define 
-  (decrescendo-tex w h cont)
-  (embedded-ps-tex (decrescendo-ps w h cont)))
+   "draw_crescendo"))
 
 (define 
   (dashed-slur-ps thick dash l)
    " ] 0 draw_dashed_slur"))
 
 (define 
-  (dashed-slur-tex thick dash l)
-  (embedded-ps-tex (dashed-slur-ps thick dash l)))
+  (decrescendo-ps w h cont)
+  (string-append 
+   (numbers->string (list w h (inexact->exact cont)))
+   "draw_decrescendo"))
 
 (define 
-  (doublebar o h)
-  ((invoke-output o "invoke-dim1") "doublebar" h))
+  (empty-ps) 
+  "\n empty\n")
 
 (define 
-  (empty o) 
-  ((invoke-output o "empty")))
+  (end-output-ps)
+  "\nshowpage\n")
+
+(define
+  (experimental-on-ps) "")
 
 (define 
-  (empty-ps) 
-  "\n empty\n")
+  (font-def-ps i s)
+  (string-append
+   "\n/" (font i) " {/" 
+   (substring s 0 (- (string-length s) 4))
+   " findfont 12 scalefont setfont} bind def\n"))
 
 (define 
-  (empty-tex) 
-  "%\n\\empty%\n")
+  (font-switch-ps i)
+  (string-append (font i) " "))
 
 (define 
-  (emptybar o h) (empty o))
+  (generalmeter-ps num den)
+  (string-append (number->string (inexact->exact num)) " " (number->string (inexact->exact den)) " generalmeter "))
+
+(define
+  (header-end-ps) "")
+(define
+  (lily-def-ps key val)
+  (string-append
+   "/" key " {" val "} bind def\n"))
 
 (define 
-  (end-output o) 
-  ((invoke-output o "end-output")))
+  (header-ps creator generate) 
+  (string-append
+   "%!PS-Adobe-3.0\n"
+   "%%Creator: " creator generate "\n"))
 
 (define 
-  (end-output-ps)
-  "\nshowpage\n")
+  (invoke-char-ps s i)
+  (string-append 
+   "(\\" (inexact->string i 8) ") " s " " ))
 
 (define 
-  (end-output-tex) 
-  "\n\\EndLilyPondOutput")
+  (invoke-dim1-ps s d) 
+  (string-append
+   (number->string d) " " s ))
 
 (define 
-  (experimental-on o) 
-  ((invoke-output o "experimental-on")))
+  (placebox-ps x y s) 
+  (string-append 
+   (number->string x) " " (number->string y) " {" s "} placebox "))
 
-(define
-  (experimental-on-ps) "")
+(define 
+  (rulesym-ps x y) 
+  (string-append 
+   (number->string x) " "
+   (number->string y) " "
+   "rulesym"))
+
+(define 
+  (slur-ps l)
+  (string-append 
+   (apply string-append (map control->string l)) 
+   " draw_slur"))
+
+(define 
+  (start-line-ps) 
+   "\nstart_line {\n")
+
+(define 
+  (stem-ps kern width height depth) 
+  (string-append (numbers->string (list kern width height depth))
+                "draw_stem" ))
+
+(define 
+  (stop-line-ps) 
+  "}\nstop_line\n")
 
 (define
-  (experimental-on-tex) "\\turnOnExperimentalFeatures")
+  (text-ps f s)
+  (string-append "(" s ") set" f " "))
+
+
+;;; output definitions
 
 (define 
-  (extender o h)
-  ((invoke-output o "invoke-dim1") "extender" h))
+  (beam o width slope thick) 
+  ((invoke-output o "beam") width slope thick))
+
+(define 
+  (bracket o h)
+  ((invoke-output o "bracket") h))
+
+(define 
+  (char o n) 
+  ((invoke-output o "invoke-char") "show" n))
+
+(define 
+  (crescendo o w h cont)
+  ((invoke-output o "crescendo") w h cont))
+
+(define 
+  (dashed-slur o thick dash l) 
+  ((invoke-output o "dashed-slur") thick dash l))
+
+(define 
+  (decrescendo o w h cont)
+  ((invoke-output o "decrescendo") w h cont))
+
+(define 
+  (doublebar o h)
+  ((invoke-output o "invoke-dim1") "doublebar" h))
+
+(define 
+  (empty o) 
+  ((invoke-output o "empty")))
+
+(define 
+  (emptybar o h) (empty o))
+
+(define 
+  (end-output o) 
+  ((invoke-output o "end-output")))
+
+(define 
+  (experimental-on o) 
+  ((invoke-output o "experimental-on")))
 
 (define
   (fatdoublebar o h)
   (font-def o i s) 
   ((invoke-output o "font-def") i s))
 
-(define 
-  (font-def-ps i s)
-  (string-append
-   "\n/" (font i) " {/" 
-   (substring s 0 (- (string-length s) 4))
-   " findfont 12 scalefont setfont} bind def\n"))
-
-(define 
-  (font-def-tex i s)
-  (string-append
-   "\\font" (font-switch-tex i) "=" s "\n"))
-
 (define 
   (font-switch o i) 
   ((invoke-output o "font-switch") i))
 
-(define 
-  (font-switch-ps i)
-  (string-append (font i) " "))
-
-(define 
-  (font-switch-tex i)
-  (string-append
-   "\\" (font i) "\n"))
-
 (define 
   (generalmeter o num den)
    ((invoke-output o "generalmeter") num den))
 
-(define 
-  (generalmeter-ps num den)
-  (string-append (number->string (inexact->exact num)) " " (number->string (inexact->exact den)) " generalmeter "))
-
-(define 
-  (generalmeter-tex num den)
-  (string-append 
-   "\\generalmeter{" (number->string (inexact->exact num)) "}{" (number->string (inexact->exact den)) "}"))
-
 (define 
   (header o creator generate) 
   ((invoke-output o "header") creator generate))
 
-(define 
-  (header-ps creator generate) 
-  (string-append
-   "%!PS-Adobe-3.0\n"
-   "%%Creator: " creator generate "\n"))
-
-(define 
-  (header-tex creator generate) 
-  (string-append
-   "%created by: " creator generate "\n"))
-
 (define 
   (header-end o) 
   ((invoke-output o "header-end")))
 
 (define
-  (header-end-ps) "")
-
-(define
-  (header-end-tex) "\\turnOnPostScript")
+  (invoke-output o s)
+   (eval-string (string-append s "-" o)))
 
 (define
   (lily-def o key val)
   ((invoke-output o "lily-def") key val))
 
-(define
-  (lily-def-ps key val)
-  (string-append
-   "/" key " {" val "} bind def\n"))
-
-(define
-  (lily-def-tex key val)
-  (string-append
-   "\\def\\" key "{" val "}\n"))
-
 (define 
   (maatstreep o h) 
   ((invoke-output o "invoke-dim1") "maatstreep" h))
   (placebox o x y b) 
   ((invoke-output o "placebox") x y (b o)))
 
-(define 
-  (placebox-ps x y s) 
-  (string-append 
-   (number->string x) " " (number->string y) " {" s "} placebox "))
-
-(define 
-  (placebox-tex x y s) 
-  (string-append 
-   "\\placebox{"
-   (number->dim-tex y) "}{" (number->dim-tex x) "}{" s "}"))
-
 (define
   (repeatbar o h)
   ((invoke-output o "invoke-dim1") "repeatbar" h))
   (rulesym o x y) 
   ((invoke-output o "rulesym") x y))
 
-(define 
-  (rulesym-ps x y) 
-  (string-append 
-   (number->string x) " "
-   (number->string y) " "
-   "rulesym"))
-
-(define 
-  (rulesym-tex x y) 
-  (string-append 
-   "\\rulesym{" (number->dim-tex x) "}{" (number->dim-tex y) "}"))
-
 (define 
   (setbold o s) 
   ((invoke-output o "text") "bold" s))
   ((invoke-output o "slur") l))
 
 (define 
-  (slur-ps l)
+  (tuplet o dx dy dir)
+  ((invoke-output o "tuplet") dx dy dir))
+
+(define 
+  (tuplet-ps dx dy dir)
   (string-append 
-   (apply string-append (map control->string l)) 
-   " draw_slur"))
+   (numbers->string (list dx dy (inexact->exact dir)))
+   "draw_tuplet"))
 
 (define 
-  (slur-tex l)
-  (embedded-ps-tex (slur-ps l)))
+  (tuplet-tex dx dy dir)
+  (embedded-ps-tex (tuplet-ps dx dy dir)))
 
 (define 
   (stem o kern width height depth) 
   ((invoke-output o "stem") kern width height depth))
 
-(define 
-  (stem-ps kern width height depth) 
-  (string-append (numbers->string (list kern width height depth))
-                "draw_stem" ))
 
-(define 
-  (stem-tex kern width height depth) 
-  (string-append 
-   "\\kern" (number->dim-tex kern)
-   "\\vrule width " (number->dim-tex width)
-   "depth " (number->dim-tex depth)
-   "height " (number->dim-tex height) " "))
 
 (define 
   (start-line o) 
   ((invoke-output o "start-line")))
 
-(define 
-  (start-line-ps) 
-   "\nstart_line {\n")
-
-(define 
-  (start-line-tex) 
-  (string-append 
-   "\\hbox{%\n")
-  )
-
-
 (define
   (startbar o h)
   ((invoke-output o "invoke-dim1") "startbar" h))
   (startrepeat o h)
   ((invoke-output o "invoke-dim1") "startrepeat" h))
 
+
 (define 
   (stop-line o) 
   ((invoke-output o "stop-line")))
 
-(define 
-  (stop-line-ps) 
-  "}\nstop_line\n")
-
-(define 
-  (stop-line-tex) 
-  "}\\interscoreline")
 
 (define
   (stoprepeat o h)
   ((invoke-output o "invoke-dim1") "stoprepeat" h))
 
-(define
-  (text-ps f s)
-  (string-append "(" s ") set" f " "))
-
-(define
-  (text-tex f s)
-  (string-append "\\set" f "{" s "}"))
-
-
-(define 
-  (tuplet o dx dy dir)
-  ((invoke-output o "tuplet") dx dy dir))
-
-(define 
-  (tuplet-ps dx dy dir)
-  (string-append 
-   (numbers->string (list dx dy (inexact->exact dir)))
-   "draw_tuplet"))
-
-(define 
-  (tuplet-tex dx dy dir)
-  (embedded-ps-tex (tuplet-ps dx dy dir)))