That fixes it, thank you everyone!

I'll have to spend some time with that Lilypond Scheme Book, it looks like
it will save me a lot of time and confusion. I wish I had found about it
earlier.

Also, I didn't know that for-each could iterate through many lists in
parallel, that's actually very useful.

Thank you for the suggestions!

2018-02-20 19:23 GMT-03:00 Thomas Morley <[email protected]>:

> Hi Stefano,
>
> others already commented about quote/unquote.
>
> Some other remark:
>
> 2018-02-20 18:55 GMT+01:00 Stefano Troncaro <[email protected]>:
> > 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))
>
> Why this resetting `i'? Use a second argument instead. See bottom.
> >>                    (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?
>
> 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))))
>          (if (= (length dir-list) (length tie-array))
>              (for-each
>                (lambda (d tie)
>                  (if (eq? tie grob) (ly:grob-set-property! grob 'direction
> d)))
>                dir-list
>                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 #`(,DOWN ,UP ,DOWN)
>     <g e c>2~ q
>   }
> }
>
> > 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
>
>
> TieColumn is a beasty thing...
> I have no suggestion at hand (and not the time to dive in deeper).
>
> Sorry being of not more help,
>   Harm
>
_______________________________________________
lilypond-user mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to