Hi Jean, thanks for your reply.

Find attached a tiny example of what I am doing. As you will see, if the 
interval is composed of 3 semitones (either C D# or C Eb) the noteheads are 
positioned one of top of the other. However, when the interval is composed of 2 
semitones they overlap.

I understand float numbers are tedious, but I don't think there is need for 
much precision here. I mean, in my case even though I want 2/3 distance between 
notes I could specify 0.7 and everything should work.

Robert
________________________________
De: Jean Abou Samra <j...@abou-samra.fr>
Enviado: domingo, 13 de marzo de 2022 0:05
Para: Robert Mengual <robert.meng...@outlook.com>; lilypond-user@gnu.org 
<lilypond-user@gnu.org>
Asunto: Re: Stem.note-collision-threshold

Hi Robert,


Le 11/03/2022 à 18:05, Robert Mengual a écrit :
> Hello everyone,
>
> I am developing a custom music notation in which distance between
> notes is different from the standard one. Instead of the tipical
> distance from C to D of 1, in mine for example this distance is 2/3.
>
> This of course causes notes in the same chord that are 1 tone away to
> overlap. I wanted to fix this by overriding
> Stem.note-collision-threshold to 1.5 (which would solve it). However,
> it won't allow to pass float numbers. My question is, shouldn't it
> allow them? Why not?


Comparing floats is hazardous due to decimal precision issues. On the
other hand, it might be possible to make it accept rational numbers like
#3/2.


> In any case, does anyone know how might I approach this challenge in a
> different way? I tried setting a different StaffSpacing but I was
> unsuccessful as well.

Could you give a code example? It's not clear to me what different
coordinate systems are being used.

Thanks,
Jean

#(define ga_note-head-y-offset-callback
   (grob-transformer
    'Y-offset
    (lambda (grob orig)
      (let* ((cause (ly:grob-property grob 'cause))
             (pitch (ly:event-property cause 'pitch))

             (steps (ly:pitch-steps pitch))
             (middle-c-offset (- (* steps .5)))

             (semitones (ly:pitch-semitones pitch))
             (offset (* 1/3 semitones)))
        (+ orig middle-c-offset offset))
      )))


\new Staff \with {
    \override NoteHead.Y-offset = #ga_note-head-y-offset-callback
    \override Stem.note-collision-threshold = #1 % I want this to be 1.5
} \relative c' {
    <c g'>
    <c f>
    <c e>
    <c ees>
    <c dis>
    <c d>
    <b c>
}

Reply via email to