[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: |
Wed, 31 Jan 2018 02:35:59 +0100 |
2018-01-31 0:00 GMT+01:00 Michael Winter <address@hidden>:
> That is really beautiful. Thank you. I have been giving myself a crash
> course in scheme and was also getting somewhat closer to a solution using a
> glissando event. Then the internet went down. And low and behold it woke up
> to your response.
>
> So this is almost what I want. And I need to dissect your code a bit more
> (again, still wrapping my head around scheme). Maybe I can adapt it. My
> ultimate goal is to specify the gradient within the given note length (as
> opposed to giving a new color directive for every note. This is where it
> gets tricky. In my current attempt (drowning in the deep end), it is a bit
> tricky because you cannot change colors in the middle of a path directive.
> So you need to combine several markups (as in my original example). I was
> piecing together stuff I found on LSR and in the user archive and was also
> having a huge problem with alignment. My current code is pasted below. It is
> a mess, but getting there. I just was reading about returning markup
> definitions in hopes that I could iterate through the gradient and build the
> markup that way.
>
> En fin, I will study your code. Like I said, it is almost exactly what I
> want except I want the gradient within the note length. Of course, any help
> in that direction will be much appreciated.
>
> Best,
>
> Michael
How about below then:
\version "2.19.65"
\paper { ragged-right = ##f }
\layout {
\context {
\Staff
\override StaffSymbol.line-count = #1
}
\context {
\Voice
\override Glissando.minimum-length = #0
%% n.b. line-breaks are TODO
\override Glissando.breakable = ##t
\override Glissando.after-line-breaking = ##t
\override Glissando.bound-details =
#'((right
(attach-dir . 0)
(end-on-accidental . #f)
(padding . 0.))
(left
(attach-dir . 0)
(padding . 0.)))
}
}
#(define (make-grey-filled-box-stencil-list x-coords color-steps half-thick rl)
(if (null? (cdr x-coords))
rl
(make-grey-filled-box-stencil-list
(cdr x-coords)
(cdr color-steps)
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))
(x11-color
(string->symbol (format #f "grey~a" (car color-steps)))))
rl))))
#(define my-gliss
(lambda (grob)
(if (ly:stencil? (ly:line-spanner::print grob))
(let* ((left-bound-info (ly:grob-property grob 'left-bound-info))
(left-Y (assoc-get 'Y left-bound-info))
(left-X (assoc-get 'X left-bound-info))
(right-bound-info (ly:grob-property grob 'right-bound-info))
(right-X (assoc-get 'X right-bound-info))
(thick (ly:grob-property grob 'thickness 0.5))
(delta-X (- right-X left-X))
(steps
(assoc-get 'color-steps (ly:grob-property grob 'details) 100))
(raw-color-steps
(iota (abs steps) 0 (round (/ 100 (min 100 (abs steps))))))
(color-steps
(if (negative? steps)
(reverse raw-color-steps)
raw-color-steps))
(x-coords (iota (1+ (abs steps)) 0 (/ delta-X (abs steps)))))
;; 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
color-steps
thick
'()))
;; the actual offset is TODO, hardcoded here
-8
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'8
}
\new Staff \mus
\new Staff {
%% negative value reverses colors
\override Glissando.details.color-steps = -100
%% thicker
\override Glissando.thickness = 2
\mus
}
\new Staff {
%% less steps, default (and max) is 100
\override Glissando.details.color-steps = 5
%% thinner
\override Glissando.thickness = 0.2
\mus
}
Cheers,
Harm
atest-70-2.png
Description: PNG image
- test spanner with controlled gradient / dynamic volume curve indicated by grey level, Michael Winter, 2018/01/30
- Re: test spanner with controlled gradient / dynamic volume curve indicated by grey level, Michael Winter, 2018/01/30
- Re: test spanner with controlled gradient / dynamic volume curve indicated by grey level, Thomas Morley, 2018/01/30
- Re: test spanner with controlled gradient / dynamic volume curve indicated by grey level, Michael Winter, 2018/01/30
- Re: test spanner with controlled gradient / dynamic volume curve indicated by grey level, David Kastrup, 2018/01/30
- Re: test spanner with controlled gradient / dynamic volume curve indicated by grey level, Karlin High, 2018/01/30
- Re: test spanner with controlled gradient / dynamic volume curve indicated by grey level,
Thomas Morley <=
- Re: test spanner with controlled gradient / dynamic volume curve indicated by grey level, Michael Winter, 2018/01/30
- Re: test spanner with controlled gradient / dynamic volume curve indicated by grey level, Thomas Morley, 2018/01/31
- Re: test spanner with controlled gradient / dynamic volume curve indicated by grey level, Michael Winter, 2018/01/31
- Re: test spanner with controlled gradient / dynamic volume curve indicated by grey level, Michael Winter, 2018/01/31
- Re: test spanner with controlled gradient / dynamic volume curve indicated by grey level, Michael Winter, 2018/01/31
- Re: test spanner with controlled gradient / dynamic volume curve indicated by grey level, Michael Winter, 2018/01/31
- Re: test spanner with controlled gradient / dynamic volume curve indicated by grey level, Thomas Morley, 2018/01/31
- Re: test spanner with controlled gradient / dynamic volume curve indicated by grey level, Thomas Morley, 2018/01/31
- Re: test spanner with controlled gradient / dynamic volume curve indicated by grey level, Michael Winter, 2018/01/31
- Re: test spanner with controlled gradient / dynamic volume curve indicated by grey level, Michael Winter, 2018/01/31