Hello Jan-Peter,
thank you for the ideas, that I have partly understood.
Am 10.05.2012 13:35, schrieb Jan-Peter Voigt:
Hello Urs,
On 10.05.2012 12:40, Urs Liska wrote:
Hi David,
thank you for the reply
Am 10.05.2012 12:05, schrieb David Kastrup:
Urs Liska<li...@ursliska.de> writes:
So now the question:
How can I write a function that produces a toplevel expression?
No such thing.
:-(
an _ugly_ way is to produce a string and then use
#(ly:parser-include-string parser topLevelString)
This snip can then be included in a music- or scheme-function to be
used in lily-syntax. There are cases, where I use this construct, but
I try to avoid it.
OK, I don't really understand it, but the cleaner
\layout { \debugCurvesOn }
is perfectly acceptable.
...
I wanted to be able to write
\liedScore "Stimme" "Klavier"
or
\liedScore "Voice" "Piano"
and get back the respective \score block with the parameters
substituted.
you can write
liedScore = \score { ... }
and you can write
liedScore = #(define-scheme-function (parser layout ...)(...)
#{
\score {
...
}
#})
... thanks to Davids remarkable parser refinements. (I was not amused
in the first place, rewriting/updating my scores accordingly, but IMO
these changes are a major step forward for lilypond!)
If you reference this, it looks all the same
\liedScore /optional parms/
So this is what I came up with. This is a minimal example of how it
could work:
% inside included (library) file:
liedScore = \score {
\new Staff {
\set Staff.instrumentName = \instName
\music
}
}
music = \relative c' { c4 e g b } % Defined in another (piece specific)
included file
instName = "Test" % already defined with default value in the library,
so I don't _have_ to write this
\score { \liedScore }
But from your answers to the other part of the question I now know
that this isn't possible.
If liedScore is a music-function (returning void), it can be placed
anywhere. This function can do anything possible in scheme: It can add
scores or markups to the current stream:
--snip--
fun = #(define-music-function (parser location mus)(ly:music?)
(add-score parser (list #{ \markup { Hello World } #}))
(add-score parser #{ \score { $mus } #})
(make-music 'SequentialMusic 'void #t))
\fun \relative c' { c4 e g b }
--snip--
Now you can put anything in your function, to create the score.
Unfortunately this doesn't seem to work for me. I don't want to pass the
music as parameter but one or more strings containing the instrument
names of the staves.
But thinking of it the above solution is probably sufficient. I can
define default values in the library and override them in the master
file if necessary.
Probably I'll look for a solution through defining a variable and
then including the file with the \score definition.
For the project at hand it's not necessary because I can have the
score block be hardcoded. But I want to distill a more generic
library/framework for use after this project.
Using lilypond is handcraft and the artist often wishes to have his
own unique tool ;-)
I also use my own functions:
http://www.xn--schne-noten-tfb.de/?tabs=3,1
http://www.xn--schne-noten-tfb.de/lalily.tgz
It is poorly to not documented, but if you are interested, I can give
you more information.
I'll look into it later
Best
Urs
Cheers, Jan-Peter
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user