[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: LSR octavation function
From: |
Jay Anderson |
Subject: |
Re: LSR octavation function |
Date: |
Sat, 31 May 2008 06:23:37 +0000 (UTC) |
User-agent: |
Loom/3.14 (http://gmane.org/) |
Tao Cumplido <tao_lilyponduser <at> gmx.net> writes:
> i.e. \octaves { \times 2/3 { c'4 c' c' } }
> results in a crash.
Ugh! I'm learning. Here's a quick fix that seems to work:
#(define (octave-up m t)
(let* ((octave (1- t))
(new-note (ly:music-deep-copy m))
(new-pitch (ly:make-pitch
octave
(ly:pitch-notename (ly:music-property m 'pitch))
(ly:pitch-alteration (ly:music-property m 'pitch)))))
(set! (ly:music-property new-note 'pitch) new-pitch)
new-note))
#(define (octavize-chord elements t)
(cond ((null? elements) elements)
((eq? (ly:music-property (car elements) 'name) 'NoteEvent)
(cons (car elements)
(cons (octave-up (car elements) t)
(octavize-chord (cdr elements) t))))
(else (cons (car elements) (octavize-chord (cdr elements ) t)))))
#(define (octavize music t)
(if (eq? (ly:music-property music 'name) 'EventChord)
(ly:music-set-property! music 'elements (octavize-chord
(ly:music-property music 'elements) t)))
music)
octaves = #(define-music-function (parser location arg mus) (integer? ly:music?)
(music-map (lambda (x) (octavize x arg)) mus))
\relative c'
{
\time 3/8
\key gis \minor
\octaves #1 { dis8( e dis')~ dis8.( cis16 b8}
\octaves #-1 { ais' gis dis) cis( dis <dis gis'>) }
\time 4/4
\octaves #1 { \times 2/3 {c,4 d e} \times 2/3 {c4 \times 2/3 {d8 e g} c,4} }
\octaves #-1 { \repeat unfold 8 {\times 2/3 {c'16 d e} } }
}