lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Making notes in Scheme?


From: Erik Sandberg
Subject: Re: Making notes in Scheme?
Date: Mon, 16 Oct 2006 21:11:05 +0200
User-agent: KMail/1.9.1

On Sunday 15 October 2006 22:59, Marcus Macauley wrote:
> Nicolas Sceaux wrote:
> And because it's possible to manually type notes within a music function
> in Scheme, e.g.:
>
> function =
> #(define-music-function (parser location var1) (integer?)
> #{
>       c'4 d' e'
> #})
>
> It seems like it should also be possible to substitute variables for those
> notes, such as:
>
> #(define-music-function (parser location var1) (integer?)
> #{
>       $firstnote #(list-ref notes 1) #(list-ref notes 2)
> #})
>
>
>  From what I can tell, the key is the "ly:music" data type, but I don't
> know how to to use that from within Scheme, if it's even possible, much
> less how (if possible) to convert e.g. strings to ly:music.
>
> The "ly:export" function may also have something to do with it, but if so,
> I haven't figured out quite what.

normally, the return value of a scheme expression is thrown away by the 
parser; ly:export is used to mark expressions that instead should be 
interpreted as music. So what you wanted above is something like:

 #(define-music-function (parser location var1) (integer?)
 #{
       $firstnote #(ly:export (list-ref notes 1)) #(ly:export (list-ref notes 
2))
 #})

Note that ly:export is built into make-music-function, so in that case you 
don't have to worry about it.

-- 
Erik





reply via email to

[Prev in Thread] Current Thread [Next in Thread]