lilypond-user
[Top][All Lists]
Advanced

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

Re: Analysis brackets


From: Kevin Barry
Subject: Re: Analysis brackets
Date: Thu, 9 Apr 2020 20:44:48 +0100

Hi Michael,

Below is some code that replaces a horizontal bracket with a curly
brace of the same width. The math is the result of experimentation,
but it seems to hold up to changes in staff size and for medium-sized
groupings of notes.

\version "2.19.84"

#(define curly-analysis-brace
   (lambda (bracket)
     (let* ((bracket-width (interval-length
                            (ly:stencil-extent
(ly:horizontal-bracket::print bracket) X)))
            (bracket-dir (ly:grob-property bracket 'direction))
            (bracket-layout (ly:grob-layout bracket))
            (output-scale
             (/ (ly:output-def-lookup bracket-layout 'output-scale)
1.75729901757299))
            (brace-rotation (if (eq? bracket-dir DOWN) 90 270))
            (brace-size (* 5 bracket-width output-scale))
            (y-scale (- 1 (* brace-size (/ brace-size 1.5) 0.000004 (/
1 output-scale))))
            (brace-offset (* (/ 1 output-scale)
                            (+ (* 0.2 output-scale) (* 0.103 brace-size))))
            )
       (ly:grob-set-property! bracket 'text
         #{ \markup
            \scale #`(1 . ,y-scale)
            \translate #`(,brace-offset . 0)
            \rotate #brace-rotation
            \left-brace #brace-size #})
       (ly:grob-set-property! bracket 'stencil ly:text-interface::print)
       )))

% \startCurlyGroup is a convenience for doing just one curly analysis bracket
startCurlyGroup = \tweak after-line-breaking #curly-analysis-brace \startGroup

\score {
  \relative {
    c''4\startGroup \startGroup \startGroup
    d4\stopGroup
    e4
    d4
    c d e d\stopGroup
    c d e d\stopGroup
  }
  \layout {
    \context {
      \Voice
      \consists "Horizontal_bracket_engraver"
      \override HorizontalBracket.after-line-breaking = #curly-analysis-brace
    }
  }
}

Kevin

On Thu, 9 Apr 2020 at 17:51, Pierre Perol-Schneider
<address@hidden> wrote:
>
> Hi Michael,
> That may work, e.g.:
>
> \version "2.20.0"
>
> #(define-markup-command (lcb layout props arg)
>    (number?)
>   "Draw a curly bracket with a variable length."
>      (interpret-markup layout props
>        (markup
>          (#:override (cons (quote filled) #t)
>           (#:path 0 `(
>            (moveto   -0.8   0.0)
>            (curveto  -0.2   0.4  -0.3  0.7 -0.3  1.5)
>            (lineto   -0.3   ,arg)
>            (curveto  -0.4   ,(+ arg 1.3) 0.5 ,(+ arg 2.8) 0.7 ,(+ arg 2.8))
>            (curveto   0.6   ,(+ arg 2.5) 0.1 ,(+ arg 2)   0.1 ,arg)
>            (lineto    0.1   1.5)
>            (curveto   0.1   0.7   0.1   0.0  -0.8   0.0)
>            (closepath)
>            (curveto  -0.2  -0.4  -0.3  -0.7  -0.3  -1.5)
>            (lineto   -0.3   ,(* arg -1))
>            (curveto  -0.4   ,(* (+ arg 1.3) -1) 0.5 ,(* (+ arg 2.8) -1) 0.7 
> ,(* (+ arg 2.8) -1))
>            (curveto   0.6   ,(* (+ arg 2.5) -1) 0.1 ,(* (+ arg 2) -1)   0.1 
> ,(* arg -1))
>            (lineto    0.1  -1.5)
>            (curveto   0.1  -0.7   0.1   0.0  -0.8   0.0)
>            (closepath)))))))
>
>
> \relative c'' {
>   c4 _\markup {
>     \with-dimensions-from \null
>       \left-align {
>         \override #'(baseline-skip . 0)
>         \center-column {
>           "a" \vspace #-.1
>           \rotate #90 \lcb #3
>           \vspace #.1 "b"
>         }
>       }
>     } d e
>   -\tweak extra-offset #'(0 . -5)
>    _\markup {
>     \with-dimensions-from \null
>       \left-align {
>         \override #'(baseline-skip . 0)
>         \center-column {
>           "a" \vspace #-.1
>           \rotate #90 \lcb #5
>           \vspace #.1 "b"
>         }
>       }
>     }d c
>   b
>   -\tweak extra-offset #'(.5 . 3)
>   ^\markup {
>     \with-dimensions-from \null
>       \left-align {
>         \override #'(baseline-skip . 0)
>         \center-column {
>           "a" \vspace #.1
>           \rotate #-90 \lcb #6
>           \vspace #-.1 "b"
>         }
>       }
>     } a g f e d c
> }
>
> HTH,
> Cheers,
> Pierre
>
> Le jeu. 9 avr. 2020 à 17:27, Michael Taylor <address@hidden> a écrit :
>>
>> Dear David,
>> Many thanks for this. I was curious about the curly analysis brackets when I 
>> saw this in Snippets http://lsr.di.unimi.it/LSR/Search?q=curly but couldn't 
>> figure out how (or if) these
>> shapes could be used for what I wanted. The only application I could find 
>> was to group an
>> ensemble within a larger instrumental contingent.
>> With best wishes
>> Michael
>>
>> On Tue, 7 Apr 2020 at 23:00, David Nalesnik <address@hidden> wrote:
>>>
>>> On Tue, Apr 7, 2020 at 11:07 AM Michael Taylor
>>> <address@hidden> wrote:
>>> > Would it be possible in a future version to have the option of placing 
>>> > text within analysis brackets as well as the default above? MT
>>>
>>> HorizontalBracketText.direction with a little more tweaking than
>>> should be necessary.
>>>
>>> \layout {
>>>   \context {
>>>     \Voice
>>>     \consists "Horizontal_bracket_engraver"
>>>     \override HorizontalBracket.direction = #UP
>>>   }
>>> }
>>>
>>> {
>>>   \once\override HorizontalBracketText.direction = #DOWN
>>>   \once\override HorizontalBracketText.text = "a"
>>>   \once\override HorizontalBracketText.padding = #-0.5
>>>   \once\override HorizontalBracket.padding = 1
>>>   c''\startGroup d''\stopGroup
>>> }



reply via email to

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