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: Carl Sorensen
Subject: Re: measurePosition within a music function?
Date: Fri, 5 Mar 2010 07:32:45 -0700



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, 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.

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.

HTH,

Carl





reply via email to

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