[Top][All Lists]

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

Re: select a note in a chord

From: Davide Bonetti
Subject: Re: select a note in a chord
Date: Tue, 15 Jan 2019 15:33:23 +0100
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0


Il 15/01/2019 11:46, Davide Bonetti ha scritto:
But I noticed that it doesn't work on the lowest pitch of a chord (drop 4 on a four note chord, drop 3 on a three note chord)

I modified

       (if (and (music-is-of-type? music 'event-chord)
                (> l n))


       (if (and (music-is-of-type? music 'event-chord)
                (>= l n))

and now it works even on the lowest pitch.

Here the complete code:


#(define (drop-n n)

   (lambda (music)
     (let* ((elts (ly:music-property music 'elements))
            (l (length elts))
            ;; The user may not have entered the notes
            ;; from the lowest to the uppermost;
            ;; let’s extract the pitches…
            (pitches (map (lambda (x) (ly:music-property x 'pitch))
                        (lambda (y)
                          (music-is-of-type? y 'note-event))
            ;; … and put them in order.
            (sorted (sort pitches ly:pitch<?)))
       (if (and (music-is-of-type? music 'event-chord)
                (>= l n))
            ;; first apply the sorted pitches
            ;; to the actual notes.
             (lambda (e p)
               (ly:music-set-property! e 'pitch p))
             elts sorted)
            ;; then transpose the specified note
            ;; (strangely, jazzmen tend to
            ;; count from the top note downward).
            (list-set! elts (- l n)
               (list-ref elts (- l n))
               (ly:make-pitch -1 0)))))





Questa e-mail è stata controllata per individuare virus con Avast antivirus.

reply via email to

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