lilypond-user
[Top][All Lists]
Advanced

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

Re: pitch name transpose into numeric per key signature


From: MING TSANG
Subject: Re: pitch name transpose into numeric per key signature
Date: Mon, 29 Oct 2012 19:41:27 -0700 (PDT)

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 <address@hidden> 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



reply via email to

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