[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
accessing absolute pitch data from within \relative?
From: |
Mark Polesky |
Subject: |
accessing absolute pitch data from within \relative? |
Date: |
Mon, 15 Jun 2009 22:42:36 -0700 (PDT) |
I want to retrieve absolute pitch data from within a \relative
block but I can't figure it out. Here's my work so far. Probably
there's a much easier way. If so, let me know!
By the way, is this a -user or a -devel question? Sometimes I
post to -devel just so I don't scare -user newbies away with
advanced stuff. Is that a misuse of -devel?
Thanks.
- Mark
__________________
\version "2.13.1"
#(begin
(use-modules (ice-9 pretty-print))
(define (EventChord? music)
(eq? (ly:music-property music 'name) 'EventChord))
(define (EventChord->NoteEvents EventChord)
(filter
(lambda (x) (eq? (ly:music-property x 'name) 'NoteEvent))
(ly:music-property EventChord 'elements)))
(define (NoteEvents->pitches NoteEvents)
(map (lambda (x) (ly:music-property x 'pitch)) NoteEvents))
(define (EventChord->pitches EventChord)
(NoteEvents->pitches (EventChord->NoteEvents EventChord)))
)
displayPitches =
#(define-music-function (parser location mus) (ly:music?)
(music-map
(lambda (x)
(if (EventChord? x) (pretty-print (EventChord->pitches x)))
x)
mus))
% running \displayPitches *outside* of \relative prints the
% correct pitches:
\displayPitches \relative { <e g b>8. }
% ==> (#<Pitch e' > #<Pitch g' > #<Pitch b' >)
% but running \displayPitches *inside* \relative prints the wrong
% pitches:
\relative { \displayPitches <e g b>8. }
% ==> (#<Pitch e > #<Pitch g > #<Pitch b >)
- accessing absolute pitch data from within \relative?,
Mark Polesky <=