lilypond-user
[Top][All Lists]
Advanced

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

Re: change custom notehead for different stem direction


From: Orm Finnendahl
Subject: Re: change custom notehead for different stem direction
Date: Wed, 8 Sep 2021 13:23:35 +0200

Hi all,

 below is a working example for the record. You can tweak the
linewidth changing "setlinewidth 1" in flpizzleft and flpizzright or
the angles/proportions of the lines in the line containing the moveto,
lineto and stroke. Even if you don't know Postscript it should be
fairly obvious. When changing the linewidth you might have to adjust
the connection points for the stems accordingly.

Thanks again, Lukas!

--
Orm

8<-------------------------------------------------------------------

flpizzleft = \markup { \with-dimensions #'(0 . 0.9) #'(0 . 0.8)
                       \postscript #"0 setgray
1 setlinecap
1 setlinejoin
0.2 setlinewidth
0.9 0.8 moveto 0 0.4 lineto 0.9 0 lineto stroke
" }

flpizzright = \markup { \with-dimensions #'(0 . 0.9) #'(0 . 0.8)
                       \postscript #"0 setgray
1 setlinecap
1 setlinejoin
0.2 setlinewidth
0 0.8 moveto 0.9 0.4 lineto 0 0 lineto stroke
" }

flutepizz = {
 \override NoteHead.stencil = #ly:text-interface::print
  \override NoteHead.text =
  #(lambda (grob)
    (let*
     ((notecolumn (ly:grob-parent grob X))
      (stem (ly:grob-object notecolumn 'stem))
      (direction (ly:grob-property stem 'direction)))
     (markup #:general-align
      Y CENTER
      (if (positive? direction) flpizzright flpizzleft))))

    \override NoteHead.stem-attachment =
  #(lambda (grob)
    (let*
     ((notecolumn (ly:grob-parent grob X))
      (stem (ly:grob-object notecolumn 'stem))
      (direction (ly:grob-property stem 'direction)))
     (if (positive? direction) '(1.223 . -0.1) '(1.223 . -0.1))))
  }

{ \flutepizz c''4 f'16 c' d' cis''}
8<-------------------------------------------------------------------


Am Mittwoch, den 08. September 2021 um 10:32:35 Uhr (+0200) schrieb 
Lukas-Fabian Moser:
> Hi Orm,
> 
> >   for flute pizzicato in contemporary music, it is quite common to use
> > a ">" as a notehead. With a stem down, the ">" should be changed to a
> > "<" as visible in the attached png.
> > 
> > I know how to change the notehead by overriding the NoteHead stencil
> > with an eps file, but can't find any information about automatically
> > changing the glyph depending on stem direction. Is that possible in
> > lilypond and does anybody have advice?
> > 
> > It's cumbersome to do this by hand each time stem direction is
> > changed.
> 
> Unfortunately you didn't provide a working example, hence my cumbersome and
> ugly choice of > or < for "note-heads".
> 
> \version "2.22.0"
> 
> \relative
> {
>   \override NoteHead.stencil = #ly:text-interface::print
>   \override NoteHead.text =
>   #(lambda (grob)
>      (let*
>       ((notecolumn (ly:grob-parent grob X))
>        (stem (ly:grob-object notecolumn 'stem))
>        (direction (ly:grob-property stem 'direction)))
>       (markup #:general-align
>               Y CENTER
>               (if (positive? direction) ">" "<"))))
>   c'4 d e f g a b c d e f
> }
> 
> Of course, one might adapt the general logic to either use glyphs better
> suited than ">"/"<", or even conditionally rotate/mirror _any_ note-head
> depending on the direction. (One might use grob-transformer for that.)
> 
> Lukas
> 



reply via email to

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