lilypond-user
[Top][All Lists]
Advanced

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

Re: Parenthensize a horizontal group?


From: Aaron Hill
Subject: Re: Parenthensize a horizontal group?
Date: Wed, 30 Jun 2021 21:58:37 -0700
User-agent: Roundcube Webmail/1.4.9

On 2021-06-30 9:07 pm, Aaron Hill wrote:
On 2021-06-30 9:00 pm, Mark Probert wrote:
Hi.

I've looked through docs and snippets and can't seem to find a way to
place parens around a horizontal group of notes (an "optional"
indicator for leadsheets). I've tried

 \parenthesize { a8 bes }

but nope. Is there a simple way? I want to do something like:

 \mark "(" a8 bes \mark ")"

and have the parens aligned on the center of the staff.

Does LSR 902 [1] help?

[1]: https://lsr.di.unimi.it/LSR/Item?id=902


Or perhaps this which might be easier to use if this sort of thing occurs often:

%%%%
\version "2.22.0"

parenthesizeMusic =
#(define-music-function (music) (ly:music?)
  (define ((stencils which) grob)
   (let* ((stens (parentheses-item::calc-parenthesis-stencils grob))
          (sten (which stens)))
(if (eq? which first) (list sten point-stencil) (list point-stencil sten))))
  (define (add-tweak event tweak)
   (ly:music-set-property! event 'tweaks
    (cons tweak (ly:music-property event 'tweaks '()))))
  (let ((evs (extract-typed-music music 'rhythmic-event)))
   (ly:music-set-property! (first evs) 'parenthesize #t)
(add-tweak (first evs) `((ParenthesesItem . stencils) . ,(stencils first)))
   (ly:music-set-property! (last evs) 'parenthesize #t)
(add-tweak (last evs) `((ParenthesesItem . stencils) . ,(stencils second))))
  music)

{
  \override ParenthesesItem.font-size = 5
  \override ParenthesesItem.extra-offset =
    #(lambda (grob) (cons 0 (* -1/2 (ly:grob-staff-position grob))))
  \parenthesizeMusic { <c' c''> d' e' f' g' }
}
%%%%


-- Aaron Hill

Attachment: group-paren.cropped.png
Description: PNG image


reply via email to

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