Hi Ming,
On Tue, Feb 11, 2014 at 4:28 PM, MING TSANG <tsan...@rogers.com> wrote:
> Hi all,
> I further reduce the code to 53 lines. line 4 - 20 & line 24 - 40 are
> identical except line 14 vs line 34. The actual code for notes is only 8
> lines ( 45 - 52). I think I cannot reduce anymore in order to show my
> problem and request.
>
Thank you for cutting this down further. I suspect you could cut down the
musical example still further, because all you need to show is inconsistent
placement of numbers vs. syllables.
> Again to ask:
> problem 1: I am expecting all numbers (jianpu) on top of the letters
> (solfege) - on bar 1 and bar 3 they are reversed; is it possible to solve?
>
Yes. You simply need to override TextScript.outside-staff-priority for one
of the voices. See attached.
> request 2: Is it possible to combine lins 4-20 & lines 24-40 into one
> define variable so that line 14 and line 34 can be access by parameter or
> by if statement?
>
Yes. Here I took the liberty of using your original file, since it's easy
enough to condense everything there and I assume that's still your goal.
See the attached file.
Best,
David
\version "2.18"
#(define syllables '("do" "re" "mi" "fa" "so" "la" "ti"))
#(define syls '("d" "r" "m" "f" "s" "l" "t"))
#(define numbers '("1" "2" "3" "4" "5" "6" "7"))
#(define (solfege-engraver lst dir)
(make-engraver
(acknowledgers
((note-head-interface engraver grob source)
(let* (
(context (ly:translator-context engraver))
(tonic-pitch (ly:context-property context 'tonic))
(tonic-index (ly:pitch-notename tonic-pitch))
(event (ly:grob-property grob 'cause))
(grob-pitch (ly:event-property event 'pitch))
(grob-index (ly:pitch-notename grob-pitch))
(delta (modulo (- grob-index tonic-index) 7))
(name (list-ref lst delta))
(newgrob (ly:engraver-make-grob engraver 'TextScript event)))
(if (string= name "Hb") (set! name "B"))
(set! (ly:grob-property newgrob 'text) name)
(set! (ly:grob-property newgrob 'direction) dir) )))))
xup = \with { \consists #(solfege-engraver syllables UP) }
xdown = \with { \consists #(solfege-engraver syllables DOWN) }
zup= \with { \consists #(solfege-engraver syls UP) }
zdown= \with { \consists #(solfege-engraver syls DOWN) }
nup= \with { \consists #(solfege-engraver numbers UP) }
ndown= \with { \consists #(solfege-engraver numbers DOWN) }
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
soprano = { g'1 | g'4 g'8.g'16 a'2 | f'1 }
alto = { e'1 | e'2 e'2 | c'1| }
\new Staff {
<<
\new Voice = "soprano" \xup {
\override TextScript.outside-staff-priority = 1000
\textLengthOn % make room for text!
\voiceOne \soprano
}
\new Voice = "alto" \nup {
\voiceTwo \alto
}
>>
}
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user