[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: command for 'sequences'?
From: |
Rune Zedeler |
Subject: |
Re: command for 'sequences'? |
Date: |
Fri, 21 Sep 2001 21:11:02 +0200 |
jos wrote:
> I have a lilypond question: is there a command for
> making sequences of notes?
Not a command but it's easy in scheme
Notice how I just use the lilypond transpose for keys different from C
major.
\version "1.4.1"
#(define ((shift-pitch amount) p)
(let* ((o (pitch-octave p))
(a (pitch-alteration p))
(n (pitch-notename p)))
(set! n (+ amount n))
(while (< n 0) (begin (set! o (- o 1)) (set! n (+ n 7))))
(while (> n 6) (begin (set! o (+ o 1)) (set! n (- n 7))))
(make-pitch o n a)))
#(define ((shift amount) music)
(let* ((es (ly-get-mus-property music 'elements))
(e (ly-get-mus-property music 'element))
(p (ly-get-mus-property music 'pitch))
(body (ly-get-mus-property music 'body))
(alts (ly-get-mus-property music 'alternatives)))
(if (pair? es)
(ly-set-mus-property
music 'elements
(map (shift amount) es)))
(if (music? alts)
(ly-set-mus-property
music 'alternatives
((shift amount) alts)))
(if (music? body)
(ly-set-mus-property
music 'body
((shift amount) body)))
(if (music? e)
(ly-set-mus-property
music 'element
((shift amount) e)))
(if (pitch? p)
(begin
(set! p ((shift-pitch amount) p))
(ly-set-mus-property music 'pitch p)))
music))
sega = \notes \relative c' <
\context Voice=va {\stemUp e8^4 f e g^5 d^2 e}
\context Voice=vb {\stemDown c4._2 b_1 }
>
segb = \notes \relative c'' <
\context Voice=va {\stemUp e4.^4 f^5 }
\context Voice=vb {\stemDown c8_2 b c a d^4 c }
>
sequence = \notes {
\sega
\apply #(shift 1) \sega
\apply #(shift 2) \sega
\apply #(shift 3) \sega
\apply #(shift 4) \sega
\apply #(shift 5) \sega
\apply #(shift 6) \sega
\segb
\apply #(shift -1) \segb
\apply #(shift -2) \segb
\apply #(shift -3) \segb
\apply #(shift -4) \segb
\apply #(shift -5) \segb
\apply #(shift -6) \segb
<
\context Voice=va {\stemUp e'2.}
\context Voice=vb {\stemDown c'2.}
>
}
\score {
\notes \context Staff {
\time 6/8
\sequence
\transpose g' \sequence
\transpose d' \sequence
\transpose a' \sequence
}
\paper { }
\midi { \tempo 8=180 }
}