Hello everyone!
I recently wrote the function bellow to be able to set the direction of ties in a TieColumn by specifying a list of directions:
\version "2.19.80"
tieDirectionFromList =
#(define-music-function (dir-list) (list?)
#{
\once \override Tie.before-line-breaking =
#(lambda (grob)
(let* ((tie-column (ly:grob-parent grob Y))
(tie-array (ly:grob-array->list (ly:grob-object tie-column 'ties)))
(i 0))
(if (= (length dir-list) (length tie-array))
(for-each
(lambda (tie)
(if (eq? tie grob)
(ly:grob-set-property! grob 'direction (list-ref dir-list i))
(set! i (+ i 1))))
tie-array)
(ly:input-warning (*location*) "tieDirectionFromList: dir-list has a different number of elements than the 'ties of the TieColumn."))
)) #} )
\score {
\new Staff \new Voice \relative c'' {
\tieDirectionFromList #'(-1 1 -1)
%The following gives warning: type check for `direction' failed; value `DOWN' must be of type `direction'
%\tieDirectionFromList #'(DOWN UP DOWN)
<g e c>2~ q
}
}
This works when I give the directions as numbers. However, I get an error when I use
UP and
DOWN instead, and I don't understand why. Aren't these constants that have the values 1 and -1? Is the problem that
ly:grob-set-property is trying to assign the symbol (
UP or
DOWN) to the property instead of the value that they evaluate to? If so, how can that be fixed?
My second question is the following. I see in the
Notation Reference that
Tie.direction has the default value of
ly:tie::calc-direction
, but when I override it with a function it doesn't call the function and uses the default direction instead:
\version "2.19.80"
\score {
\new Staff \new Voice \relative c'' {
\override Tie.direction = #UP
<g e c>2~ q
}
}
\score {
\new Staff \new Voice \relative c'' {
\override Tie.direction = #(lambda (irrelevant-var) UP)
<g e c>2~ q
}
}
I wanted to use
Tie.direction instead of
Tie.before-line-breaking, but it doesn't work and I would like to know if I'm doing something wrong or this is just the way it is.
As a last question, is there a way to get the same results by overriding TieColumn.tie-configuration but keeping the default distance to the center of the Staff of each Tie? Or is there something like that already implemented but not documented?
Thank you in advance for your help!
Stéfano