[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Programming Question
From: |
Jay Vara |
Subject: |
Re: Programming Question |
Date: |
Thu, 18 Sep 2014 23:28:17 +0000 (UTC) |
User-agent: |
Loom/3.14 (http://gmane.org/) |
> I am not top-posting
David,
I defined a second variable nsiz which is 1, 2 or 3
Tried
(case duration-log
((nsiz) "a" )
(else "")))
This condition was never succeeding although I printed out nsiz and
duration-log and they were the same.
Then I changed it into an if statement - that worked. This is to add a
suffix to note name for half notes in normal duration, quarter notes in
halved durations, and eighth notes when durations are further halved. It
should be obvious from the output that it has worked.
Then further, I wanted the suffix to be "i" if the note was d or b. I
tried various if statements and they are all failing for some reason.
default-name which is equal to "d" gives a #f when tested, for example.
Not sure what to do to make it work.
Here is the code:
\version "2.18.2"
music = \relative c' {d2 b2 b4 d} % {c4 d2 e f g2 g a4 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")
)
#(display newnames)
#(define (myNoteNames size nsiz)
(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) (if (= nsiz 1) (if (or (eqv? new-name "R") (eqv?
default-name "b")) "i" "a") "")) ;; half note
((2) (if (= nsiz 2) "a" "")) ;; quarter note
((3) (if (= nsiz 3) "a" "")) ;; eighth note
(else "")))
(text (string-append new-name suffix))
)
(display default-name) (display (eq? default-name "d"))
(display duration-log) (display size) (display nsiz) (display text)
(newline);; 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 0 1)
\music
\override NoteName.stencil = #(myNoteNames -1 2)
\shiftDurations #1 #0 {\music }
\override NoteName.stencil = #(myNoteNames -2 3)
\shiftDurations #2 #0 {\music \music }
}
>>
}
- Re: Programming Question, (continued)
- Re: Programming Question, David Nalesnik, 2014/09/18
- Re: Programming Question, Jay Vara, 2014/09/18
- Re: Programming Question, David Nalesnik, 2014/09/18
- Re: Programming Question, Jay Vara, 2014/09/18
- Re: Programming Question, David Nalesnik, 2014/09/18
- Re: Programming Question, Jay Vara, 2014/09/18
- Re: Programming Question,
Jay Vara <=
- Re: Programming Question, David Nalesnik, 2014/09/18
- Re: Programming Question, Paul Morris, 2014/09/18
- Re: Programming Question, Jay Vara, 2014/09/19
- Re: Programming Question, David Nalesnik, 2014/09/19
- Re: Programming Question, Jay Vara, 2014/09/19
- Re: Programming Question, Jay Vara, 2014/09/19