lilypond-user
[Top][All Lists]
Advanced

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

Re: rhythm fragments in different pitches


From: David Kastrup
Subject: Re: rhythm fragments in different pitches
Date: Sat, 22 Sep 2012 13:11:27 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.50 (gnu/linux)

Kai Lautenschläger <address@hidden> writes:

>> Am 22.09.2012 um 12:42 schrieb:
>>
>>> At some point of time, we probably should have a convenience function
>>> for the pattern
>>> 
>>> (reverse! (fold-some-music [predicate]
>>>                           (lambda (l m) (cons ([extractor] m) l))
>>>                           '()
>>>                           [music]))
>>> 
>>> The example code I posted uses this twice already.
>
>
> Thanks for explaining. As for your idea [above] I would like that
> feature very much, though I do not understand the code because I am
> illiterate to programming languages.

It turns out that the ([extractor] m) pattern can be equally well done
separately using map!, so actually every function needed here is already
available, making this somewhat simpler:

\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 address@hidden #})
         (map!
          (lambda (m) (ly:music-property m 'pitch))
          (extract-music melody
                         (lambda (m) (ly:music-property m 'pitch #f))))
         (apply circular-list
                (map!
                 (lambda (m) (cons (ly:music-property m 'duration)
                                   (ly:music-property m 'articulations)))
                 (extract-typed-music rhythm 'skip-event))))
   #})

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

-- 
David Kastrup

reply via email to

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