[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
makeOctaves (LSR 445) 2.15 (ugly quick fix)
From: |
Jan-Peter Voigt |
Subject: |
makeOctaves (LSR 445) 2.15 (ugly quick fix) |
Date: |
Mon, 05 Mar 2012 15:18:28 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux i686; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2 |
Hello list,
I made a quick fix for the makeOctaves function from
http://lsr.dsi.unimi.it/LSR/Item?id=445
Since 2.15.x notes may appear as single NoteEvents *not* wrapped in an
EventChord, I added a check for 'NoteEvent and did a map on EventChord
elements.
This is an ugly solution, because EventChords are octaved twice.
But it works for the moment.
If my googling was wrong and there is a better solution around, a hint
is appreciated.
Cheers, Jan-Peter
--snip--
\version "2.15.31"
#(define (octave-up m octave)
(let* ((old-pitch (ly:music-property m 'pitch))
(new-note (ly:music-deep-copy m))
(new-pitch (ly:make-pitch
(+ octave (ly:pitch-octave old-pitch))
(ly:pitch-notename old-pitch)
(ly:pitch-alteration old-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)
(cond ((eq? (ly:music-property music 'name) 'EventChord)
(ly:music-set-property! music 'elements (octavize-chord
(map (lambda (e) (if (eq? (ly:music-property music
'name) 'EventChord)
(car (ly:music-property e
'elements)) e)) (ly:music-property music 'elements)) t)))
((eq? (ly:music-property music 'name) 'NoteEvent)
(set! music (make-music 'EventChord 'elements (list
music (octave-up music t) ))))
)
music)
#(define-public makeOctaves (define-music-function (parser location arg
mus) (integer? ly:music?)
(music-map (lambda (x) (octavize x arg)) mus)))
\makeOctaves #1 \relative c' { <c e>4 c }
--snip--
- makeOctaves (LSR 445) 2.15 (ugly quick fix),
Jan-Peter Voigt <=