Hi Andrew,

Of course there is nothing wrong with setting the minimum length around
4.5. In this example this setting results in the Ties ending halfway
between the Noteheads, which I feel as a "loss of continuity" (for lack of
better words), and this did not leave me fully satisfied. I am aware this
is nitpicking, but this is why I was looking for an alternative.

My previous answer was not without problems however. First, the alignment
of the Accidentals to the Notes is off, which is ugly. Second, the code
lacked coherence and had hard-coded values, so it was not useful outside of
this very specific case. I tinkered with it and got rid of the misaligned
Accidentals by using whiteout in the Ties, and wrapped the whole thing in a
more flexible shell which will be useful to me in other situations.

Attached is my updated solution, hope someone finds it useful!

2018-02-27 20:04 GMT-03:00 Andrew Bernard <andrew.bern...@gmail.com>:

> Hi Stefano,
>
> Am I missing something? If you set minimum tie length to say 4.5 or even
> 4.2  it looks fine to me.
>
>   \override Tie.minimum-length = #4.5
>
> Using #4 is just too short, that's all.
>
> Given that you have gone to great effort to elaborate this in Scheme, I
> fear I must be missing something in your request.
>
> Andrew
>
>
\version "2.19.80"
\language "english"

%%% Definitions %%%
%Predicates
#(define (proc-list? obj)
   (and (list? obj)
        (every procedure? obj)))

#(define (note-column? obj)
   (and (ly:grob? obj)
        (let ((name (assq-ref 
                     (ly:grob-property obj 'meta) 
                     'name)))
          (eq? name 'NoteColumn))))

%Selection functions
#(define NoteColumn->Accidentals
   (define-scheme-function (nc) (note-column?)
     (let ((noteheads (ly:grob-array->list (ly:grob-object nc 'note-heads))))
       (filter ly:grob? 
               (map
                (lambda (notehead)
                  (ly:grob-object notehead 'accidental-grob))
                noteheads)))))

%Functions that apply to lists of grobs
#(define set::stencil->alb-phantom
   (define-scheme-function (list-of-grobs) (grob-list?)
     (for-each
      (lambda (grob)
        (let ((stil (ly:grob-property grob 'stencil)))
          (ly:grob-set-property! grob 'stencil #f)
          (ly:grob-set-property! grob 'after-line-breaking
            (lambda (alb-grob)
              (ly:grob-set-property! alb-grob 'stencil stil)))))
      list-of-grobs)))

#(define set::stencil->scale
   (define-scheme-function (x y) (number? number?)
     (define-scheme-function (list-of-grobs) (grob-list?)
       (for-each
        (lambda (grob)
          (let ((stil (ly:grob-property grob 'stencil)))
            (ly:grob-set-property! grob 'stencil (ly:stencil-scale stil x y))))
        list-of-grobs))))

%Main function
applyTo =
#(define-music-function (blb-grob selection-proc procs-to-apply) (symbol? procedure? proc-list?)
   #{ \override $blb-grob .before-line-breaking =
      #(lambda (grob)
         (let ((selection (delete-duplicates (selection-proc grob))))
           (for-each
            (lambda (proc)
              (proc selection))
            procs-to-apply))) #} )

%%% End of definitions %%%

\relative c'' {
  <as~ fs~> <cs as fs cs>
}

\relative c'' {
  \override Tie.minimum-length = 4.5
  <as~ fs~> <cs as fs cs>
}

\relative c'' {
  \override Tie.minimum-length = 4.5
  \override Tie.details.height-limit = 0.5
  <as fs>~
  \override TieColumn.tie-configuration = #`((-3.05 . ,DOWN) (-1 . ,DOWN))
  <cs as fs cs>
}

\relative c'' {
  \override Tie.minimum-length = 4
  \override Tie.whiteout-style = #'outline
  \override Tie.whiteout = 1.2
  <as fs>~ 
  \override TieColumn.tie-configuration = #`((-3 . ,DOWN) (-1 . ,DOWN))
  \override Accidental.extra-offset = #'(-1.5 . 0)
  \override Accidental.layer = 0
  \applyTo NoteColumn #NoteColumn->Accidentals #`(,(set::stencil->scale 0.95 0.9) ,set::stencil->alb-phantom)
  <cs as fs cs>
}

\relative c'' {
  \override Tie.minimum-length = 4.5
  \override Tie.details.height-limit = 0.5
  \override Tie.whiteout-style = #'outline
  \override Tie.whiteout = 1.2
  <as fs>~
  \override TieColumn.tie-configuration = #`((-3 . ,DOWN) (-1 . ,DOWN))
  \override Accidental.extra-offset = #'(-1.5 . 0)
  \override Accidental.layer = 0
  \applyTo NoteColumn #NoteColumn->Accidentals #`(,(set::stencil->scale 0.95 0.9) ,set::stencil->alb-phantom)
  <cs as fs cs>
}
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to