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 08:00:58 -0500

 Hi Jay,

On Thu, Sep 18, 2014 at 7:28 AM, David Nalesnik <address@hidden> wrote:


On Thu, Sep 18, 2014 at 7:01 AM, David Nalesnik <address@hidden> wrote:
 

 

Now, if you want to have LilyPond detect the note durations and make the fontsize decisions for you, I don't believe you'll be able to use the NoteNames grob as it stands.

I mean NoteName grob, of course.
 

Now that's not true, it turns out...
\version "2.18.2"

music =  \relative c' {c2 d e f g a b c c b a g f e d c}


newnames =
#`(("c" . "S")
   ("d" . "R")
   ("e" . "G")
   ("f" . "M")
   ("g" . "P")
   ("a" . "D")
   ("b" . "N")
   )



myNoteNames =
#(lambda (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))
           (size
            (case duration-log
              ((2) -2)
              ((3) -4)
              (else 1)))
           )
     ;; body
     (ly:grob-set-property! grob 'text
       (markup #:fontsize size new-name))
     (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
      \music

      \shiftDurations #1 #0 {\music }

      \shiftDurations #2 #0 {\music \music }

    }
  >>
}
 


reply via email to

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