[CM] "notes from metalevel" (Cap. 12) - Mixing objects - ERROR

andersvi@extern.uio.no andersvi@extern.uio.no
29 Jun 2007 11:27:11 +0200


The code concering the arithmetic-up or arithmetic-downfrom in the
example is wrong.  You can make it function with something like this:

     for key = key1 then (+ key step)


>>>>> "p" == padovani  <josepadovani@yahoo.com.br> writes:

    p> So, now I'm trying to evaluate the Mixing objects code:
    p> (define (strums key1 key2 rate dur amp)
    p> (let ((step (if (< key2 key1) -1 1))
    p>       (diff (abs (- key1 key2))))
    p>   (loop repeat (+ diff 1)
    p>         for key from key1 by step
    p>         for beg from 0 by rate
    p>         collect (new midi :time beg
    p>                      :duration dur
    p>                      :amplitude amp
    p>                      :keynum key))))

    p> but, in SBCL, the "-1" in the second line gives an error in SBCL:

    p> ;;;; (pwd)  ...
    p> ;;;; (define (strums key1 key2 rate dur amp)   (let ((step (if (< ...
    p> ; in: LAMBDA NIL
    p> ;     (IF (< CM::KEY2 CM::KEY1) -1 1)
    p> ; ==>
    p> ;   -1
    p> ;
    p> ; caught WARNING:
    p> ;   This is not a (OR (SINGLE-FLOAT (0.0)) (DOUBLE-FLOAT (0.0d0))
    p> (RATIONAL (0))):
    p> ;     -1
    p> ;   See also:
    p> ;     The SBCL Manual, Node "Handling of Types"
    p> ;
    p> ; compilation unit finished
    p> ;   caught 1 WARNING condition



-- 
Plato: Music is the movement of sound to reach the soul for
the education of its virtue.