[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Subject: Re: flats as sharps and sharp as flats
From: |
Stefan Thomas |
Subject: |
Subject: Re: flats as sharps and sharp as flats |
Date: |
Sun, 26 Apr 2009 16:24:57 +0200 |
Dear community,
with Your hints I made success with my idea of changing the enharmonic context.
But, what I did doesn't still work like I expect it.
Here is an example with short comments on it:
\version "2.13.0"
#(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))
%shows only sharps
showSharps = #(define-music-function (parser location x) (ly:music?)
#{
\naturalizeMusic \transpose ges fis $x
#})
%show only flats
showFlats = #(define-music-function (parser location x) (ly:music?)
#{
\naturalizeMusic \transpose fis ges $x
#})
scale = \relative c' {
c4 cis d dis e f fis g gis a ais b c b bes a aes g ges f e es d des
}
\new Staff {
\showSharps {\scale } %this works fine!
\showSharps { \transpose c e \scale } %why it shows "eis", and not "f"?
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Subject: Re: flats as sharps and sharp as flats,
Stefan Thomas <=