[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 |
Hello!
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))
with
(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))
(filter
(lambda (y)
(music-is-of-type? y 'note-event))
elts)))
;; … and put them in order.
(sorted (sort pitches ly:pitch<?)))
(if (and (music-is-of-type? music 'event-chord)
(>= l n))
(begin
;; first apply the sorted pitches
;; to the actual notes.
(map
(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)
(ly:music-transpose
(list-ref elts (- l n))
(ly:make-pitch -1 0)))))
music)))
%%%%%%%%%%%%%%%%%%%%%%%%%
cheers
Davide
---
Questa e-mail è stata controllata per individuare virus con Avast antivirus.
https://www.avast.com/antivirus
- 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, 2019/01/14
- 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 <=
- 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
- Re: select a note in a chord, David Kastrup, 2019/01/17
- Re: select a note in a chord, Davide Bonetti, 2019/01/18
- Re: select a note in a chord, David Kastrup, 2019/01/18