On 2020-01-21 7:02 pm, Kieren MacMillan wrote:
HOLD THE PRESSES!!

I think I have it:

%%%%  SNIPPET BEGINS
\version "2.19.83"

some-music = { a'4 bes' b' aes' g' cis' d' ees' fis' f' e' c' }

#(define-markup-list-command (diffints layout props mus) (ly:music?)
   (interpret-markup-list layout props
     (map (lambda (d) (string-append (if (positive? d) "+" "")
(number->string d)))
       (let ((muspst (map ly:pitch-semitones (music-pitches mus))))
         (map - (cdr muspst) muspst)))))

\markup \line \with-color #red \diffints #some-music
\markup \line  \with-color #red \diffints ##{ c' d' e' c' #}
%%%%  SNIPPET ENDS

Comments and code critique appreciated.

Instead of string-append and number->string, try (format #f "~@d" d).

  ~d formats an integer as a decimal value
   @ includes "+" for positive values

One caveat is it formats zero as "+0".

Perhaps:  (lambda (d) (if (zero? d) "0" (format #f "~@d" d)))


-- Aaron Hill

Reply via email to