[EMAIL PROTECTED] writes:
> I've just entered a request on cosource.com :
>
> http://www.cosource.com/cgi-bin/cos.pl/wish/info/387
>
> Here's a copy of my feature request :
> Your task, if you accept it is to implement a \smarttranspose command
> that would translate such oddities into more natural notations. Double
> accidentals should be removed, as well as #E (-> F), bC (-> B), bF (->
> E), #B (-> C).
You mean like this. (Sorry 'bout the nuked indentation.)
#(define (unhair-pitch p)
(let* ((o (pitch-octave p))
(a (pitch-alteration p))
(n (pitch-notename p))
)
(cond
((and (> a 0) (or (eq? n 6) (eq? n 2)))
(set! a (- a 1)) (set! n (+ n 1)))
((and (< a 0) (or (eq? n 0) (eq? n 3)))
(set! a (+ a 1)) (set! n (- n 1)))
)
(cond
((eq? a 2) (set! a 0) (set! n (+ n 1)))
((eq? a -2) (set! a 0) (set! n (- n 1)))
)
(if (< n 0) (begin (set! o (- o 1)) (set! n (+ n 7))))
(if (> n 7) (begin (set! o (+ o 1)) (set! n (- n 7))))
(make-pitch o n a)
))
#(define (smart-transpose music pitch)
(let* ((es (ly-get-mus-property music 'elements))
(e (ly-get-mus-property music 'element))
(p (ly-get-mus-property music 'pitch))
(boddhi (ly-get-mus-property music 'body))
(alts (ly-get-mus-property music
'alternatives))
)
(if (pair? es)
(ly-set-mus-property music 'elements (map (lambda
(x) (smart-transpose x pitch)) es))
)
(if (music? alts)
(ly-set-mus-property music 'alternatives
(smart-transpose alts pitch)))
(if (music? boddhi)
(ly-set-mus-property music 'body
(smart-transpose boddhi pitch)))
(if (music? e)
(ly-set-mus-property music 'element
(smart-transpose e pitch)))
(if (pitch? p)
(begin
(set! p (unhair-pitch
(Pitch::transpose p pitch)))
(ly-set-mus-property music 'pitch p)
))
music
))
m = \notes \relative c' { c4 d e f g a b c }
\score {
\notes \context Staff { \transpose ais' \m
\apply #(lambda (x) (smart-transpose x (make-pitch 0 5 1)))
\m
}
}
Add IMPLEMENT_TYPE_P(Music, "music?"); to music.cc, and presto, done.
That's an easy $ 100; if I'd make $ 200/hour for every hour
I worked on Lily, I'd be very rich :)
--
Han-Wen Nienhuys | [EMAIL PROTECTED] | http://www.cs.uu.nl/~hanwen/
_______________________________________________
Gnu-music-discuss mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/gnu-music-discuss