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 15:03:41 -0500

Hi Jay,

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

Is this the way I enter it? For some reason, does not seem to be working
- it seems to be ignoring the suffix.

By the time you set the 'text property, new-name doesn't hold the "newest" name, rather the variable text does.  You could also rename the variable text new-name.  let* allows you to do that.
 
If I wanted to display new-name as the program runs, is there a command
for that?

Just insert this outside of the let block (and before the last _expression_ so the function has a valid return)

(display text) (newline)

You can do fancier things with format:

(format #t "default name: ~a new name: ~a~%" default-name text)
 
You should see the output in the log.


Thanks
Jay

\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")
   )



#(define (myNoteNames size)
(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))
           (suffix
            (case duration-log
              ((1) "a") ;; half note
              (else "")))
           (text (string-append new-name suffix))
         )
          ;; body

[Change new-name in the following line to text]
 
         (ly:grob-set-property! grob 'text (markup #:fontsize size new-
name))
         (ly:text-interface::print grob)

         )
   ))


Hope this helps!

David 


reply via email to

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