Created
July 14, 2013 08:03
-
-
Save sevvie/5993569 to your computer and use it in GitHub Desktop.
I haven't had this much fun programming in a long time. Live-coding example, with Clojure, Overtone & SuperCollider. I don't know if it's actually music, though.
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 overtone-tutorial.second-song | |
(:use overtone.live | |
overtone.inst.drum)) | |
(def metro (metronome 120)) | |
(definst saw-wave [freq 440 attack 0.01 sustain 0.4 release 0.1 vol 0.4] | |
(* (env-gen (lin-env attack sustain release) 1 1 0 1 FREE) | |
(saw freq) | |
vol)) | |
(defn play-chord [chrd] | |
(doseq [mnote chrd] | |
(saw-wave (midi->hz (note mnote))))) | |
(defn play-halfnote-chord [chrd] | |
(doseq [mnote chrd] | |
(saw-wave (midi->hz (note mnote)) 0.01 0.2 0.1 0.4))) | |
(defn second-song-beat [nome] | |
(let [beat (nome)] | |
(at (nome beat) (kick)) | |
(at (nome (+ 0.5 beat)) (closed-hat)) | |
(at (nome (+ 0.25 beat)) (tone-snare)) | |
(apply-at (nome (inc beat)) #'second-song-beat nome []))) | |
(defn second-song-progression [nome] | |
(let [beat (nome)] | |
(at (nome (+ 1 beat)) (play-chord (chord :A3 :major))) | |
(at (nome (+ 2 beat)) (play-chord (chord :G3 :major))) | |
(at (nome (+ 3 beat)) (play-halfnote-chord (chord :D3 :minor))) | |
(at (nome (+ 3.5 beat)) (play-halfnote-chord (chord :F3 :minor))) | |
(apply-at (nome (+ 4 beat)) #'second-song-progression nome []))) | |
(defn second-song [nome] | |
(second-song-beat nome) | |
(second-song-progression nome)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment