[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
In octaves
From: |
Jay Anderson |
Subject: |
In octaves |
Date: |
Sun, 13 Apr 2008 08:45:21 -0700 |
I found myself writing long sections like these in some piano parts:
{<c c'> <d d'> <e e'> <f f'>}
I wrote a function to add the upper octave for me:
\octaves {c d e f}
I though that I'd share:
#(define (octave-up noteevent)
(let* ((pitch (ly:music-property noteevent 'pitch))
(octave (ly:pitch-octave pitch))
(note (ly:pitch-notename pitch))
(alteration (ly:pitch-alteration pitch))
(duration (ly:music-property noteevent 'duration))
(newnoteevent
(make-music 'NoteEvent
'duration duration
'pitch (ly:make-pitch (1+ octave) note alteration))))
newnoteevent))
#(define (octavize-chord elements)
(cond ((null? elements) elements)
((eq? (ly:music-property (car elements) 'name) 'NoteEvent)
(cons (car elements)
(cons (octave-up (car elements))
(octavize-chord (cdr elements)))))
(else (cons (car elements) (octavize-chord (cdr elements))))))
#(define (octavize music)
(let* ((es (ly:music-property music 'elements))
(e (ly:music-property music 'element))
(name (ly:music-property music 'name)))
(cond ((eq? name 'EventChord)
(ly:music-set-property! music 'elements (octavize-chord es)))
((pair? es)
(for-each (lambda(x) (octavize x)) es))
((ly:music? e)
(octavize e))))
music)
octaves = #(define-music-function (parser location mus) (ly:music?)
(octavize mus))
I tried << {c d e f} {c' d e f} >> but it didn't look right so I
resorted to a function. Is there an easier way to do this?
-----Jay
- In octaves,
Jay Anderson <=
- Re: In octaves, Wilbert Berendsen, 2008/04/14
- Re: In octaves, Valentin Villenave, 2008/04/24
- Re: In octaves, Jonathan Kulp, 2008/04/24
- Message not available
- Re: In octaves, Valentin Villenave, 2008/04/24
- Re: In octaves, Jonathan Kulp, 2008/04/24
- Re: In octaves, Valentin Villenave, 2008/04/24
- Re: In octaves, Jonathan Kulp, 2008/04/24
- Re: In octaves, Jay Anderson, 2008/04/24
- Re: In octaves, Valentin Villenave, 2008/04/25