diff options
author | David Kastrup <dak@gnu.org> | 2015-12-04 16:09:00 +0100 |
---|---|---|
committer | David Kastrup <dak@gnu.org> | 2015-12-28 09:53:08 +0100 |
commit | 0365d088246f222afe9f9a91818ab949d2f13336 (patch) | |
tree | 2e3f3e63f960d49b23e3e5dee9c3f984d1783da0 | |
parent | fe98061250a3f14181bcdc119ce0d66ddfdbd444 (diff) |
Issue 4702/1: Implement `music-pitches' function
-rw-r--r-- | scm/music-functions.scm | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/scm/music-functions.scm b/scm/music-functions.scm index d5a4b2478a..325da29dd5 100644 --- a/scm/music-functions.scm +++ b/scm/music-functions.scm @@ -2073,6 +2073,21 @@ are expanded using the default settings of the parser." (map (lambda (x) (ly:music-property x 'pitch)) (event-chord-notes event-chord))) +(define-public (music-pitches music) + "Return a list of all pitches from @var{music}." + ;; Opencoded for efficiency. + (reverse! + (let loop ((music music) (pitches '())) + (let ((p (ly:music-property music 'pitch))) + (if (ly:pitch? p) + (cons p pitches) + (let ((elt (ly:music-property music 'element))) + (fold loop + (if (ly:music? elt) + (loop elt pitches) + pitches) + (ly:music-property music 'elements)))))))) + (define-public (event-chord-reduce music) "Reduces event chords in @var{music} to their first note event, retaining only the chord articulations. Returns the modified music." |