lilypond-user
[Top][All Lists]
Advanced

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

Re: Can an augmentation dot be parenthesized?


From: Thomas Morley
Subject: Re: Can an augmentation dot be parenthesized?
Date: Wed, 24 May 2017 23:46:49 +0200

Hi David,

2017-05-24 22:40 GMT+02:00 David Nalesnik <address@hidden>:
> Hi,
>
> On Wed, May 24, 2017 at 12:47 PM, Lukas-Fabian Moser <address@hidden> wrote:
>> Hi Robert,
>>
>>>
>>> I would tather like to parenthesize these added augmenation dots but I've
>>> not found a way to do that.
>>
>>
>> I don't know how to parenthesize them, but here is a solution yielding
>> brackets around them:
>
> You can use the function parenthesize-stencil to do this.
>>
>> \version "2.19.44"
>>
>> #(define (special-bracketify original-stencil len thick protusion padding)
>>   (let* (
>>          (left-bracket (ly:bracket Y (cons (- len) len) thick (-
>> protusion)))
>>          (right-bracket (ly:bracket Y (cons (- len) len) thick protusion)))
>>     (set! original-stencil
>>  (ly:stencil-combine-at-edge original-stencil X RIGHT right-bracket (- -0.73
>> padding)))
>>     (set! original-stencil
>> (ly:stencil-combine-at-edge original-stencil X RIGHT left-bracket padding))
>>     original-stencil))
>>
>> bracketDot = \once \override Dots.stencil = #(lambda (grob)
>>     (special-bracketify (ly:dots::print grob) 0.4 0.1 0.2 0))
>> % first number (0.4): bracket length
>> % second number (0.1): thickness
>> % third number (0.2): protrusion
>> % fourth number (0.1): space between dot and brackets
>>
>>
>>  {
>>   c''4.
>>   r8
>>   \bracketDot
>>   a'4.
>>   r8
>> }
>>
>>
>> Question to the experts: If I unterstand my own code correctly :-), the
>> right-hand edge of the dot stencil (used by stencil-combine-at-edge) is the
>> right-most part of the dot itself, while the left-hand edge seems to be the
>> right-most part of the note the dot is attached to.
>> For this reason I took (for the left bracket) the *right* hand edge of the
>> dot and added offsets with trial-and-error, which should be fine since I
>> assume the dot will have the same size wherever it occurs. But nevertheless
>> there must be a more conceptual way?
>
> The dots are created by a character in the font which consists of the
> actual dot and whitespace to the left.  (This means that the space
> between dots can't be adjusted.

To illustrate:

{
  \once \override Dots.stencil =
    #(lambda (grob) (box-stencil (ly:dots::print grob) 0 0))
  <a' c'' e''>4.
}

> I wonder if it would be better to
> trim the character and add a property, like 'dot-separation.)

I tend to agree, though, more for DotColumn than Dots, I assume.
And DotColumn is a beasty thing ...

> You can go your route, adding the brackets individually with an
> offset, or you could make your own dots, gleaning information from the
> dots.dot glyph. That's what I do below.  (You can get either
> parentheses or brackets.)
>
> %%%%%%%%%%%%%%%%%
> \version "2.19.44"
>
> #(define (parenthesized-dots grob)
>    (let ((mol empty-stencil)
>          (c (ly:grob-property grob 'dot-count)))
>      (if (number? c)
>          (let* ((d (ly:font-get-glyph (ly:grob-default-font grob) "dots.dot"))
>                 (thick (ly:output-def-lookup (ly:grob-layout grob)
> 'line-thickness))
>                 (Y-ext (ly:stencil-extent d Y))
>                 (replacement-dot (make-circle-stencil
>                                   (/ (- (interval-length Y-ext) thick) 2)
>                                   thick
>                                   #t))
>                 (dw (interval-length (ly:stencil-extent d X)))
>                 (mol-lst (make-list c replacement-dot))
>                 (mol (reduce
>                       (lambda (elem prev) (ly:stencil-combine-at-edge
> prev X RIGHT elem dw))
>                       point-stencil
>                       mol-lst))
>                 ; to make brackets instead
>                 ; stencil, axis, thick, protrusion, padding
>                 ;(mol (bracketify-stencil mol Y thick 0.2 0))
>                 ; stencil, half-thickness, width, angularity, padding
>                 (mol (parenthesize-stencil mol (/ thick 2) 0.2 0 0))
>                 (mol (ly:stencil-translate-axis mol (+ dw thick) X)))
>            mol))))
>
> parenthesizeDots = \override Dots.stencil = #parenthesized-dots
>
> {
>   \parenthesizeDots
>   c''4 r
>   c''4. r8
>   c''4.. r16
>   c''4... r32
>   c''4.... r64
>   c''4..... r128
> }

Well done. Though I can't see a way how to parenthesize only one dot in
<c'' d''>4.

So I prefer my coding at
http://lists.gnu.org/archive/html/lilypond-user/2017-05/msg00371.html

Otoh, with your coding and only a little additional code it is be
possible to parenthesize only the last dot in
c''4..
but not with mine.

#(define (parenthesized-dots grob)
   (let ((mol empty-stencil)
         (c (ly:grob-property grob 'dot-count)))
     (if (number? c)
         (let* ((d (ly:font-get-glyph (ly:grob-default-font grob) "dots.dot"))
                (thick (ly:output-def-lookup (ly:grob-layout grob)
'line-thickness))
                (Y-ext (ly:stencil-extent d Y))
                (replacement-dot (make-circle-stencil
                                  (/ (- (interval-length Y-ext) thick) 2)
                                  thick
                                  #t))
                (dw (interval-length (ly:stencil-extent d X)))
                (mol-lst (make-list c replacement-dot))
;; added
                ;; all but elegant,
                ;; just a proof of concept:
                (mol-lst
                  (append
                     (drop-right mol-lst 1)
                     (list
                       (parenthesize-stencil
                         replacement-dot (/ thick 2) 0.2 0 0))))
                (mol (reduce
                      (lambda (elem prev)
                        (ly:stencil-combine-at-edge prev X RIGHT elem dw))
                      point-stencil
                      mol-lst))
                ; to make brackets instead
                ; stencil, axis, thick, protrusion, padding
                ;(mol (bracketify-stencil mol Y thick 0.2 0))
                ; stencil, half-thickness, width, angularity, padding
;; commented
                ;(mol (parenthesize-stencil mol (/ thick 2) 0.2 0 0))
                (mol (ly:stencil-translate-axis mol (+ dw thick) X)))
           mol))))

>
> %%%%%%%%%%%
>
> Hope this helps,
> David

Cheers,
  Harm



reply via email to

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