lilypond-user
[Top][All Lists]
Advanced

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

sequences


From: Thomas Fehr
Subject: sequences
Date: Mon, 12 Jan 2009 15:33:45 +0100
User-agent: Thunderbird 2.0.0.19 (Windows/20081209)

I am looking for a way to create sequences in a key. The old posting I found (Re: command for 'sequences'? Rune Zedeler Fri, 21 Sep 2001) is written for an old version.

leaving away the old stuff I get to this solution - which does not work. Any help available

Thomas

\version "2.12.1"

#(define  ((shift-pitch amount) p)
 (let* ((o (ly:pitch-octave p))
        (a (ly:pitch-alteration p))
        (n (ly: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))))

   (ly: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 (ly:music? alts)
       (ly:set-mus-property!         music 'alternatives
        ((shift amount) alts)))

   (if (ly:music? body)
       (ly:set-mus-property!         music 'body
        ((shift amount)  body)))

   (if (ly:music? e)
       (ly:set-mus-property!         music 'element
        ((shift amount) e)))

   (if (ly:pitch? p)
       (begin
         (set! p ((shift-pitch amount) p))
         (ly:set-mus-property!music 'pitch p)))

   music))

   seg = {c' d' e' d' }
{
       \seg
         \apply #(shift 1) \seg
         \apply #(shift 2) \seg
   }





reply via email to

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