lilypond-user
[Top][All Lists]
Advanced

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

Re: Minor variations on a re-used section


From: Evan Driscoll
Subject: Re: Minor variations on a re-used section
Date: Sat, 22 Jun 2019 15:46:55 -0500

On Sat, Jun 22, 2019 at 3:57 AM Pierre Perol-Schneider <address@hidden> wrote:
How about using tags: http://lilypond.org/doc/v2.19/Documentation/notation/different-editions-from-one-source.html#using-tags

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 =
      #(define-music-function
        (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 {
        c1
        d-\tag #'first_rep \ff
        e-\tag #'last_rep \p
        f
      }
    }


* Another question I meant to ask in my earlier email. It seems like I can't define variables within a \relative block, so this isn't permitted:
      part = \relative c {
        ... tons of lines ...
        motif = { a b c }
        \motif
     }
This is why I prefer \repeat unfold -- with variables, I feel like I have to go to an entirely different part of the file to actually define the music, then come back to where it actually is. It also makes point and click worse, because sometimes I want to go to the use (\motif) rather than the definition.

Is there a way to define a variable "locally"?

Evan

 

HTH.
Cheers,
Pierre

Le sam. 22 juin 2019 à 09:01, Evan Driscoll <address@hidden> a écrit :
I've got a couple variants of the same question.

Suppose I have a few measures that are reused exactly multiple times. If they are adjacent, I can use '\repeat unfold' and only write it once. If they're not, I can put them into a music variable and use that.

But what can I do if they are... *almost* the same? For example, there are expressive marks I want to appear in only one of the occurrences, or a page break I only want one of. Or maybe there are "minor" modifications musically. I'll give a couple examples below of the kinds of things I'm thinking of from a piece I'm typesetting now (the piano+cello arrangement by Saint-Saens of his Danse Macabre), but ask my questions first.

1. Is there some abstraction that's worth doing that will simplify or shorten my code? (I seem to remember seeing some suggestion for example to put dynamics and other expressive marks separate from the actual music, but I can't find where I saw that, don't know if it's appropriate in my situation, and don't really know how to do it.)

2. How much effort is worthwhile to put in to avoid duplication like this? (There are some drawbacks to using music variables as well, such as the point-and-click output feature points you at the variable instead of the variable's invocation. Which is of course perfectly reasonable, but the fact that there *are* two locations of potential interest is itself a drawback.)

3. Am I just worrying about this too much? I come from a coding background where "don't repeat yourself" is a pretty strong mantra, and maybe it just doesn't work as well in this circumstance. 

For what it's worth, 90% of the time when I'm writing something with Lilypond, it's a single instrument, and I can't envision doing anything as remotely complex as a big orchestral score or whatever. There's a small-ish chance I'll do the piano part for this, and that would be the first time I've done a piano part, and that'll be a huge step up in complexity.

Thanks,
Evan

Examples:

Here's something I have in the current draft until I stop being lazy and duplicate the measures and edit the second copy:
      \repeat unfold 2 {
        fs,, a d fs a d |
        bf^\markup{\italic "stringendo"} g d bf g d |
      }
I want the stringendo to appear just the first occurrence.

Earlier in the piece, I have
      r4 <af, ef' c' af'>4 <c' af'> |
 
      % PAGE 1 LINE 10
      \break
      \repeat unfold 3 { r4 <af, ef' c' af'>4 <c' af'> | }
where I could have done '\repeat unfold 4'  and save a copy/paste, except I needed the \break in there.


As a different kind of thing, there's this theme:
      d4 | g2 g4 |  f2 f4 |  e2 e4 |  ef2 ef4 |  d g bf |  a fs d |  fs2 e4 |  d
and it appears three times. First time (actually pair of times, but I'm not counting immediate repeats) it shows up exactly as above. Second time, it's played in a different key (easy enough) with double stops where you keep going with the initial G (g4 | <g g'>2 q4 | <g f'>2 q4 | <g e'>2 q4 | ...). Third time, it's played in yet another key in octaves (a'4 |
  <d, d'>2-> q4 | <c c'>2-> q4 |  <b b'>2-> q4 | ...)


_______________________________________________
lilypond-user mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/lilypond-user

reply via email to

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