Livecoding composition: 'Piano Scales' (Extempore + Ableton Live)

In general, algorithmic compositions using piano instruments always strike me for their captivating simplicity. So here's a new little experiment, titled 'Piano Scales'.

Repeated scales with a touch of randomness

The gist of this musical algorithm is amazingly simple.

Pick a scale. You play it using a variable time-interval between its notes, which is determined by a cosine function (cosr). The variable interval gives the final result a touch of suspense and makes it less computer-like.

(define xsc 
    (lambda (beat vel scale) 
        (let ((dur (cosratio 4 2 1/128)))

After each note, more notes are played programmatically, after brief (random) intervals of half a beat, or 3/2 of a beat. Fifths, octaves, minor sevenths... as you please.

This whole thing repeating itself, at each iteration of the loop though the sound volume gets quieter by a fixed amount. Eventually, when the volume goes to 0, the repetition stops.

(define xsc
  (lambda (beat vel scale)
    (let ((dur (cosratio 4 2 1/128)))

      ;; piano
      (play (car scale) vel dur 1)
      (play 5 (+ 12 (car scale)) 1 (* dur 2) 1)
      (play (oneof 3/2 2) (+ 24 (car scale)) 1 (* dur 2) 1)

      ;; bass
      (play 5 (car scale) 90 (* dur 2) 2)
      (:chance .8 (play 6 (+ (car scale) 2) 90 (* dur 2) 2))

      ;; repeat
      (set! scale (rotate scale -1))
      (set! vel (- vel 1))

      (if (> vel 0)
        (callback (*metro* (+ beat (* 1/2 dur))) 'xsc 
          (+ beat dur)

;; set scale to play so that scales overlap with each other

(xsc (*metro* 'get-beat 1) 
  50 ; vol 
  (:mkscale c1 'pentatonic 2)) 
  ;; run again with 'ionian, 'aeolian etc.. for interesting harmonic effects

The full source code on GitHub.

About Extempore

Extempore is a programming language and runtime environment designed by Andrew Sorensen to support livecoding and cyberphysical programming, where a human programmer operates as an active agent in the world.

Algorithmic composition is the technique of using algorithms to create music.

Cite this blog post:

Michele Pasin. Livecoding composition: 'Piano Scales' (Extempore + Ableton Live). Blog post on Published on Nov. 2, 2020.


See also: