Aaron, thanks a million for the solution (with the convincing demo).
I'm examining note data rather than tweaking output, but with your
example as a guide the rest will be 'easy' (as easy as Scheme goes for me).
If you have time for a question: The "for-some-music" function is new to
me. Any quick comments when to use each of the different
functions/methods for recursion through input music? Or do you know of
any tutorials/explications of recursion through music? LilyPond offers
'music-map,' 'map-some-music,' and 'for-some-music,' and I've also
seen code based on plain old 'map.'
Steve
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
non-chord-notes.cropped.png*
*