lilypond-user
[Top][All Lists]
Advanced

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

Re: measurePosition within a music function?


From: Marc Hohl
Subject: Re: measurePosition within a music function?
Date: Sun, 07 Mar 2010 10:02:30 +0100
User-agent: Thunderbird 2.0.0.23 (X11/20090817)

Carl Sorensen schrieb:

On 3/5/10 5:05 AM, "Marc Hohl" <address@hidden> 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





reply via email to

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