lilypond-user
[Top][All Lists]
Advanced

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

Re: Cautionary Accidental Stencil


From: Benjamin Strecker
Subject: Re: Cautionary Accidental Stencil
Date: Mon, 28 Nov 2016 14:31:25 -0500

Abraham,

> On Tue, Nov 22, 2016 at 1:25 PM, Abraham Lee <[hidden email]> wrote:
>>
>>
>> Here's how you can use the same functionality as the markup macro
>> "bracket" to do the job:
>>
>> %%%%%%%%%%%%%%%
>>
>> \version "2.19.36"
>>
>> bracketAcc = {
>>   \once \override AccidentalCautionary.parenthesized = ##f
>>   \once \override AccidentalCautionary.stencil =
>>   #(lambda (grob)
>>      (let ((stil (ly:accidental-interface::print grob))
>>            (th 0.1))
>>        (bracketify-stencil stil Y th (* 2.5 th) th)))
>> }
>>
>> \score {
>>   \new Staff {
>>     c''4 c''? \bracketAcc c''? c''
>>   }
>> }
>>
>> %%%%%%%%%%%%%%%
>>
>> An unfortunate side-effect of this is that each accidental's brackets will
>> look different because it draws brackets that span the accidental's exact
>> vertical extent (e.g., compare a flat vs. a natural). So, here's another
>> variant that I cobbled together based on the same macro and the underlying
>> "bracketify-stencil" command. It works better because it makes the brackets
>> *act like the normal parentheses* so you get a more consistent look for any
>> accidental:
>>
>> %%%%%%%%%%%%%%%
>>
>> \version "2.19.36"
>>
>> bracketAcc = {
>>   \once \override AccidentalCautionary.parenthesized = ##f
>>   \once \override AccidentalCautionary.stencil =
>>   #(lambda (grob)
>>      (let* ((paren-stil
>>               (grob-interpret-markup grob
>>                 (markup #:musicglyph "accidentals.leftparen")))
>>             (axis Y)
>>             (other-axis (lambda (a) (remainder (+ a 1) 2)))
>>             (ext (ly:stencil-extent paren-stil axis))
>>             (stil (ly:accidental-interface::print grob))
>>             (thick
>>               (ly:output-def-lookup (ly:grob-layout grob) 'line-thickness
>> 0.1))
>>             (padding thick)
>>             (protrusion (* 2.5 thick))
>>             (lb (ly:bracket axis ext thick protrusion))
>>             (rb (ly:bracket axis ext thick (- protrusion))))
>>        (set! stil
>>              (ly:stencil-combine-at-edge stil (other-axis axis) 1 rb
>> padding))
>>        (set! stil
>>              (ly:stencil-combine-at-edge stil (other-axis axis) -1 lb
>> padding))
>>        stil))
>> }
>>
>> \score {
>>   \new Staff {
>>     c''4 c''? \bracketAcc c''? c''
>>   }
>> }
>>
>> %%%%%%%%%%%%%%%
>>
>> HTH,
>> Abraham

That's pretty helpful.  The second one in particular looks quite good on the accidentals.  I'm trying to apply a similar approach for producing a bracketed trill marking, but I'm not having much luck.  Here's what I currently have:

\version "2.19.50"

brack = {
  \once\override ParenthesesItem.stencil =
  #(lambda (grob)
     (let ((stil (ly:script-interface::print grob))
          (th 0.1))
       (bracketify-stencil stil Y th (* 2.5 th) th)))
}

\score {
  \new Staff {
    \brack
    c''-\parenthesize \trill
  }
}


But this fails for me with the following error:

/home/gub/NewGub/gub/target/darwin-x86/src/lilypond-git.sv.gnu.org--lilypond.git-release-unstable/lily/script-interface.cc:36: failed assertion `scm_is_pair (s)'


From my (incomplete) understanding of the internal workings, I would have thought this would produce something in the neighborhood of what I want.  Any advice to point me in the correct direction?

Thanks,
Ben

reply via email to

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