[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: transpose pitch by semitones
From: |
Gilles THIBAULT |
Subject: |
Re: transpose pitch by semitones |
Date: |
Tue, 01 Dec 2015 15:48:23 +0100 |
User-agent: |
KMail/4.14.5 (Linux/4.1.13-desktop-2.mga5; KDE/4.14.5; x86_64; ; ) |
> OK, this one is more straightforward...
...but your idea was probably the best :
%%%%%%%%%%%%%%%%%%%%
#(define (semitones->pitch semitone)
(let ((index (modulo semitone 12))
(octave (quotient semitone 12)))
(apply ly:make-pitch (cons
octave
(list-ref
'((0 0) ; c
(0 1/2) ; cis
(1 0) ; d
(1 1/2) ; dis
(2 0) ; e
(3 0) ; f
(3 1/2) ; fis % \jiPitch 2 1
(4 0) ; g
(4 1/2) ; gis
(5 0) ; a
(5 1/2) ; ais
(6 0)) ; b
index)))))
%%test
#(for-each
(lambda(n)(format #t "~2,' d - ~a\n" n (semitones->pitch n)))
'(-5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15))
%%%%%%%%%%%%%%%%%%%%%%
-- The End ---
--
Gilles