Caio Giovaneti de Barros <caio.bar...@gmail.com> writes: > On 02-01-2016 16:18, David Kastrup wrote: >> It might also be worth taking a look at the facilities provided by >> issue 4702 >> <URL:http://sourceforge.net/p/testlilyissues/issues/4702/> to see >> how (or whether) they would have helped here. > Do you think you could write some small example of what those > functions do? I didn't understand how they are used. One thing that I > really wanted is an automatic way for the software to decide what > notes should be flat and what should be sharp, even if it's not > perfect. Currently my code only outputs sharps and to be honest this > is not very natural to read (pun intended).
\version "2.19.35" #(define semi->pitch (make-semitone->pitch (music-pitches #{ c cis d es e f fis g gis a bes b #}))) { #@(map (lambda (s) #{ $(semi->pitch s) 2 #}) (iota 37 (ly:pitch-semitones #{ g #}))) } % That's usually close to C Major/A Minor, let's try something more % befitting Fis Major/Dis Minor #(define femi->pitch (shift-semitone->pitch #{ fis #} semi->pitch)) { #@(map (lambda (s) #{ $(femi->pitch s) 2 #}) (iota 37 (ly:pitch-semitones #{ g #}))) }
Note that make-semitone->pitch is a comparatively expensive call so it makes sense to store the result, here semi->pitch and reuse it. shift-semitone->pitch is quite cheap in contrast, so storing femi->pitch is done more to make things more readable rather than out of efficiency reasons. -- David Kastrup
_______________________________________________ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user