On Wed 09 Mar 2016 at 17:57:25 (+0100), Gianmaria Lari wrote:
> Last "relative" applies only to the whole musical expression generated by
> "changePitch". You can see it clearly here:
> \version "2.19.35"
> \include "changePitch.ly"
> pattern =
> {
> r2 a16 a8 a8 a16
> }
> \relative c'''
> {
> a4 c e g
> \relative c' \changePitch \pattern {a b c d}
> a4 c e g
> }Hmm. Not nice, in my eyes. I prefer to set my notes (set as in jelly) early rather than late. The example attached is somewhat artificial but it illustrates the difference. To run it, you need the scheme code from page 12 of the Notation Manual (2.19.36), also attached. Page 14 of the Learning Manual says: "Accidentals are totally ignored in the calculation of relative position." Setting the notes early makes the result less surprising in this case, thereby following the Principle of Least Astonishment/Surprise. Cheers, David.
\version "2.19.36" \paper { #(set-paper-size "a6") }
\include "scheme-code-from-page-12-of-the-NM"
{ c' geses }
{ \relative { c' geses } }
{ \naturalizeMusic \relative { c' geses } }
{ \relative \naturalizeMusic { c' geses } }
{ \relative c' { c geses } }
{ \naturalizeMusic \relative c' { c geses } }
{ \relative c' \naturalizeMusic { c geses } }
relative.pdf
Description: Adobe PDF document
#(define (naturalize-pitch p)
(let ((o (ly:pitch-octave p))
(a (* 4 (ly:pitch-alteration p)))
;; alteration, a, in quarter tone steps,
;; for historical reasons
(n (ly:pitch-notename p)))
(cond
((and (> a 1) (or (eq? n 6) (eq? n 2)))
(set! a (- a 2))
(set! n (+ n 1)))
((and (< a -1) (or (eq? n 0) (eq? n 3)))
(set! a (+ a 2))
(set! n (- n 1))))
(cond
((> a 2) (set! a (- a 4)) (set! n (+ n 1)))
((< a -2) (set! a (+ a 4)) (set! n (- n 1))))
(if (< n 0) (begin (set! o (- o 1)) (set! n (+ n 7))))
(if (> n 6) (begin (set! o (+ o 1)) (set! n (- n 7))))
(ly:make-pitch o n (/ a 4))))
#(define (naturalize music)
(let ((es (ly:music-property music 'elements))
(e (ly:music-property music 'element))
(p (ly:music-property music 'pitch)))
(if (pair? es)
(ly:music-set-property!
music 'elements
(map (lambda (x) (naturalize x)) es)))
(if (ly:music? e)
(ly:music-set-property!
music 'element
(naturalize e)))
(if (ly:pitch? p)
(begin
(set! p (naturalize-pitch p))
(ly:music-set-property! music 'pitch p)))
music))
naturalizeMusic =
#(define-music-function (m)
(ly:music?)
(naturalize m))
_______________________________________________ lilypond-user mailing list [email protected] https://lists.gnu.org/mailman/listinfo/lilypond-user
