[CM] possible to compare negatives in cond

Lynn Artas artaslynn at gmail.com
Tue May 17 16:32:59 PDT 2016


Hi list!

I've isolated my problem, but have no idea how to fix it and would really
appreciate some help

I'm using a span of numbers within a cond to set case. Some of the values
in the number span in the cond are
negative. This doesn't work. The same version of the code with all the
slopes positive works as expected.

Notes:
1. please ignore the things about longdurs—they shouldn't come into play
with the envelope set to '(0 1000 630 1000). If they
happen, it'll still work, but won't go into the case statement.
2. the doubled midi calls inside the case statement are for keyswitching.
If you have EastWest, set your DAW to cello
to add a little interest to the listening. (You may miss a col legno if it
goes out of range. This version
doesn't include the transposition loop.)

This is a simplified version of my code. I tried to cut as much of the fat
as possible while still giving an idea of how it works, when it
works with the positive slopes. Also pasting in case attachments aren't
allowed on the list.

Any and all help appreciated,
Best,
~L.


;;;;;;;;;;;;;;;;;;;;;ruby-simple5-noNegs;;;;;;;;;;;;;;;;;;;;;;;;
;;; -*- syntax: Lisp; font-size: 16; line-numbers: no; -*-

(define headings (make-cycle '(
 258.6 299.5 334.1 38.5 318.5 210.3 215.1 255.5 210.3 221.3 270 297.6 320.2
188.9 239.5 285.7 277 254.2 212.4
209.8 172.1 191.1 308 327.1 242.8 111.3 161.9 329.3 163.5 168.7
)))

(define slopes (make-cycle '(1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
19 20 21 22 23 24 25 26 27 28 29 30)))

(define speeds (make-cycle '(.125 .125 .125 .125 .125  .25 .25 .25 .25 .25
 .5 .5 .5 .5 .5 .75 .75 .75 .75 .75  1 1 1 1 1 1.5 1.5 1.5 1.5 1.5 )))


(define (ruby4 zeronote fullcirclenote shortestnote longestnote quantVal
longdurs longdurchanceenv datapoints)
(let* (
       (longdurs longdurs)
       (datapoints datapoints)
       (shortestnote shortestnote)
       (longestnote longestnote)
       (longdurchanceenv longdurchanceenv)
       (quantVal quantVal)
       (count 0)
       (newkey 0)
       (thelongdur 0)
       (longdurchance 0)
       (thecase 0)
       (theslope 0)
       (outrhythm 0)
       (start-time 0)
       (thedurpick 0)
       (waittime 0)
       (thespeed 0)
       (thedur 0)
       (theheading 0)
       (theamp 0)
       (zeronote zeronote)
       (fullcirclenote fullcirclenote)
       )

 (process repeat datapoints
   do

   (set! theslope (next slopes))

   (print "theslope is") (print theslope)
   (cond
      ((and (>= theslope 1) (<= theslope 5))
      (begin
        (print "chose case 0")
        (set! thecase 0)
         ))

     ((and (>= 6 theslope) (<= theslope 10))
      (begin
        (print "chose case 1")
        (set! thecase 1)
      ))

      ((and (>= theslope 11 ) (<= theslope 15))
      (begin
        (print "chose case 2")
        (set! thecase 2)
      ))

     ((and (>= theslope 16) (<= theslope 20))
      (begin
        (print "chose case 3")
        (set! thecase 3)
      ))

     ((and (>= theslope 21 ) (<= theslope 25))
      (begin
        (print "chose case 4")
        (set! thecase 4)
      ))

     ((and (>= theslope 26) (< theslope 30))
      (begin
        (print "chose case 5")
        (set! thecase 5)
        ))
     )

 append

   (set! longdurchance  (interp count longdurchanceenv))
   (if (<= (random longdurchance) 1)
     (begin
       (set! thedurpick (floor (interp count 0 0 631 (- (length longdurs) 1
))))
       (set! thelongdur (nth longdurs thedurpick))
       (mp:midi :time start-time :key (pick 28 29) :dur (quantize
thelongdur quantVal) :amp 1 :chan 0)
       (mp:midi :time start-time :key newkey :dur (quantize thelongdur
quantVal) :amp (between 0.6 0.75) :chan 1)
       (mp:midi :time start-time :key (+ newkey (pick 8 9)) :dur (quantize
thelongdur quantVal) :amp (between 0.6 0.75)  :chan 1)
       (set! start-time (+ start-time thelongdur))
       )
     )
   (set! outrhythm .5)
   (set! theheading (next headings))
   (set! newkey (floor (rescale theheading 0 359.4 zeronote
fullcirclenote)))
   (set! theamp (between 0.6 0.75))

   (case thecase
         ((0)
          (print "IN CASE 0")
          (mp:midi :time start-time :key (pick 28 29) :dur outrhythm :amp
theamp :chan 0);normal E0 and F0
          (mp:midi :time start-time :key  newkey :dur outrhythm :amp theamp
:chan 1)
          (set! start-time (+ start-time outrhythm))
         )

         ((1)
          (print "IN CASE 1-pizz")
          (mp:midi :time start-time :key 90 :dur outrhythm :amp theamp
:chan 0) ;pizz
          (mp:midi :time start-time :key  newkey :dur outrhythm :amp theamp
:chan 1)
          (set! start-time (+ start-time outrhythm))
          )

         ((2)
          (print "IN CASE 2")
          (mp:midi :time start-time :key (pick 28 29) :dur outrhythm :amp
theamp :chan 0) ;normal
          (mp:midi :time start-time :key newkey :dur outrhythm :amp theamp
:chan 1)
          (mp:midi :time start-time :key (+ 4 newkey) :dur outrhythm :amp
theamp :chan 1)
          (set! start-time (+ start-time outrhythm))
          )

         ((3)
          (print "IN CASE 3")
          (mp:midi :time start-time :key 89  :dur outrhythm :amp theamp
:chan 0)
          (mp:midi :time start-time :key newkey :dur outrhythm :amp theamp
:chan 1)
          (set! start-time (+ start-time outrhythm))
          )

         ((4)
          (print "IN CASE 4")
          (mp:midi :time start-time :key (pick 28 29) :dur outrhythm :amp
theamp :chan 0);normal E0 and F0
          (mp:midi :time start-time :key newkey :dur outrhythm :amp theamp
:chan 1)
          (mp:midi :time start-time :key (+ 2 newkey) :dur outrhythm :amp
theamp :chan 1)
          (set! start-time (+ start-time outrhythm))
          )

         ((5)
          (print "IN CASE 5")
          (mp:midi :time start-time :key 91 :dur outrhythm :amp theamp
:chan 0)
          (mp:midi :time start-time :key newkey :dur outrhythm :amp theamp
:chan 1)
          (set! start-time (+ start-time outrhythm))
          )
         )
   )
 )
)

(sprout (ruby4 36 82         .125              1         .125     '(2 1 .75
1 2) '(0 1000 630 1000 ) 100))


;;;;;;;;;;;;;;;;;;;;;ruby-simple5-withNegs;;;;;;;;;;;;;;;;;;;;;;;;
;;; -*- syntax: Lisp; font-size: 16; line-numbers: no; -*-

(define headings (make-cycle '(
 258.6 299.5 334.1 38.5 318.5 210.3 215.1 255.5 210.3 221.3 270 297.6 320.2
188.9 239.5 285.7 277 254.2 212.4
209.8 172.1 191.1 308 327.1 242.8 111.3 161.9 329.3 163.5 168.7
)))

(define slopes (make-cycle '(1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
19 20 21 22 23 24 25 26 27 28 29 30)))

(define speeds (make-cycle '(.125 .125 .125 .125 .125  .25 .25 .25 .25 .25
 .5 .5 .5 .5 .5 .75 .75 .75 .75 .75  1 1 1 1 1 1.5 1.5 1.5 1.5 1.5 )))



(define (ruby4 zeronote fullcirclenote shortestnote longestnote quantVal
longdurs longdurchanceenv datapoints)
(let* (
       (longdurs longdurs)
       (datapoints datapoints)
       (shortestnote shortestnote)
       (longestnote longestnote)
       (longdurchanceenv longdurchanceenv)
       (quantVal quantVal)
       (count 0)
       (newkey 0)
       (thelongdur 0)
       (longdurchance 0)
       (thecase 0)
       (theslope 0)
       (outrhythm 0)
       (start-time 0)
       (thedurpick 0)
       (waittime 0)
       (thespeed 0)
       (thedur 0)
       (theheading 0)
       (theamp 0)
       (zeronote zeronote)
       (fullcirclenote fullcirclenote)
       )

 (process repeat datapoints
   do

   (set! theslope (next slopes))
   (cond
      ((and (>= theslope -5) (<= theslope -1))
      (begin
        (print "chose case 0")
        (set! thecase 0)
         ));normal

     ((and (>= -6 theslope) (<= theslope -10))
      (begin
        (print "chose case 1")
        (set! thecase 1)
      ));pizz

      ((and (>= theslope -11 ) (<= theslope -15))
      (begin
        (print "chose case 2")
        (set! thecase 2)
      )) ; M3 sing

     ((and (>= theslope -16) (<= theslope -20))
      (begin
        (print "chose case 3")
        (set! thecase 3)
      )) ;martele

     ((and (>= theslope -21 ) (<= theslope -25))
      (begin
        (print "chose case 4")
        (set! thecase 4)
      )) ;M2 for sul pont

     ((and (>= theslope -26) (< theslope -30))
      (begin
        (print "chose case 5")
        (set! thecase 5)
        )) ;col legno
     )

 append

   (set! longdurchance  (interp count longdurchanceenv))
   (if (<= (random longdurchance) 1)
     (begin
       (set! thedurpick (floor (interp count 0 0 631 (- (length longdurs) 1
))))
       (set! thelongdur (nth longdurs thedurpick))
       (mp:midi :time start-time :key (pick 28 29) :dur (quantize
thelongdur quantVal) :amp 1 :chan 0)
       (mp:midi :time start-time :key newkey :dur (quantize thelongdur
quantVal) :amp (between 0.6 0.75) :chan 1)
       (mp:midi :time start-time :key (+ newkey (pick 8 9)) :dur (quantize
thelongdur quantVal) :amp (between 0.6 0.75)  :chan 1)
       (set! start-time (+ start-time thelongdur))
       )
     )
   (set! outrhythm .5)
   (set! theheading (next headings))
   (set! newkey (floor (rescale theheading 0 359.4 zeronote
fullcirclenote)))
   (set! theamp (between 0.6 0.75))

   (case thecase
         ((0)
          (print "IN CASE 0")
          (mp:midi :time start-time :key (pick 28 29) :dur outrhythm :amp
theamp :chan 0);normal E0 and F0
          (mp:midi :time start-time :key  newkey :dur outrhythm :amp theamp
:chan 1)
          (set! start-time (+ start-time outrhythm))
         )

         ((1)
          (print "IN CASE 1-pizz")
          (mp:midi :time start-time :key 90 :dur outrhythm :amp theamp
:chan 0) ;pizz
          (mp:midi :time start-time :key  newkey :dur outrhythm :amp theamp
:chan 1)
          (set! start-time (+ start-time outrhythm))
          )

         ((2)
          (print "IN CASE 2")
          (mp:midi :time start-time :key (pick 28 29) :dur outrhythm :amp
theamp :chan 0) ;normal
          (mp:midi :time start-time :key newkey :dur outrhythm :amp theamp
:chan 1)
          (mp:midi :time start-time :key (+ 4 newkey) :dur outrhythm :amp
theamp :chan 1)
          (set! start-time (+ start-time outrhythm))
          )

         ((3)
          (print "IN CASE 3")
          (mp:midi :time start-time :key 89  :dur outrhythm :amp theamp
:chan 0)
          (mp:midi :time start-time :key newkey :dur outrhythm :amp theamp
:chan 1)
          (set! start-time (+ start-time outrhythm))
          )

         ((4)
          (print "IN CASE 4")
          (mp:midi :time start-time :key (pick 28 29) :dur outrhythm :amp
theamp :chan 0);normal E0 and F0
          (mp:midi :time start-time :key newkey :dur outrhythm :amp theamp
:chan 1)
          (mp:midi :time start-time :key (+ 2 newkey) :dur outrhythm :amp
theamp :chan 1)
          (set! start-time (+ start-time outrhythm))
          )

         ((5)
          (print "IN CASE 5")
          (mp:midi :time start-time :key 91 :dur outrhythm :amp theamp
:chan 0)
          (mp:midi :time start-time :key newkey :dur outrhythm :amp theamp
:chan 1)
          (set! start-time (+ start-time outrhythm))
          )
         )
   )
 )
)


(sprout (ruby4 36 82         .125              1         .125     '(2 1 .75
1 2) '(0 1000 630 1000 ) 100))
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cm-mail.stanford.edu/mailman/private/cmdist/attachments/20160517/fc59191a/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ruby-simple5-noNegs
Type: application/octet-stream
Size: 5714 bytes
Desc: not available
URL: <https://cm-mail.stanford.edu/mailman/private/cmdist/attachments/20160517/fc59191a/attachment-0002.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ruby-simple5-withNegs
Type: application/octet-stream
Size: 5744 bytes
Desc: not available
URL: <https://cm-mail.stanford.edu/mailman/private/cmdist/attachments/20160517/fc59191a/attachment-0003.obj>


More information about the Cmdist mailing list