lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Transposing in modes??


From: Han-Wen Nienhuys
Subject: Re: Transposing in modes??
Date: Wed, 15 Feb 2006 12:11:39 +0100
User-agent: Mozilla Thunderbird 1.0.7-1.1.fc4 (X11/20050929)

Johannes Schindelin wrote:
Hi,

I always wanted to learn how to transform music with scheme, so I implemented half of it. If some of you experts could look at it and tell me what could be done more elegantly (Scheme is not my native language), and especially what needs to be done to make this easy to use, that would be super!

Ciao,
Dscho



------------------------------------------------------------------------

#(define (scale-semitones scale)
        "Get a vector of semitones for a given scale"
        (if (equal? scale "ionian") #(0 2 4 5 7 9 11)
        (if (equal? scale "dorian") #(0 2 3 5 7 9 10)

try (cond .. )

#(define (alter-mode-aux music transpose-vector)
                "Transpose according to transpose-vector"
                (if (ly:music? music)
                 (let ((pitch (ly:music-property music 'pitch)))
                  (if (ly:pitch? pitch)
                   (let* ((off (modulo (ly:pitch-semitones pitch) 12))
                          (trans (vector-ref transpose-vector off)))
                    (if (eq? trans null)
                        (begin (display "Warning: Mode mismatch")
                                (display-music pitch))
                     (if (not (eq? trans 0))
                      (begin (set! pitch (ly:pitch-transpose pitch trans))
                       (ly:music-set-property! music 'pitch pitch))))))))
                music)


I usually do

  (let* ((a (blah))
         (b (if (is-a? a) (blub a)  #f)
         (c (if (is-b? b) (blab b) #f))
          ...
         )

--
 Han-Wen Nienhuys - address@hidden - http://www.xs4all.nl/~hanwen




reply via email to

[Prev in Thread] Current Thread [Next in Thread]