Created
February 18, 2014 16:48
-
-
Save bartolsthoorn/9074720 to your computer and use it in GitHub Desktop.
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 overtour.core | |
(:use [overtone.live] | |
[overtone.inst.piano])) | |
(defn -main [& args] | |
(piano (note :g4)) | |
(println "Piano ready!")) | |
; Random number between l and h (l inclusive, h exclusive) | |
(defn rand-between [l h] | |
; (0 - (h - l)) + l | |
; l: 1, h: 10 random-int 0-9 (exl) | |
; in case random-int: 8 => 9 | |
; in case random-int: 0 => 1 | |
(+ (rand-int (- h l)) l)) | |
; Piano shorthand | |
(defn p [music-note] | |
(piano (note music-note))) | |
; Piano chord | |
; a-chord = (chord :E4 :minor) => (64 67 71) | |
(defn play-chord [a-chord] | |
(doseq [note a-chord] (p note))) | |
; Random interval (octave is + 12) | |
; (note :E4) => 64 | |
; (cons 2 [4]) => (2 4) | |
(defn play-random-interval [base-note] | |
(doseq [note (cons (+ (note base-note) (rand-between 1 12)) [(note base-note)])] (p note))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment