Am Montag, 4. Mai 2009 17:28:54 schrieb Jonathan Kulp:
> Mark Austin wrote:
> > Is it possible to enclose a note in brackets? I need to do this to
> > indicate a lead note played the first time but not on subsequent
> > repeats.
>
> In a thread a while back we came up with a way to put brackets (not
> parentheses) around a rest.  You could try it with your lead note, too:

Another possibility is to hook into the way \parenthesize formats the 
parentheses: It obtains stencils for the opening and closing parentheses, so 
one was is to simply override them with opening and closing brackets. See the 
attached snippet, which defines a \bracketify command, which can be used almost 
like \parenthesize (bracketing individual notes of a chord doesn't work due to 
my use of \once\override inside the function).

Cheers,
Reinhold

-- 
------------------------------------------------------------------
Reinhold Kainhofer, reinh...@kainhofer.com, http://reinhold.kainhofer.com/
 * Financial & Actuarial Math., Vienna Univ. of Technology, Austria
 * http://www.fam.tuwien.ac.at/, DVR: 0005886
 * LilyPond, Music typesetting, http://www.lilypond.org
\version "2.13.1"

#(define-public (bracket-stencils grob)
  (let* ((font (ly:grob-default-font grob))
         (layout (ly:grob-layout grob))
         (props (ly:grob-alist-chain grob (ly:output-def-lookup layout 'text-font-defaults)))
	 (lp (ly:text-interface::interpret-markup layout props (markup #:fontsize 3.5 #:translate (cons -0.3 -0.5) "[")))
	 (rp (ly:text-interface::interpret-markup layout props (markup #:fontsize 3.5 #:translate (cons -0.3 -0.5) "]"))))
    (list lp rp)))

bracketify = #(define-music-function (parser loc arg) (ly:music?)
   (_i "Tag @var{arg} to be parenthesized.")
#{
  \once \override ParenthesesItem #'stencils = #bracket-stencils
  \parenthesize $arg
#}
)

\relative c'' {
  c4 
  \parenthesize c 
  \bracketify c4 
  \bracketify g4 
%   < e \bracketify g b >  % This doesn't work!!!
  \bracketify < e g b > 
  \bracketify r4 
}

Attachment: bracket.pdf
Description: Adobe PDF document

_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to