On 1-Aug-04, at 1:31 AM, Han-Wen Nienhuys wrote:
[EMAIL PROTECTED] writes:
I know how to display the new tuning for a stringed instrument. Can
Lilypond (almost certainly via scheme) print the noteheads correctly?
I mean, can the lilypond input file be written in C, and have
Lilypond/scheme transpose only the appropriate notes?
you will need a scheme function for that.
look at input/test/smart-transpose for inspiration.
Thanks! For the list archives, here's how to do it:
As it happened, all I had to do was add three lines to the
top of the (naturalise-pitch p) function:
(cond
((or (< o -1) (and (= o -1) (< n 4)))
(set! a (+ a 2))))
pseudocode: if the note is low enough (a low octave, or the right octave
but a note below G -- F, E, D, or C), then make the note sharp.
(the existing code takes care of making a B# into a C and the like)
Here's my complete test file; again for future googling or maillist
archive searching:
\version "2.3.8"
#(define (naturalise-pitch p)
(let* ((o (ly:pitch-octave p))
(a (ly:pitch-alteration p))
(n (ly:pitch-notename p)))
(cond
((or (< o -1) (and (= o -1) (< n 4)))
(set! a (+ a 2))))
(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)))
#(define (naturalise 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) (naturalise x)) es)))
(if (ly:music? e)
(ly:music-set-property!
music 'element
(naturalise e)))
(if (ly:pitch? p)
(begin
(set! p (naturalise-pitch p))
(ly:music-set-property! music 'pitch p)))
music))
music = \relative c' { b4 a g f | e d c b | b c d e | f g a b | }
\score {
\context Staff {
\clef alto
\transpose c c \music
\applymusic #naturalise \transpose c c \music
}
}
_______________________________________________
lilypond-user mailing list
[EMAIL PROTECTED]
http://lists.gnu.org/mailman/listinfo/lilypond-user