Steve,

 

I'm not familiar with music-map, but I know you can modify music using
music-map.

How about doing it twice:

First time you add a (ly:music-set-property! note 'my-chord 'yes) to the
notes inside the EventChord, and the second time you can identify the notes
from the chords using the music property my-chord

 

Jaap

 

Van: lilypond-user <lilypond-user-bounces+lilypond=de-wolff....@gnu.org>
Namens Steve Cummings
Verzonden: Wednesday, November 27, 2019 6:22 PM
Aan: lilyp...@de-wolff.org; lilypond-user@gnu.org
Onderwerp: Re: Identifying non-chord notes in Scheme

 

Jaap, thank you for taking this up but I'm not sure whether your answer
helps--yes, I can find notes within chords because they are branches of
EventChord, but those same notes also occur as individual NoteEvent events
*before* the EventChord event. If I'm trying to extract or otherwise process
only notes that *don't* belong to any chord, waiting for the ChordEvent that
follows and then backtracking would be complicated.  

I should think I could check some property of a NoteEvent ("parent" or
"chord" would be nice).  So is there any way to tell that a note is *not* a
branch (a leaf?) on any EventChord  event?

Notice that I'm using "music-map" to get a list of the events, and the list
it generates includes chord notes twice: first as separate NoteEvents and
then again as members of the Chord of which they are branches/members. If
there's no simple way to look at a NoteEvent and tell whether it is part of
a chord,  maybe there's a different way to get a list of music events that
doesn't have this duplication of chord notes. Or maybe there's a different
way entirely to approach the problem of processing/extracting non-chord
notes. 

Thanks for pointing out ContextSpeccedMusic. 

lilyp...@de-wolff.org <mailto:lilyp...@de-wolff.org>  wrote on 11/27/2019
8:45 AM:

Steve,

When you see the music expression as a tree, then the NoteEvent's belonging
to a chord are branches of an EventChord.

This is for all chords including <a c>4 etc.

And as an extra bonus:

When you have chords like "c:7+"  the EventChord's are branches (or
sub-branches) of an ContextSpeccedMusic event with the music-attribute
'context-type' = "ChordsName"

 

Jaap 

 

Van: lilypond-user
<mailto:lilypond-user-bounces+lilypond=de-wolff....@gnu.org>
<lilypond-user-bounces+lilypond=de-wolff....@gnu.org> Namens Steve Cummings
Verzonden: Tuesday, November 26, 2019 7:31 PM
Aan: lilypond-user@gnu.org <mailto:lilypond-user@gnu.org> 
Onderwerp: Identifying non-chord notes in Scheme

 

What's the test for differentiating between non-chord notes and notes within
a chord, when iterating through events in music? I can examine the notes
within a chord individually, but I can't been able to find the way to
capture notes that don't belong to a chord (or alternatively, to discard
note events do belong to a chord).

Leaning heavily on code from Giles T, here's a simple routine that displays
pitches of note events when they are encountered as such, and also when they
occur within a chord. If the goal is to process non-chord notes only, how
can I pick them out? In the listing below I've marked relevant places with
"<<--" 

Thanks,
Steve

\version "2.19"

#(use-modules (ice-9 receive)) %% so 'receive' can be used

#(define (noteEvent? music)
(eq? (name-of music) 'NoteEvent))

#(define (name-of music) 
" (display-scheme-music (ly:music-property music 'name))"
   (ly:music-property music 'name)
   )

#(define* (music-to-console music #:optional (strict-comp? #t))
  (music-map
    (lambda(mus)
     (display (name-of mus))
     (newline)
     (cond 
      ((eq? 'EventChord (name-of mus))
       (display "Chord")(newline)
        (receive (notes others)
          (partition noteEvent? (ly:music-property mus 'elements))
<<--Examine different music property?
          (map(lambda(note)(display (ly:music-property note 'pitch))) notes)
(newline)))
      ((eq? 'NoteEvent (name-of mus))
<<----- Test here?
        (display "A note event, but does it stand alone, or is it part of a
chord?")                 <<----- or here?
        (newline) (display (ly:music-property mus 'pitch))(newline))
      (else (display "(Not a note or a chord)")(newline))     
     )
     (newline)
    #{
      #mus
    #})
    music))

showNotesAndChords = #(define-music-function (music) (ly:music?)
    (music-to-console music #t))

someNotes = \transpose c f { <g b d'>4 c'4 d'4 \transpose f c {<f' a' c''>2
c'}}
\showNotesAndChords \someNotes

Reply via email to