lilypond-user
[Top][All Lists]
Advanced

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

Re: Programming Question


From: David Nalesnik
Subject: Re: Programming Question
Date: Thu, 18 Sep 2014 10:20:07 -0500

Hi Jay,

On Thu, Sep 18, 2014 at 9:54 AM, Jay Vara <address@hidden> wrote:
 

On the other hand, what would be nice is if the NoteName could be changed
based on duration. In particular, if the note is a half note, I would like
to add a character (say a "-" or a "a") to the note name. This could be
more involved probably.


That would actually be simple:

#(define ((myNoteNames size) grob)
   (let* (
           ;; bindings
           (default-name (ly:grob-property grob 'text))
           (new-name (assoc-get default-name newnames))
           (cause (event-cause grob))
           (duration (ly:prob-property cause 'duration))
           (duration-log (ly:duration-log duration))
           (suffix
            (case duration-log
              ((1) "a") ;; half note
              (else "")))
           (text (string-append new-name suffix))
           )
     ;; body
     (ly:grob-set-property! grob 'text
       (markup #:fontsize size text))
     (ly:text-interface::print grob)
     )
   )


\new Staff {
  <<
    \new Voice {
      \music
      \shiftDurations #1 #0 {\music }
      \shiftDurations #2 #0 {\music \music }
    }
    \context NoteNames {

      \override NoteName.stencil = #(myNoteNames 1)
      \music
      
      \override NoteName.stencil = #(myNoteNames -2)
      \shiftDurations #1 #0 {\music }
      
      \override NoteName.stencil = #(myNoteNames -4)
      \shiftDurations #2 #0 {\music \music }

    }
  >>
}
%%%%


--David

reply via email to

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