lilypond-user
[Top][All Lists]
Advanced

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

Re: Can NoteNames in higher octaves be changed?


From: David Nalesnik
Subject: Re: Can NoteNames in higher octaves be changed?
Date: Mon, 15 Sep 2014 18:55:53 -0500

Hi Jay,

On Mon, Sep 15, 2014 at 4:27 AM, Jay Vara <address@hidden> wrote:
> I'm not top posting.

NoteNames will print the higher (and lower) octave names with
printOctaveNames set to true. It prints them as c', d', c, d, etc.

My question is: Is it possible to have the higher octaves print using a
different character, say C D E F etc rather than c', d', e', f'.


Yes, it is possible to do this by modifying the stencil of the NoteName grob.  I'm not sure what your system is, so I thought I'd show how you might convert Lilypond's pitch representation into the familiar C4=middle C system.  You could probably adapt it to your needs.

This only works with single notes at the moment, but I'll fiddle around with it some more.

Hope this helps,
David

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \version "2.18.2"

pitches = \relative c,, {
  \clef bass
  c c' c' c'
  \clef treble
  c' c' c' c'
}

#(define (extract-note-name str)
   (let* ((lst (string->list str))
          (hd (take-while char-alphabetic? lst)))
     (list->string hd)))

\new Staff {
  <<
    \pitches
    \context NoteNames {
      \set printOctaveNames = ##t
      \override NoteName.stencil =
      #(lambda (grob)
         (let* ((text (ly:grob-property grob 'text))
                (name (string-upcase (extract-note-name text)))
                (up-count (string-count text #\'))
                (down-count (string-count text #\,))
                (num
                 (cond
                  ((> up-count 0) (+ up-count 3))
                  ((> down-count 0) (- 3 down-count))
                  (else 3)))
                (num-text (number->string num))
                (name (string-append name num-text)))  
           (grob-interpret-markup grob name))) 
      \pitches
    }
  >>
}

reply via email to

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