Die höchste Note in einem Akkord/scheme
Zur Navigation springen
Zur Suche springen
#(use-modules (srfi srfi-11))
#(define (higher? note1 note2)
(let* ((p1 (ly:music-property note1 'pitch))
(p2 (ly:music-property note2 'pitch)))
(and (ly:pitch<? p2 p1)
note2
note1)))
#(define (high-note-chord music)
"Reduces event chords in @var{music} to their first note event,
retaining only the chord articulations. Returns the modified music."
(map-some-music
(lambda (m)
(and (music-is-of-type? m 'event-chord)
(let*-values
(((notes arts)
(partition
(lambda (mus)
(music-is-of-type? mus 'rhythmic-event))
(ly:music-property m 'elements)))
((
full-arts)
(append arts
(ly:music-property m 'articulations)))
((highest) (car (sort notes higher?)))
)
(cond
(highest
(set! (ly:music-property highest 'articulations)
full-arts)
highest)
((ly:duration? dur)
(make-music 'NoteEvent
'duration dur
'articulations full-arts))
(else
;; This is an empty chord. Ugh. We cannot really
;; reduce this in any manner, so we just keep it.
m)))))
music))