[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: select a note in a chord
From: |
Valentin Villenave |
Subject: |
Re: select a note in a chord |
Date: |
Tue, 15 Jan 2019 01:07:02 +0100 |
On 1/14/19, Davide Bonetti <address@hidden> wrote:
> I'm looking for a function to select a note in a chord.
> This can be useful for automatic inversions, or to change the voicing
> (like the drop 2 in a four note chord).
Hello Davide,
Here’s how I would do it (using list-ref and list-set!), but this
assumes that the user always enters chords from the lowest to the
uppermost pitch. (It would be possible to first re-order the notes
automatically and then apply the transformation, but I’m too lazy to
add it right now :-)
%%%%%%%%%%%%
#(define (drop-n n)
(lambda (music)
(let* ((elts (ly:music-property music 'elements))
(l (length elts)))
(if (and (music-is-of-type? music 'event-chord)
(> l n))
(list-set! elts (- l n)
(ly:music-transpose
(list-ref elts (- l n))
(ly:make-pitch -1 0))))
music)))
dropTwo =
#(define-music-function (music) (ly:music?)
#{ \musicMap #(drop-n 2) $music #})
\dropTwo \relative {
<c' e g b> <d f a c>
\chordmode { d2:maj7 }
}
%%%%%%%%%%%%
V.
- select a note in a chord, Davide Bonetti, 2019/01/14
- Re: select a note in a chord, Malte Meyn, 2019/01/14
- Re: select a note in a chord,
Valentin Villenave <=
- Re: select a note in a chord, Valentin Villenave, 2019/01/15
- Re: select a note in a chord, Davide Bonetti, 2019/01/15
- Re: select a note in a chord, Davide Bonetti, 2019/01/15
- Re: select a note in a chord, Valentin Villenave, 2019/01/15
- Re: select a note in a chord, David Kastrup, 2019/01/15
- Re: select a note in a chord, Davide Bonetti, 2019/01/17
- Re: select a note in a chord, Valentin Villenave, 2019/01/17
- Re: select a note in a chord, David Kastrup, 2019/01/17
- Re: select a note in a chord, Valentin Villenave, 2019/01/17
- Re: select a note in a chord, David Kastrup, 2019/01/17