lilypond-user
[Top][All Lists]
Advanced

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

Re: What to do wanting a 4th order Bézier?


From: Thomas Morley
Subject: Re: What to do wanting a 4th order Bézier?
Date: Sat, 17 Sep 2016 21:34:03 +0200

2016-09-17 20:45 GMT+02:00 Kieren MacMillan <address@hidden>:
> Hi Simon,
>
>> I’m attaching an excerpt from my current project, where I’d actually really 
>> need a 4th order Bézier slur – but that’s impossible with Lily now. 
>> Unfortunately I also lack an idea what else to do in this situation – I’d 
>> like to avoid an extra staff…
>> Any ideas?
>
> What about something like this "compound slur"?
> (Obviously, you could/should spend more time to really make the slur nice.)
>
> %%%  SNIPPET BEGINS
> \version "2.19.46"
> \language "deutsch"
>
> slurfixA = {
>   \shape #'((1 . -2.625) (2 . 1) (-32 . -14) (-28.25 . -5)) Slur
> }
> slurfixB = {
>   \shape #'((0 . 1.5) (4 . 6) (-4 . 2) (-0.5 . -3)) Slur
> }
>
> upper = \relative {
>   \key d \major
>   \clef bass
>   s2 r8 d,16 g h d g h
>   d8 r s2.
>   s4 \voiceTwo h8.(-- c16-- h2--)
> }
> lower = \relative {
>   \key d \major
>   \clef bass
>   r2 \slurfixA <d' h g=>~-^\=1(
>   <<
>     {
>       <d h g>4 \slurfixB <c g e>\=2( <h g> \voiceOne cis
>       \change Staff = upper
>       \clef treble \voiceOne d e fis2\=1)\=2)\fermata
>     }
>     \new Voice {
>       \voiceTwo
>       s2. <g,= e>4 \oneVoice
>       <fis h,> <g e> <fis dis>2\fermata
>     }
>   >>
> }
> \score {
>   <<
>     \new PianoStaff <<
>       \new Staff = upper \upper
>       \new Staff = lower \lower
>     >>
>   >>
> }
> %%%  SNIPPET ENDS
>
> Hope that helps!
> Kieren.



Hi Simon,

Kieren already demonstrated a possible workaround.

Below my own approach, probably a very first step in the direction
David mentioned.
You'll need to find all the values manually. Displaying the original
control-points and/or making the new ones visible with those crosses
may help.

\version "2.19.47"
\language "deutsch"

#(define (proc grob)
  (let*  (;; only here for reference:
          (cps (ly:slur::calc-control-points grob))
          (cps1
            '((0.6 . 5.8)
              (3.6 . 7.8)
              (25.0 . 5.0)
              (32 . 12)))
          (cps2
            '((32 . 12)
              (39.0 . 17.5)
              (53.1 . 16.0)
              (55.5 . 12.5)))
          (first-spline-stil
            (begin
              (ly:grob-set-property! grob 'control-points cps1)
              (ly:slur::print grob)))
          (second-spline-stil
            (begin
              (ly:grob-set-property! grob 'control-points cps2)
              (ly:slur::print grob)))
          ;; annotates all new control-points
          (crosses
            (apply
              ly:stencil-add
              (map
                (lambda (c)
                  (make-cross-stencil c))
                (append cps1 cps2))))
                )
  ;(pretty-print cps)
  ;; returns
  ;;  ((0.631380973009261 . 7.545004)
  ;;   (3.65053718406404 . 9.82511349243875)
  ;;   (53.1972252988833 . 16.0566485774538)
  ;;   (56.6869647738747 . 14.5951692170292))

  (ly:stencil-add
    first-spline-stil
    second-spline-stil
    ;; comment next line to get rid of the crosses
    crosses
    )))

upper = \relative {
  \key d \major
  \clef bass
  s2 r8 d,16 g h d g h
  d8 r s2.
  s4 \voiceTwo h8.(-- c16-- h2--)
}
lower = \relative {
  \key d \major
  \clef bass
  r2
  \override Slur.stencil = #proc
  <d' h g=>~-^(
  <<
    {
      <d h g>4 <c g e> <h g> \voiceOne cis
      \change Staff = upper
      \clef treble \voiceOne d e fis2)
      \fermata
    }
    \new Voice {
      \voiceTwo
      s2. <g,= e>4 \oneVoice
      <fis h,> <g e> <fis dis>2\fermata
    }
  >>
}
\score {
  <<
    \new PianoStaff <<
      \new Staff = upper \upper
      \new Staff = lower \lower
    >>
  >>
}


Cheers,
  Harm



reply via email to

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