Create a gist now

Instantly share code, notes, and snippets.

@oubiwann /01-setup.sh forked from digego/keynote.scm
Last active Feb 11, 2016

Instructions for Running Andrew Sorensen's OSCON 2014 Keynote Performance
$ git clone https://gist.github.com/8b4404e538e61c7996a5.git
$ cd 8b4404e538e61c7996a5
$ mkdir salamander && cd salamander
$ curl -L -O https://archive.org/download/SalamanderDrumkit/salamanderDrumkit.tar.bz2
$ curl -L -O https://github.com/johnsen/drumsandpercussion/blob/master/SalamanderKick/salamanderdrum-kick-r1.tar.gz
$ curl -L -O http://freepats.zenvoid.org/Piano/SalamanderGrandPianoV3_44.1khz16bit.tar.bz2
$ tar xvfz salamanderDrumkit.tar.bz2
$ tar xvfz salamanderdrum-kick-r1.tar.gz
$ mv Kick/kick* OH/
$ tar xvfz SalamanderGrandPianoV3_44.1khz16bit.tar.bz2
$ brew tap benswift/extempore
$ brew install extempore
$ cd /usr/local/Cellar/extempore/0.52
$ ./extempore
;;;; Much of the content in this file is taken from various Extempore
;;;; blog posts by Ben Swift which are indexed here:
;;;; http://benswift.me/extempore-docs/index.html
;;;;
;;; Load the needed libraries -- this will take several minutes
;;;
(sys:load "libs/core/instruments.xtm")
(sys:load "libs/core/pc_ivl.xtm")
(sys:load "libs/external/instruments_ext.xtm")
;;; Set up the constants we're going to need
;;;
(define sample-path "/Users/oubiwann/Downloads/8b4404e538e61c7996a5/")
(define drum-path (string-append sample-path "salamander/OH/"))
(define piano-regex "^.*([ABCDEFG][#b]?[0-9])v([0-9]+)\.wav$")
;;; Add the samplers/instruments we're going to need to the dsp output
;;; callback
;;;
(define-sampler drums sampler_note_hermite_c sampler_fx)
(define-sampler piano sampler_note_hermite_c sampler_fx)
(bind-func dsp:DSP
(lambda (in time chan dat)
(cond ((< chan 2.0)
(+ (drums in time chan dat)
(piano in time chan dat)
(fmsynth in time chan dat)))
(else 0.0))))
(dsp:set! dsp)
;;; Set up drum samples
;;;
(define add-drum-sample
(lambda (file-name const-name)
(set-sampler-index drums
(string-append drum-path file-name)
const-name
0 0 0 1)))
(define drum-sample-data
(list
(list "kick_OH_F_9.wav" *gm-kick*)
(list "hihatClosed_OH_F_20.wav" *gm-closed-hi-hat*)
(list "hihatFoot_OH_MP_12.wav" *gm-pedal-hi-hat*)
(list "hihatOpen_OH_FF_6.wav" *gm-open-hi-hat*)))
(define add-drum-samples
(lambda (data)
(map (lambda (sample-pair)
(add-drum-sample (car sample-pair) (cadr sample-pair)))
data)))
(add-drum-samples drum-sample-data)
;;; Set up piano samples
;;;
(define parse-salamander-piano
(lambda (file-list)
(map (lambda (fname)
(let ((result (regex:matched fname piano-regex)))
(if (null? result)
#f
;; load 4th velocity layer only
(if (= (string->number (caddr result)) 4)
(list fname
(note-name-to-midi-number (cadr result))
0
0)
#f))))
file-list)))
(load-sampler
piano
;; Can't use a variable here; need the actual path string
"/Users/oubiwann/Downloads/8b4404e538e61c7996a5/salamander/SalamanderGrandPianoV3_44.1khz16bit/44.1khz16bit"
;; 'sound bank' index
0
parse-salamander-piano)
;; Now that everything is loaded, try out some notes ...
(play-note (now) drums *gm-kick* 180 44100)
(play-note (now) drums *gm-open-hi-hat* 140 44100)
(play-note (now) piano 24 180 44100)
(play-note (now) fmsynth (random 60 80) 100 (* 1.0 *second*))
(define base-note 12)
(define get-note
(lambda (octave offset)
(+ (* base-note octave) offset)))
(define C1 (get-note 1 0))
(define C2 (get-note 2 0))
(define C3 (get-note 3 0))
(define C4 (get-note 4 0))
(define C5 (get-note 5 0))
(define C6 (get-note 6 0))
(define C7 (get-note 7 0))
(define D1 (get-note 1 2))
(define D2 (get-note 2 2))
(define D3 (get-note 3 2))
(define D4 (get-note 4 2))
(define D5 (get-note 5 2))
(define D6 (get-note 6 2))
(define D7 (get-note 7 2))
(define E1 (get-note 1 4))
(define E2 (get-note 2 4))
(define E3 (get-note 3 4))
(define E4 (get-note 4 4))
(define E5 (get-note 5 4))
(define E6 (get-note 6 4))
(define E7 (get-note 7 4))
(define G1 (get-note 1 7))
(define G2 (get-note 2 7))
(define G3 (get-note 3 7))
(define G4 (get-note 4 7))
(define G5 (get-note 5 7))
(define G6 (get-note 6 7))
(define G7 (get-note 7 7))
(define A1 (get-note 1 9))
(define A2 (get-note 2 9))
(define A3 (get-note 3 9))
(define A4 (get-note 4 9))
(define A5 (get-note 5 9))
(define A6 (get-note 6 9))
(define A7 (get-note 7 9))
(define B1 (get-note 1 11))
(define B2 (get-note 2 11))
(define B3 (get-note 3 11))
(define B4 (get-note 4 11))
(define B5 (get-note 5 11))
(define B6 (get-note 6 11))
(define B7 (get-note 7 11))
(define root E3)
(define scale (pc:scale 4 'aeolian))
(define left-hand-notes-1 (list C3 G3))
(define left-hand-notes-2 (list G4 G4 A4 B4))
;; start with this
(define left-hand
(lambda (beat ps ds)
(play piano (car ps) 170 (* 2.0 (car ds)))
(callback (*metro* (+ beat (* .95 (car ds)))) 'left-hand (+ beat (car ds))
(rotate ps -1)
(rotate ds -1))))
(left-hand (*metro* 'get-beat 4) left-hand-notes-2 (list 1))
;; after a bit, switch to this
(define left-hand
(lambda (beat ps ds)
(play piano (car ps) 170 (* 2.0 (car ds)))
(play 1/2 piano root 170 (* 2.0 (car ds)))
(callback (*metro* (+ beat (* .95 (car ds)))) 'left-hand (+ beat (car ds))
(rotate ps -1)
(rotate ds -1))))
;; don't wait too long to execute the next bit
(define left-hand
(lambda (beat ps ds)
(if (= 0 (modulo beat 8))
(set! root (random (remove root left-hand-notes-1))))
(play piano (car ps) 170 (* 2.0 (car ds)))
(play 1/2 piano root 170 (* 2.0 (car ds)))
(callback (*metro* (+ beat (* .95 (car ds)))) 'left-hand (+ beat (car ds))
(rotate ps -1)
(rotate ds -1))))
(define left-hand-notes-1 (list E3 D3 C3))
(define right-hand
(lambda (beat dur)
(play piano
(pc:quantize (cosr (+ root C2) (cosr 5 3 1/2) 7/3) scale)
(cosr 160 20 7/3)
(* 4.0 dur))
(callback (*metro* (+ beat (* .5 dur))) 'right-hand (+ beat dur) dur)))
(right-hand (*metro* 'get-beat 4) 1/4)
(define bassline
(lambda (beat ps ds)
(play fmsynth root 100 (* (car ps) (car ds)) 1.0 0.5)
(callback (*metro* (+ beat (* .95 (car ds)))) 'bassline (+ beat (car ds))
(rotate ps -1)
(rotate ds -1))))
(bassline (*metro* 'get-beat 4) (list .25 .25 .6) '(3/2 1 3/2))
(define right-hand
(lambda (beat dur)
(play piano
(pc:quantize (cosr (+ root C2) (cosr 5 3 1/2) 7/3) scale)
(cosr 160 20 7/3)
(* 4.0 dur))
(if (> (random) .6)
(play fmsynth
(pc:quantize (+ 7 (cosr (+ root 36) (cosr 5 3 1/2) 7/3)) scale)
(cosr 75 20 7/3)
(* .2 dur) 0.5 5.0))
(callback (*metro* (+ beat (* .5 dur))) 'right-hand (+ beat dur) dur)))
(define kick
(lambda (beat dur)
(play drums 35 150 dur)
(callback (*metro* (+ beat (* .5 dur))) 'kick (+ beat dur) dur)))
(kick (*metro* 'get-beat 4) 1)
(define kick
(lambda (beat dur)
(play drums 35 150 dur)
(play -1/4 drums 35 130 (* .5 dur))
(callback (*metro* (+ beat (* .5 dur))) 'kick (+ beat dur) dur)))
(define hats
(lambda (beat dur)
(play drums (random '(44 42)) (cosr 80 60 (random '(7/3 5/2))) dur)
(callback (*metro* (+ beat (* .5 dur))) 'hats (+ beat dur) dur)))
(hats (*metro* 'get-beat 4) 1/4)
(define left-hand-notes-1 (list E3 D3 C3 G3))
(define right-hand
(lambda (beat dur)
(play piano
(pc:quantize (cosr (+ root C2) (cosr 5 3 1/2) 7/3) scale)
(cosr 170 20 7/3)
(* 4.0 dur))
(if (> (random) 0)
(play fmsynth
(pc:quantize (+ 12 (cosr (+ root 36) (cosr 5 3 1/2) 7/3)) scale)
(cosr 60 20 7/3)
(* .2 dur) 0.5 5.0))
(callback (*metro* (+ beat (* .5 dur))) 'right-hand (+ beat dur) dur)))
;; bring volume of sparkles up to 70 then 80
(define left-hand-notes-1 (list C3 G3))
(define left-hand-notes-1 (list E3 D3 C3 G3))
(define right-hand
(lambda (beat dur)
(play piano
(pc:quantize (cosr (+ root C2) (cosr 5 3 1/2) 7/3) scale)
(cosr 170 20 7/3)
(* 4.0 dur))
(if (> (random) .6)
(play fmsynth
(pc:quantize (+ 7 (cosr (+ root 36) (cosr 5 3 1/2) 7/3)) scale)
(cosr 80 20 7/3)
(* .2 dur) 0.5 5.0))
(callback (*metro* (+ beat (* .5 dur))) 'right-hand (+ beat dur) dur)))
;; bring volume of sparkles down to 70 then 60
(define left-hand-notes-1 (list C3 G3))
;; now bring down the piano volume of 160 by increments to 10
(define right-hand)
(define kick)
(define bassline)
(define hats)
(define left-hand
(lambda (beat ps ds)
(if (= 0 (modulo beat 8))
(set! root (random (remove root left-hand-notes-1))))
(play piano (car ps) 170 24.0)
(play piano root 170 24.0)))
;;;; This is a slightly modiifed version of code for the OSCON Keynote
;;;; which Andrew Sorenson performed live in Portland Oregon in July, 2014.
;;;;
;;;; Some of the differences include:
;;;; * Free samples were used instead of the cuomst samples that Andrew uses
;;;; * Note definitions are used instead of numbers
;;;; * The sustain of the piano notes was increased
;;;; * Some of the relative volumes were changed.
;;;;
;;;; The original is preserved in the history of this gist, which was forked
;;;; from Andrew's gist.
;;;;
;;;; Final note: thank you so much, Andrew, for the inspiring performance
;;;; you gave to OSCON; it was an absolute delight to finally be able to
;;;; attend one of your live performances!
;;;;
(define root E3)
(define scale (pc:scale 4 'aeolian))
;; (define left-hand-notes-1 (list E2 D2 C2 G2))
;; (define left-hand-notes-2 (list G3 G3 A3 B3))
;; (define left-hand-notes-1 (list E3 D3 C3 G3))
(define left-hand-notes-1 (list E3 D3 C3))
;; (define left-hand-notes-1 (list E4 D4 C4))
(define left-hand-notes-2 (list G4 G4 A4 B4))
;; (define left-hand-notes-1 (list E4 D4 C4 G4))
;; (define left-hand-notes-2 (list G5 G5 A5 B5))
;; (define left-hand-notes-1 (list E5 D5 C5 G5))
;; (define left-hand-notes-2 (list G6 G6 A6 B6))
(define left-hand)
(define left-hand
(lambda (beat ps ds)
(if (= 0 (modulo beat 8))
(set! root (random (remove root left-hand-notes-1))))
(play piano (car ps) 170 (* 2.0 (car ds)))
(play 1/2 piano root 170 (* 2.0 (car ds)))
(callback (*metro* (+ beat (* .95 (car ds)))) 'left-hand (+ beat (car ds))
(rotate ps -1)
(rotate ds -1))))
(left-hand (*metro* 'get-beat 4) left-hand-notes-2 (list 1))
(define right-hand)
(define right-hand
(lambda (beat dur)
(play piano
(pc:quantize (cosr (+ root 24) (cosr 5 3 1/2) 7/3) scale)
(cosr 160 20 7/3)
(* 4.0 dur))
(if (> (random) .6)
(play fmsynth
(pc:quantize (+ 7 (cosr (+ root 36) (cosr 5 3 1/2) 7/3)) scale)
(cosr 60 20 7/3)
(* .2 dur) 0.5 5.0))
(callback (*metro* (+ beat (* .5 dur))) 'right-hand (+ beat dur) dur)))
(right-hand (*metro* 'get-beat 4) 1/4)
(define bassline
(lambda (beat ps ds)
(play fmsynth root 110 (* (car ps) (car ds)) 1.0 0.5)
(callback (*metro* (+ beat (* .95 (car ds)))) 'bassline (+ beat (car ds))
(rotate ps -1)
(rotate ds -1))))
(bassline (*metro* 'get-beat 4) (list .25 .25 .6) '(3/2 1 3/2))
(define kick
(lambda (beat dur)
(play drums 35 150 dur)
(play -1/4 drums 35 130 (* .5 dur))
(callback (*metro* (+ beat (* .5 dur))) 'kick (+ beat dur) dur)))
(kick (*metro* 'get-beat 4) 1)
(define hats
(lambda (beat dur)
(play drums (random '(44 42)) (cosr 80 60 (random '(7/3 5/2))) dur)
(callback (*metro* (+ beat (* .5 dur))) 'hats (+ beat dur) dur)))
(hats (*metro* 'get-beat 4) 1/4)
;;;; 04 left
(define root E3)
(define scale (pc:scale 4 'aeolian))
(define left-hand-notes-1 (list C3 G3))
(define left-hand-notes-2 (list G4 G4 A4 B4))
;; start with this
(define left-hand
(lambda (beat ps ds)
(play piano (car ps) 170 (* 2.0 (car ds)))
(callback (*metro* (+ beat (* .95 (car ds)))) 'left-hand (+ beat (car ds))
(rotate ps -1)
(rotate ds -1))))
(left-hand (*metro* 'get-beat 4) left-hand-notes-2 (list 1))
;; after a bit, switch to this
(define left-hand
(lambda (beat ps ds)
(play piano (car ps) 170 (* 2.0 (car ds)))
(play 1/2 piano root 170 (* 2.0 (car ds)))
(callback (*metro* (+ beat (* .95 (car ds)))) 'left-hand (+ beat (car ds))
(rotate ps -1)
(rotate ds -1))))
;; don't wait too long to execute the next bit
(define left-hand
(lambda (beat ps ds)
(if (= 0 (modulo beat 8))
(set! root (random (remove root left-hand-notes-1))))
(play piano (car ps) 170 (* 2.0 (car ds)))
(play 1/2 piano root 170 (* 2.0 (car ds)))
(callback (*metro* (+ beat (* .95 (car ds)))) 'left-hand (+ beat (car ds))
(rotate ps -1)
(rotate ds -1))))
(define left-hand-notes-1 (list E3 D3 C3))
;;;; 05 right-and-baseline
(define right-hand
(lambda (beat dur)
(play piano
(pc:quantize (cosr (+ root C2) (cosr 5 3 1/2) 7/3) scale)
(cosr 160 20 7/3)
(* 4.0 dur))
(callback (*metro* (+ beat (* .5 dur))) 'right-hand (+ beat dur) dur)))
(right-hand (*metro* 'get-beat 4) 1/4)
(define bassline
(lambda (beat ps ds)
(play fmsynth root 100 (* (car ps) (car ds)) 1.0 0.5)
(callback (*metro* (+ beat (* .95 (car ds)))) 'bassline (+ beat (car ds))
(rotate ps -1)
(rotate ds -1))))
(bassline (*metro* 'get-beat 4) (list .25 .25 .6) '(3/2 1 3/2))
(define right-hand
(lambda (beat dur)
(play piano
(pc:quantize (cosr (+ root C2) (cosr 5 3 1/2) 7/3) scale)
(cosr 160 20 7/3)
(* 4.0 dur))
(if (> (random) .6)
(play fmsynth
(pc:quantize (+ 7 (cosr (+ root 36) (cosr 5 3 1/2) 7/3)) scale)
(cosr 75 20 7/3)
(* .2 dur) 0.5 5.0))
(callback (*metro* (+ beat (* .5 dur))) 'right-hand (+ beat dur) dur)))
;;;; 06 drums
(define kick
(lambda (beat dur)
(play drums 35 150 dur)
(callback (*metro* (+ beat (* .5 dur))) 'kick (+ beat dur) dur)))
(kick (*metro* 'get-beat 4) 1)
(define kick
(lambda (beat dur)
(play drums 35 150 dur)
(play -1/4 drums 35 130 (* .5 dur))
(callback (*metro* (+ beat (* .5 dur))) 'kick (+ beat dur) dur)))
(define hats
(lambda (beat dur)
(play drums (random '(44 42)) (cosr 80 60 (random '(7/3 5/2))) dur)
(callback (*metro* (+ beat (* .5 dur))) 'hats (+ beat dur) dur)))
(hats (*metro* 'get-beat 4) 1/4)
;;;; 07 climax ... and fade
(define left-hand-notes-1 (list E3 D3 C3 G3))
(define right-hand
(lambda (beat dur)
(play piano
(pc:quantize (cosr (+ root C2) (cosr 5 3 1/2) 7/3) scale)
(cosr 170 20 7/3)
(* 4.0 dur))
(if (> (random) 0)
(play fmsynth
(pc:quantize (+ 12 (cosr (+ root 36) (cosr 5 3 1/2) 7/3)) scale)
(cosr 60 20 7/3)
(* .2 dur) 0.5 5.0))
(callback (*metro* (+ beat (* .5 dur))) 'right-hand (+ beat dur) dur)))
;; bring volume of sparkles up to 70 then 80
(define left-hand-notes-1 (list C3 G3))
(define left-hand-notes-1 (list E3 D3 C3 G3))
(define right-hand
(lambda (beat dur)
(play piano
(pc:quantize (cosr (+ root C2) (cosr 5 3 1/2) 7/3) scale)
(cosr 170 20 7/3)
(* 4.0 dur))
(if (> (random) .6)
(play fmsynth
(pc:quantize (+ 7 (cosr (+ root 36) (cosr 5 3 1/2) 7/3)) scale)
(cosr 80 20 7/3)
(* .2 dur) 0.5 5.0))
(callback (*metro* (+ beat (* .5 dur))) 'right-hand (+ beat dur) dur)))
;; bring volume of sparkles down to 70 then 60
(define left-hand-notes-1 (list C3 G3))
;; now bring down the piano volume of 160 by increments to 10
(define right-hand)
(define kick)
(define bassline)
(define hats)
(define left-hand
(lambda (beat ps ds)
(if (= 0 (modulo beat 8))
(set! root (random (remove root left-hand-notes-1))))
(play piano (car ps) 170 24.0)
(play piano root 170 24.0)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment