-
-
Save ericmoritz/1959374 to your computer and use it in GitHub Desktop.
Binaural Beats with Overtone and Clojure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns overtone-clj-toys.binaural | |
(:use [overtone.live])) | |
;; | |
;; Binaural Beat Synthesis: | |
;; Generates binaural beats given the provided carrier and desired | |
;; frequency. Brown noise is used to soften the background and | |
;; block out outside noise. | |
;; freq effect | |
;; < 4 Delta, Sleep | |
;; 3 - 7 Theta, relaxation, meditation | |
;; 7 - 13 Alpha, Relaxation while Awake | |
;; | |
(defsynth bbeat [amp 0.3 | |
carrier 440 | |
freq 4.5] | |
(let [freq-a carrier | |
freq-b (+ carrier freq) | |
left (* 0.8 (sin-osc freq-a)) | |
right (* 0.8 (sin-osc freq-b))] | |
(out 0 (* amp left)) | |
(out 1 (* amp right)))) | |
(defcgen snare-drum | |
"basic synthesised snare drum" | |
[bpm {:default 120 :doc "tempo of snare in beats per minute"}] | |
(:ar | |
(let [snare (* 3 (pink-noise [1 1]) (apply + (* (decay (impulse (/ bpm 240) 0.5) [0.4 2]) [1 0.05]))) | |
snare (+ snare (bpf (* 4 snare) 2000))] | |
(clip2 snare 1)))) | |
(defcgen kick-drum | |
"basic synthesised kick drum" | |
[bpm {:default 120 :doc "tempo of kick in beats per minute"} | |
pattern {:default [1 0] :doc "sequence pattern of beats"}] | |
(:ar | |
(let [kickenv (decay (t2a (demand (impulse:kr (/ bpm 30)) 0 (dseq pattern INF))) 0.7) | |
kick (* (* kickenv 7) (sin-osc (+ 40 (* kickenv kickenv kickenv 200))))] | |
(clip2 kick 1)))) | |
(definst drums [bpm 120] | |
(let [kick (kick-drum bpm :pattern [1 0 0 0 0 0 1 0 1 0 0 1 0 0 0 0]) | |
snare (snare-drum bpm)] | |
(clip2 (+ kick snare) 1))) | |
;;(bbeat 0.2 440 3) | |
;;(stop) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment