lilypond-user
[Top][All Lists]
Advanced

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

Re: test spanner with controlled gradient / dynamic volume curve indicat


From: Thomas Morley
Subject: Re: test spanner with controlled gradient / dynamic volume curve indicated by grey level
Date: Thu, 1 Feb 2018 01:35:33 +0100

2018-02-01 1:28 GMT+01:00 Thomas Morley <address@hidden>:
> 2018-01-31 19:02 GMT+01:00 Michael Winter <address@hidden>:
>
>> I am now curious what you are thinking about the line breaking. Maybe I am
>> out to lunch here and you have a much better idea. I will wait to hear from
>> you before I do any heavy lifting.
>
>
> I'm very busy. My shitty regular job eats far too much time.
> So no point in waiting for me. I'll almost surely come back, but I
> don't know when.
> And well, sometimes I need some leisure time as well ...
>
> Nevertheless, here some thoughts and a new coding.
>
> Line-breaks:
> (1)
> bound-details are extended with settings for left/right-broken
> causing better padding/aligning
> (2)
> The part on the new line gets all colors again.
> One could think of distributing the colors over first and second part,
> more complicated though.
> (3)
> colors now don't rely on the predefined anymore.
> You can set arbitrary steps, I tested with 1000.
> Well, the result is more fine-grained then my pdf-viewer or my screen
> can handle, lol.
> (4)
> various other changes, ask if not clear.
>
> Here the code:
>
> \version "2.19.65"
>
> \paper { ragged-right = ##f }
>
> \layout {
>   \context {
>       \Staff
>       \override StaffSymbol.line-count = #1
>       \omit Clef
>   }
>   \context {
>       \Voice
>       \override Glissando.minimum-length = #0
>       %% construction-helper, delete-me
>       \override Glissando.layer = 500
>       %% n.b. line-breaks are TODO
>       \override Glissando.breakable = ##t
>       \override Glissando.after-line-breaking = ##t
>         \override Glissando.bound-details =
>         #'((right
>              (attach-dir . -1)
>              (end-on-accidental . #f)
>              (padding . 0))
>            (right-broken
>              (padding . 0.5))
>            (left-broken
>              (padding . 0.5)
>              (attach-dir . 1))
>            (left
>              (attach-dir . -1)
>              (padding . 0)
>              (start-at-dot . #f)))
>     }
> }
>
> #(define (make-grey-filled-box-stencil-list x-coords colors half-thick rl)
>   (if (null? (cdr x-coords))
>       rl
>       (make-grey-filled-box-stencil-list
>         (cdr x-coords)
>         (cdr colors)
>         half-thick
>         (cons
>           (stencil-with-color
>             (make-filled-box-stencil
>               (interval-widen (cons (car x-coords) (cadr x-coords)) 0.1)
>               (cons (- half-thick) half-thick))
>             (car colors))
>           rl))))
>
> #(define my-gliss
>   (lambda (grob)
>     (if (ly:stencil? (ly:line-spanner::print grob))
>         (let* ((stencil (ly:line-spanner::print grob))
>                (X-ext (ly:stencil-extent stencil X))
>                (Y-ext (ly:stencil-extent stencil Y))
>                (Y-length (- (cdr Y-ext) (car Y-ext)))
>                (left-bound-info (ly:grob-property grob 'left-bound-info))
>                (left-Y (assoc-get 'Y left-bound-info))
>                (thick
>                  (assoc-get 'thickness (ly:grob-property grob 'details) 0.5))
>                (layout (ly:grob-layout grob))
>                (blot (ly:output-def-lookup layout 'blot-diameter))
>                (right-bound (ly:spanner-bound grob RIGHT))
>                (right-par (ly:grob-parent right-bound X))
>                (stem
>                  (if (grob::has-interface right-par 'note-column-interface)
>                      (ly:grob-object right-par 'stem)
>                      '()))
>                (stem-stencil
>                  (if (ly:grob? stem)
>                      (ly:grob-property stem 'stencil)
>                      #f))
>                (stem-thick
>                  (if (ly:stencil? stem-stencil)
>                      (interval-length (ly:stencil-extent stem-stencil X))
>                      0))
>                (corr-delta-X (- (interval-length X-ext)
>                     Y-length
>                     blot
>                     stem-thick
>                     ;; mmh, why this value??
>                     -0.01))
>                (steps
>                  (assoc-get 'color-steps (ly:grob-property grob 'details) 
> 100))
>                (raw-colors
>                  (map
>                    (lambda (e)
>                      (make-list 3 e))
>                  (iota (abs steps) 0 (/ 1.0 (abs steps)))))
>                (colors
>                  (if (negative? steps)
>                      (reverse raw-colors)
>                      raw-colors))
>                (raw-x-coords
>                  (iota (1+ (abs steps)) 0 (/ corr-delta-X (abs steps))))
>                (x-coords
>                  (map
>                    (lambda (e)
>                      (+ (car X-ext) Y-length blot e))
>                    raw-x-coords)))
>
>           ;; create a flat glissando
>           (ly:grob-set-nested-property! grob '(right-bound-info Y) left-Y)
>
>           ;; return the stencil of added boxes
>           (ly:stencil-translate-axis
>              (apply
>                ly:stencil-add
>                (make-grey-filled-box-stencil-list
>                  x-coords
>                  colors
>                  thick
>                  '()))
>             ;; the actual offset is TODO, hardcoded here
>               -5
>             Y))
>          #f)))
>
> #(define (add-gliss m)
>    (case (ly:music-property m 'name)
>      ((NoteEvent)
>       (set! (ly:music-property m 'articulations)
>             (append
>               (ly:music-property m 'articulations)
>               (list (make-music 'GlissandoEvent))))
>       m)
>      (else #f)))
>
> addGliss =
> #(define-music-function (music)
>   (ly:music?)
>   (map-some-music add-gliss music))
>
> %%%%%%%%%%%%%%%%%%%%%%%%%
> %% EXAMPLE
> %%%%%%%%%%%%%%%%%%%%%%%%%
>
> mus =
>   {
>     \addGliss {
>       \override Glissando.stencil = #my-gliss
>       b'16 b'16 b'8 b'4
>       \override Staff.Beam.color = #(x11-color 'grey60)
>       b'8 b'16 b'16 ~
>     }
>     %% n.b. If glissando-skip is #t \addGliss needs to be interrupted
>     %% otherwise a programming error occurs
>     \once \override NoteColumn.glissando-skip = ##t
>     b'16
>     \addGliss {
>       b'16 b'8
>     %% a final target for the last glissando needs to be present, otherwise
>     %% lily complains about unterminated glissando
>     b'1\glissando
>     \break
>     b'1
>     \break
>     }
>     s b'
>   }
> <<
>   \new Staff \mus
>
>   \new Staff {
>     %% negative value reverses colors
>     \override Glissando.details.color-steps = -100
>     %% thicker
An oversight, this should rather be:
    %% We go for Glissando.details.thickness, because Glissando.thickness would
    %% affect the stencil-extent
    \override Glissando.details.thickness = 2
>     \override Glissando.thickness = 2
>     \mus
>   }
>
>   \new Staff {
>     \override Glissando.details.color-steps = -1000
>     \mus
>   }
>>>
>
>
> Cheers,
>   Harm



reply via email to

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