Working with music properties

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Working with music properties

Joseph Wakeling
Hello again :-)

Following Neil's advice and after some scheme-y research I've made some
rewrites of the code.

The various naturalize-* functions now take as input a list of four
pairs, which determine the cases when pitch alterations are too high or
two low (see naturalize.scm).  The various naturalizeMusic* expressions
in naturalizeMusicIntegrated.ly have been rewritten to use this form.

I also added a music property, naturalize-style (see attached version of
define-music-properties.scm).

As per naturalizeMusicIntegrated.ly the idea would be to set the value
of 'naturalize-style and use that to determine the naturalization rules.

So, as a first step, I'd like to rewrite naturalizeMusic to use the
music property.  Currently it's defined as,

> naturalizeMusic =
> #(define-music-function (parser location m)
>    (ly:music?)
>    (naturalize m (list (cons >= 1) (cons <= -1) (cons >= SHARP) (cons <= FLAT))))

I tried replacing that with,

> naturalizeMusic =
> #(define-music-function (parser location m)
>    (ly:music?)
>    (naturalize m (ly:music-property m 'naturalize-style)))

... but that generated an error:

> GNU LilyPond 2.13.28
> Processing `naturalizeMusicIntegrated.ly'
> Parsing...~/code/lily/out/share/lilypond/current/scm/naturalize.scm:10:33: In procedure list-ref in expression (list-ref pitch-limits 0):
> ~/code/lily/out/share/lilypond/current/scm/naturalize.scm:10:33: Argument 2 out of range: 0

... which suggests to me that (ly:music-property m 'naturalize-style) is
returning an empty list.

Is that because I'm doing something wrong in setting the value of the
'naturalize-style music property, or is it that I'm incorrectly trying
to _get_ the value?  Either way, can someone advise on the solution?

Thanks & best wishes,

    -- Joe

naturalizeMusicIntegrated.ly (5K) Download Attachment
naturalize.scm (2K) Download Attachment
define-music-properties.scm (12K) Download Attachment
Loading...