[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: My own wishlist...
From: |
Nicolas Sceaux |
Subject: |
Re: My own wishlist... |
Date: |
Fri, 06 Feb 2004 19:35:29 +0100 |
User-agent: |
Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux) |
Tue, 3 Feb 2004 15:58:07 +0100, Han-Wen a dit :
> address@hidden writes:
>> A cheap functionality, which would prove very useful in
>> practice, would be the ability to declare Lilypond stuff
>> in scheme, as in:
>>
>> (map myfunc {\notes { a b c d | a b c d}})
>>
>> which would be equivalent to:
>>
>> tempvar0981 = \notes { a b c d | a b c d}
>>
>> (map myfunc tempvar0981)
>>
>> Since we already have the ability to declare
>> Scheme stuff within LilyPond, allowing for the
>> reverse might be enough for most applications....
>>
>> Is this just nonsense, or is this reasonable to implement
>> (I don't know whether one can plug language extensions in
>> GUILE...) ?
> I don't know how it can be done. Perhaps our Scheme macro expert can
> chip in some ideas. Nicolas?
sorry for the delay, I was not at home.
What is easy, is to write a set of scheme operators that would reflect
common LilyPond commands, for instance:
(context-property-override Voice Stem thickness 2.0)
==> \property Voice.Stem \override #'thickness = #2.0
or: (skip "1.*4/3") ==> s1.*4/3
etc.
Actually, I have started to build such a library on a per need basis
for my scores. I am considering contributing a complete set of these
scheme operators, aiming at programatically building any music
expressions.
As for reading a lilypond expression in scheme, it is not trivial. I
once tried to hack my lilypond-program so that the lilypond-language
compiler could be called within scheme via a call to a C function in a
lily shared library, without real success. I didn't know enough of
lilypond internals. It is feasible, however, but when I discovered
what the \apply command could do, I definitely got rid of the idea of
using lilypond expression in scheme. \apply is enough -- if you don't
have to call a function with several music arguments. Some kind of
multi-arguments apply would be cool.
\apply-3 #bass-part
{ ...bass notes... }
{ ...figures... }
> In the meantime, you can achieve the same thing with apply, albeit a
> little more verbose
> \apply #(lambda (m)
> ..more stuff.. )
> \notes { a b c d | a b c d}
What could be also usefull is some specialized mapping functions:
\apply #(lambda (music)
(map-if mus:note?
(lambda (note) (..do something on a note..))
music))
\notes { a b c d | a b c d}
where `map-if' would look deeply into `music', and for each element
satisfying the predicate (eg. `mus:note?') would apply the function
on it.
Oh, this is not very beautiful for a LilyPond score... macrology may
help:
\apply #(with-note-mapping (note)
(..do something on a note..))
\notes { a b c d | a b c d}
etc.
nicolas