Thank you Valentin. This is great. Works perfectly and also instructive for
a relative newbie to Scheme.

On Mon, 6 Feb 2023 at 16:49, Valentin Petzel <valen...@petzel.at> wrote:

> Hello Adam,
>
> Using #{ ... #} does not magically register the music or something. A
> scheme
> expression such as (begin ...) will evaluate to the last statement. So
>
> (begin #{ ... #} (enact-tempo-decrease ...))
>
> will simply evaluate to the second part, thus always to #{#}.
>
> What you do in fact need to do is to gather the music created thus into a
> list, most cleanly by using a separate recursion function (so
> (define-music-
> function (...) (...) (define (rec steps) ...) #{ #@(rec steps) #} )) or by
> using
>
> (make-music 'SequentialMusic 'elements (cons #{ ... #} (ly:music-property
> (enact-tempo-decrease ...) 'elements))
>
> But as I already said in my previous response you can do this easier using
> map.
>
> With regards to that version: To handle negative values simply add a
> filter
> call:
>
> myRall =
> #(define-music-function
>   (steps duration)
>   (integer? ly:duration?)
>   (let* ((tempi-list (iota steps 100 -1))
>          (tempi-list (filter (lambda (x) (> x 0)) tempi-list))
>          (tempi-mus (map (lambda (t) #{ \tempo 4 = $t s$duration #}) tempi-
> list)))
>     #{ #@tempi-mus #}))
>
> Cheers,
> Valentin
>
> Am Montag, 6. Februar 2023, 07:50:02 CET schrieb Adam M. Griggs:
> > I've given it some more work. The \repeat construct is gone, and the
> > displayed messages indicate that my recursion is working correctly.
> >
> > Metronome marks are not yet printed, however. What am I missing? Also,
> I'm
> > getting a wrong type argument error message when I try to (let*
> > (current-tempo (car tempo-list))). I feel like I'm almost there though.
> >
> > Code attached, and thanks again.
> >
> > On Mon, 6 Feb 2023 at 14:19, Adam M. Griggs <adammgri...@gmail.com>
> wrote:
> > > Hello list,
> > >
> > > I'm trying to create a Scheme function that will automatically
> calculate
> > > and enact a *rall*. as a sequence of \tempo assignments. I am aware of
> > > the basic *rall*., *rit*., and *accel*. functions in "articulate.ly"
> but
> > > I wanted something I have a little more control over.
> > >
> > > I need help, and I don't know if it's just in the implementation
> details
> > > or my overall approach to the problem.
> > >
> > > For now, it's just a *rall*. The algorithm describing the rate of
> > > slowdown is extremely basic but that can be adjusted later.
> > >
> > > My approach so far has been to create a list of values starting at 100
> > > (let's assume percentages of the initial tempo and work that in later)
> and
> > > then have them trickle down. Using #(display ...), I see this is
> working
> > > just fine.
> > >
> > > Clearly my \repeat call isn't appropriate here and I should replace it
> > > with a recursive function call containing just its body (the {\tempo 4
> =
> > > ... \skip ...} part). And I'm sure I'm not really going to get anywhere
> > > with #@tempi-list but I hope it communicates what I'm aiming for. I've
> > > been
> > > playing with this for a few hours but I haven't been able to get the
> parts
> > > to mesh together. I could keep stabbing at it, or ask for help here.
> > >
> > > Code attached, and thank you!
>
>

Reply via email to