lilypond-user
[Top][All Lists]
Advanced

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

Re: Harmonic notehead style


From: Paul
Subject: Re: Harmonic notehead style
Date: Wed, 1 Jun 2016 08:37:26 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0

Hi Andrew,

On 05/31/2016 09:48 PM, Andrew Bernard wrote:
I am using a custom stencil for noteheads, to achieve a certain look and ellipticity and rotation compared to the default noteheads. Suddenly doing a guitar piece I have to use \harmonic style and this does not have any effect when using a custom notehead symbol.

Do I need to add scheme code in my stencil function to take cognisance of the \harmonic style instruction and also draw my own shapes for that, or am I missing something?

Yes, you'll want to check the 'style property of the note head grob and when it is 'harmonic then leave the default stencil alone (or provide your own harmonic note head stencil).  There are a number of different note head styles like this.  See my custom note head engraver below (for Clairnote music notation[1]) which just leaves the default stencil in place for a given list of styles.

HTH,
-Paul

[1] http://clairnote.org/software/

#(define Cn_note_heads_engraver
    ;; Customizes stencil, stencil-width, stem-attachment, rotation.
    (make-engraver
     (acknowledgers
      ((note-head-interface engraver grob source-engraver)
       ;; make sure \omit is not in effect (i.e. stencil is not #f)
       ;; and do nothing for certain notehead styles
       (if
        (and
         (ly:grob-property-data grob 'stencil)
         (not (memq (ly:grob-property-data grob 'style)
                (list 'harmonic 'harmonic-black 'harmonic-mixed
                  'diamond 'cross 'xcircle 'triangle 'slash))))
        ;; TODO: better handling of various notehead styles
        ;; http://lilypond.org/doc/v2.18/Documentation/notation/note-head-styles
        ;; output-lib.scm
        (let*
         ((context (ly:translator-context engraver))
          (black-note (= 0 (modulo (cn-notehead-semitone grob) 2)))
          (dur-log (ly:grob-property grob 'duration-log))
          (stil-proc (ly:context-property context 'cnNoteheadStencilProcedure))
          (width-scale (ly:context-property context 'cnNoteheadWidthScale 1))
          (height-scale (ly:context-property context 'cnNoteheadHeightScale 1))
          (rot (ly:context-property context 'cnNoteheadRotation #f))
          (stem-attach (ly:context-property context 'cnStemAttachment #f)))

         (ly:grob-set-property! grob 'stencil
           (stil-proc grob context black-note dur-log))

         (if (>= dur-log 1)
             (if (not (and (= 1 width-scale) (= 1 height-scale)))
                 (ly:grob-set-property! grob 'stencil
                   (ly:stencil-scale
                    (ly:grob-property grob 'stencil)
                    width-scale height-scale))))

         (if (and rot (>= dur-log 1))
             (ly:grob-set-property! grob 'rotation (list rot 0 0)))

         (if (and stem-attach (>= dur-log 1))
             (ly:grob-set-property! grob 'stem-attachment
               (if black-note
                   (car stem-attach)
                   (cdr stem-attach))))
         ))))))


reply via email to

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