Hi, Gilles,
Thank you for the solution. It seems the padding method is simplier. I am not
a programmer.
Blessing in+,
Ming.
>________________________________
> From: Gilles <gilles.thiba...@free.fr>
>To: lilypond-usermailinglist <lilypond-user@gnu.org>; MING TSANG
><tsan...@rogers.com>
>Sent: Monday, November 5, 2012 11:30:39 AM
>Subject: Re: pitch name transpose into numeric per key signature
>
>
>> Additional question: Can the numeric line up horizontally?
>I am 3 days late answering.
>The traditional way to do that is to override the padding property, but I
>wanted to explore the method using context, that I was not used to.
>Here are the result of my tries.
>
>%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>\include "english.ly"
>%% http://lsr.dsi.unimi.it/LSR/Snippet?id=818
>
> %%%%%%%%%%%%%%%%%%%%%%%%%%%
>numbr = #(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 '("1" "2" "3" "4" "5" "6" "7") delta))
> (newgrob (ly:engraver-make-grob engraver 'TextScript event)))
> (set! (ly:grob-property newgrob 'text) name)
> ;(set! (ly:grob-property newgrob 'direction) UP)
> ))))
> %%%%%%%%%%%%%%%%%%%%%%%%%%%
>
>music = \relative c' {
>\key c\major c4 e g b d f a2 |\break
>\key g\major g,,4 b d fs a c e2 | \break
>\key ef\major ef,4 g bf d f af c2 | \break
>\key d \major d,,4 fs a cs e g b2 | \break
>\key cf\major cf,,4 ef gf bf df ff af2 | \break
>}
> %%%%%%%%%%%%%%%%%%%%%%%%%%%
>\markup "with padding"
>\score{
> \new Staff \with {
> \consists #numbr
> \override TextScript #'direction = #UP
> \override TextScript #'padding = #3
> }
> \music
>
> \layout {}
>}
> %%%%%%%%%%%%%%%%%%%%%%%%%%%
>\markup "with a new context"
>\score { <<
> \new NumbrStaff \music
> \new Staff \music
>>>
>\layout {
> \context {
> \type Engraver_group
> \name NumbrStaff
> \consists Output_property_engraver
> \consists Key_engraver % needed for tonic pitch
> \consists Note_heads_engraver % needed for pitch of note
> \consists Text_engraver
> \consists #numbr
> \consists Axis_group_engraver
>
> \override KeySignature #'stencil = ##f
> \override KeyCancellation #'stencil = ##f
> \override NoteHead #'stencil = ##f
> % this section is a copy of NoteNames engraver in engraver-init.ly
> \override VerticalAxisGroup #'staff-affinity = #UP
> \override VerticalAxisGroup #'nonstaff-nonstaff-spacing =
> #'((basic-distance . 0)
> (minimum-distance . 2.8)
> (padding . 0.2)
> (stretchability . 0))
> \override VerticalAxisGroup #'nonstaff-relatedstaff-spacing =
> #'((basic-distance . 5.5)
> (padding . 0.5)
> (stretchability . 1))
> \override VerticalAxisGroup
> #'nonstaff-unrelatedstaff-spacing #'padding = 1.5
> }
> \context { \Score \accepts NumbrStaff }
>}
>}
>%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>
>-- Gilles
>
>
>
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user