lilypond-user
[Top][All Lists]
Advanced

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

Re: programming error for thickness/control-points of Slur


From: Thomas Morley
Subject: Re: programming error for thickness/control-points of Slur
Date: Fri, 27 May 2022 11:54:28 +0200

Am Fr., 27. Mai 2022 um 11:32 Uhr schrieb Jean Abou Samra <jean@abou-samra.fr>:
>
>
>
> Le 27/05/2022 à 11:22, Thomas Morley a écrit :
> > Hi,
> >
> > lsr-snippet "Variable bow thickness depending on length"
> > https://lsr.di.unimi.it/LSR/Item?u=1&id=1028 looks at 'control-points
> > to calculate a modified thickness.
> >
> > For recent lily-versions this throws
> > programming error: cyclic dependency: calculation-in-progress
> > encountered for Slur.thickness
> > as soon as 'control-points are called in a thickness-override.
> >
> > Stripped down example:
> >
> > \version "2.23.9"
> >
> > {
> >    \override Slur.thickness =
> >    #(lambda (grob)
> >      ;; all of below trigger the programming error
> >      (ly:slur::calc-control-points grob)
> >      ;(ly:grob-property grob 'control-points)
> >      ;((assoc-get 'control-points (ly:grob-basic-properties grob)) grob)
> >      2)
> >
> >    b1( b')
> > }
> >
> > I think I can make it work with an override for 'after-line-breaking
> > (calling 'control-points, set 'thickness to the result of calculations
> > based on the 'control-points and finally redo setting
> > 'control-points).
> >
> > Is there a better way?
>
>
> Yes, quite logical since the control points depend on the
> thickness. No, short of refactoring the C++ code, I don't
> see a better way than what you described.
>
> Best,
> Jean
>

Thanks Jean!
After further thinking and testing I'll not reset the 'control-points:
It would trash a user-tweak for \shape and ua ser-override for \shape
returns a more serious ERROR:

#(define (variable-bow-thickness-harm min-l max-l min-t max-t)
  (lambda (grob)
      (let* ((cpt (ly:grob-property grob 'control-points))
             (cp0 (car cpt))
             (cp3 (cadddr cpt))
             (dx (- (car cp3) (car cp0)))
             (dy (- (cdr cp3) (cdr cp0)))
             (len (magnitude (make-rectangular dx dy)))
             (thickness
               (cond ((< len min-l) min-t)
                     ((> len max-l) max-t)
                     (else
                       (+ min-t
                         (* (- len min-l)
                            (/ (- max-t min-t)
                               (- max-l min-l))))))))
        (ly:grob-set-property! grob 'thickness thickness)
        ;; DELETE-ME:
        (ly:grob-set-property! grob 'control-points
          ((assoc-get 'control-points (ly:grob-basic-properties grob)) grob))
          )))

{
  \override Slur.after-line-breaking = #(variable-bow-thickness-harm 1 2 1 33)

  %% \shape as override errors, if overruled by the 'thickness-override
  \shape #'((10 . 0) (0 . 0) (0 . 0) (0 . 0) ) Slur
  b1( b')

  %% \shape as tweak works, if not overruled by the 'thickness-override
  %b1-\shape #'((10 . 0) (0 . 0) (0 . 0) (0 . 0)) ( b')
}

=>
ERROR: Wrong type to apply: #<unpure-pure-container #<procedure
560c1a58a580 at ice-9/eval.scm:333:13 (a)> #<procedure 560c1a58a560 at
ice-9/eval.scm:386:13 (a . rest)> >

Cheers,
  Harm



reply via email to

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