lilypond-user
[Top][All Lists]
Advanced

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

Re: Generating music expressions from within \applyContext?


From: David Kastrup
Subject: Re: Generating music expressions from within \applyContext?
Date: Tue, 26 Jul 2016 09:48:36 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux)

"H. S. Teoh" <address@hidden> writes:

> I have a Scheme function that returns a music expression. Unfortunately,
> the expression returned depends on the properties of the context it's
> evaluated in. I.e., based on the current setting of
> Staff.dynamicAbsoluteVolumeFunction it will return a different number of
> events in the music expression.
>
> Is this possible?

\applyContext works at the process-music stage.  That's actually a bit
late to generate stream events.

> The background of this is that I'm writing a Scheme function that
> generates single-note crescendos by emitting a series of \set
> Staff.midiExpression = ... events.

Oh, but that's perfectly manageable with \applyContext.  Don't generate
any events, just call ly:context-set-property! directly.  If you don't
want to find Staff yourself, you can just write

\context Staff \applyContext (lambda ...

and then the context passed to the applyContext function will already be
a Staff context.

> Currently I've written a Scheme function that's able to generate these
> events; however, it requires me to specify numerical starting / ending
> values for midiExpression. I'd like to be able to specify dynamics
> instead of numerical values, and have the Scheme function
> automatically look up the numerical values based on the current volume
> function defined for the Staff.
>
> However, so far I haven't been able to figure out how to read the
> Staff properties except using \applyContext with a lambda, and AFAICT
> it's not possible to return a music expression from this lambda?

So far it does not sound like you want anything returned rather than
setting some properties.

-- 
David Kastrup



reply via email to

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