lilypond-user
[Top][All Lists]
Advanced

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

Re: Set a temporary tempo change


From: Aaron Hill
Subject: Re: Set a temporary tempo change
Date: Sun, 17 Nov 2019 15:10:46 -0800
User-agent: Roundcube Webmail/1.3.8

On 2019-11-17 12:38 pm, Paolo Prete wrote:
Hello,
is it possible to revert a tempo change to the previous tempo setting,
without explicitly writing this previous one? 
Something like (pseudo-code):
\tempo 4 = 120  { ...some music .... } \temporaryTempo 4 = 160 { ...
some other music .... } \unset \temporaryTempo

Not sure if this is really the right way to do things:

%%%%
\version "2.19.83"

#(define tempoStack '())
pushTempo = #(define-music-function () ()
  (define (pushTempoHelper ctx)
    (let ((tempo (ly:context-property ctx 'tempoWholesPerMinute #f)))
      (set! tempoStack (cons tempo tempoStack))))
  #{ \context Score \applyContext $pushTempoHelper #})
popTempo = #(define-music-function () ()
  (define (popTempoHelper ctx)
    (let ((tempo (car tempoStack)))
      (ly:context-set-property! ctx 'tempoWholesPerMinute tempo)
      (set! tempoStack (cdr tempoStack))))
  #{ \context Score \applyContext $popTempoHelper #})

\score {
  {
    \markLengthOn
    \bar "||" \tempo "Andante" 4=90
    \repeat unfold 2 { b'4 4 4 4 }
    \bar "||" \pushTempo \tempo "Allegro" 4=140
    \repeat unfold 2 { b'4 4 4 4 }
    \bar "||" \popTempo \tempo "a tempo"
    \repeat unfold 2 { b'4 4 4 4 }
  }
  \layout {} \midi {}
}
%%%%


-- Aaron Hill



reply via email to

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