A “cookbook” for cl-patterns; various recipes for ideas and inspiration.
cl-patterns provides musical scale data in scales.lisp
. If we feel like being blasphemous, we can play random notes from a scale and call it “automatic jazz”:
(pb :automatic-jazz
:note (pshuf (scale-notes :minor) 4)
:octave (pr (pwhite 2 7))
:root (pr (pwhite 0 12))
:dur (pshuf (list 1/3 1/4)))
In this example, the notes of the minor scale are shuffled and the shuffled list is played through four times before the pattern ends and they’re reshuffled. For each playthrough of the pattern, an octave and a root note are selected at random. :dur
alternates between 1/3
and 1/4
to give the music a rudimentary shuffle rhythm or “swing”.
With the bdef library, you can conveniently load sound files and define splits
, which represent sections of the file. The library comes with a psplits
pattern in its bdef/cl-patterns
sub-system which makes it easy to integrate with cl-patterns. Example:
(bdef :song "/path/to/song.wav")
(pbind :instrument :spt
:buffer (bdef :song)
:split (pseries 0 1 (splits-length (bdef :song)))
:legato 1
:embed (psplits))
The above does the following:
- Loads a song into a buffer with
bdef
, giving it thesong
key. - Selects the
spt
synth, which has agate
parameter, as well asstart
andend
, which represent the start and end points of the split as a percentage in the file (0..1
). - Loads a song.
- Automatically finds onset points in the song with any defined bdef “auto-metadata”.
- Uses
pseries
to select each split associated with the bdef, in order. - Sets the
legato
to 1 to ensure the full split is played. - Uses
psplits
to embed the parameters for the selected split to be played withspt
.
So what does this pattern actually do? All it does is play each section of the audio file in order. If the file is divided into a series of consecutive, non-overlapping splits, the pattern will sound just like the input file.
Why would we want to do this? This is often a good starting point for if you want to do something like remixing a song. From here you can add further keys to the end of the pbind
to change the split pitch, send the output to an effect, change the rhythm, etc.
Keep in mind that psplits
outputs events that include start
, end
, and dur
for each split. So if you wanted to do something like playing every even split for half its original length, and every odd for double, you’d add the following after the psplits
:
:dur (p* (pk :dur) (pseq '(1/2 2)))
Of course, the possibilities are endless here. And thanks to splits
having a comments
slot, you can associate any data you want with each split. This could be manually-entered textual comments, automatically-generated audio analysis data, etc.
Ideas for things to use the comments
field for:
- Divide the splits up by the part of the song they fall into, to allow a remix to run different “algorithms” for each.
- Analyze the pitch of each split, then use it to create a makeshift “autotune”.
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. Fortunately, the pcycles
pattern accepts strings as input and reads the same notation as the provided tabs.
(tempo 136/60) ;; the Amen break is 136 BPM
(pb :hat
:instrument :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
:embed (pcycles "----o--o-o--o--o") ;; using the snare tab from the page linked above
:instrument :snare
:dur 1/4
:quant 4)
(pb :kick
:embed (pcycles "o-o-------oo----")
:instrument :kick
:dur 1/4
:quant 4)
;; play the patterns we've defined:
(play (list :hat :snare :kick))
A cool 12-bar blues-style pattern, contributed by TatriX. Best played with a nice, possibly guitar-like, instrument
. :)
(pb :12-bar-blues
:scale :chromatic
:root 4 ; E for all guitar lovers out there
:octave 4
:dur (pseq (list 2/3 1/3))
:amp (pseq (list 0.5 0.4))
:legato (pseq (list 0.7 0.2))
:degree (pr (pseq (list (pseq '((0 7) (0 9)) 8)
(pseq '((5 12) (5 14)) 4)
(pseq '((0 7) (0 9)) 4)
(pseq '((7 14) (7 16)) 2)
(pseq '((5 12) (5 14)) 2)
(pseq '((0 7) (0 9)) 2)
(pseq '((7 14) (7 16)) 2))
1)
2))