[CM] lisp loop iteration in cm
Juan Reyes
juanig@ccrma.Stanford.EDU
Sat, 16 Sep 2006 12:47:26 -0700
Hi Rick,
Below is my example for using loop iteration using the Henon Map. If you
change a and b values the algorithm can be more stable or unstable. For
instance a=0.42 and b=-0.99 are also good choices. The initial
conditions x and y of this map can also be changed!
--* Juan
;;;; this function maps Henon values to midi note values
(defun midinormz (x)
(let ((offset 1.0)
(maxinput 2.0)
(slope 1.25)
(maxoutput 127.0)
(c 0.75)
(lowbound 15))
(floor (+ (* (/ (+ x offset) (* maxinput slope))
(+ maxoutput c))
lowbound)) ))
;;;
;;; Function to generate MIDI notes using the henon map
;;;
;;; http://henon.sapp.org/
;;;
(defun henonseq (cycles rhy dur amp &key
(a -1.85039) ;; a=-1.56693 b= -0.011811
(b 0.003937)
(x 0.63135448)
(y 0.18940634))
(process repeat cycles
with newx = 0.00
with newy = 0.00
do (progn
(setf newx (+ (* a (expt x 2)) (* b y) 1))
(setf newy x)
(setf x newx)
(setf y newy))
output (new midi :time (now)
:duration dur
:amplitude amp
:keynum (midinormz x))
wait rhy))
;;; (events (henonseq 12 0.25 0.1 0.7) "henonseq.mid")