Arpeggiator or auto-accompaniment using supercollider

I’ve been thinking about making some kind of arpeggiator or auto-accompaniment system using supercollider for quite a while but never felt up to the task. Recently, I decided to take the plunge and try to come up with a proof of concept based on patterns.

Sclang reacts to chords played on a midi keyboard (or input manually by hand, i guess something like this could also be useful to spice up performances in a live coding context) and uses the notes in the chords to realize patterns.

I wanted to find an approach that is flexible, closely matches how you’d use patterns in a non-interactive context, and something that reacted quickly to input note changes (so no need to wait until a complete arpeggio is finished playing before you can change the underlying chord).

Here’s what I came up with:

Feel free to comment/critique the approach or to create something really cool with it (or an alternative approach) and explain/demonstrate it.