Hi David, On Dec 8, 2012, at 2:03 PM, David Nalesnik <[email protected]> wrote:
> Hi Paul, > > On Sat, Dec 8, 2012 at 12:00 PM, Paul Morris <[email protected]> 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/[email protected]/msg70733.html). Is > the solution I provided there no longer working for you? Yes, your solution still works well (thanks again!). I think by using tiny examples that focus on how X-offset is not working, it hasn't been clear that I'm working on a more automated approach. I have written some code to automatically apply certain offsets in certain cases[1], so I do not have to manually apply them. I use ly:grob-relative-coordinate to find out which side of the stem a note head is on (in order to know which side I need to place the next note head), but then for some reason that prevents changing the X-offset of the NoteHead from having any effect. My current approach is to override the NoteHead rather than the NoteColumn as in your solution. I could override the NoteColumn instead (and this might even be a better way to go...), but I will still need to determine which side of the stem a note is on, so might still need to use ly:grob-relative-coordinate to do that and would run into the same problem. But maybe there is another way to tell which side of the stem a note head is on, without using ly:grob-relative-coordinate? Anyway, thanks again for your help. -Paul [1] Notes that are 3 semitones apart are placed on opposite sides of the stem. This is for use with an alternative notation system (http://twinnote.org) > 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 _______________________________________________ lilypond-user mailing list [email protected] https://lists.gnu.org/mailman/listinfo/lilypond-user
