Joseph Wakeling wrote:
> Currently Lilypond's transposition is tonal only, with the 'smart
> transpose' snippet providing a Scheme function to minimise accidental
> use.  Unfortunately this function is incompatible with quarter-tone
> notation.  The attached snippet shows the problem.  A quarter-tone
> chromatic scale is displayed, first untransposed; then untransposed and
> run through the naturalizeMusic function; then transposed a quarter-tone
> up; then transposed up and run through naturalizeMusic; and finally, run
> through naturalizeMusic and then transposed.

... the attached snippet is now attached. :-P
\version "2.12"

#(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 (parser location m)
  (ly:music?)
  (naturalize m))


microphrase = \relative c'' { geses geseh ges geh g gih gis gisih gisis }


{
        \time 9/4
        #(set-accidental-style 'dodecaphonic)
        \microphrase
        \naturalizeMusic { \microphrase }
        \transpose c cih { \microphrase }
        \naturalizeMusic { \transpose c cih { \microphrase } }
        \transpose c cih { \naturalizeMusic { \microphrase } }
}

<<attachment: micro-transpose.png>>

_______________________________________________
lilypond-user mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to