lilypond-user
[Top][All Lists]
Advanced

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

Re: Function or command to omit only certain accidentals of a chord?


From: Thomas Morley
Subject: Re: Function or command to omit only certain accidentals of a chord?
Date: Sat, 3 Feb 2018 12:52:36 +0100

2018-02-03 3:52 GMT+01:00 Stefano Troncaro <address@hidden>:

> 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.

Hi Stefano,

I had a look at the function, some remarks.
(1)
We have `event-chord-pitches' to extract pitches from an event-chord.
It works for sequential-music as well.
If you go for ly:music? and extract pitches you can delete some definitions.
Ofcourse you can't go for a single target-pitch anymore. Instead you
would need to do <single-pitch> or { single-pitch }.
I don't see a problem with it, though
(2)
No point in using map and throwing the resulting list away.
Use for-each if you're only interested in the side-effect(s)

Leading to:

\version "2.19.65"

condGrobTweak =
#(define-music-function (use_octave target grob_proc)
   ((boolean? #f) ly:music? procedure?)
   (let ((pitches (event-chord-pitches 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)))
            (for-each
              (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))))

{
    \once \condGrobTweak <cs> #omit-accidental
    <cs' es' gs' bs'>
}

Cheers,
  Harm



reply via email to

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