lilypond-devel
[Top][All Lists]
Advanced

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

Re: accessing accidentals with \tweak


From: Carl Sorensen
Subject: Re: accessing accidentals with \tweak
Date: Sat, 18 Jul 2009 13:07:21 -0600



On 7/15/09 4:19 PM, "Mark Polesky" <address@hidden> wrote:

> Mark Polesky wrote:
> 
> Okay, I figured out a way around this -- by passing an property-alist to
> the 'before-line-breaking tweak, I was able to get all the accidental
> modifications done in one tweak (see "modify-accidental" below). I've
> also included an improved suppress-accidental callback that I think
> could be added to the source.
> 
> 
> So, I guess I can't complain, because all of the functionality I need is
> now accessible. My only gripe is that this is a lot of typing. Could a
> special property be devised that would automate this? Something like:
> 
> \relative {
>   <c!
>   \tweak #'tweak-accidental #`((font-size . -3) (color . ,red)))) e!>
> }
> 
> Or is there some other way of reducing all that code?

I've tried lots of ways, but couldn't figure out anything that I *really*
liked.

If the tweak is intended to be the same for most tweaks, things can be
simplified a little bit by using global variables:

\version "2.13.2"

#(define (modify-accidental note-grob prop-alist)
  ;; notehead before-line-breaking callback
  (let ((accidental (ly:grob-object note-grob 'accidental-grob)))
    (if (not (null? accidental))
        (for-each
          (lambda (x)
            (ly:grob-set-property! accidental (car x) (cdr x)))
          prop-alist))))

#(define (suppress-accidental note-grob)
  ;; notehead before-line-breaking callback
  (let ((accidental (ly:grob-object note-grob 'accidental-grob)))
    (if (not (null? accidental))
        (ly:grob-suicide! accidental))))

#(define tweaklist `((font-size . -3)
                     (color . ,green)))

#(define tweak-func #f)

#(define (modify-test grob)
   (modify-accidental grob tweaklist))

\relative {
<\tweak #'before-line-breaking #suppress-accidental c!
  \tweak #'before-line-breaking #modify-test e!>
}

Thanks for your creativity!

Carl





reply via email to

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