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 10:45:17 +0100



On 20 November 2017 at 23:01, David Kastrup <address@hidden> wrote:
Gianmaria Lari <address@hidden> writes:

> On 20 November 2017 at 15:18, David Kastrup <address@hidden> wrote:
>
>> Gianmaria Lari <address@hidden> writes:
>>
>> > On 20 November 2017 at 12:00, David Kastrup <address@hidden> wrote:
>> >
>> >> Gianmaria Lari <address@hidden> writes:
>>
>> >> > Is there any (simple) way to rewrite it in a more concise way like
>> >> > this for example?
>> >> >
>> >> >   \repeat unfold 7 {
>> >> >     \modalTranspose c "c+index" \scale \pattern
>> >> >   }
>> >>
>> >> What is simple?
>> >>
>> >> \version "2.18.0"
>> >>
>> >> scale = {c d e f g a b}
>> >> pattern = {c d e f}
>> >>
>> >> \fixed c' {
>> >>   #@(map
>> >>       (lambda (p)
>> >>         #{ \modalTranspose c #(ly:make-pitch -1 p) \scale \pattern #})
>> >>       (iota 8))
>> >> }
>> >
>> > Thank you David, it works perfectly!
>> >
>> > Is there any way to encapsulate it in a function to avoid to write
>> > all the code any time I need it?
>>
>> What is "all the code"?  I really have no idea what makes you consider
>> something simple (and your "explanation" below does not help at all
>> since it is tantamount to "simple depends on the viewer's metrics").
>> I also have no idea what part of the above you consider "it" to be
>> encapsulated and what you consider variable.
>
> I'm sorry I have not been clear. If you have a look to the following source
> you'll see that the same code is repeated three times (only the variable
> 'pattern' changes).
>
> \version "2.18.0"
> scale = {c d e f g a b}
>
> pattern = {c d e f}
> \fixed c' {
>   #@(map
>       (lambda (p)
>         #{ \modalTranspose c #(ly:make-pitch -1 p) \scale \pattern #})
>       (iota 8))
> }
>
> pattern = {f e d c}
> \fixed c' {
>   #@(map
>       (lambda (p)
>         #{ \modalTranspose c #(ly:make-pitch -1 p) \scale \pattern #})
>       (iota 8))
> }
>
> pattern = {a c e g}
> \fixed c' {
>   #@(map
>       (lambda (p)
>         #{ \modalTranspose c #(ly:make-pitch -1 p) \scale \pattern #})
>       (iota 8))
> }
>
>
> I was wondering if it was possible to to avoid this redundancy.

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?
Thank you, g.

reply via email to

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