Skip to content

Instantly share code, notes, and snippets.

@illiichi
Last active December 22, 2023 22:33
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save illiichi/44c7c59ebec45d6dff3ed1fbe0bbf810 to your computer and use it in GitHub Desktop.
Save illiichi/44c7c59ebec45d6dff3ed1fbe0bbf810 to your computer and use it in GitHub Desktop.
pseudoethnological clojure code in 30 lines
(defproject pseudoethnological "0.1.0-SNAPSHOT"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:jvm-opts ["-Xmx2g" "-server"]
:dependencies [[org.clojure/clojure "1.8.0"]
[overtone "0.10.3"]])
;; pseudoethnological clojure code in 30 lines
;; by illiichi
(use 'overtone.live)
(defmacro c-saw [freq phase c-min c-max min max step]
`(-> (lf-saw:kr ~freq ~phase)
(clip ~c-min ~c-max)
(lin-lin ~c-min ~c-max ~min ~max)
(round ~step)))
(defmacro reduce-> [initial f xs]
`(reduce ~f ~initial ~xs))
(let [freq (env-gen (envelope [1/900 1/90 1/10 1] [350 5 250]))
width (c-saw 1/300 7/8 -7/8 3/4 1/4 1 1/8)]
((synth (out 0
(-> (map #(let [gate (* (impulse %1) (line:kr 1 0 600)
(lf-pulse:kr (* 1/8 %2) 1/2 width))]
(* (c-saw freq %3 0 1 1/32 1 0.01)
(rhpf (white-noise) (* 100 %2) 0.4) 512
(env-gen (env-perc 1e-6 0.01) gate)))
(map #(* %3 (c-saw (/ %1 5) 0.1 0.8 0.95 1 3 1)
(c-saw %1 %2 0 0.2 1/4 1 1/4))
(map #(/ 1/120 %) (iterate inc 1))
(map #(* % 1/16) (range 16))
(cycle [1 2 3 5 7 9]))
(reductions * 1 (cycle [5/2 3/2 4/5 5/11]))
(shuffle (map #(* % 1/16) (range 16))))
splay
(reduce-> (fn [acc [x y z]]
(+ acc (* (lf-pulse y 0 z) (ringz acc x 0.001))))
[[8000 1/8 1/2] [20 1/12 1/16] [300 1.1 1/8]])
(reduce-> free-verb [0.1 0.4 0.2])
(g-verb 1.1)
tanh)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment