[Top][All Lists]

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

Re: Minor variations on a re-used section

From: Aaron Hill
Subject: Re: Minor variations on a re-used section
Date: Sat, 22 Jun 2019 14:19:55 -0700
User-agent: Roundcube Webmail/1.3.8

On 2019-06-22 1:46 pm, Evan Driscoll wrote:
Originally I was going to say that would work well in many cases if I have
a music variable, but I don't know how to use them in the context of
\repeat unfold, which I very much prefer when applicable(*).

But I realized that I could write something that helps here. Any thoughts on the following? Am I missing something that means I don't have to do this?
    \version "2.19.80"

    fancy_repeat_unfold =
        (parser location rep_spec notes)
        (integer? ly:music?)
          \removeWithTag #'last_rep  $notes
          \removeWithTag #'(first_rep last_rep)
              \repeat unfold #(- rep_spec 2) $notes
          \removeWithTag #'first_rep $notes

    \relative c' {
      \fancy_repeat_unfold 3 {
        d-\tag #'first_rep \ff
        e-\tag #'last_rep \p

I would opt for a design like this which is more flexible w.r.t. the naming and number of tags to be used:

\version "2.19.82"

#(define (multipleWithTagHelper proc)
  (define (symbol-list-list? x)
    (and (list? x) (every symbol-list? x)))
  (define-music-function (tags music) (symbol-list-list? ly:music?)
    #{ $@(map (lambda (x) #{ $proc $x $music #}) tags) #} ))

multipleKeepWithTag = #(multipleWithTagHelper keepWithTag)
multipleRemoveWithTag = #(multipleWithTagHelper removeWithTag)

  \multipleKeepWithTag #'((a) (a b) (b))
  { \tag #'a a'4 \tag #'b b'4 c''4 }
  \multipleRemoveWithTag #'((a) (a b) (b))
  { \tag #'a a'4 \tag #'b b'4 c''4 }

-- Aaron Hill

reply via email to

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