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: Paolo Prete
Subject: Re: Set a temporary tempo change
Date: Mon, 18 Nov 2019 01:51:03 +0000 (UTC)

Aaron,

that's great.
I propose to the ML to add the function to the official release. It's very helpful when you want to make the midi output more realistic, with frequent tempo changes

Il lunedì 18 novembre 2019, 00:11:29 CET, Aaron Hill <address@hidden> ha scritto:


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]