[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
shift-music
From: |
Laurent Martelli |
Subject: |
shift-music |
Date: |
20 Feb 2001 16:44:35 +0100 |
User-agent: |
Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 |
Based on smart-transpose, here's music-shift. It will just shift notes
by one delta degrees in the current key. It's very usefull for
typesetting scale execises.
#(define (shift-pitch p delta)
(make-pitch
(pitch-octave p)
(+ (pitch-notename p) delta)
(pitch-alteration p)))
#(define (shift-music music delta)
(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 (lambda (x) (shift-music x delta)) es)))
(if (music? alts)
(ly-set-mus-property
music 'alternatives
(shift-music alts delta)))
(if (music? body)
(ly-set-mus-property
music 'body
(shift-music body delta)))
(if (music? e)
(ly-set-mus-property
music 'element
(shift-music e delta)))
(if (pitch? p)
(begin
(set! p (shift-pitch p delta))
(ly-set-mus-property music 'pitch p)))
music))
pattern = \notes \relative c' { c8 d16 e f g a b | c4 r | }
\score {
\context Staff {
\notes \relative c' {
\time 2/4;
\pattern
\apply #(lambda (x) (shift-music x 1))
\pattern
\apply #(lambda (x) (shift-music x 2))
\pattern
}
}
}
--
Laurent Martelli
address@hidden http://www.linuxfan.com/~laurent
- shift-music,
Laurent Martelli <=