Create a gist now

Instantly share code, notes, and snippets.

(define root 52)
(define scale (pc:scale 4 'aeolian))
(define right-hand
(lambda (beat dur)
(play sampler
(pc:quantize (cosr (+ root 24) (cosr 5 3 1/2) 7/3) scale)
(cosr 80 20 7/3)
(* 2.0 dur))
(if (> (random) .6)
(play fmsynth
(pc:quantize (+ 7 (cosr (+ root 12) (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)))
(right-hand (*metro* 'get-beat 4) 1/4)
(define left-hand
(lambda (beat ps ds)
(if (= 0 (modulo beat 8))
(set! root (random (remove root (list 52 50 48 43)))))
(play sampler (car ps) 80 (car ds))
(play 1/2 sampler root 80 (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) (list 55 55 57 59) (list 1))
(define bassline
(lambda (beat ps ds)
(play fmsynth root 80 (* (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 sampler2 35 100 dur)
(play -1/4 sampler2 35 80 (* .5 dur))
(callback (*metro* (+ beat (* .5 dur))) 'kick (+ beat dur) dur)))
(kick (*metro* 'get-beat 4) 1)
(define hats
(lambda (beat dur)
(play sampler2 (random '(44 42)) (cosr 60 50 (random '(7/3 5/2))) dur)
(callback (*metro* (+ beat (* .5 dur))) 'hats (+ beat dur) dur)))
(hats (*metro* 'get-beat 4) 1/4)
@oubiwann

For future reference (context for those that may not have it), this code appeared in @digego's keynote at OSCON 2014. It was brilliant :-) Here's proof: https://www.youtube.com/watch?v=yY1FSsUV-8c

@oubiwann

Also, I've forked this to provide the missing steps to get new Extempore coders from zero to actually playing the music: https://gist.github.com/oubiwann/8b4404e538e61c7996a5

I plan on turning this into a blog post soon ... gotta share the amazing fun of Extempore, which has a lovely feel all its own.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment