Urs Liska <u...@openlilylib.org> writes: > Am 01.12.2015 um 15:48 schrieb Gilles THIBAULT: >>> OK, this one is more straightforward... >> ...but your idea was probably the best : > > :-) > > Thank you for your input and sorry I didn't have time to reply earlier. > Maybe "best" is also a matter of use case here, but I have the > impression that in this case a simple lookup *is* the most > straightforward solution. In the light of your suggestions I would add a > second lis producing flats instead of sharps, though. > > Still I think there should be a built-in solution. When LilyPond does > transpositions and similar operations doesn't it work on semitones > either, converting to and from?
See issue 4702. After it passes, you can say something like >> %%%%%%%%%%%%%%%%%%%% >> #(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 (define semitones->pitch (make-semitone->pitch (music-pitches #{ c cis d dis e f fis g gis a ais b #}))) You can use any other coverage of the semitone space as well for the lookup. Or add quartertones into the mix. Or use "bad octave" notes like bis or ces for lookup. -- David Kastrup _______________________________________________ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user