lilypond-user
[Top][All Lists]
Advanced

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

Re: Ambitus per voice and Ez_numbers_engraver


From: Thomas Morley
Subject: Re: Ambitus per voice and Ez_numbers_engraver
Date: Wed, 9 Jan 2019 01:41:06 +0100

Am Di., 8. Jan. 2019 um 14:51 Uhr schrieb Gloops <address@hidden>:
>
> Hello!
> Ambitus by voice and Ez_numbers_engraver can not work together?

The problem: Ez_numbers_engraver works on every grob with a
note-head-interface. NoteHeads and AmbitusNoteHead both have this.
Though, at the time this engraver works the pitch of AmbitusNoteHead
is not yet known, thus an error occurs if one tries to rely on this
pitch.

Suggestion:
Do settings for AmbitusNoteHead after-line-breaking, switched on by
the (new introduced) details.ez-numbers-property and let the other
code do as before.

There's wide room for improvements, ofcourse. Nevertheless here the code:

\version "2.19.82"

#(define Ez_numbers_engraver_harm
   (make-engraver
    (acknowledgers
     ((note-head-interface engraver grob source-engraver)
      (let* ((context (ly:translator-context engraver))
             (tonic-pitch (ly:context-property context 'tonic))
             (tonic-name (ly:pitch-notename tonic-pitch)))
        (if (grob::has-interface grob 'ambitus-interface)
            (let* ((details (ly:grob-property grob 'details))
                   (ez-numbers (assoc-get 'ez-numbers details #f)))
              (if ez-numbers
                  (ly:grob-set-property! grob 'after-line-breaking
                    (lambda (grob)
                      (let* ((grob-pitch
                              (ly:event-property (event-cause grob) 'pitch))
                             (grob-name (ly:pitch-notename grob-pitch))
                             (delta (modulo (- grob-name tonic-name) 7))
                             (note-names
                              (make-vector 7 (number->string (1+ delta)))))
                    (ly:grob-set-property! grob 'note-names note-names)
                    (ly:grob-set-property! grob 'stencil
                      (note-head::brew-ez-stencil grob))
                    (ly:grob-set-property! grob 'font-family 'sans)
                    (ly:grob-set-property! grob 'font-series 'bold))))))

            (let* ((grob-pitch
                    (ly:event-property (event-cause grob) 'pitch))
                   (grob-name (ly:pitch-notename grob-pitch))
                   (delta (modulo (- grob-name tonic-name) 7))
                   (note-names
                    (make-vector 7 (number->string (1+ delta)))))
              (ly:grob-set-property! grob 'note-names note-names))))))))

easyAmbitusHeadsOn = \override AmbitusNoteHead.details.ez-numbers = ##t


\layout {
  ragged-right = ##t
  \context {
    \Voice
    \consists \Ez_numbers_engraver_harm
    \consists "Ambitus_engraver"
    \easyAmbitusHeadsOn
  }
}

\new Staff <<
  \new Voice \with {

  } \relative c'' {
      \key f \major
    \override Ambitus.X-offset = #2.0
    \voiceOne
    \easyHeadsOn
    c4 a d e
    f2
  }
  \new Voice \with {

  } \relative c' {
    \voiceTwo
    \easyHeadsOn
    es4 f g  as
    b1
  }
>>

HTH,
  Harm



reply via email to

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