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: Sun, 13 Jan 2019 19:41:15 +0100

Well, I'm still confused what you're after...

Am So., 13. Jan. 2019 um 13:43 Uhr schrieb Gloops <address@hidden>:

> Hello Harm!
> Sorry, I did not express myself well!
> I want to go through "Ez_numbers_engraver_harm"
> to convert NoteHead to a number and display AmbitusNoteHead directly.
> I do not want (if possible) to go through "brew-ez-stencil" ...
> Gilles
>
> <http://lilypond.1069038.n5.nabble.com/file/t5463/document.png>
>
> <http://lilypond.1069038.n5.nabble.com/file/t5463/document2.png>

>From the images, something like below?

#(define-public (note-head::brew-ez-no-head-stencil grob)
  (let* ((pitch (ly:event-property (event-cause grob) 'pitch))
         (pitch-index (ly:pitch-notename pitch))
         (note-names (ly:grob-property grob 'note-names))
         (pitch-string (if (and (vector? note-names)
                                (> (vector-length note-names) pitch-index))
                           (vector-ref note-names pitch-index)
                           (string
                            (integer->char
                             (+ (modulo (+ pitch-index 2) 7)
                                (char->integer #\A))))))
         (staff-space (ly:staff-symbol-staff-space grob))
         (line-thickness (ly:staff-symbol-line-thickness grob))
         (font-size (ly:grob-property grob 'font-size 0))
         (radius (* (magstep font-size) (/ (+ staff-space line-thickness) 2)))
         (letter
           (make-fontsize-markup
             font-size
             (make-center-align-markup (make-vcenter-markup pitch-string)))))

    (ly:stencil-translate-axis
     (grob-interpret-markup grob letter)
     radius
     X)))


#(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))))
                             (stencil-proc
                               (assoc-get
                                 'stencil-proc
                                 details
                                 ;; fall-back:
                                 note-head::brew-ez-stencil)))
                    (ly:grob-set-property! grob 'note-names note-names)
                    (ly:grob-set-property! grob 'font-family 'sans)
                    (ly:grob-set-property! grob 'font-series 'bold)
                    (ly:grob-set-property! grob 'stencil
                      (if (procedure? stencil-proc)
                          (stencil-proc grob)
                          point-stencil)))))))

            (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

\score {
  \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
    }
  >>
  \layout {
    ragged-right = ##t
    \context {
      \Voice
      \consists \Ez_numbers_engraver_harm
      \consists "Ambitus_engraver"
%% Choose the font-size
      \override AmbitusNoteHead.font-size = -3
%% Choose the procedure to create the "ez-stencil"
%% Possible is currently:
%% note-head::brew-ez-no-head-stencil
%% or
%% note-head::brew-ez-stencil
%% Which is the fall-back as well (if details.stencil-proc is unset/commented)
%% An unsuitable setting here will result in point-stencil
      \override AmbitusNoteHead.details.stencil-proc =
        #note-head::brew-ez-no-head-stencil
      \easyAmbitusHeadsOn
    }
  }
}

HTH,
  Harm



reply via email to

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