That would work, yes.  Thank you.

On Fri, Dec 5, 2025 at 8:58 AM Lukas-Fabian Moser <[email protected]> wrote:
>
> Hi Matthew,
>
> > The code in question is:
> >
> > \version "2.25.1"
> >
> > % firstNoteOfChord collapses chord objects inside a music object into
> > % single notes.  Useful for pitch squashing /chordmode objects into nice
> > % printable \improvisatoinOn rhythm notation for guitarists.
> >
> > firstNoteOfChord =
> > #(define-music-function (music) (ly:music?)
> >     (define (iter mus)
> >       (let ((elt (ly:music-property mus 'element))
> >             (elts (ly:music-property mus 'elements)))
> >         (map iter elts)
> >         (if (not (null? elt)) (iter elt))
> >         (if (and (music-is-of-type? mus 'event-chord) (not (null? elts)))
> >             (ly:music-set-property! mus 'elements (list (car elts))))))
> >     (iter music)
> >     music)
> >
> > Assuming that I'd have to extract and add items based on what's in the
> > variable mus.  I'm still not understanding quite well enough to see
> > what to access to fetch any accents/articulations added to them.
>
> Something like this?
>
> % firstNoteOfChord collapses chord objects inside a music object into
> % single notes.  Useful for pitch squashing /chordmode objects into nice
> % printable \improvisatoinOn rhythm notation for guitarists.
>
> #(define (is-note? mus) (music-is-of-type? mus 'note-event))
>
> #(define (invert-predicate pred?) (lambda (x) (not (pred? x))))
>
> firstNoteOfChord =
> #(define-music-function (music) (ly:music?)
>     (define (iter mus)
>       (let ((elt (ly:music-property mus 'element))
>             (elts (ly:music-property mus 'elements)))
>         (map iter elts)
>         (if (not (null? elt)) (iter elt))
>         (if (music-is-of-type? mus 'event-chord)
>             (let ((first-note (find is-note? elts)))
>               (if first-note
>                   (ly:music-set-property! mus 'elements
>                                           (cons first-note
>                                                 (filter
> (invert-predicate is-note?) elts))))))))
>     (iter music)
>     music)
>
> \firstNoteOfChord \chordmode {
>    e16:9_>
> }
>
> This keeps all elements of chords that are not notes.
>
> Lukas
>

Reply via email to