> 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

_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to