[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Set a temporary tempo change
From: |
David Kastrup |
Subject: |
Re: Set a temporary tempo change |
Date: |
Mon, 18 Nov 2019 15:24:34 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) |
Aaron Hill <address@hidden> writes:
> 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:
It isn't. It maintains the "stack" in a global variable rather than
some context property, meaning that when several iterations interlock
(like with tempo being changed in several contexts or in polyrhythmic
situations), chaos will ensue.
>
> %%%%
> \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
>
>
--
David Kastrup
- Set a temporary tempo change, Paolo Prete, 2019/11/17
- Re: Set a temporary tempo change, David Kastrup, 2019/11/17
- Re: Set a temporary tempo change, Aaron Hill, 2019/11/17
- Re: Set a temporary tempo change, Aaron Hill, 2019/11/17
- Re: Set a temporary tempo change, Paolo Prete, 2019/11/17
- Re: Set a temporary tempo change,
David Kastrup <=
- Re: Set a temporary tempo change, Aaron Hill, 2019/11/18
- Re: Set a temporary tempo change, Thomas Morley, 2019/11/18
- Re: Set a temporary tempo change, Aaron Hill, 2019/11/18
- Re: Set a temporary tempo change, Aaron Hill, 2019/11/18
- Re: Set a temporary tempo change, Thomas Morley, 2019/11/18