Discussion:
Glissando tweaks in chords
Peter Crighton
2018-12-07 00:49:51 UTC
Permalink
Hello all,

I have the following (reduced) scenario where one voice has a chord with a
glissando in it and I want to tweak both glissandos differently. Is it
possible? The second (currently commented out) tweak is never applied even
if I comment out the first tweak.

\version "2.19.82"
one = \relative c'' {
g2
-\tweak Y-offset #0.25
\glissando a
}
two = \relative c'' {
\context Voice = "one" {
c2
% this tweak is never applied
% -\tweak Y-offset #-0.25
\glissando d
}
}
\new Staff <<
\new Voice = "one" \one
\two
Thanks,
Peter

--
Peter Crighton | Musician & Music Engraver based in Mainz, Germany
http://www.petercrighton.de
Ben
2018-12-07 01:48:17 UTC
Permalink
Post by Peter Crighton
Hello all,
I have the following (reduced) scenario where one voice has a chord
with a glissando in it and I want to tweak both glissandos
differently. Is it possible? The second (currently commented out)
tweak is never applied even if I comment out the first tweak.
\version "2.19.82"
one = \relative c'' {
  g2
  -\tweak Y-offset #0.25
  \glissando a
}
two = \relative c'' {
  \context Voice = "one" {
    c2
    % this tweak is never applied
    % -\tweak Y-offset #-0.25
    \glissando d
  }
}
\new Staff <<
  \new Voice = "one" \one
  \two
Thanks,
Peter
Hi Peter,


If you just want to tweak the top line of the gliss, for example, you
could try this maybe? Or did I misunderstand?

Does that help?

(see attached)

one = \relative c'' {
  \override Voice.Glissando.extra-offset =
    #(lambda (grob)
       (if (= 1 (ly:grob-property grob 'glissando-index)) '(0.5 . 0.5)
'(0 . 0)))
  g2
  -
  \glissando a
}
two = \relative c'' {
  \context Voice = "one" {
    c2
    % this tweak is never applied
    % -\tweak Y-offset #-0.25
    \glissando d
  }
}
\new Staff <<

  \new Voice = "one" \one
  \two
Ben
2018-12-07 01:55:34 UTC
Permalink
Post by Peter Crighton
Hello all,
I have the following (reduced) scenario where one voice has a chord
with a glissando in it and I want to tweak both glissandos
differently. Is it possible? The second (currently commented out)
tweak is never applied even if I comment out the first tweak.
\version "2.19.82"
one = \relative c'' {
  g2
  -\tweak Y-offset #0.25
  \glissando a
}
two = \relative c'' {
  \context Voice = "one" {
    c2
    % this tweak is never applied
    % -\tweak Y-offset #-0.25
    \glissando d
  }
}
\new Staff <<
  \new Voice = "one" \one
  \two
Thanks,
Peter
Actually, I was wrong about that sorry - I missed something in testing it.
Ben
2018-12-07 01:59:06 UTC
Permalink
Post by Peter Crighton
Hello all,
I have the following (reduced) scenario where one voice has a chord
with a glissando in it and I want to tweak both glissandos
differently. Is it possible? The second (currently commented out)
tweak is never applied even if I comment out the first tweak.
\version "2.19.82"
one = \relative c'' {
  g2
  -\tweak Y-offset #0.25
  \glissando a
}
two = \relative c'' {
  \context Voice = "one" {
    c2
    % this tweak is never applied
    % -\tweak Y-offset #-0.25
    \glissando d
  }
}
\new Staff <<
  \new Voice = "one" \one
  \two
Thanks,
Peter
A while ago, there was a function created that allowed tweaks like
you're asking - I think this is what you are looking for :) It should
get you started.

http://lilypond.1069038.n5.nabble.com/How-to-tweak-override-the-individual-Glissando-objects-in-a-chord-td149575.html

(see attached)


\version "2.19.82"

#(define (radians->degree radians)
  (/ (* radians 180) PI))

#(define ((gliss-plus-text padding text) grob)
  (let* ((text-stencil (grob-interpret-markup grob text))
         (spanner-stencil (ly:line-spanner::print grob))
         (left-bound-info (ly:grob-property grob 'left-bound-info))
         (y-left (cdar left-bound-info))
         (right-bound-info (ly:grob-property grob 'right-bound-info))
         (y-right (cdar right-bound-info))
         (slant (if (> y-right y-left) 1 -1))
         (spanner-stencil-x-length
            (interval-length (ly:stencil-extent spanner-stencil X)))
         (spanner-stencil-y-length
            (interval-length (ly:stencil-extent spanner-stencil Y)))
         (alpha
            (radians->degree
              (atan (/ spanner-stencil-y-length
spanner-stencil-x-length))))
         (spanner-center-X
            (interval-center (ly:stencil-extent spanner-stencil X)))
         (label-center-X (interval-center (ly:stencil-extent
text-stencil X))))
  (ly:stencil-combine-at-edge
    spanner-stencil
    Y UP
    (ly:stencil-translate
      (ly:stencil-rotate text-stencil (* slant alpha) 0 0)
      (cons (- spanner-center-X label-center-X) 0))
    (+ (* -0.5 spanner-stencil-y-length) padding))))

glissTweak =
#(define-music-function (parser location lst)(pair?)
#{
       \once \override Glissando #'after-line-breaking =
          #(lambda (grob)
            (let ((gliss-count (ly:grob-property grob 'glissando-index)))
            (map (lambda (x)
              (let ((gliss-nmbr (car x))
                    (property-value-alist (cdr x)))
                (if (eq? gliss-nmbr gliss-count)
                  (map
                    (lambda (y) (ly:grob-set-property! grob (car y)
(cdr y)))
                    property-value-alist)
                  #f)))
;             $lst))) % for Version "2.14.2"
              lst)))
       $(make-music 'EventChord 'elements (list (make-music
'GlissandoEvent)))
#})

tweakedGliss = {
        \once \override Glissando #'minimum-length = #8
        \once \override Glissando #'springs-and-rods =
          #ly:spanner::set-spacing-rods
}

\relative c' {
        \override TextScript #'font-size = #-2

        <c e g bes d>2\glissando^"\"no tweaks\""
        <d, a' fis' c' e'>

        \tweakedGliss
        \glissTweak
          #`((0 . ((color . ,red)
                   (normalized-endpoints . (0 . 0.8))
                   (stencil . ,(gliss-plus-text -1.8
                                 (markup #:italic #:fontsize -8
"gliss.")))))
             (1 . ((style . zigzag)))
             (2 . ((style . trill)
                   (color . (0.5 0.5 0.5))))
             (3 . ((style . dashed-line)))
             (4 . ((stencil . ,(gliss-plus-text 0
                                 (markup #:italic #:fontsize -8 "gliss.")))
                   (normalized-endpoints . (0 . 0.7))
                   (color . ,green))))
        <c' e g bes d>2^"\"some tweaks\""
        <d, a' fis' c' e'>

        \once \override Glissando #'(bound-details right arrow) = ##t
        \glissTweak
          #`((0 . ((style . dashed-line)
                   (normalized-endpoints . (0 . -2.1))))
             (1 . ((stencil . #f)))
             (2 . ((stencil . #f)))
             (3 . ((stencil . #f)))
             (4 . ((style . dashed-line)
                   (normalized-endpoints . (0 . -1.5)))))
        <c' e g bes d>2^"\"some other tweaks\""
        <d, a' fis' c' e'>

}
Peter Crighton
2018-12-07 05:06:35 UTC
Permalink
Post by Peter Crighton
Hello all,
I have the following (reduced) scenario where one voice has a chord with a
glissando in it and I want to tweak both glissandos differently. Is it
possible? The second (currently commented out) tweak is never applied even
if I comment out the first tweak.
\version "2.19.82"
one = \relative c'' {
g2
-\tweak Y-offset #0.25
\glissando a
}
two = \relative c'' {
\context Voice = "one" {
c2
% this tweak is never applied
% -\tweak Y-offset #-0.25
\glissando d
}
}
\new Staff <<
\new Voice = "one" \one
\two
Thanks,
Peter
A while ago, there was a function created that allowed tweaks like you're
asking - I think this is what you are looking for :) It should get you
started.
http://lilypond.1069038.n5.nabble.com/How-to-tweak-override-the-individual-Glissando-objects-in-a-chord-td149575.html
Thanks, that helped a lot! I boiled it down to:

\version "2.19.82"
glissTweak =
#(define-music-function (parser location lst)(pair?)
#{
\once \override Glissando #'after-line-breaking =
#(lambda (grob)
(let ((gliss-count (ly:grob-property grob 'glissando-index)))
(map (lambda (x)
(let ((gliss-nmbr (car x))
(property-value-alist (cdr x)))
(if (eq? gliss-nmbr gliss-count)
(map
(lambda (y) (ly:grob-set-property! grob (car y) (cdr
y)))
property-value-alist)
#f)))
lst)))
$(make-music 'EventChord 'elements (list (make-music
'GlissandoEvent)))
#})

one = \relative c'' {
\glissTweak #`((0 . ((Y-offset . 0.25)))
(1 . ((Y-offset . -0.25))))
g2 a
}
two = \relative c'' {
\context Voice = "one" {
c2 d
}
}
\new Staff <<
\new Voice = "one" \one
\two
This is lovely and very flexible and does what I need it to do (and more).
But I would also be interested in a more minimal version because I usually
only care about Y-offsets. Preferably something that wouldn’t remove the
\glissandos from the syntax, so I could have something like

\once \override Glissando.Y-offset =
#(lambda (grob) (and
(if (= 0 (ly:grob-property grob 'glissando-index)) '0.25)
(if (= 1 (ly:grob-property grob 'glissando-index)) '-0.25)))
<g c>2\glissando <a d>

if only that would work. It probably won’t be as easy as that. But my
Scheme is very modest, and I don’t even know where to begin with something
like that. Any ideas?

--
Peter Crighton | Musician & Music Engraver based in Mainz, Germany
http://www.petercrighton.de
Thomas Morley
2018-12-08 10:37:05 UTC
Permalink
Am Fr., 7. Dez. 2018 um 06:08 Uhr schrieb Peter Crighton
Post by Peter Crighton
Post by Peter Crighton
Hello all,
I have the following (reduced) scenario where one voice has a chord with a glissando in it and I want to tweak both glissandos differently. Is it possible? The second (currently commented out) tweak is never applied even if I comment out the first tweak.
\version "2.19.82"
one = \relative c'' {
g2
-\tweak Y-offset #0.25
\glissando a
}
two = \relative c'' {
\context Voice = "one" {
c2
% this tweak is never applied
% -\tweak Y-offset #-0.25
\glissando d
}
}
\new Staff <<
\new Voice = "one" \one
\two
Thanks,
Peter
A while ago, there was a function created that allowed tweaks like you're asking - I think this is what you are looking for :) It should get you started.
http://lilypond.1069038.n5.nabble.com/How-to-tweak-override-the-individual-Glissando-objects-in-a-chord-td149575.html
This is one of my older codings. As far as adding text to glissandi is
concerned, I use a better coding nowadays, I'll probably out it in LSR
Post by Peter Crighton
\version "2.19.82"
glissTweak =
#(define-music-function (parser location lst)(pair?)
#{
\once \override Glissando #'after-line-breaking =
#(lambda (grob)
(let ((gliss-count (ly:grob-property grob 'glissando-index)))
(map (lambda (x)
(let ((gliss-nmbr (car x))
(property-value-alist (cdr x)))
(if (eq? gliss-nmbr gliss-count)
(map
(lambda (y) (ly:grob-set-property! grob (car y) (cdr y)))
property-value-alist)
#f)))
lst)))
$(make-music 'EventChord 'elements (list (make-music 'GlissandoEvent)))
with
<>\glissando
or delete it and put \glissando in \one below. Both works.
Post by Peter Crighton
#})
one = \relative c'' {
\glissTweak #`((0 . ((Y-offset . 0.25)))
(1 . ((Y-offset . -0.25))))
g2 a
}
two = \relative c'' {
\context Voice = "one" {
c2 d
}
}
\new Staff <<
\new Voice = "one" \one
\two
This is lovely and very flexible and does what I need it to do (and more).
But I would also be interested in a more minimal version because I usually only care about Y-offsets. Preferably something that wouldn’t remove the \glissandos from the syntax, so I could have something like
\once \override Glissando.Y-offset =
#(lambda (grob) (and
(if (= 0 (ly:grob-property grob 'glissando-index)) '0.25)
(if (= 1 (ly:grob-property grob 'glissando-index)) '-0.25)))
<g c>2\glissando <a d>
if only that would work. It probably won’t be as easy as that. But my Scheme is very modest, and I don’t even know where to begin with something like that. Any ideas?
It doesn't work because the return value is unspecified, if
glissando-index is zero. Try:

{
\once \override Glissando.Y-offset =
#(lambda (grob)
(cond
((= 0 (ly:grob-property grob 'glissando-index)) 1.25)
((= 1 (ly:grob-property grob 'glissando-index)) -1.25)
))
<g c>2\glissando <a d>
}
Ofcourse there is no coding yet, if glissando-index is greater than 1.
Btw, there's no need to prepend numbers in guile with a '-sign


Cheers,
Harm

Loading...