[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: NoteHead X-offset, conflict with ly:grob-relative-coordinate?
From: |
David Nalesnik |
Subject: |
Re: NoteHead X-offset, conflict with ly:grob-relative-coordinate? |
Date: |
Sat, 8 Dec 2012 13:03:28 -0600 |
Hi Paul,
On Sat, Dec 8, 2012 at 12:00 PM, Paul Morris <address@hidden> wrote:
[snip]
>>
>> In this case you can make use of the 'stem-attachment property:
>>
>> \override NoteHead #'stem-attachment = #'(-0.8 . 0)
>
> Thanks David, I hadn't thought of using stem-attachment. It works for
> single notes, but unfortunately does not seem to work for repositioning
> individual noteheads within chords, which is what I want to do.
>
> For example, the snippet below changes stem-attachment to try to reposition
> every other note (colored green as well just for purposes of illustration).
> But the notes in a given chord all end up on the same side of the stem rather
> than some on one side and some on the other.
>
> (I tried using the extra-offset property, and it worked, but it is applied
> after the spacing has been set, and so could lead to collisions or bad
> horizontal spacing. The X-offset property, on the other hand, is applied
> before spacing is determined.)
>
> -Paul
>
> \version "2.16.1"
>
> note-counter = 1
>
> CustomNoteHeads =
> #(lambda (grob)
> (let*
> (
> (notecol (ly:grob-parent grob 0))
> (rel-coord (ly:grob-relative-coordinate grob notecol 0))
> )
> (cond ((= 0 (modulo note-counter 2))
> (set! (ly:grob-property grob 'stem-attachment) '(-0.8 . 0))
> (set! (ly:grob-property grob 'color) green)
> ))
> (set! note-counter (+ 1 note-counter))
> ))
>
> \score {
> \new Staff
> \with {
> \override NoteHead #'before-line-breaking = \CustomNoteHeads
> }
> {
> <c'' e''> <d'' f''> <e'' g'' b''> <f'' a'' c'''>
> <c' e'> <d' f'> <e' g' b'> <f' a' c''>
> }
> \layout { }
> }
You posted this question awhile back
(http://www.mail-archive.com/address@hidden/msg70733.html). Is
the solution I provided there no longer working for you?
I needed to change some values to deal with normal note-shapes, but
this seems to work just fine:
#(define ((shift offsets) grob)
(let ((note-heads (ly:grob-array->list (ly:grob-object grob 'note-heads))))
(for-each
(lambda (p q) (set! (ly:grob-property p 'X-offset) q))
note-heads offsets)))
displaceHeads =
#(define-music-function (parser location offsets) (list?)
#{
\once \override NoteColumn #'before-line-breaking = #(shift offsets)
#}
)
theMusic = {
\displaceHeads #'(0 0 1.3)
<c' e' g' >4
\displaceHeads #'(0 1.3 1.3)
<d' f' a'>
\displaceHeads #'(0 1.3 1.3)
<d' f' a'>
\displaceHeads #'(0 0 1.3)
< c' e' g'>
\displaceHeads #'(-1.3 -1.3 0)
< c'' e'' g''>
\displaceHeads #'(-1.3 -1.3 0)
< c''' e''' g'''>
\displaceHeads #'(0 0 1.3)
< c e g>
\displaceHeads #'(0 -1.3 0)
< c'' e'' g''>
\displaceHeads #'(0 0 -1.3)
< c'' e'' g''>
}
\new Staff {
\theMusic
}
-David