[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
NoteEvent->grob ?
From: |
Mark Polesky |
Subject: |
NoteEvent->grob ? |
Date: |
Tue, 16 Jun 2009 12:32:28 -0700 (PDT) |
Given a NoteEvent expression, is there a way to access
the grob associated with it? I'm trying to access staff-
positions of notes within chords, and I want to do so
using music-map from within a music-function definition.
Maybe there's a better way, but this is the direction
I've taken so far.
(make-music
'NoteEvent
'duration
(ly:make-duration 2 0 1 1)
'pitch
(ly:make-pitch 0 0 0))
I'm imagining something like this, but fill in the "..."
_______________________________
\version "2.13.1"
#(begin
(use-modules (ice-9 pretty-print))
(define (EventChord? music)
(eq? (ly:music-property music 'name) 'EventChord))
(define (NoteEvent? music)
(eq? (ly:music-property music 'name) 'NoteEvent))
(define (EventChord->NoteEvents EventChord)
(filter NoteEvent?
(ly:music-property EventChord 'elements)))
(define (NoteEvent->grob NoteEvent)
...)
(define (get-staff-position NoteEvent)
(ly:grob-property (NoteEvent->grob NoteEvent)
'staff-position))
(define (get-staff-positions EventChord)
(map get-staff-position
(EventChord->NoteEvents EventChord)))
(define showPositions
(define-music-function (parser location mus) (ly:music?)
(music-map
(lambda (x)
(if (EventChord? x)
(pretty-print (get-staff-positions x)))
x)
mus)))
) %end of (begin ...)
\relative { \showPositions { <c e g> <d f a> } }
%{
the desired output for this would be:
(-6 -4 -2)
(-5 -3 -1)
%}
_______________________________
Or is there a better access staff-positions for individual
notes in a chord? I know I can use an override like below,
but it's not the console display that I care about. I'd
like to be able to access staff-positions of each chord as
a list, or something like that, so I can use it, as I
mentioned, with music-map within a music-function.
_______________________________
%% so, this doesn't really help me.
\relative {
\override NoteHead #'stencil =
#(lambda (grob)
(pretty-print (ly:grob-staff-position grob))
(ly:note-head::print grob))
<c e g> <d f a>
}
Anyone?
Thanks.
- Mark
- NoteEvent->grob ?,
Mark Polesky <=