lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Identifying non-chord notes in Scheme


From: Steve Cummings
Subject: Re: Identifying non-chord notes in Scheme
Date: Wed, 27 Nov 2019 09:21:52 -0800
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.1

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.

address@hidden 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 <lilypond-user-bounces+lilypond=address@hidden> Namens Steve Cummings
Verzonden: Tuesday, November 26, 2019 7:31 PM
Aan: address@hidden
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

[Prev in Thread] Current Thread [Next in Thread]