Carl Sorensen schrieb:
On 3/5/10 5:05 AM, "Marc Hohl" <m...@hohlart.de> wrote:
This works fine, but I wanted to evaluate the position of the current note
within the current bar. I found the measurePosition property, but to use
ly:context-property context 'measurePosition
in my function, I need the appropriate context. How can I achieve that?
(I think it must be something very simple, but digging in the sources and
the manuals, I didn't get a hint. the lsr provides a solution with
\applyOutput, but this doesn't work here).
It's actually not simple at all,
Great to hear that I didn't overlook the obvious ;-)
because music functions are evaluated
during the parsing stage, when events are put on the music tree, rather than
during the iteration/translation stage when the events are handed to
contexts. Therefore, you need something in your music function that will
have evaluation delayed until the translation stage when a context will be
provided as an argument.
This was something I didn't understand when I started working on the
autobeaming. And it caused me lots of grief until I figured out a
workaround.
Thanks for clarification!
The workaround is to create a context-spec-music expression and export it
with ly:export. You can see some examples at the bottom of
scm/beam-settings.scm. I won't promise that they're good examples, but they
are examples.
I'll have to study this in more detail, but I am not sure whether
this is the right way to go.
The main idea behind this question is a function which converts straight
eights into swing style. I think I managed the mathematic and
algorithmic stuff already more or less completely (for any positive
swing factor x:y), and I had a look at Peter Chubb's articulate.ly to get
an idea of how to go further.
For the swing stuff, I need the position of the note within the measure.
Another (and probably more straightforward) way to solve this
would be to just sum up all the durations modulo the length of a
measure.
On the other hand, a more generic solution should be included into
the lily/*-performer.cc structure, isn't it?
Marc
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user