lilypond-user
[Top][All Lists]
Advanced

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

Re: TrillPitchHead doesn’t implement note-head-interface (?)


From: Thomas Morley
Subject: Re: TrillPitchHead doesn’t implement note-head-interface (?)
Date: Tue, 4 Feb 2020 00:04:55 +0100

Am Mo., 3. Feb. 2020 um 20:35 Uhr schrieb Kieren MacMillan
<address@hidden>:
>
> Hi Harm,
>
> > which question, is it solved?
>
> Yes. I fixed the OP’s MWE (see 1st score in this snippet) so that it did what 
> he wants (see 2nd score in this snippet):
>
> %%%
> \version "2.19.83"
>
> { \pitchedTrill e''2 \harmonic \startTrillSpan f'' \stopTrillSpan }
>
> dtrillOn = {
> \temporary \override TrillPitchHead.stencil = #ly:text-interface::print
> \temporary \override TrillPitchHead.text = \markup { \musicglyph 
> #"noteheads.s0harmonic" }
> }
> dtrillOff = {
> \revert TrillPitchHead.stencil
> \revert TrillPitchHead.text
> }
>
> { \dtrillOn \pitchedTrill e''2 \harmonic \startTrillSpan f'' \stopTrillSpan 
> \dtrillOff }
> %%%
>
> If there’s a better way, let me know!
>
> Cheers,
> Kieren.
> ________________________________
>
> Kieren MacMillan, composer (he/him/his)
> ‣ website: www.kierenmacmillan.info
> ‣ email: address@hidden
>

Hi Kieren,

here my own thoughts about the topic, you may recognize some parts
from my Salzburg-example ;)
And I learned something myself: I didn't know TrillPitchHead is looks
at 'duration-log before.


(1) the default always uses filled note-heads
{
    \pitchedTrill e''2 \startTrillSpan f'' \stopTrillSpan
}

(2) you can change this behaviour, setting duration-log.
Useful values are usually 0, 1, 2. If unset, the fall-back is 2
NB not all note-head-glyphs have settings for each of those numbers
{
    \override TrillPitchHead.duration-log = 0
    \pitchedTrill e''1 \startTrillSpan f'' \stopTrillSpan
    \override TrillPitchHead.duration-log = 1
    \pitchedTrill e'' \startTrillSpan f'' \stopTrillSpan
    \override TrillPitchHead.duration-log = 2
    \pitchedTrill e'' \startTrillSpan f'' \stopTrillSpan
}

(3) The default stencil-procedure is ly:note-head::print, as for common
  note-heads. But in the case of TrillPitchHead any setting of 'style leads to
  a warning and a missing stencil. Looks like only default note-heads are
  searched for TrillPitchHead.
  Conclusio: rewrite the stencil, a minimal implementation below.

\layout {
  \override TrillPitchHead.stencil =
    #(lambda (grob)
      (let* ((style (ly:grob-property grob 'style ""))
             (dur-log (ly:grob-property grob 'duration-log 2))
             (font (ly:grob-default-font grob))
             (trill-head (format #f "noteheads.s~a~a" dur-log style))
             (trill-head-stil (ly:font-get-glyph font trill-head)))
        (if (ly:stencil-empty? trill-head-stil)
            (begin
              (ly:warning
                "No note-head found for: ~a, using default." trill-head)
              (ly:grob-set-property! grob 'style '())
              (ly:note-head::print grob))
            trill-head-stil)))

  %% unrelated, just to not clutter output
  \omit TrillPitchAccidental
  \override Score.RehearsalMark.self-alignment-X = #LEFT
  %\override TrillSpanner.to-barline = ##t
}


{
    \mark "default"
    \pitchedTrill e''2 \harmonic \startTrillSpan f'' \stopTrillSpan
}


{
    \mark "style: harmonic (filled, because of default duration-log)"
    \override TrillPitchHead.style = #'harmonic
    \pitchedTrill e''2 \harmonic \startTrillSpan f'' \stopTrillSpan
}


{
    \mark "style: harmonic"
    %% a harmonic-note-head for duration-log = 1 does not exist, thus:
    \once \override TrillPitchHead.duration-log = 0
    \once \override TrillPitchHead.style = #'harmonic
    \pitchedTrill e''2 \harmonic \startTrillSpan f'' \stopTrillSpan
}


{
    \mark "other examples"
    %% a harmonic-note-head for duration-log = 1 does not exist, thus:
    \once \override TrillPitchHead.duration-log = 0
    \once \override TrillPitchHead.style = #'slash
    \override NoteHead.style = #'slash
    \pitchedTrill e''2 \startTrillSpan f'' \stopTrillSpan

    s2

    \once \override TrillPitchHead.duration-log = 1
    \once \override TrillPitchHead.style = #'diamond
    \override NoteHead.style = #'diamond
    \pitchedTrill e''2  \startTrillSpan f'' \stopTrillSpan

    s2

    %\once \override TrillPitchHead.duration-log = 1
    \once \override TrillPitchHead.style = #'cross
    \override NoteHead.style = #'cross
    \pitchedTrill e''2 \startTrillSpan f'' \stopTrillSpan

    s2
}

Best,
  Harm



reply via email to

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