cl-patterns is a library for conveniently writing patterns to generate or process (a)musical sequences of mathematically (un)related (non-)compound values in Lisp.

Put more simply, cl-patterns is a system for sequencing and composing music and noise via Lisp code.

Its code is primarily hosted on GitHub, which is also the best place to find its documentation currently; see the README for the overview, or the doc directory for additional help and information.

It is also more conveniently available via Common Lisp's Quicklisp package manager simply by calling (ql:quickload :cl-patterns).


Amen break

It should be fairly easy to write the amen break based on textual notation. For example, the page here provides drum tabs. There's no reason a computer couldn't read these as easily as a human can.

(tempo 136/60)                        ; set the tempo of the primary clock to 136 BPM.

(pb :hat                              ; define a pattern named "hat"
  :instrument :hat                    ; set it to use the instrument named "hat"
  :dur 1/2                            ; play the hihat every 1/2 beat
  :pfindur 4                          ; limit the pattern to 4 beats in length (it loops automatically)
  :quant 4                            ; ensure that the pattern starts on a beat that is divisible by 4

(pb :snare                            ; define a "snare" pattern
  :embed (pcycles "----o--o-o--o--o") ; use the snare tab from the page linked above
  :instrument :snare                  ; use the "snare" instrument
  :dur 1/4                            ; set the pattern so each step is 1/4 of a beat long
  :quant 4)

(pb :kick
  :embed (pcycles "o-o-------oo----") ; use the kick tab from the page linked above
  :instrument :kick
  :dur 1/4
  :quant 4)

(play (list :hat :snare :kick))       ; play the patterns we've defined


See the cl-patterns cookbook for more recipes and inspiration.

See also