Paolo Prete <paolopr...@gmail.com> writes: > On Thu, Oct 21, 2021 at 2:01 PM David Kastrup <d...@gnu.org> wrote: > >> Paolo Prete <paolopr...@gmail.com> writes: >> >> > On Thu, Oct 21, 2021 at 1:22 PM David Kastrup <d...@gnu.org> wrote: >> > >> >> Paolo Prete <paolopr...@gmail.com> writes: >> >> >> >> > Hello, >> >> > >> >> > after a \tempo X = Y is set, is there a way (a scheme function or >> >> > variable?) to get X and Y? >> >> >> >> What does "after" mean and "is set"? At a later point in the source >> >> text, at a later time in musical execution? >> >> >> >> >> > yes >> >> Those are two different things entirely. "yes" as an answer is not >> suitable. >> > > > Sorry, I used a bad quote of the text. With "yes" I mean "at a later point > in the source text".
And then you go on to give an example where clearly "at a later time in musical execution" is desired. >> > unfortunately this doesn't sound trivial to achieve, and I presume >> > that tempoWholesPerMinute is not in the API. >> >> I have no idea what you mean by "is not in the API". What is the API >> according to your definition? >> >> > API is the public interface exposed to the user. I assumed that > tempoWholesPerMinute was internal stuff, > but I just checked that it IS in the API: > https://lilypond.org/doc/v2.22/Documentation/internals/tempo_005fperformer Given that the manual is called "Internals", you may need to adjust your terminology to that other LilyPond users work with. > Anyway, I don't know if it fits what I need. More specifically, I'm > trying to obtain in the midi output the behavior of growing beams > (Beam.grow-direction). For example, a sort of accelerando from a fixed > metronome (which is not the previous metronome mark). After the beam, > the metronome must be reset to the initial value. For example: > > %%%%%%%%%%%%%%%%%%% > { > > \tempo 4 = 120 > > c'4 > > \override Beam.grow-direction = #RIGHT > %start from \tempo 4 = 40 > c'16[ > % \tempo 4 = 40 + 20% > c' > % \tempo 4 = 40 + 40% > c' > % \tempo 4 = 40 + 60% > c'] > > %reset \tempo to 4 = 120 > c'4 > > } > %%%%%%%%%%%%%%%%%%% > > I already wrote a Scheme function that increases a tempo by 20% for each > note grouped by the beam, starting from a chosen value, but I don't know > how to reset the tempo after the beam. Here's a cut&paste of something I currently use in scores of mine for doing things like accelerando, ritardando, and so on. tempoChange = #(define-music-function (interval endscale thenscale music) (ly:duration? scale? (scale? 1) ly:music?) "Make a gradual tempo change over @var{music}, essentially changing speed after every duration of @var{interval}, approaching a factor of speed of @var{endscale} compared to the start. Afterwards, tempo is switched to @var{thenscale} of the original speed (default 1). If @var{thenscale} is 0, the speed reached at the end is just maintained and can be overriden with an explicit @samp{\\tempo} command if required." (define (scaletempo oldscale newscale) (make-apply-context (lambda (ctx) (set! (ly:context-property ctx 'tempoWholesPerMinute) (ly:moment-mul (ly:context-property ctx 'tempoWholesPerMinute) (ly:make-moment (/ newscale oldscale))))))) (let* ((muslen (ly:moment-main (ly:music-length music))) (intlen (ly:moment-main (ly:duration-length interval))) (steps (/ muslen intlen)) (endfactor (scale->factor endscale)) (thenfactor (scale->factor thenscale))) (make-simultaneous-music (list music (context-spec-music (make-sequential-music (let loop ((rsteplst (iota (1+ steps) endfactor (/ (- 1 endfactor) steps))) (res (if (positive? thenfactor) (list (scaletempo endfactor thenfactor)) (list)))) (if (null? (cdr rsteplst)) res (loop (cdr rsteplst) (cons* (scaletempo (cadr rsteplst) (car rsteplst)) (make-skip-music (ly:make-duration 0 0 intlen)) res))))) 'Score))))) See if that helps you achieve your objective. -- David Kastrup