Skip to content

Instantly share code, notes, and snippets.

@digego
Last active June 2, 2016 13:15
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save digego/0c2a68200a6aefad3871 to your computer and use it in GitHub Desktop.
Save digego/0c2a68200a6aefad3871 to your computer and use it in GitHub Desktop.
(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
Copy link

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
Copy link

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