Skip to content

Instantly share code, notes, and snippets.

@sleexyz
Created January 20, 2014 04:07
Show Gist options
  • Save sleexyz/8514731 to your computer and use it in GitHub Desktop.
Save sleexyz/8514731 to your computer and use it in GitHub Desktop.
Overtone Code
(ns insane-noises.core
(:use [overtone.live]
[overtone.inst.piano]
[overtone.inst.sampled-piano]
[overtone.inst.drum]
[overtone.inst.synth]
))
;;defsynth vs definfst
;(definst foo [freq 220] (lpf (saw (mouse-y 10 300 LIN)) (mouse-x 40 5000 EXP)))
;(defsynth sinne [freq 220] (out 0 (saw freq)))
(definst bar [freq 220 amp 0.1]
(* amp
(lpf
(square (+ freq (mouse-y -100 200 LIN)))
(mouse-x 40 5000 EXP))))
(bar 20 1)
(kill bar)
(bar 440)
(def foo [freq] (bar freq))
(defn play-chord [a-chord]
(doseq [note a-chord] (bar (midi->hz note))))
;; check out overtone github for send osc message
;
(play-chord (rand-chord :G1 #{0 3 7 10 12 14 17 21 23} 10 100))
;(kill sampled-piano)
;
(def metro (metronome 80))
;;cool
(defn haz [] (haziti-clap 44 0.036 1.884 0.03 0.8))
(haz)
(defn offset []
(choose [0 1/3 3/5 5/9 5/16 7/16 12/16]))
(defn player [beat]
(at (metro (+ (/ 0 3) beat)) (haz))
(at (metro (+ (offset) beat)) (haz))
(at (metro (+ (offset) beat)) (haz))
(at (metro (+ (offset) beat)) (haz))
(at (metro (+ (offset) beat)) (haz))
(apply-at (metro (inc beat)) #'player (inc beat)[]))
(defn player [beat]
(at (metro (+ (/ 0 3) beat)) (haz))
; (at (metro (+ (/ 1 3) beat)) (haz))
(apply-at (metro (inc beat)) #'player (inc beat)[]))
(defn player [beat]
(at (metro (+ (/ 0 3) beat)) (haz))
(at (metro (+ (/ 1 3) beat)) (haz))
(at (metro (+ (/ 2 4) beat)) (haz))
(apply-at (metro (inc beat)) #'player (inc beat)[]))
(defn player [beat]
(at (metro (+ (/ 0 6) beat)) (haz))
(at (metro (+ (/ 1 6) beat)) (haz))
(at (metro (+ (/ 2 6) beat)) (haz))
(at (metro (+ (/ 3 6) beat)) (haz))
(at (metro (+ (/ 4 6) beat)) (haz))
(at (metro (+ (/ 5 6) beat)) (haz))
(apply-at (metro (inc beat)) #'player (inc beat)[]))
(defn player [beat]
(at (metro (+ (/ 0 3) beat)) (haz))
(at (metro (+ (/ 1 3) beat)) (haz))
(at (metro (+ (/ 2 3) beat)) (haz))
(at (metro (+ (/ 24 32) beat)) (dance-kick 19))
; (at (metro (+ (/ 26 32) beat)) (dance-kick 29))
(apply-at (metro (inc beat)) #'player (inc beat)[]))
(defn player [beat]
(at (metro (+ (/ 0 6) beat)) (hat3))
(at (metro (+ (/ 1 6) beat)) (haz))
(at (metro (+ (/ 2 8) beat)) (haz))
(at (metro (+ (/ 3 6) beat)) (dance-kick 40 0.0001 0.2))
(at (metro (+ (/ 4 6) beat)) (haz))
(at (metro (+ (/ 6 8) beat)) (haz))
(apply-at (metro (inc beat)) #'player (inc beat)[]))
(defn player [beat]
(at (metro (+ (/ 0 3) beat)) (haz))
(at (metro (+ (/ 1 3) beat)) (haz))
;(at (metro (+ (/ 1 6) beat)) (haz))
(at (metro (+ (/ 2 4) beat)) (haz))
(at (metro (+ (offset) beat)) (haz))
;(at (metro (+ (/ 16 32) beat)) (dance-kick 25))
;(at (metro (+ (/ 30 32) beat)) (dance-kick 20))
(at (metro (+ (/ 24 32) beat)) (dance-kick 29))
;(at (metro (+ (offset) beat)) (dance-kick 32))
(apply-at (metro (inc beat)) #'player (inc beat)[]))
(defn player [beat]
(at (metro (+ (/ 0 3) beat)) (haz))
(at (metro (+ (/ 1 3) beat)) (haz))
(at (metro (+ (/ 24 32) beat)) (dance-kick 25 0.01))
(apply-at (metro (inc beat)) #'player (inc beat)[]))
(defn player [beat]
(at (metro (+ (/ 0 3) beat)) (haz))
(at (metro (+ (/ 1 3) beat)) (haz))
(at (metro (+ (/ 16 32) beat)) (soft-hat))
(at (metro (+ (/ 18 32) beat)) (quick-kick 800))
(at (metro (+ (/ 22 32) beat)) (quick-kick 600))
(at (metro (+ (/ 20 32) beat)) (quick-kick 700))
(at (metro (+ (/ 24 32) beat)) (quick-kick 800))
(at (metro (+ (/ 26 32) beat)) (quick-kick 600))
(apply-at (metro (inc beat)) #'player (inc beat)[]))
(defn player [beat]
(at (metro (+ (/ 0 3) beat)) (haz))
(at (metro (+ (/ 1 3) beat)) (haz))
(at (metro (+ (/ 1 6) beat)) (haz))
(at (metro (+ (/ 5 6) beat)) (haz))
(at (metro (+ (/ 16 32) beat)) (dance-kick 30 0.01))
;(at (metro (+ (/ 20 32) beat)) (quick-kick 80))
(at (metro (+ (/ 24 32) beat)) (dance-kick 30 0.01))
(apply-at (metro (inc beat)) #'player (inc beat) []))
(player (metro))
;(metro-bpm metro 180)
(metro-bpm metro 1)
;(metro-bpm metro 1)
(def server (osc-server 44100 "osc-clj"))
(zero-conf-on)
(defn control-bpm
[val]
(let [val (scale-range val 0 400 20 1000)]
(metro-bpm metro val)))
(osc-handle server "/test" (fn [msg] (control-bpm (first (:args msg)))))
(defn control-foo
[val]
(let [val (scale-range val 0 400 20 1000)]
(ctl metro val)))
(stop)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment