[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Pull in external LilyPond files into a score of movements
From: |
Paul Morris |
Subject: |
Re: Pull in external LilyPond files into a score of movements |
Date: |
Mon, 28 Apr 2014 09:33:01 -0700 (PDT) |
Hi Jan-Peter,
Jan-Peter Voigt wrote
> to use a file for including definitions and also to compile it
> stand-alone, I use a command to conditionally create the score. It is
> integrated in a system to execute templates:
> https://github.com/openlilylib/snippets/tree/master/templates/lalily
>
> Attached is a short example, which conditionally compiles (without the
> template framework).
Wow, thanks, this is a nice solution! So the "conditional-compile.ly" file
is the child file (for a single movement) and the "conditional-compile2.ly"
file is the parent file (that contains several movements). Below is a
version of "conditional-compile.ly" where I added some logging commands if
that helps anyone else see how it's working.
Your "doScore" function seems to be a workaround for the limitation that
music functions can't return a score. (I tried to rewrite it as a music
function but got "error: music function cannot return #<Score>".
I think this would be a nice standalone snippet for the LSR or openLilyLib.
And I need to take a closer look at your lalily template system and edition
engraver.
Thanks,
-Paul
BTW, if anyone is wondering what "smob" refers to, for example in
"parser-smob" in the docs, I found this ("small object"):
https://www.gnu.org/software/guile/manual/html_node/Defining-New-Types-_0028Smobs_0029.html#Defining-New-Types-_0028Smobs_0029
%%%%%%%%%%%%%%%%%%%%
% "conditional-compile.ly"
\version "2.18.2"
#(use-modules (ice-9 regex))
#(define (lalily-test-location? parser location)
(let ((outname (ly:parser-output-name parser))
(locname (car (ly:input-file-line-char-column location))))
(display "1. ")(display outname) (newline)
(display "2. ")(display locname) (newline)
; check if parser-output-name and location-name match
(regexp-match? (string-match (format "^(.*/)?~A\\.i?ly$" outname)
locname))
(display "3. ")(display (regexp-match? (string-match (format
"^(.*/)?~A\\.i?ly$" outname) locname))) (newline)
))
doScore =
#(define-void-function (parser location cond? mus)(procedure? ly:music?)
; if condition is met, parser shall create score
(if (cond? parser location)
(begin
(ly:parser-define! parser 'doScoreMusic mus)
(ly:parser-include-string parser (format "\\score { \\doScoreMusic
}"))
(display "4. ")(display (format "\\score { \\doScoreMusic
}"))(newline)
)))
% music definition
exampleMusic = \relative c'' { c4 b bes a }
% create score, if condition is met
\doScore #lalily-test-location? \exampleMusic
--
View this message in context:
http://lilypond.1069038.n5.nabble.com/Pull-in-external-LilyPond-files-into-a-score-of-movements-tp161839p161894.html
Sent from the User mailing list archive at Nabble.com.
- Pull in external LilyPond files into a score of movements, Knute Snortum, 2014/04/26
- Re: Pull in external LilyPond files into a score of movements, Jay Anderson, 2014/04/26
- Re: Pull in external LilyPond files into a score of movements, Knute Snortum, 2014/04/26
- Re: Pull in external LilyPond files into a score of movements, Paul Morris, 2014/04/26
- Re: Pull in external LilyPond files into a score of movements, Urs Liska, 2014/04/27
- Re: Pull in external LilyPond files into a score of movements, Nick Payne, 2014/04/27
- Re: Pull in external LilyPond files into a score of movements, Jan-Peter Voigt, 2014/04/27
- Re: Pull in external LilyPond files into a score of movements,
Paul Morris <=
- Re: Pull in external LilyPond files into a score of movements, David Kastrup, 2014/04/28
- Re: Pull in external LilyPond files into a score of movements, Paul Morris, 2014/04/28
- Re: Pull in external LilyPond files into a score of movements, David Kastrup, 2014/04/28
- Re: Pull in external LilyPond files into a score of movements, Paul Morris, 2014/04/28