Created
February 11, 2015 11:46
-
-
Save ctford/d3fce6482260d39c9b56 to your computer and use it in GitHub Desktop.
Some music via Leipzig and Overtone.
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 home-alone.home-alone | |
(:require [overtone.live :refer :all] | |
[leipzig.melody :refer :all] | |
[leipzig.scale :as scale] | |
[leipzig.live :as live] | |
[leipzig.chord :as chord] | |
[leipzig.canon :as canon] | |
[leipzig.temperament :as temperament])) | |
; Instruments | |
(definst bow [freq 110 dur 1.0 volume 0.1] | |
(-> (saw freq) | |
(rlpf (* 440 4) 1/8) | |
(* (env-gen (perc 0.2 0.4) :action FREE)) | |
(* volume))) | |
(definst plink [freq 110 volume 0.1] | |
(-> (square freq) | |
(+ (sin-osc (* 2 freq))) | |
(clip2 0.6) | |
(* (env-gen (perc 0.01 0.4) :action FREE)) | |
(* volume))) | |
(definst organ [freq 440 dur 1 volume 0.2] | |
(-> (sin-osc freq) | |
(+ (sin-osc (* 2 freq))) | |
(+ (* 1/3 (sin-osc (* 4 freq)))) | |
(+ (* 1/5 (sin-osc (* 3.01 freq)))) | |
(+ (* 1/4 (sin-osc (* 2.99 freq)))) | |
(+ (* 1/8 (sin-osc (* 5 freq)))) | |
(* (env-gen (adsr 0.01 0.2 0.3) (line:kr 1 0 dur) :action FREE)) | |
(* volume 1/3))) | |
(definst woo [freq 440 dur 1.0 volume 0.2] | |
(-> (sin-osc freq) | |
(+ (sin-osc (* 2 freq))) | |
(+ (* 1/5 (sin-osc (* 2.01 freq)))) | |
(+ (* 1/4 (sin-osc (* 2.99 freq)))) | |
(+ (* 1/6 (sin-osc (* 4.1 freq)))) | |
(rlpf (mul-add (sin-osc 4) 200 500) 1/2) | |
(* (env-gen (adsr 0.01 0.5 0.5) (line:kr 1 0 dur) :action FREE)) | |
(* volume))) | |
(definst kick [freq 110] | |
(-> (line:kr freq (* freq 1/2) 0.5) | |
sin-osc | |
(+ (sin-osc freq)) | |
(* (env-gen (perc 0.01 0.3) :action FREE)) | |
(* 1/3))) | |
(definst tip [freq 110] | |
(-> (white-noise) | |
(* (env-gen (perc 0.01 0.1) :action FREE)) | |
(* 1/10))) | |
; Arrangement | |
(defmethod live/play-note :melody [{hertz :pitch}] | |
(plink hertz)) | |
(defmethod live/play-note :highlight [{hertz :pitch seconds :duration}] | |
(woo hertz seconds)) | |
(defmethod live/play-note :bass [{hertz :pitch seconds :duration}] | |
(bow hertz seconds)) | |
(defmethod live/play-note :accompaniment [{hertz :pitch seconds :duration}] | |
(organ hertz seconds)) | |
(defmethod live/play-note :beat [{hertz :pitch}] | |
(kick hertz)) | |
(defmethod live/play-note :clap [{hertz :pitch}] | |
(tip hertz)) | |
; Composition | |
(def progression | |
[(-> chord/triad (chord/inversion 2)) | |
(-> chord/triad (chord/inversion 2) (chord/root -1)) | |
(-> chord/triad (chord/root -3)) | |
(-> chord/triad (chord/root -4)) ]) | |
(defn bass [{:keys [i v]}] | |
(->> (phrase (repeat 8 1/2) [i i i i i i v i]) | |
(where :pitch (comp scale/lower scale/lower)) | |
(where :part (is :bass)))) | |
(defn riff [chord] | |
(let [[l m h] (-> chord vals sort)] | |
(->> (phrase (repeat 1/2) [m l m h l m l m]) | |
(where :part (is :melody))))) | |
(defn accompaniment [chord] | |
(->> | |
(phrase [4] [chord]) | |
(where :part (is :accompaniment)))) | |
(def melody | |
(->> (phrase (cycle [3/2 3/2 2/2]) | |
[0 2 0 1 2 3 1 2 3 0 2 0]) | |
(then (phrase [6/3 2/2 5 1/4 1/4 1/4 1/4 2] | |
[0 0 1 2 1 0 -1 0])) | |
(then (phrase [1/4 1/4 1/4 1/4 4] [2 1 0 -1 0])) | |
(where :part (is :highlight)))) | |
(def beat | |
(->> (phrase [1 1 1/2 1/4 1/4 1/2 1/2] [-14 -21 -21 -21 -21 -21 -21]) | |
(where :part (is :beat)) | |
(with (->> (phrase [1 1 1 1] [0 0 0 0]) | |
(after 1/2) | |
(where :part (is :clap)))) | |
(times 4))) | |
(def home | |
(->> (phrase [5/2 1/2 1 6] | |
[2 3 4 1]) | |
(then (phrase [1/4 1/4 1/2 1/4 1/4 1/4 1/4 2/4 1/2 1/2 | |
1/4 1/4 1/4 1/4 3/2] | |
[3 3 3 4 4 4 4 4 2 1 | |
0 0 0 0 0 0])) | |
(times 2) | |
(where :part (is :highlight)))) | |
(def ba-bam | |
(->> (phrase [1/2 1] [-21 -21]) | |
(after 29/2) | |
(where :part (is :clap)) | |
(canon/canon (partial where :part (is :beat))))) | |
(def speckles | |
(->> | |
(phrase (repeat 1/4) | |
(->> (range -7 8) | |
(concat (range 6 -1 -1)) | |
(concat (range 14 4 -1)) | |
(interleave (cycle [-3 0])))) | |
(where :part (is :melody)))) | |
; Track | |
(def plain | |
(->> | |
(mapthen bass progression) | |
(with (mapthen riff progression)) | |
(with (mapthen accompaniment progression)) | |
(with beat) | |
(times 2))) | |
(def chorus | |
(->> plain | |
(with melody))) | |
(def verse | |
(->> | |
(mapthen bass progression) | |
(with (mapthen accompaniment progression)) | |
(times 2) | |
(with home))) | |
(def intro | |
(->> | |
(mapthen bass progression) | |
(with ba-bam) | |
(times 2) | |
(with (->> (phrase (repeat 1) (repeat -21)) | |
(take 15) | |
(after 16) | |
(where :part (is :beat)))))) | |
(def track | |
(->> | |
intro | |
(then plain) | |
(then verse) | |
(then (with verse beat)) | |
(then chorus) | |
(then verse) | |
(then (with verse beat (mapthen riff progression))) | |
(then (->> intro | |
(where :pitch scale/raise) | |
(with (after 16 speckles)))) | |
(then (with chorus (times 2 speckles))) | |
(then (times 4 | |
(with | |
(mapthen bass (take 1 progression)) | |
(after -12 (take-last 16 speckles))))) | |
(where :pitch (comp temperament/equal scale/A scale/minor)) | |
(where :time (bpm 130)) | |
(where :duration (bpm 130)))) | |
(defn -main [] | |
(live/play track)) | |
(comment | |
; Loop the track, allowing live editing. | |
(live/jam (var track)) | |
(recording-start "home-alone.wav") | |
(live/play track) | |
(recording-stop) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment