[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Equal ends of glissandi
From: |
Thomas Morley |
Subject: |
Re: Equal ends of glissandi |
Date: |
Sat, 30 Sep 2017 22:48:45 +0200 |
2017-09-30 11:46 GMT+02:00 Thomas Morley <address@hidden>:
> Hi all,
>
> consider the code below
>
> \score {
> \relative c' {
> <c e g b>4\glissando
> <d' fis g bes>\glissando
> <c, e g ais>
> }
> %% for better viewing:
> \layout {
> ragged-right = ##f
> \override Glissando.color = #red
> \override Glissando.thickness = 2.5
> }
> }
>
> I want to create an override which should end all glissandi (starting
> at the NoteHeads of a certain NoteColumn) at the same X-coordinate
> left from all target-NoteHeads.
>
> I tried:
>
> #(define same-gliss-end
> (lambda (grob)
> (let* ((vertical-axis-group-elts
> (ly:grob-object (ly:grob-parent grob Y) 'elements))
> (all-gliss
> (if (ly:grob-array? vertical-axis-group-elts)
> (filter
> (lambda (elt)
> (grob::has-interface elt 'glissando-interface))
> (ly:grob-array->list vertical-axis-group-elts))
> '()))
> (gliss-X
> (map
> (lambda (gliss)
> (assoc-get 'X (ly:line-spanner::calc-right-bound-info
> gliss)))
> all-gliss))
> (min-x (apply min gliss-X)))
>
> (ly:grob-set-nested-property! grob '(right-bound-info X) min-x))))
>
> tst = \override Glissando.after-line-breaking = #same-gliss-end
>
> \score {
> \relative c' {
> \tst
> <c e g b>4\glissando
> <d' fis g bes>\glissando
> <c, e g ais>
> }
> %% for better viewing:
> \layout {
> ragged-right = ##f
> \override Glissando.color = #red
> \override Glissando.thickness = 2.5
> }
> }
>
> Which indeed does the job for the first group of glissandi.
> But all other vanish, because I take the glissandi from
> VertivalAxisGroup. Meaning the last call of the override points
> _every_ glissando to the same X-value, which is the minimum-X of _all_
> glissandi of the current system.
>
> Do I overlook something simple?
> If not, how to do it different?
>
> Any hint appreciated!
>
>
> Thanks,
> Harm
Eventually I've found a method to limit the affected glissandi to
those of the same NoteColumn.
Though, do we really have no direct method to get all glissandi from
every note of an event-chord? As far as I understand 'glissando-index
and glissandoMap are of no help with this.
Anyway, here what I did:
\version "2.19.65"
#(define same-gliss-start-end
;; All glissandi between chords should start at the same X-coordinate, same
;; for glissando-endings.
(lambda (grob)
(let* ((left-bound (ly:spanner-bound grob LEFT))
(parent-nc (ly:grob-parent left-bound X))
(vertical-axis-group-elts
(ly:grob-object (ly:grob-parent grob Y) 'elements))
;; Filter VerticalAxisGroup-elements for Glissandi, restricted to
;; those starting at the NoteHeads from same NoteColumn.
;; Return their 'X-value for start/end
(relevant-gliss-Xs
(if (ly:grob-array? vertical-axis-group-elts)
(filter-map
(lambda (elt)
(and
(grob::has-interface elt 'glissando-interface)
(equal?
(ly:grob-parent (ly:spanner-bound elt LEFT) X)
parent-nc)
(cons
(assoc-get 'X
(ly:grob-property elt 'left-bound-info))
(assoc-get 'X
(ly:grob-property elt 'right-bound-info)))))
(ly:grob-array->list vertical-axis-group-elts))
'()))
;; Get the most left 'X for the final 'X-value of the end.
;; Get the most right 'X for the final 'X-value of the start.
;; Override left/right-bound-info with those values.
(min-x-right (apply min (map cdr relevant-gliss-Xs)))
(max-x-left (apply max (map car relevant-gliss-Xs))))
(ly:grob-set-nested-property! grob '(left-bound-info X) max-x-left)
(ly:grob-set-nested-property! grob '(right-bound-info X) min-x-right))))
\score {
\relative c' {
\override Glissando.after-line-breaking = #same-gliss-start-end
<c e g b>1\glissando
<d' fis g bes>\glissando
\break
%% \grace is used only to show behaviour of broken glissandi
\grace s16
<c, e g ais>1
}
%% for better viewing:
\layout {
ragged-right = ##f
\override Glissando.color = #red
\override Glissando.thickness = 2.5
\override Glissando.breakable = ##t
%% further customizing possible with tweaks/overrides like:
%\override Glissando.springs-and-rods = #ly:spanner::set-spacing-rods
%\override Glissando.minimum-length = 8
\override Glissando.bound-details.left.padding = #1
%\override Glissando.bound-details.right.padding = #3
}
}
@David N
Attached you'll find the full coded feature. I.e. a method to indicate
equal notes in the same chord-voice of a chord-progression.
It's meant for educational purpose.
Maybe a usefull addition to your partwriter, although I didn't test
whether both codings are compatible.
Cheers,
Harm
glissando-indicates-equals-01.pdf
Description: Adobe PDF document
glissando-indicates-equals.ly
Description: Text Data