lilypond-user
[Top][All Lists]
Advanced

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

Re: Discern single note-event from one in a chord


From: David Kastrup
Subject: Re: Discern single note-event from one in a chord
Date: Sun, 01 Jul 2018 10:04:41 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

Urs Liska <address@hidden> writes:

> Hi,
>
> is there a way to discern whether the ly:music? passed into a music
> function is a single note-event or a note within a chord?
>
> \version "2.19.80"
>
> testType =
> #(define-music-function (music)(ly:music?)
>    (ly:message "Music type(s): ~a" (ly:music-property music 'types))
>    music)
>
> {
>   \clef bass
>   \testType c
>   <c \testType e g>
> }
>
> prints `Music type(s): (event note-event rhythmic-event
> melodic-event)` in both cases.
>
>
> Is there anything else besides the 'types music-property I can check
> for in this context?

No.

> I hope there is because there are many respects in which the two would
> have to be treated differently.

Which ones?

> Is there maybe a way to get to a music's "parent" in order to check
> what type that is?

No.  A music function is a local transform.  It does not get to see
where its result is being used.  You can use its result in a variable
which you may use both as a single note and inside of a chord.

If you want to work with music in context, you need to analyze stream
events in an engraver.

-- 
David Kastrup



reply via email to

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