lilypond-user
[Top][All Lists]
Advanced

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

Re: NoteHeads vs duration


From: David Kastrup
Subject: Re: NoteHeads vs duration
Date: Sat, 20 Aug 2016 12:20:17 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux)

Pierre Perol-Schneider <address@hidden> writes:

> Typo, sorry : so, again, how can I get access to the note head when
> duration is shorter than a fourth note ?
>
> \version "2.19.46"
>
> \score {
>   \new Staff \relative c'' { c1 2 4 8 16 32 64 128 }
>   \layout {
>     \context {
>       \Staff
>       \omit Stem
>       \omit Flag
>       \override NoteHead.stencil =
>         #(lambda (grob)
>           (let ((duration (ly:grob-property grob 'duration-log)))
>                 (case duration
>                   ((0) (grob-interpret-markup grob (markup "0")))
>                   ((1) (grob-interpret-markup grob (markup "1")))
>                   ((2) (grob-interpret-markup grob (markup "2")))
>                   ((3) (grob-interpret-markup grob (markup "3")))
>                   ((4) (grob-interpret-markup grob (markup "4")))
>                   ((5) (grob-interpret-markup grob (markup "5")))
>                   ((6) (grob-interpret-markup grob (markup "6")))
>                   ((7) (grob-interpret-markup grob (markup "7")))
>                   (else (ly:note-head::print grob)))))
>         }
>   }
> }

You don't want to "get access to the note head" since the note heads,
indeed, are all the same for durations shorter than a fourth note.
Instead, go at the actual _note_ instead, namely the stream event.

\version "2.19.46"

\score {
  \new Staff \relative c'' { c1 2 4 8 16 32 64 128 }
  \layout {
    \context {
      \Staff
      \omit Stem
      \omit Flag
      \override NoteHead.stencil =
        #(lambda (grob)
          (let ((duration (ly:duration-log
                           (ly:event-property (event-cause grob) 'duration))))
                (case duration
                  ((0) (grob-interpret-markup grob (markup "0")))
                  ((1) (grob-interpret-markup grob (markup "1")))
                  ((2) (grob-interpret-markup grob (markup "2")))
                  ((3) (grob-interpret-markup grob (markup "3")))
                  ((4) (grob-interpret-markup grob (markup "4")))
                  ((5) (grob-interpret-markup grob (markup "5")))
                  ((6) (grob-interpret-markup grob (markup "6")))
                  ((7) (grob-interpret-markup grob (markup "7")))
                  (else (ly:note-head::print grob)))))
        }
  }
}

-- 
David Kastrup

reply via email to

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