Re: pitch name transpose into numeric per key signature
Hi, Gilles, Thank you for the solution. It seems the padding method is simplier. I am not a programmer. Blessing in+, Ming. > > From: Gilles >To: lilypond-usermailinglist ; MING TSANG > >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
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
Re: pitch name transpose into numeric per key signature
Gilles, Thank you for you answer. This is great. Additional question: Can the numeric line up horizontally? Blessing in+, Lyndon. > > From: Gilles > >> One question though: Can the numeric displayed above the staff? > >Just set the property of newgrob to UP ( = 1 ) > > > >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) > >%% >--Gilles > > >___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: pitch name transpose into numeric per key signature
One question though: Can the numeric displayed above the staff? Just set the property of newgrob to UP ( = 1 ) 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) %% -- Gilles ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: pitch name transpose into numeric per key signature
The code below is a "mix" of the code you gave and this snippet. I forget \include "english.ly" (It's was the original language) -- Gilles ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: pitch name transpose into numeric per key signature
Gilles: Thank you for your solution concerning \numbr. It is great and is what I am looking for. I have been using Ez_numbers_engraver for sometime now. It is great to display numeric of pitch name per key signature inside notehead. One draw back is that the notehead need to be large for easy reading. When notehead is large, the staff becomes large as well. The \numbr you provided is excellent. The staff and noteheads remain the same while the numeric equivalent notehead pitch per key signature is displayed below the staff. One question though: Can the numeric displayed above the staff? Thanks again for your solution. Blessing +, Ming. <><><><><><><><><><><><><><><> Le Sun, 28 Oct 2012 23:16:34 +0100, MING TSANG a écrit: (let* ... (scalestep (modulo (- (ly:pitch-notename pitch) (...base of key signature...)) 7)) (name (format #f "~a~a" (string-ref "1234567" (scalestep))... If i well understand what you want, there is a snippet very near of what you are searching. http://lsr.dsi.unimi.it/LSR/Snippet?id=818The code below is a "mix" of the code you gave and this snippet. %%numbr = #(make-engraver (acknowledgers ((note-head-interfaceengraver grob source) (let* ( (context (ly:translator-contextengraver)) (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-grobengraver 'TextScript event))) (set! (ly:grob-property newgrob 'text) name) music= \relative c' { \key c\major c4 d e f g a b2 |\break \key g\major g4 a b c d e fs2 | \break \key ef\major ef,4 f g af bf c d2 | \break \key d \major d,4 e fs g a b cs2 | \break \key cf\major cf,4 df ef ff gf af bf2 | \break } \score{ \new Staff \with {\consists #numbr } \music \layout {} } %%% -- Gilles ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: pitch name transpose into numeric per key signature
Le Sun, 28 Oct 2012 23:16:34 +0100, MING TSANG a écrit: (let* ... (scalestep (modulo (- (ly:pitch-notename pitch) (...base of key signature...)) 7)) (name (format #f "~a~a" (string-ref "1234567" (scalestep))... If i well understand what you want, there is a snippet very near of what you are searching. http://lsr.dsi.unimi.it/LSR/Snippet?id=818 The code below is a "mix" of the code you gave and this snippet. %% 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) music = \relative c' { \key c\major c4 d e f g a b2 |\break \key g\major g4 a b c d e fs2 | \break \key ef\major ef,4 f g af bf c d2 | \break \key d \major d,4 e fs g a b cs2 | \break \key cf\major cf,4 df ef ff gf af bf2 | \break } \score{ \new Staff \with {\consists #numbr } \music \layout {} } %%% -- Gilles ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: pitch name transpose into numeric per key signature
(let* ... (scalestep (modulo (- (ly:pitch-notename pitch) (...base of key signature...)) 7)) (name (format #f "~a~a" (string-ref "1234567" (scalestep))... assuming someone can point out what to substitute for my unknown quantity. The following is only work for C Major. It is not working for other keys. I am no programer. I don't know how to code for blue text above. the original code: 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 "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) Blessing in+,___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: pitch name transpose into numeric per key signature
Hi, lily user community: I apologize if my email to the community offended anyone. I am truly sorry. I understand all of you are volunteer and I also understood you all felt satisfaction when one of the user is help. Thank you for what all of you have done in the past and I am sure the help for lily user community will continue. Blessing in+, Ming ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user