Le samedi 16 août 2014, 23:16:15 rm damerell a écrit :
> pitch-semitones converts a pitch to semitones. Please does the inverse
> function exist?
> 

Don't know exactly what you need. Perhaps you think at something like that :
(The function takes c' as reference note, and shows all altered notes with 
sharps)

%%%%%%%%%%%%%%%%%%%%%%
\version "2.18.2"

#(define (semitones-pitch n)
(let loop ((a 0)
           (b 0)
           (c n))
  (cond 
   ((> c 11)(loop (1+ a) b (- n 12)))
   ((< c 0)(loop (1- a) b (+ n 12)))
   ((< c 5) (ly:make-pitch a (quotient c 2) (* 1/2 (modulo c 2))))
   (else (ly:make-pitch a (quotient (1+ c) 2) (* 1/2 (modulo (1+ c) 2)))))))

#(for-each 
   (lambda(n)(format #t "~a - ~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))

%%%%%%%%%%%%%%%%%%%%%%


-- 
Gilles

_______________________________________________
lilypond-user mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to