[Fluxus] scala.scm, rev. 1

Kassen signal.automatique at gmail.com
Wed Dec 21 08:14:12 PST 2011


On 21/12/2011, Joel Matthys <joel at matthysmusic.com> wrote:

> I think most people who want to do microtonal stuff will want to do it
> with equal temperament, and that's already implemented. Scala files
> aren't really suitable for microtonal because it's possible to define
> vastly different interval sizes from one note to the next, so I think
> anyone who tries it should be happy with what they get. The "purist"
> approach would be your "brutal" method, (floor ) the keynum, but I think
> a little interpolation would be nice.
>

I agree. More strongly even; when we do want to be in a tuning and
want to round floats we will most likely want to do that relative to
some scale, not to the tuning itself.
That way we could -for example- turn a scaled (sin (time)) in to a
sort of melody.

Here is a part of a toolset I'm working on;



(define major (list 0 2 4 5 7 9 11))
(define minor (list 0 2 3 5 7 9 11))
(define acoustic (list 0 2 4 6 7 9 10))
(define whole (list 0 2 4 6 8 10))

;gets the nth note of a given scale
(define (in-scale myscale note)
    (let* ( (note (inexact->exact (round note)))
            (l (length myscale))
            (r (remainder note l)))
        (+
            (* (quotient note l) 12)
            (if (negative? r)
                (- (list-ref myscale (+ l r)) 12)
                (list-ref myscale r)))))

;rounds to the nearest note that is in the given scale
(define (to-scale myscale x)
    (let*  ((myscale (append myscale '(12)))
            (ret 0)
            (over (quotient (inexact->exact (round x)) 12))
            (over (if (negative? x) (- over 1) over))
            (x (- x (* 12 over))))
        (for ((n (in-range 0 (length myscale))))
            (when (<
                    (abs (- (list-ref myscale n) x))
                    (abs (- ret x)))
                (set! ret (list-ref myscale n))))
        (+ ret (* over 12))))


Might be interesting/fun/helpful. I'll publish the whole thing once
I'm at least sure of it all myself and we can see whether others like
it and perhaps push it in.

Yours,
Kas.



More information about the Fluxus mailing list