Hi Jay,

On Thu, Sep 18, 2014 at 9:54 AM, Jay Vara <j...@diljun.com> 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
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to