Created
November 30, 2015 13:25
-
-
Save martensjostrand/e9197ee17020be7774f5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 repl-test.mud-experiment | |
(:use [overtone.live]) | |
(:use [overtone.studio.scope]) | |
(:use mud.core) | |
(:require [mud.timing :as timing])) | |
(defn bpm->rate-of-16 [bpm] | |
(* (/ bpm 60) 4.)) | |
(ctl timing/root-s :rate (bpm->rate-of-16 127)) | |
(defbufs 8 [hat-seq-buf]) | |
(pattern! hat-seq-buf [1 0 0 0 1 0 0 0]) | |
(defsynth hihat [ | |
; Sound shaping | |
cutoff 8000 | |
resonance 0.3 | |
attack 0.01 | |
decay 0.1 | |
sustain 0.1 | |
release 0.1 | |
gain 0.2 | |
; Audio patching | |
out-bus 0 | |
; Timing/sequencer realted properties | |
gate 0 | |
num-steps 8 | |
seq-buf hat-seq-buf | |
beat-bus (:count timing/main-beat) | |
beat-trg-bus (:beat timing/main-beat) | |
gate-time 0.4 | |
] | |
(let [ | |
; Beat gates | |
cnt (mod (in:kr beat-bus) num-steps) ; Index in pattern | |
beat-trg (in:kr beat-trg-bus) ; Trigger signal | |
bar-trg (and (buf-rd:kr 1 seq-buf cnt) beat-trg) ; Should this synt play at current beat? | |
; Sound shaping | |
snd (white-noise) | |
env (env-gen (adsr attack decay sustain release) :gate bar-trg) | |
snd (rhpf (* gain snd env) cutoff resonance) | |
] | |
(out out-bus snd))) | |
(comment | |
(def the-hihat (hihat)) | |
(scope (:beat timing/main-beat)) | |
(ctl the-hihat :decay 1) | |
(ctl the-hihat :sustain 0.7) | |
(ctl the-hihat :release 0.3) | |
(ctl the-hihat :attack 0) | |
(ctl the-hihat :cutoff 9000) | |
(ctl the-hihat :resonance 0.5) | |
(ctl the-hihat :gate 1) | |
(ctl the-hihat :gate 0) | |
(kill the-hihat) | |
(stop) | |
(event-debug-on) | |
(event-debug-off)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment