6 Here's a copy of my feature request :
8 Your task, if you accept it is to implement a \smarttranspose
9 command> that would translate such oddities into more natural
10 notations. Double accidentals should be removed, as well as E-sharp
11 (-> F), bC (-> B), bF (-> E), B-sharp (-> C).
14 You mean like this. (Sorry 'bout the nuked indentation.)
16 Modified to use the standard transpose mechanism. The question is
17 how useful these enharmonic modifications are. Mats B.
22 #(define (unhair-pitch p)
23 (let* ((o (pitch-octave p))
24 (a (pitch-alteration p))
25 (n (pitch-notename p)))
28 ((and (> a 0) (or (eq? n 6) (eq? n 2)))
29 (set! a (- a 1)) (set! n (+ n 1)))
30 ((and (< a 0) (or (eq? n 0) (eq? n 3)))
31 (set! a (+ a 1)) (set! n (- n 1))))
34 ((eq? a 2) (set! a 0) (set! n (+ n 1)))
35 ((eq? a -2) (set! a 0) (set! n (- n 1))))
37 (if (< n 0) (begin (set! o (- o 1)) (set! n (+ n 7))))
38 (if (> n 6) (begin (set! o (+ o 1)) (set! n (- n 7))))
42 #(define (simplify music)
43 (let* ((es (ly-get-mus-property music 'elements))
44 (e (ly-get-mus-property music 'element))
45 (p (ly-get-mus-property music 'pitch))
46 (body (ly-get-mus-property music 'body))
47 (alts (ly-get-mus-property music 'alternatives)))
52 (map (lambda (x) (simplify x)) es)))
71 (set! p (unhair-pitch p))
72 (ly-set-mus-property music 'pitch p)))
76 music = \notes \relative c' { c4 d e f g a b c }
79 \notes \context Staff {
80 \transpose ais' \music
81 \apply #simplify \transpose ais' \music
83 \paper { linewidth = -1. }