Patterns
Patterns objects are are the fundamental pieces that make sequences.
If Sattern was a traditional synthesizer then
Pattern
objects can be thought of as its "sounds".
Each Pattern can be mapped across a key/velocity range and respond to input event(s) like MIDI note-on(s), controller messages etc. and return a sequence of Step
objects.
Let's add some code to our current project to generate a simple sequence. We'll create a new pattern
object, add it to sattern
, and assign its onSequence
property to a custom function that returns a list of Step
objects.
Line #15
creates a new pattern object, line #16
adds the newly created pattern object to sattern
, lines #17-24
assign the pattern object's onSequence property to a custom function
that returns an Array
of Step
objects.
Now hit a key on your midi keyboard or on the virtual (12) "MIDI Keyboard" inside the Sattern UI. You should hear a simple 4 note ("E3", "B3", "G#3", "E4") sequence that will loop as long as you hold down the key on the keyboard.
Patterns are polyphonic, and you can have up-to 128 pattern voices playing at the same time. Try holding down multiple keys on your midi keyboard.
The above code is a little verbose, and was written that way for example purposes only. Let's take it a step further and try not to repeat ourselves... We know that we want to trigger 4 different notes, but everything else stays the same i.e. the target we want to trigger (sampler) and the duration and gate values (4, 4).
Let's improve the code just a bit...
Ok, that looks much better. Let's move on to Step
(s).
Try replacing the keys array contents with ["E3", "B3", "G#3", "E4"]
. Keys can be expressed with strings e.g. "C1", "D#1", etc.
Last updated