lilypond-user
[Top][All Lists]
Advanced

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

Re: Calculate BarLine 'kern to fit with a given stencil-x-extent


From: Thomas Morley
Subject: Re: Calculate BarLine 'kern to fit with a given stencil-x-extent
Date: Wed, 10 Jul 2013 02:24:05 +0200

2013/7/6 Pierre Perol-Schneider <address@hidden>:
> 2013/7/5 Pierre Perol-Schneider <address@hidden>
>>
>>
>> kern =x-length*1,4*EXP(-(LN(0,14)/LN(20)*LN(Staff-Size)))
>>
>
> Dear Harm, dear David,
>
> Here's a simplified version of the kernel.
> It's exactly the same fuction :
>
> kernel = 1.4*x-length/Staff-size^[ln(0,14)/ln(20)]
>
> Sorry for being so slow, i'm a litlle rusty with log calculation.
>
> Enc. is a better copy of this function.
>
> Now I have to leave for vacations, i promise you'll won't here from me for
> the next days ;).
>
> Have fun !
> Pierre

Hi Pierre,

I wrote a testing-function: \show
It calls a 'adjust-kern', where I tried to write your calculation
using scheme, and a new markup-command: \rectangle as replacement for
\draw-line (on purpose of better viewing).
The value in
#(define staff-size 35)
is used for 'set-global-staff-size' and 'adjust-kern' to ease typing.
This value should be changed in order to test with different sizes.
Several possibilities to read out all kind of values are commented.

So far as I can observe the calculations isn't exact: with higher or
lower staff-size values it goes increasingly wrong.
Did I something wrong while tranforming your calculation into scheme?

Regards,
  Harm

\version "2.17.21"

%% A markup-command for better viewing and the possibility
%% to read out some values
#(define-markup-command (rectangle layout props x) (number?)
" returns a rectangle "
   (let ((osc (ly:output-def-lookup layout 'output-scale))
         (pt (ly:output-def-lookup layout 'pt)))

    ;; (display "\n\t'output-scale \t")(write osc)
    ;; (display "\n\tpt from layout \t")(write pt)
    ;; (display "\n\t(* osc pt) \t")(write (* osc pt))
    ;; (newline)

   (interpret-markup layout props
     (markup #:stencil (make-filled-box-stencil  `(0 . ,x) '(0 . 3))))))

\paper {
        indent = 30
        %% #(display "\n\tpt from within \\paper \t")
        %% #(write pt)
}

\layout {
        % Better viewing:
        \override Score.RehearsalMark #'color = #red
        \override Score.RehearsalMark #'layer = #10
        \override Score.RehearsalMark #'extra-offset = #'(0 . -2.5)
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Test here with different values:

#(define staff-size 16)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

#(set-global-staff-size staff-size)

#(define (adjust-kern staff-size x-lngth)
;; Pierre's calculation
   (/
     (* 10 0.14 x-lngth)
     (expt staff-size (/ (log 0.14) (log 20)))))


show =
#(define-music-function (parser location x-length)(number?)
"
 returns some test-music, with the rectangle and tweaked BarLine.kern
"
#{
        \set Staff.instrumentName =
        \markup \fontsize #-1 \center-column {
                "stencil/kern-length?"
                #(number->string x-length)
        }
        
        R1
        \mark \markup
        \rectangle #x-length
        \override Staff.BarLine.kern = #(adjust-kern staff-size x-length)
        \bar "||"
        R1
#})

\header {
        title = "Adjust BarLine 'kern to stencil-extent"
        subtitle = #(format #f "Used global-staff-size: ~a" staff-size)
        subsubtitle = \markup \vspace #2
}

\show #1
\show #2
\show #10
\show #20



reply via email to

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