Hi everyone,
I am notating a score which uses a lot of clustered chords, to be
notated in the style of Henry Cowell. I found a post from 2008 from the
Lilypond user list but the solution is very cumbersome, unfortunately.
The code below is adapted from that post: (
https://lists.gnu.org/archive/html/lilypond-user/2008-10/msg00555.html )
%%%%%%%%%%%%%%%%
\version "2.20.0"
qLinkCowell =
#(ly:make-stencil (list 'embedded-ps
"gsave
currentpoint translate
newpath
0.3 0.51 moveto
1.0125 0.51 lineto
1.0125 -0.51 lineto
0.3 -0.51 lineto
closepath
fill
grestore")
(cons 0 1.3125)
(cons 0 0))
% Example 1
{
\time 2/4
\override NoteHead #'X-offset = #0
\override NoteHead #'stem-attachment = #'(1 . 4.75)
<
f'
\tweak #'stencil \qLinkCowell g'
\tweak #'stencil \qLinkCowell a'
\tweak #'stencil \qLinkCowell b'
\tweak #'stencil \qLinkCowell c''
d''
>4
<
g'
\tweak #'stencil \qLinkCowell a'
\tweak #'stencil \qLinkCowell b'
\tweak #'stencil \qLinkCowell c''
\tweak #'stencil \qLinkCowell d''
e''
>4
}
% Example 2
{
\time 4/4
\override NoteHead #'X-offset = #0
\override NoteHead #'stem-attachment = #'(1 . 4.75)
<
f'
\tweak #'stencil \qLinkCowell g'
\tweak #'stencil \qLinkCowell a'
\tweak #'stencil \qLinkCowell b'
\tweak #'stencil \qLinkCowell c''
d''
>2
<
g'
\tweak #'stencil \qLinkCowell a'
\tweak #'stencil \qLinkCowell b'
\tweak #'stencil \qLinkCowell c''
\tweak #'stencil \qLinkCowell d''
e''
>2
}
% Example 3
{
\time 2/4
\override NoteHead #'X-offset = #0
\override NoteHead #'stem-attachment = #'(1 . 4.75)
<
d'
\tweak #'stencil \qLinkCowell e'
\tweak #'stencil \qLinkCowell f'
g'
>4
<
b'
\tweak #'stencil \qLinkCowell c''
\tweak #'stencil \qLinkCowell d''
\tweak #'stencil \qLinkCowell e''
\tweak #'stencil \qLinkCowell f''
\tweak #'stencil \qLinkCowell g''
\tweak #'stencil \qLinkCowell a''
b''
>4
}
%%%%%%%%%%%%%%%%
Producing: https://i.postimg.cc/xdmMRpkh/clusters.png
As can be seen from the image above, the topmost example (which is the
original one from that post) is notated perfectly fine, but this
approach fails when using notes with white note heads (example 2). The
stem-attachment value is also hard-coded, and needs to be tweaked
manually for every single cluster (see example 3), which is an absolute
pain.
Ideally, the best approach would be a function that would take a chord
of two notes (i.e. the bottom and topmost notes of the cluster only),
attach the stem to the correct notehead only (i.e. top notehead when
stem up or bottom notehead when stem down) and find an elegant way of
adding a vertical connector between the noteheads. So that usage would
be something as simple as \cowellCluster <e' a'>4 \cowellCluster <b' g''>2
Unfortunately I am not very good at writing LilyPond functions myself,
so I was wondering if anyone here could give me a hand with this one, or
perhaps give me some advice on how to tackle this.
Many thanks!
Gilberto