lilypond-user
[Top][All Lists]
Advanced

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

Programming Question


From: Jay Vara
Subject: Programming Question
Date: Thu, 18 Sep 2014 09:43:26 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

> I'm not top posting.

I am using NoteNames context to print the note names automatically for 
scales of half notes, quarter notes and eighth notes. I have redefined 
the NoteNames using override NoteName.Stencil.

I need different font sizes for the note names of half, quarter and 
eighth notes. Currently I have got this working by using three different 
versions of the myNoteNames function. The only change between them is 
the fontsize of text. Is there a way to combine the three functions - 
perhaps have two arguments. I tried this and since the syntax of 
defining the function and of using it were not clear, I was not able to 
get it to work.

Here is the code:

\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))
         )  
          ;; body
         (ly:grob-set-property! grob 'text new-name)
         (ly:text-interface::print grob)
         )
   )
myNoteNamesS =
#(lambda (grob)
   (let* (
          ;; bindings
          (default-name (ly:grob-property grob 'text))
          (new-name (assoc-get default-name newnames))
         )  
          ;; body
         (ly:grob-set-property! grob 'text (markup #:fontsize -2 new-
name))
         (ly:text-interface::print grob)
         )
   )

myNoteNamesT =
#(lambda (grob)
   (let* (
          ;; bindings
          (default-name (ly:grob-property grob 'text))
          (new-name (assoc-get default-name newnames))
         )  
          ;; body
         (ly:grob-set-property! grob 'text (markup #:fontsize -4 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 
        
       \override NoteName.stencil = #myNoteNamesS
        \shiftDurations #1 #0 {\music } 
        
        \override NoteName.stencil = #myNoteNamesT
        \shiftDurations #2 #0 {\music \music }
        
    }
  >>
}





reply via email to

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