Jump to content

Including accidental and dots in a parenthesized note (obsolete in 2.23)

From LilyPond wiki

[This snippet is obsolete since LilyPond version 2.19.20.]

Sometimes a parenthesized note should include its accidental sign and/or dot.

Using \parenthesize won't do that.

The defined function \parentheAll will.

\version "2.24"

%%%% http://lsr.di.unimi.it/LSR/Item?id=972
% added by PPS on Jan. 2015.
%% => https://code.google.com/p/lilypond/issues/detail?id=155
%% => http://lilypond.1069038.n5.nabble.com/Pitched-trill-glissando-tc170876.html
%%
%% The functionality of this snippet is default for 2.19.20;
%% it is thus obsolete.

parentheAll = #(define-music-function (note) (ly:music?)
#{
  \once \override Parentheses.font-size = #-1
  \once \override Parentheses.stencil = #(lambda (grob)
       (let* ((acc (ly:grob-object (ly:grob-parent grob Y) 'accidental-grob))
              (dot (ly:grob-object (ly:grob-parent grob Y) 'dot)))
         (if (not (null? acc)) (ly:pointer-group-interface::add-grob grob 'elements acc))
         (if (not (null? dot)) (ly:pointer-group-interface::add-grob grob 'elements dot))
         (parentheses-interface::print grob)))
  \parenthesize $note
#})


\paper { indent = 0 }
\header { tagline = ##f }

{
  \textMark\markup\small\column { 
    \italic "Using" \vspace #.3
    \typewriter "\parenthesize" 
  }
  \parenthesize cis''4.
  s1
  \stopStaff
  s1

  \startStaff
  s4 \bar ""
  \textMark\markup\small\column { 
    \italic "Using" \vspace #.3
    \typewriter "\parentheAll" 
  }
  \parentheAll cis''!4.
  s1 s4
  \stopStaff
  s1

  \startStaff
  s4 \bar ""
  \tweak padding #4
  \textMark\markup\small\column { 
    \italic "e.g., when applied in a" \vspace #.3
    \typewriter "\pitchedTrill"  \vspace #.3
    \italic "context:"
  }
  \pitchedTrill b2\startTrillSpan 
    -\tweak minimum-length #10
    -\tweak springs-and-rods #ly:spanner::set-spacing-rods
    -\tweak bound-details.right.Y #-2.7
    -\tweak bound-details.left.padding #3.5
    -\tweak bound-details.right.padding #.8
    \glissando ~ ces'
  \once \omit Staff.Flag
  \once \omit Staff.Stem
  \once \override NoteHead.font-size = #-4
  \once \override NoteHead.X-offset = #-.4
    \grace { \parentheAll c'!8 }
  b8\stopTrillSpan r8 
}

\layout {
  \context {
    \Score
    \omit TimeSignature
    \override Clef.transparent = ##t
    \override BarLine.transparent = ##t
  }
}