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 23:38:48 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux)

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

> On Tue, Jul 26, 2016 at 09:48:36AM +0200, David Kastrup wrote:
>> "H. S. Teoh" <address@hidden> writes:
> [...]
>> > 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.
>
> Sound good, but how do I set the property at evenly-spaced time
> intervals from inside the lambda?
>
> The main problem I'm having is that the number of intervals will differ
> depending on the volume levels of the given dynamics. Since the MIDI
> expression controller only has 127 discrete volume levels, if I'm going
> from 0 to 127 then I'd need 127 property changes, but if I'm going from
> 64 to 96 I only need 32 property changes.  But I wouldn't know this
> until the \applyContext lambda is called. How do I insert property
> changes at regularly-spaced intervals from inside the lambda?

No, this is something entirely different since you want things to happen
at more than one point of time.  SequentialMusic can generate its
elements via the elements-callback hook, but this hook only has the
SequentialMusic expression itself to work with.

But semi-continuous controller changes in Midi don't make sense to
require actual iteration by LilyPond.  Instead this should be made a
feature of the Midi backend.

I don't see a feasible way to do that in the current state of LilyPond
by mere Scheme programming.

-- 
David Kastrup



reply via email to

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