lilypond-user
[Top][All Lists]
Advanced

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

Re: repeat index


From: Gianmaria Lari
Subject: Re: repeat index
Date: Fri, 24 Nov 2017 14:36:34 +0100

It works fantastically well. To automatically generate exercise this is more than great. 
Thanks a lot David!
g.

On 24 November 2017 at 10:55, David Kastrup <address@hidden> wrote:
Gianmaria Lari <address@hidden> writes:

> On 20 November 2017 at 23:01, David Kastrup <address@hidden> wrote:
>>
>> whatever =
>> #(define-music-function (pattern) (ly:music?)
>>   #{ \fixed c' {
>>        #@(map
>>            (lambda (p)
>>              #{ \modalTranspose c #(ly:make-pitch -1 p) \scale #pattern #})
>>            (iota 8))
>>      } #})
>>
>> \whatever {c d e f}
>> \whatever {f e d c}
>> \whatever {a c e g}
>>
>
> I tried the above code but without success. When I tried it few days ago I
> was thinking there was some simple to solve problem  and I didn't write you
> immediately; I wanted to try to solve the problem by myself but I have not
> been able to do it.
>
> This is the complete code according what you wrote (I hope I didn't
> introduce any errors):
>
> \version "2.19.80"
> scale = {c d e f g a b }
>
> whatever =
> #(define-music-function (pattern) (ly:music?)
>   #{ \fixed c' {
>        #@(map
>            (lambda (p)
>              #{ \modalTranspose c #(ly:make-pitch -1 p) \scale #pattern #})
>            (iota 8))
>      } #})
>
> \whatever {c d e f}
> \whatever {a c e g}
>
>
> It looks that #(ly:make-pitch -1 p) inside this function does not decrease
> the value of p. So the result is always the same _non transposed_ sequence.
> There is also a strange (to me) problem with the octave that's too high ( I
> have been able to solve it but I don't understand why it happens).
>
> The same code outside the function works well:
>
> \fixed c' {
>   #@(map
>       (lambda (p)
>         #{ \modalTranspose c #(ly:make-pitch -1 p) \scale {c d e f} #})
>       (iota 8))
> }
>
>
> What's the issue?

Sorry, my fault.  The result is sky-high pitches.  That's typical for
"failure to copy": here #pattern is used over and over again and being
(destructively) transposed every time.

The solution is simply to write $pattern (which _does_ copy, as does
\scale) instead of #pattern in the function.

--
David Kastrup


reply via email to

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