<div dir="ltr">Hi list!<div>  </div><div>I&#39;ve isolated my problem, but have no idea how to fix it and would really appreciate some help</div><div><br></div><div>I&#39;m using a span of numbers within a cond to set case. Some of the values in the number span in the cond are</div><div>negative. This doesn&#39;t work. The same version of the code with all the slopes positive works as expected. </div><div><br></div><div>Notes:</div><div>1. please ignore the things about longdurs—they shouldn&#39;t come into play with the envelope set to &#39;(0 1000 630 1000). If they</div><div>happen, it&#39;ll still work, but won&#39;t go into the case statement.</div><div>2. the doubled midi calls inside the case statement are for keyswitching. If you have EastWest, set your DAW to cello</div><div>to add a little interest to the listening. (You may miss a col legno if it goes out of range. This version</div><div>doesn&#39;t include the transposition loop.)</div><div><br></div><div>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 </div><div>works with the positive slopes. Also pasting in case attachments aren&#39;t allowed on the list.</div><div><br></div><div>Any and all help appreciated, </div><div>Best, </div><div>~L.</div><div><br></div><div><br></div><div>;;;;;;;;;;;;;;;;;;;;;ruby-simple5-noNegs;;;;;;;;;;;;;;;;;;;;;;;;</div><div><div>;;; -*- syntax: Lisp; font-size: 16; line-numbers: no; -*-</div><div><br></div><div>(define headings (make-cycle &#39;(</div><div> 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 </div><div>209.8 172.1 191.1 308 327.1 242.8 111.3 161.9 329.3 163.5 168.7 </div><div>)))</div><div><br></div><div>(define slopes (make-cycle &#39;(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)))</div><div><br></div><div>(define speeds (make-cycle &#39;(.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 )))</div><div><br></div><div><br></div><div>(define (ruby4 zeronote fullcirclenote shortestnote longestnote quantVal longdurs longdurchanceenv datapoints)</div><div>(let* (</div><div>       (longdurs longdurs)</div><div>       (datapoints datapoints)</div><div>       (shortestnote shortestnote)</div><div>       (longestnote longestnote)</div><div>       (longdurchanceenv longdurchanceenv)</div><div>       (quantVal quantVal)</div><div>       (count 0)</div><div>       (newkey 0)</div><div>       (thelongdur 0)</div><div>       (longdurchance 0)</div><div>       (thecase 0)</div><div>       (theslope 0)</div><div>       (outrhythm 0)</div><div>       (start-time 0)</div><div>       (thedurpick 0)</div><div>       (waittime 0)</div><div>       (thespeed 0)</div><div>       (thedur 0)</div><div>       (theheading 0)</div><div>       (theamp 0)</div><div>       (zeronote zeronote)</div><div>       (fullcirclenote fullcirclenote)</div><div>       )</div><div><br></div><div> (process repeat datapoints</div><div>   do</div><div><br></div><div>   (set! theslope (next slopes))</div><div><br></div><div>   (print &quot;theslope is&quot;) (print theslope)</div><div>   (cond </div><div>      ((and (&gt;= theslope 1) (&lt;= theslope 5))</div><div>      (begin</div><div>        (print &quot;chose case 0&quot;)</div><div>        (set! thecase 0)</div><div>         ))</div><div>     </div><div>     ((and (&gt;= 6 theslope) (&lt;= theslope 10))</div><div>      (begin</div><div>        (print &quot;chose case 1&quot;)</div><div>        (set! thecase 1)</div><div>      ))</div><div>      </div><div>      ((and (&gt;= theslope 11 ) (&lt;= theslope 15))</div><div>      (begin</div><div>        (print &quot;chose case 2&quot;)</div><div>        (set! thecase 2)</div><div>      )) </div><div>     </div><div>     ((and (&gt;= theslope 16) (&lt;= theslope 20))</div><div>      (begin</div><div>        (print &quot;chose case 3&quot;)</div><div>        (set! thecase 3)</div><div>      ))</div><div>     </div><div>     ((and (&gt;= theslope 21 ) (&lt;= theslope 25))</div><div>      (begin</div><div>        (print &quot;chose case 4&quot;)</div><div>        (set! thecase 4)</div><div>      )) </div><div>     </div><div>     ((and (&gt;= theslope 26) (&lt; theslope 30))</div><div>      (begin</div><div>        (print &quot;chose case 5&quot;)</div><div>        (set! thecase 5)</div><div>        )) </div><div>     )</div><div> </div><div> append</div><div>  </div><div>   (set! longdurchance  (interp count longdurchanceenv))</div><div>   (if (&lt;= (random longdurchance) 1)</div><div>     (begin</div><div>       (set! thedurpick (floor (interp count 0 0 631 (- (length longdurs) 1 ))))</div><div>       (set! thelongdur (nth longdurs thedurpick))</div><div>       (mp:midi :time start-time :key (pick 28 29) :dur (quantize thelongdur quantVal) :amp 1 :chan 0) </div><div>       (mp:midi :time start-time :key newkey :dur (quantize thelongdur quantVal) :amp (between 0.6 0.75) :chan 1)</div><div>       (mp:midi :time start-time :key (+ newkey (pick 8 9)) :dur (quantize thelongdur quantVal) :amp (between 0.6 0.75)  :chan 1)</div><div>       (set! start-time (+ start-time thelongdur))</div><div>       )</div><div>     )</div><div>   (set! outrhythm .5)</div><div>   (set! theheading (next headings))</div><div>   (set! newkey (floor (rescale theheading 0 359.4 zeronote fullcirclenote)))</div><div>   (set! theamp (between 0.6 0.75))</div><div>   </div><div>   (case thecase </div><div>         ((0)</div><div>          (print &quot;IN CASE 0&quot;)</div><div>          (mp:midi :time start-time :key (pick 28 29) :dur outrhythm :amp theamp :chan 0);normal E0 and F0</div><div>          (mp:midi :time start-time :key  newkey :dur outrhythm :amp theamp :chan 1)</div><div>          (set! start-time (+ start-time outrhythm))</div><div>         )</div><div>         </div><div>         ((1)</div><div>          (print &quot;IN CASE 1-pizz&quot;)</div><div>          (mp:midi :time start-time :key 90 :dur outrhythm :amp theamp :chan 0) ;pizz</div><div>          (mp:midi :time start-time :key  newkey :dur outrhythm :amp theamp :chan 1)</div><div>          (set! start-time (+ start-time outrhythm))</div><div>          )</div><div>         </div><div>         ((2)</div><div>          (print &quot;IN CASE 2&quot;)</div><div>          (mp:midi :time start-time :key (pick 28 29) :dur outrhythm :amp theamp :chan 0) ;normal</div><div>          (mp:midi :time start-time :key newkey :dur outrhythm :amp theamp :chan 1)</div><div>          (mp:midi :time start-time :key (+ 4 newkey) :dur outrhythm :amp theamp :chan 1)</div><div>          (set! start-time (+ start-time outrhythm))</div><div>          )</div><div>         </div><div>         ((3)</div><div>          (print &quot;IN CASE 3&quot;)</div><div>          (mp:midi :time start-time :key 89  :dur outrhythm :amp theamp :chan 0) </div><div>          (mp:midi :time start-time :key newkey :dur outrhythm :amp theamp :chan 1)</div><div>          (set! start-time (+ start-time outrhythm))</div><div>          ) </div><div>         </div><div>         ((4)</div><div>          (print &quot;IN CASE 4&quot;)</div><div>          (mp:midi :time start-time :key (pick 28 29) :dur outrhythm :amp theamp :chan 0);normal E0 and F0</div><div>          (mp:midi :time start-time :key newkey :dur outrhythm :amp theamp :chan 1) </div><div>          (mp:midi :time start-time :key (+ 2 newkey) :dur outrhythm :amp theamp :chan 1)</div><div>          (set! start-time (+ start-time outrhythm))</div><div>          ) </div><div>         </div><div>         ((5) </div><div>          (print &quot;IN CASE 5&quot;)</div><div>          (mp:midi :time start-time :key 91 :dur outrhythm :amp theamp :chan 0) </div><div>          (mp:midi :time start-time :key newkey :dur outrhythm :amp theamp :chan 1)</div><div>          (set! start-time (+ start-time outrhythm))</div><div>          )</div><div>         )</div><div>   )</div><div> )</div><div>)</div><div><br></div><div>(sprout (ruby4 36 82         .125              1         .125     &#39;(2 1 .75 1 2) &#39;(0 1000 630 1000 ) 100))<br></div><div><br></div><div><br></div><div>;;;;;;;;;;;;;;;;;;;;;ruby-simple5-withNegs;;;;;;;;;;;;;;;;;;;;;;;;</div><div></div><div>;;; -*- syntax: Lisp; font-size: 16; line-numbers: no; -*-<br></div><div><div><br></div><div>(define headings (make-cycle &#39;(</div><div> 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 </div><div>209.8 172.1 191.1 308 327.1 242.8 111.3 161.9 329.3 163.5 168.7 </div><div>)))</div><div><br></div><div>(define slopes (make-cycle &#39;(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)))</div><div><br></div><div>(define speeds (make-cycle &#39;(.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 )))</div><div><br></div><div><br></div><div><br></div><div>(define (ruby4 zeronote fullcirclenote shortestnote longestnote quantVal longdurs longdurchanceenv datapoints)</div><div>(let* (</div><div>       (longdurs longdurs)</div><div>       (datapoints datapoints)</div><div>       (shortestnote shortestnote)</div><div>       (longestnote longestnote)</div><div>       (longdurchanceenv longdurchanceenv)</div><div>       (quantVal quantVal)</div><div>       (count 0)</div><div>       (newkey 0)</div><div>       (thelongdur 0)</div><div>       (longdurchance 0)</div><div>       (thecase 0)</div><div>       (theslope 0)</div><div>       (outrhythm 0)</div><div>       (start-time 0)</div><div>       (thedurpick 0)</div><div>       (waittime 0)</div><div>       (thespeed 0)</div><div>       (thedur 0)</div><div>       (theheading 0)</div><div>       (theamp 0)</div><div>       (zeronote zeronote)</div><div>       (fullcirclenote fullcirclenote)</div><div>       )</div><div><br></div><div> (process repeat datapoints</div><div>   do</div><div><br></div><div>   (set! theslope (next slopes))</div><div>   (cond </div><div>      ((and (&gt;= theslope -5) (&lt;= theslope -1))</div><div>      (begin</div><div>        (print &quot;chose case 0&quot;)</div><div>        (set! thecase 0)</div><div>         ));normal</div><div>     </div><div>     ((and (&gt;= -6 theslope) (&lt;= theslope -10))</div><div>      (begin</div><div>        (print &quot;chose case 1&quot;)</div><div>        (set! thecase 1)</div><div>      ));pizz</div><div>      </div><div>      ((and (&gt;= theslope -11 ) (&lt;= theslope -15))</div><div>      (begin</div><div>        (print &quot;chose case 2&quot;)</div><div>        (set! thecase 2)</div><div>      )) ; M3 sing </div><div>     </div><div>     ((and (&gt;= theslope -16) (&lt;= theslope -20))</div><div>      (begin</div><div>        (print &quot;chose case 3&quot;)</div><div>        (set! thecase 3)</div><div>      )) ;martele</div><div>     </div><div>     ((and (&gt;= theslope -21 ) (&lt;= theslope -25))</div><div>      (begin</div><div>        (print &quot;chose case 4&quot;)</div><div>        (set! thecase 4)</div><div>      )) ;M2 for sul pont</div><div>     </div><div>     ((and (&gt;= theslope -26) (&lt; theslope -30))</div><div>      (begin</div><div>        (print &quot;chose case 5&quot;)</div><div>        (set! thecase 5)</div><div>        )) ;col legno</div><div>     )</div><div> </div><div> append</div><div>  </div><div>   (set! longdurchance  (interp count longdurchanceenv))</div><div>   (if (&lt;= (random longdurchance) 1)</div><div>     (begin</div><div>       (set! thedurpick (floor (interp count 0 0 631 (- (length longdurs) 1 ))))</div><div>       (set! thelongdur (nth longdurs thedurpick))</div><div>       (mp:midi :time start-time :key (pick 28 29) :dur (quantize thelongdur quantVal) :amp 1 :chan 0) </div><div>       (mp:midi :time start-time :key newkey :dur (quantize thelongdur quantVal) :amp (between 0.6 0.75) :chan 1)</div><div>       (mp:midi :time start-time :key (+ newkey (pick 8 9)) :dur (quantize thelongdur quantVal) :amp (between 0.6 0.75)  :chan 1)</div><div>       (set! start-time (+ start-time thelongdur))</div><div>       )</div><div>     )</div><div>   (set! outrhythm .5)</div><div>   (set! theheading (next headings))</div><div>   (set! newkey (floor (rescale theheading 0 359.4 zeronote fullcirclenote)))</div><div>   (set! theamp (between 0.6 0.75))</div><div>   </div><div>   (case thecase </div><div>         ((0)</div><div>          (print &quot;IN CASE 0&quot;)</div><div>          (mp:midi :time start-time :key (pick 28 29) :dur outrhythm :amp theamp :chan 0);normal E0 and F0</div><div>          (mp:midi :time start-time :key  newkey :dur outrhythm :amp theamp :chan 1)</div><div>          (set! start-time (+ start-time outrhythm))</div><div>         )</div><div>         </div><div>         ((1)</div><div>          (print &quot;IN CASE 1-pizz&quot;)</div><div>          (mp:midi :time start-time :key 90 :dur outrhythm :amp theamp :chan 0) ;pizz</div><div>          (mp:midi :time start-time :key  newkey :dur outrhythm :amp theamp :chan 1)</div><div>          (set! start-time (+ start-time outrhythm))</div><div>          )</div><div>         </div><div>         ((2)</div><div>          (print &quot;IN CASE 2&quot;)</div><div>          (mp:midi :time start-time :key (pick 28 29) :dur outrhythm :amp theamp :chan 0) ;normal</div><div>          (mp:midi :time start-time :key newkey :dur outrhythm :amp theamp :chan 1)</div><div>          (mp:midi :time start-time :key (+ 4 newkey) :dur outrhythm :amp theamp :chan 1)</div><div>          (set! start-time (+ start-time outrhythm))</div><div>          )</div><div>         </div><div>         ((3)</div><div>          (print &quot;IN CASE 3&quot;)</div><div>          (mp:midi :time start-time :key 89  :dur outrhythm :amp theamp :chan 0) </div><div>          (mp:midi :time start-time :key newkey :dur outrhythm :amp theamp :chan 1)</div><div>          (set! start-time (+ start-time outrhythm))</div><div>          ) </div><div>         </div><div>         ((4)</div><div>          (print &quot;IN CASE 4&quot;)</div><div>          (mp:midi :time start-time :key (pick 28 29) :dur outrhythm :amp theamp :chan 0);normal E0 and F0</div><div>          (mp:midi :time start-time :key newkey :dur outrhythm :amp theamp :chan 1) </div><div>          (mp:midi :time start-time :key (+ 2 newkey) :dur outrhythm :amp theamp :chan 1)</div><div>          (set! start-time (+ start-time outrhythm))</div><div>          ) </div><div>         </div><div>         ((5) </div><div>          (print &quot;IN CASE 5&quot;)</div><div>          (mp:midi :time start-time :key 91 :dur outrhythm :amp theamp :chan 0) </div><div>          (mp:midi :time start-time :key newkey :dur outrhythm :amp theamp :chan 1)</div><div>          (set! start-time (+ start-time outrhythm))</div><div>          )</div><div>         )</div><div>   )</div><div> )</div><div>)</div><div><br></div><div><br></div><div>(sprout (ruby4 36 82         .125              1         .125     &#39;(2 1 .75 1 2) &#39;(0 1000 630 1000 ) 100))</div><div><br></div><div><br></div><div><br></div><div><br></div></div><div><br></div><div><br></div></div></div>