Thank you for your help everyone!

After a lot of stumbling around I finally managed to expand Jan-Peters'
function so that it can modify more than one note in a given chord. I
attached it so its available for anyone interested in using it.

On the other hand, I too think that the real solution would be to upgrade
the Edition Engraver. But that code is way too complex for me to be able to
help, so waiting is all I can do on that front.

2018-02-02 15:25 GMT-03:00 Kieren MacMillan <kieren_macmil...@sympatico.ca>:

> Hi David (et al.),
>
> > I think it would make a whole lot more sense to teach the Edition
> > Engraver how to mark/identify and tweak single items.
>
> +1
>
> At the risk of opening a serious can-o'-worms… I would love for you (David
> K.) — who has the best Lilypond-fundamentals programming mind I know — to
> glance through the EE codebase, to see if you can see any ways to help
> Jan-Peter improve and/or extend it. All of the EE code is well above my pay
> grade, unfortunately, but a quick dak-glance might reveal some
> revolutionary things/thinks.
>
> Thanks/Best,
> Kieren.
> ________________________________
>
> Kieren MacMillan, composer
> ‣ website: www.kierenmacmillan.info
> ‣ email: i...@kierenmacmillan.info
>
>
> _______________________________________________
> lilypond-user mailing list
> lilypond-user@gnu.org
> https://lists.gnu.org/mailman/listinfo/lilypond-user
>
\version "2.19.80"
\language "english"
\include "oll-core/package.ily"
\loadPackage edition-engraver
\consistToContexts #edition-engraver Voice.Staff.Score

#(define (pitch-or-chord? obj)
   (or (ly:pitch? obj)
       (if (ly:music? obj)
           (equal? (ly:music-property obj 'name) 'EventChord))))

#(define (pitch->pitch-list pitch)
   (list pitch))

#(define (chord->pitch-list chord)
   (map (lambda (element)
          (ly:music-property element 'pitch))
        (ly:music-property chord 'elements)))

condGrobTweak = 
#(define-music-function (use_octave target grob_proc)((boolean? #f) pitch-or-chord? procedure?)
   (let ((pitches (if (ly:pitch? target)
                      (pitch->pitch-list target)
                      (chord->pitch-list target))))
     #{
       \override NoteHead.before-line-breaking =
       #(lambda (grob)
          (let* ((cause (ly:grob-property grob 'cause))
                 (pitch (ly:prob-property cause 'pitch))
                 (note (ly:pitch-notename pitch))
                 (alteration (ly:pitch-alteration pitch))
                 (octave (ly:pitch-octave pitch)))
            (map (lambda (this-pitch)
                   (if (and (eqv? alteration (ly:pitch-alteration this-pitch))
                            (eqv? note (ly:pitch-notename this-pitch))
                            (or (not use_octave)(eqv? octave (ly:pitch-octave this-pitch))))
                       (grob_proc grob)))
                 pitches)))   
     #}))

#(define (omit-accidental grob)
   (let ((accidental (ly:grob-object grob 'accidental-grob)))
     (if (ly:grob? accidental)
         (ly:grob-set-property! accidental 'stencil #f)
         )))

\addEdition accidentals
\editionMod accidentals 1 0/4 Voice \once \condGrobTweak <cs gs> #omit-accidental

{ <cs' es' gs' bs'> }
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to