"Dr. med. Kai Lautenschläger" <[email protected]> writes:

> Hi Everyone,
>
> Although I am positive, that I read about this in the list, I cannot
> find it anymore. So I kindly ask for a pointer in the right direction.
>
> I am trying to code a piece with voices that use the same rhythmical
> fragment over and over again. I would like to write something like:
>
>
> \version "2.17.2"
>
> rhythm = { s8.[ s16] }
> melody = \relative c { a d g f e b}
>
> \score {
> \new staff <<
> \relative c { g2 d8 h e4 f  } 
> \applyRhythm \rhythm \melody
> \relative c { g2 d8 h e4 f  } 
>>>
> \layout {  }
> }
>

It is annoying how many bugs you built into your skeleton.  You should
really try to make them work except for the missing parts.  At any rate,
it would appear that something like

\language "deutsch"

rhythm = { s8.[ s16] }
melody = \relative c { a d g f e b}

applyRhythm =
#(define-music-function (parser location rhythm melody)
  (ly:music? ly:music?)
  #{ $@(map
        (lambda (p da) #{ $p $@da #})
        (reverse!
         (fold-some-music
          (lambda (m) (ly:music-property m 'pitch #f))
          (lambda (m l) (cons (ly:music-property m 'pitch) l))
          '()
          melody))
        (apply circular-list
         (reverse!
          (fold-some-music
           (lambda (m) (music-is-of-type? m 'skip-event))
           (lambda (m l)
            (cons (cons (ly:music-property m 'duration)
                   (ly:music-property m 'articulations))
             l))
           '()
           rhythm))))
  #})

\score {
\new Voice {
\relative c { g2 d8 h e4 f  } 
\applyRhythm \rhythm \melody
\relative c { g2 d8 h e4 f  } 
}
\layout {  }
}
does the trick.

-- 
David Kastrup
_______________________________________________
lilypond-user mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to