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
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)
> (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?