[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Separating pitch and rhythm
From: |
David Kastrup |
Subject: |
Re: Separating pitch and rhythm |
Date: |
Wed, 21 Mar 2012 19:54:10 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.94 (gnu/linux) |
Siska Ádám <address@hidden> writes:
> Dear List,
>
>
> is there an effective way to separate the pitches and the rhythms in a
> voice? I'm thinking about something like defining a variable
> consisting only of rhythms:
>
> Rhythm = {
> \time 4/4
> 4 4 4. 8
> 8 8 4 4 8 8
> 2 4 8 8 ...
> }
>
> and then apply this to different sequences of pitches:
>
> Seq1 = {
> \clef treble
> c d e f
> g a g f e d
> c e g c ...
> }
>
> Seq2 = {
> \clef bass
> c b a g
> f e f g a b
> c g e c ...
> }
#(define-public (for-some-music recurse? music)
"Walk through @var{music}, process all elements calling @var{recurse?}
and only recurse if this returns true."
(let loop ((music music))
(if (recurse? music)
(let ((elt (ly:music-property music 'element)))
(if (ly:music? elt)
(loop elt))
(for-each loop (ly:music-property music 'elements))
(for-each loop (ly:music-property music 'articulations))))))
#(define (extract-all-durations music)
(map! (lambda (m) (ly:music-property m 'duration))
(extract-music music
(lambda (m) (ly:duration?
(ly:music-property m 'duration))))))
applyRhythm =
#(define-music-function (parser location p r)
(ly:music? ly:music?)
(let ((l (extract-all-durations r)))
(for-some-music
(lambda (m)
(and (pair? l)
(if (ly:duration? (ly:music-property m 'duration))
(begin
(set! (ly:music-property m 'duration) (car l))
(set! l (cdr l))
#f)
#t)))
p))
p)
Rhythm = {
s4 s4 s4. s8
s8 s8 s4 s4 s8 s8
s2 s4 s8 s8
}
SeqI = {
\clef treble
c d e f
g a g f e d
c e g c
}
SeqII = {
\clef bass
c b a g
f e f g a b
c g e c
}
\new PianoStaff
<< \new Staff \applyRhythm \SeqI \Rhythm
\new Staff \applyRhythm \SeqII \Rhythm
>>
I have written the "for-some-music" function previously but not
committed it since I could not immediately think of an application. But
it fits the bill here reasonably nicely.
--
David Kastrup
- Re: Separating pitch and rhythm AND structure, (continued)
- Re: Separating pitch and rhythm,
David Kastrup <=