lilypond-user
[Top][All Lists]
Advanced

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

Find Voice/etc. context from Staff/etc. context


From: Urs Liska
Subject: Find Voice/etc. context from Staff/etc. context
Date: Wed, 11 Jul 2018 10:19:03 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0

One more understanding question regarding contexts and engravers.

If I \consist an engraver in a bottom context like Voice I can travel up the chain of parent contexts, retrieving their name and id properties. But if I \consist it in Staff level contexts I don't see if/how I can get to the bottom-level context a grob is possibly in.

The issue is: the annotations I'm working on check the context's context-id to determine if it has an explicit name (for example "Flute 3"). It can travel upwards to find names like "Flutes staff", "winds" or "my-score".

In order to be able to catch explicit names on voice level I need to \consist the engraver to all bottom contexts. But then staff-level grobs like time signatures are of course not detected in the engraver. If on the other hand I \consist the engraver to the staff-level contexts explicit voice-level names are not found.

One solution I think would work to \consist the engraver in both bottom and staff-level contexts. Originally that would cause voice-level grobs to be processed twice (resulting in duplicate annotations) but I can avoid that by checking if the grob has already been recorded. This would require one (if (not (memq grob all-grobs))) check for each acknowledged grob, with all-grobs seemingly of length between 0 and 40 (from what I've seen so far).

Anyway, even if it works it seems somewhat inefficient and hacky to me to \consist the engraver to both Voice and Staff and filter out matches that way. So it would seem more plausible if it is possible to get to the bottom context's name and id from a staff-level engraver. Is that possible?

Well, a final solution would be to simply not support voice-level explicit names and start on staff-level. Usually that is what one wants to see anyway, but I can imagine one would still want to see the voice-level names, for example in comined parts where I would want the annotation to announce "flute 2" rather than "flutes".

Urs




reply via email to

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