Hi Trevor!
Hey John :-)
Le dimanche 14 décembre 2008 à 12:42 -0600, Trevor Bača a écrit :
> Is there a way to print out the name (or other identity) of the
> currently active voice just before any given note or rest in an input
> file?
> Does something like this exist?
I haven't found such a function in Lily sources and docs, try these two
music functions (freely inspired from barNumberCheck definition):
whichContext = #(define-music-function (parser location) ()
(make-music 'ApplyContext
'origin location
'procedure (
lambda (c)
(display
(string-append
"\nCurrent voice is "
(ly:context-id c)
"\n")))))
locationWhichContext = #(define-music-function (parser location) ()
(make-music 'ApplyContext
'origin location
'procedure (
lambda (c)
(display
(ly:input-message location
"current voice is ~a"
(ly:context-id c))))))
Oh wow: these are *super* helpful! Exactly what I was looking for.
Thanks, John!
It's also possible to make Scheme avatars of these functions, but then
they would need to take the location as an argument.
This should be added to the docs IMHO; should this be added in LSR, the
manual or the (yet to be written) docstring of applyContext?
> [The motivation is that I'm researching the way that LilyPond
> determines which voice music events are assigned to ... from a user's
> perspective based solely on looking at input files. Voice-resolution
> in the example above is of course quite clear; voice-resolution when
> there are multiple anonymous voices, possibly in parallel, has become
> extremely tricky as I've written more and more test files, all of
> which I'll be happy to post if anyone else is interested in that sort
> of thing.]
Please do :-) I guess some of these tests may be added to LSR.