Urs Liska <li...@openlilylib.org> 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

_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to