6

In a piece I have a bunch of:

   b( es b es b es)  b( es b es b es)

repeating stuff.

I'd like to just copy-paste whatever template and insert the notes once.

I could do:

\repeat unfold 6 { c d }

or:

\repeat unfold 2 { \repeat unfold 3 { c( d) } }

but the slurs will be incorrect.

So how can I add a slur to a note sequence?

2
  • 1
    What about \repeat unfold 2 {b( \repeat unfold 2 { es b } es)}? Is there some reason that won't work for you?
    – Aaron
    Dec 20, 2023 at 18:40
  • Works, but this pattern is repeating many times. I'd like to write the notes ONCE, and in the proposed solution it appears twice.
    – pihentagy
    Dec 21, 2023 at 9:25

1 Answer 1

2

As long as you remain quite simple something like this could work for you:

enslur =
#(define-music-function (n base count music)
   ((number? 1) (ly:duration? (ly:make-duration 3)) (number? 6) ly:music?)
   #{
     << \repeat unfold #n { s$base ( s$base * $(- count 2) s$base) } #music >>
   #})

\new Voice {
  \time 6/8
  \repeat unfold 2 { \enslur \repeat unfold 3 { c8 d } }
  \enslur 2 \repeat unfold 6 { c8 d }
  \enslur 4 4 3 \repeat unfold 6 { c4 d }
}

With more complex cases the problem is that slurs generally are started on the first note and ended on the last note, which means that if you want to add a slur you’d need to add the slur end event to the last note, which means having to determine the last note relevant to the slur.

7
  • Oh, nice. I am a developer, but when engraving music, I haven't yet tried lisp. Is there a good tutorial to start with?
    – pihentagy
    Dec 21, 2023 at 9:10
  • Well, sometimes I need to add a \f mark to the first note. I guess that would quickly make things very complicated.
    – pihentagy
    Dec 21, 2023 at 9:13
  • 4
    @pihentagy extending-lilypond.gitlab.io/en/index.html
    – Lazy
    Dec 21, 2023 at 10:32
  • Also adding \f on the first note can be done by <>\f \repeat ..., adding it on later notes can be done like \after 8 \f \repeat .... Generally this \enslur could also be done like <>( \after 8*5 ) \repeat ...
    – Lazy
    Dec 21, 2023 at 10:37
  • 1
    @pihentagy This is unrelated to \enslur .... You will see the same with \repeat unfold 3 { g!? fes }. The reason is that ? and ! set the 'force-accidental property, as you can see here: \displayMusic { g g? g! g!? } (!? does the same as ?, as ? does more than !). You could do something like \repeat unfold 3 { \volta 1 g? \volta 2,3 g fes }. If you define altFirst = #(define-music-function (n first others) (number? ly:music? ly:music?) #{ \volta 1 #first \volta #(iota (1- n) 2) #others #}) you could also write this as \repeat unfold 3 { \altFirst 3 g? g fes }.
    – Lazy
    Jan 11 at 21:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.