Skip to content

Instantly share code, notes, and snippets.

@samaaron
Forked from kawabata/tarai.clj
Created December 2, 2011 13:55
Show Gist options
  • Save samaaron/1423313 to your computer and use it in GitHub Desktop.
Save samaaron/1423313 to your computer and use it in GitHub Desktop.
tarai mawashi in overtone
(ns tarai.core
(:use [overtone.live]))
;; basic.clj より
(defsynth foo [freq 200 dur 0.5]
(let [src (saw [freq (* freq 1.01) (* 0.99 freq)])
low (sin-osc (/ freq 2))
filt (lpf src (line:kr (* 10 freq) freq 10))
env (env-gen (perc 0.1 dur) :action FREE)]
(out 0 (pan2 (* 0.1 low env filt)))))
;; この関数はお好みで。
(defn foo-play [x y z j]
(foo (* 110 (+ x 3)) 1.0)
(Thread/sleep 150)
(foo (* 110 (+ y 3)) 1.0)
(Thread/sleep 150)
(foo (* 110 (+ z 3)) 1.0)
(Thread/sleep 150)
(foo (* 110 (+ j 3)) 1.0)
(Thread/sleep 150))
(defn tarai [x y z j]
(println x y z j)
(foo-play x y z j)
(if (<= x y)
y
(tarai (tarai (- x 1) y z j) (tarai (- y 1) z j x) (tarai (- z 1) j x y) (tarai (- j 1) x y z))))
(tarai 8 3 2 3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment