X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=Documentation%2Fsnippets%2Fgenerating-whole-scores-also-book-parts-in-scheme-without-using-the-parser.ly;h=b710ea507da6631be11320f5cb325860a4dad067;hb=2755c70c630d8f4a7fc8cd77621a4e3ee05096ab;hp=a8e3f0cb732d8443c815f7e60a188521711ca61a;hpb=820bbcbc38981f5a1866f291cdf40042ea686db0;p=lilypond.git diff --git a/Documentation/snippets/generating-whole-scores-also-book-parts-in-scheme-without-using-the-parser.ly b/Documentation/snippets/generating-whole-scores-also-book-parts-in-scheme-without-using-the-parser.ly index a8e3f0cb73..b710ea507d 100644 --- a/Documentation/snippets/generating-whole-scores-also-book-parts-in-scheme-without-using-the-parser.ly +++ b/Documentation/snippets/generating-whole-scores-also-book-parts-in-scheme-without-using-the-parser.ly @@ -1,20 +1,19 @@ %% DO NOT EDIT this file manually; it is automatically -%% generated from LSR http://lsr.dsi.unimi.it +%% generated from LSR http://lsr.di.unimi.it %% Make any changes in LSR itself, or in Documentation/snippets/new/ , %% and then run scripts/auxiliar/makelsr.py %% %% This file is in the public domain. -\version "2.14.2" +\version "2.19.22" \header { - lsrtags = "really-cool, automatic-notation, scheme-language" + lsrtags = "automatic-notation, really-cool, scheme-language" texidoc = " A lilypond score internally is just a Scheme expression, generated by the lilypond parser. Using scheme, one can also automatically generate a score without an input file. If you have the music expression in -scheme, a score can be generated by simply calling (scorify-music music -parser) on your music. This will generate a score object, for which you +scheme, a score can be generated by simply calling (scorify-music music) on your music. This will generate a score object, for which you can then set a custom layout block with (let* ((layout (ly:output-def-clone $defaultlayout))) ; modify the layout here, then assign it: @@ -23,8 +22,8 @@ can then set a custom layout block with (let* ((layout Finally, all you have to do it to pass this score to lilypond for -typesetting. This snippet defines functions @code{(add-score parser -score)}, @code{(add-text parser text)} and @code{(add-music parser +typesetting. This snippet defines functions @code{(add-score +score)}, @code{(add-text text)} and @code{(add-music music)} to pass a complete score, some markup or some music to lilypond for typesetting. @@ -38,35 +37,35 @@ modified to inser all collected scores so far to the book. " doctitle = "Generating whole scores (also book parts) in scheme without using the parser" } % begin verbatim +%% -#(define-public (add-score parser score) - (ly:parser-define! parser 'toplevel-scores - (cons score (ly:parser-lookup parser 'toplevel-scores)))) +#(define-public (add-score score) + (ly:parser-define! 'toplevel-scores + (cons score (ly:parser-lookup 'toplevel-scores)))) -#(define-public (add-text parser text) - (add-score parser (list text))) +#(define-public (add-text text) + (add-score (list text))) -#(define-public (add-music parser music) +#(define-public (add-music music) (collect-music-aux (lambda (score) - (add-score parser score)) - parser + (add-score score)) music)) -#(define-public (toplevel-book-handler parser book) +#(define-public (toplevel-book-handler book) (map (lambda (score) (ly:book-add-score! book score)) - (reverse! (ly:parser-lookup parser 'toplevel-scores))) - (ly:parser-define! parser 'toplevel-scores (list)) - (print-book-with-defaults parser book)) + (reverse! (ly:parser-lookup 'toplevel-scores))) + (ly:parser-define! 'toplevel-scores (list)) + (print-book-with-defaults book)) #(define-public (book-score-handler book score) - (add-score parser score)) + (add-score score)) #(define-public (book-text-handler book text) - (add-text parser text)) + (add-text text)) -#(define-public (book-music-handler parser book music) - (add-music parser music)) +#(define-public (book-music-handler book music) + (add-music music)) %%% @@ -78,9 +77,9 @@ modified to inser all collected scores so far to the book. (lambda (parser) (let* ((music (make-music 'EventChord 'elements (list (make-music 'NoteEvent - 'duration (ly:make-duration 2 0 1 1) + 'duration (ly:make-duration 2 0 1/1) 'pitch (ly:make-pitch 0 pitch 0))))) - (score (scorify-music music parser)) + (score (scorify-music music)) (layout (ly:output-def-clone $defaultlayout)) (note-name (case pitch ((0) "do") @@ -93,13 +92,13 @@ modified to inser all collected scores so far to the book. (else "huh"))) (title (markup #:large #:line ("Score with a" note-name)))) (ly:score-add-output-def! score layout) - (add-text parser title) - (add-score parser score)) + (add-text title) + (add-score score)) (set! pitch (modulo (1+ pitch) 7))))) oneNoteScore = -#(define-music-function (parser location) () - (add-one-note-score parser) +#(define-music-function () () + (add-one-note-score (*parser*)) (make-music 'Music 'void #t)) %%%