lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Directional NoteHead Stencil Support


From: tisimst
Subject: Re: Directional NoteHead Stencil Support
Date: Sat, 21 Mar 2015 19:13:17 -0700 (MST)

David,

You are a genius! I've almost got it, but I'm not sure how to handle rests. Here's my current function:

#(define (flipnotes grob)
   (let ((notes (ly:grob-array->list (ly:grob-object grob 'note-heads))))
     (for-each
       (lambda (note)
         (let* ((pitch (ly:event-property (event-cause note) 'pitch))
                (stem (ly:grob-object note 'stem))
                (dir (ly:grob-property stem 'direction))
                (offset (ly:grob-relative-coordinate note grob X)))
           (if (eq? dir DOWN)
               (if (and (< offset 0.1) (> offset -0.1))
                 (ly:grob-set-property! note 'rotation '(180 0 0))
                 (ly:grob-set-property! note 'rotation '(0 0 0)))
               (if (and (< offset 0.1) (> offset -0.1))
                   (ly:grob-set-property! note 'rotation '(0 0 0))
                   (ly:grob-set-property! note 'rotation '(180 0 0)))
               )
           ))
       notes)))

This works perfectly when there are NO rests, but I get this error when there is a rest in the NoteColumn:

In procedure ly:grob-array->list in _expression_ (ly:grob-array->list (ly:grob-object grob #)): Wrong type argument in position 1 (expecting Grob_array): ()

Thanks so much for your help, everyone.

- Abraham

On Sat, Mar 21, 2015 at 5:27 PM, David Nalesnik-2 [via Lilypond] <[hidden email]> wrote:
Hi,

On Sat, Mar 21, 2015 at 4:32 PM, tisimst <[hidden email]> wrote:
You and me both, Pierre. I've tried for hours to find something that works automatically. I've managed to use a single notehead for both up- and down-stem notes, thanks to everyone's help here, but I still have one problem relating to chords. 

If a notehead, in a chord stack, is forced out of the main column (to the right for up-stem chords, to the left for down-stem chords) what property (or relationship between grobs) puts them there? I can't seem to figure it out. 

- Abraham


If  there's a property which indicates on which side of a stem the note falls, I don't find it.  Seems like there definitely should be one!

Anyway, here's a snippet which suggests a possible way to go.  It prints out the X-coordinate of the note heads in a chord, relative to the organizing NoteColumn.

\version "2.19.17"

{
  \override NoteColumn.before-line-breaking = 
  #(lambda (grob)
     (let ((notes (ly:grob-array->list (ly:grob-object grob 'note-heads))))
       (for-each
        (lambda (note)
          (format #t "~a at coordinate: ~a~%"
            (ly:event-property (event-cause note) 'pitch)
            (ly:grob-relative-coordinate note grob X)))
        notes)
       (newline)))
  <c' d' e' g' c'' d''>
  <cis'' fis'' gis''>
}

%%%%

And the output:

#<Pitch c' > at coordinate: 0.0

#<Pitch d' > at coordinate: 1.251178

#<Pitch e' > at coordinate: 0.0

#<Pitch g' > at coordinate: 0.0

#<Pitch c'' > at coordinate: 0.0

#<Pitch d'' > at coordinate: 1.251178


#<Pitch cis'' > at coordinate: 0.0

#<Pitch fis'' > at coordinate: -1.251178

#<Pitch gis'' > at coordinate: 0.0


Hope this helps!!


-David


_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user



If you reply to this email, your message will be added to the discussion below:
http://lilypond.1069038.n5.nabble.com/Directional-NoteHead-Stencil-Support-tp173361p173452.html
To start a new topic under User, email [hidden email]
To unsubscribe from Lilypond, click here.
NAML


View this message in context: Re: Directional NoteHead Stencil Support
Sent from the User mailing list archive at Nabble.com.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]