lilypond-user
[Top][All Lists]
Advanced

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

Re: Scheme : "catching" property values


From: Carl Sorensen
Subject: Re: Scheme : "catching" property values
Date: Thu, 23 Sep 2010 10:39:42 -0600



On 9/23/10 4:02 AM, "Éditions IN NOMINE" <address@hidden>
wrote:

>      Hi list !
>  I'm training some Scheme stuff, especially by rewriting basic Lily functions
> in Scheme. I'm now trying to create a function that increases by 1 the degree
> of the note argument. So I have to "catch" the second figure of the
>  'pitch
>  (ly:make-pitch a b c))
>  to add 1 to it.
>  
>  The function begins with :
>  
>   increasedegree= #(define-music-function (parser location note)(ly:music?)
>           "adds 1 to the second figure of the pitch"
>           (let ((result-note (ly:music-deep-copy note)))   ;local copy of the
> note passed as argument
>                ((result-pitch (ly:music-property (first (ly:music-property
> result-note 'elements))                                 'pitch))) ;local copy
> of the pitch of result-note
>  
>  How can I call for the second figure of the pitch?
>  This trick would be usefull for other functions I'm trying to write ! Maybe
> this trick is treated in the manual, but I haven't seen it...

You shouldn't try to catch the second value of the pitch, as that is getting
into the data structure.  You should instead use the defined functions for
altering pitches.

(let ((new-pitch (ly:pitch-transpose old-pitch (ly:make-pitch 0 1 0))))


If you really want to get the middle value, you should also do that with a
defined function, which is a poorly-named one (pitch-notename implies a name
like c, d, e, rather than an integer -- but it actually returns an integer).

(let ((pitch-step (ly:pitch-notename old-pitch)))

HTH,

Carl





reply via email to

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