lilypond-user
[Top][All Lists]
Advanced

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

pitch name transpose into numeric pr key signature


From: MING TSANG
Subject: pitch name transpose into numeric pr key signature
Date: Sun, 14 Oct 2012 15:08:56 -0700 (PDT)

The following snippet did not transpose the pitch name to numbers

e.g.  for key g\major the transpose should be:
     g= 1(do)  a= 2(re)  b= 3(mi)  c= 4(fa)  d= 5(so)  e= 6(la) ff=7(ti)

I was told to substitute CDEFGAB(namer) for 1234567(numbr) will produce the right numeric.  I appreciate if someone can show me how to fix \numbr so that it will generate proper numeric per key signature.  Attached png file is the output of the snippet.

%snippet begins
%
\version "2.17.0"
\include "english.ly"
%\include "include_namer.ly"
namer =
#(make-engraver
(acknowledgers
((note-head-interface engraver grob source)
(let* ((event (ly:grob-property grob 'cause))
(pitch (ly:event-property event 'pitch))
(newgrob (ly:engraver-make-grob engraver 'TextScript event))
(name (format #f "~a~a"
(string-ref "CDEFGAB" (ly:pitch-notename pitch))
(assoc-ref
'((-1/2 . "") (0 . "") (1/2 . ""))
(ly:pitch-alteration pitch)))))
(if (string= name "Hb")
(set! name "B"))
(set! (ly:grob-property newgrob 'text) name)))))
numbr =
#(make-engraver
(acknowledgers
((note-head-interface engraver grob source)
(let* ((event (ly:grob-property grob 'cause))
(pitch (ly:event-property event 'pitch))
(newgrob (ly:engraver-make-grob engraver 'TextScript event))
(name (format #f "~a~a"
(string-ref "1234567" (ly:pitch-notename pitch))
(assoc-ref
'((-1/2 . "") (0 . "") (1/2 . ""))
(ly:pitch-alteration pitch)))))
(if (string= name "Hb")
(set! name "B"))
(set! (ly:grob-property newgrob 'text) name)))))
SRxxSSa = \relative c' {
\clef treble \key c\major
\set Staff.instrumentName = \markup {\larger "AA"}
c4 d e f g a b2 | \key g\major g4 a b c d e fs2 | \key ef\major ef,4 f g af bf c d2
}
SRxxSSb = \relative c' {
\set Staff.instrumentName = \markup {\larger "BB"}
\key c\major
c4 d e f g a b2 | \key g\major g4 a b c d e fs2 | \key ef\major ef,4 f g af bf c d2
}
\score{
\new Staff
\with {\consists #namer }
{
\SRxxSSa
}
\layout {}
}
\score{
\new Staff
\with {\consists #numbr }
{
\SRxxSSb
}
\layout {}
}
%
%snippet ends
 
Blessing in+,

Attachment: 2012-10-14_180700.png
Description: PNG image


reply via email to

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