bug-lilypond
[Top][All Lists]
Advanced

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

Re: Changing volta number text


From: Ralph Palmer
Subject: Re: Changing volta number text
Date: Fri, 14 May 2021 18:40:59 -0700

On Fri, May 14, 2021 at 5:13 PM Aaron Hill <lilypond@hillvisions.com> wrote:

> On 2021-05-14 2:47 pm, Ralph Palmer wrote:
> > I *did* find a thread in the archive :
> > change of volta number
> > which has gotten me close, but has an extra end-repeat before the first
> > volta ending bracket. I'm also not sure the format is the most recent.
>
> How about this?
>
> %%%%
> \version "2.22.0"
> \include "english.ly"
>
> changeVoltaText =
> #(define-music-function
>    (text) (markup?)
>    (define (is-volta-text? cmd)
>     (and (pair? cmd) (eq? 'volta (car cmd)) (markup? (cadr cmd))))
>    (define (replace-volta-text cmd)
>     (if (is-volta-text? cmd) `(volta ,text) cmd))
>    (define (proc ctxt)
>     (let ((cmds (ly:context-property ctxt 'repeatCommands)))
>      (set! cmds (map replace-volta-text cmds))
>      (ly:context-set-property! ctxt 'repeatCommands cmds)))
>    #{ \context Score \applyContext #proc #} )
>
> test = {
>    \time 3/4
>    \repeat volta 3
>    {
>      a'4 b' c' |
>      b'4 c' d' |
>    }
>    \alternative {
>      {
>        \changeVoltaText "1., 3."
>        e'4 f' g' |
>      }
>      {
>        d'4 c' b' |
>      }
>      {
>        \changeVoltaText \markup \with-color #red "4."
>        g'4 a' b' |
>      }
>    }
>    c'1
> }
>
> \score {
>    \test
> }
> %%%%
>
> NOTE: I'm using \markup in the final alternative just to demonstrate
> that it works.
>
>
> -- Aaron Hill
>

Excellent! Thank you, Aaron. I wish I could understand what your function
does - how it works.

Would it make sense to add this to either the Lilypond Snippet Repository
or the documentation or both?

All the best,

Ralph

-- 
Ralph Palmer
Seattle
USA
(he, him, his)
palmer.r.violin@gmail.com


reply via email to

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