Am Sa., 30. Nov. 2019 um 19:43 Uhr schrieb Paolo Prete <p4olo_pr...@yahoo.it>: > > Hello, > > given a note/rest/chord/skip-event is there a way to display the name of its > staff? I need to check if it belongs to staff "UP" or "DOWN" of a piano-staff. > What if I use map-some-music() function? > > %%%%%%%%%%%%%%%% > > (map-some-music (lambda (evt) > (let ((name (ly:music-property evt 'name))) > (cond > ((or (eq? name 'NoteEvent )(eq? name 'EventChord) (eq? name > 'RestEvent ) (eq? name 'SkipEvent )) > > %%%%%%% (display ?????) %%%%%%%%% > > evt) > (else #f)))) ; => #f = continue, go deeper > music) > > %%%%%%%%%%%%%%%% > > Thanks.
There are not many methods to access context and grob at the same time. \applyOutput is one of them printStaffID = \applyOutput Staff.NoteHead #(lambda (grob ctx c) (pretty-print (ly:context-id c) )) musI = { c1 \printStaffID d } \new Staff = "foo" \musI musII = { c1 \change Staff = "up" \printStaffID d } \new PianoStaff << \new Staff = "up" s1*2 \new Staff = "down" \musII >> HTH, Harm