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: Aaron Hill
Subject: Re: Identifying non-chord notes in Scheme
Date: Wed, 27 Nov 2019 11:09:12 -0800
User-agent: Roundcube Webmail/1.3.8

Hi Steve,

Sorry for the delay in responding to your original query. But as some say, "better late, than never." (:

%%%%
\version "2.19.83"

colorNonChordNotes = #(define-music-function
  (color music) (color? ly:music?)
  (define (color-stop? mus)
    (if (music-is-of-type? mus 'note-event)
      (let* ((curr (ly:music-property mus 'tweaks '()))
             (new `((color . ,color)
                    ((Accidental . color) . ,color)))
             (tweaks (append curr new)))
        (set! (ly:music-property mus 'tweaks) tweaks))
      ;; Stop recursion on chords.
      (music-is-of-type? mus 'event-chord)))
  (for-some-music color-stop? music) music)

soprano = \fixed c' { <b e'>4 b8 d' <b e'>2 }
alto = \fixed c' { e8 d <b, e>4 dis2 }
tenor = \fixed c { <g b>4 <fis a> b2 }
bass = \fixed c { c4 d <e gis>2 }

\score {
  \colorNonChordNotes #(x11-color 'tomato)
  \new ChoirStaff <<
    \new Staff \voices 1,2 << \clef "treble" \soprano \\ \alto >>
    \new Staff \voices 1,2 << \clef "bass" \tenor \\ \bass >>
  >>
}
%%%%

Not knowing *what* you intended to do with non-chord notes, I just simply appended a few \tweaks to those notes to demonstrate the technique of using for-some-music with a custom stop? procedure.


-- Aaron Hill

Attachment: non-chord-notes.cropped.png
Description: PNG image


reply via email to

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