API for changing patterns (… in a playlist)?

Good news @ratkins !
Here’s a beta build with sequencer APIs. This should let you implement what you are looking for with a bit of pattern code. You’ll need to copy some code to each pattern for reading/debouncing SB inputs and going next/prev, but cleaner than making a mega pattern.

Docs haven’t been updated, but here’s what’s new:

  • sequencerNext() Universal advance to next pattern, pretty much the same as button press. This API does nothing on a follower, so it won’t advance multiple times if you trigger it from a sensor board value; a follower will follow whatever pattern the leader is doing.
  • sequencerGetMode() returns the current mode, one of :
    SEQ_OFF: 0,
    SEQ_SHUFFLE_ALL: 1,
    SEQ_PLAYLIST: 2,
    SEQ_SYNCHRONIZED: 3 //follower

While in playlist mode, these APIs are available:

  • playlistGetPosition() current index of the playlist (starts at 0)
  • playlistSetPosition(position) switch to this item unless it’s already the playlist’s current position.
  • playlistGetLenght() number of items in the playlist

Going to the previous pattern is possible in playlist mode, and could work like this:

function previous() {
  var p = playlistGetPosition() - 1;
  p = mod(p, playlistGetLength()) //wrap back to beginning, and ensure position fits length
  playlistSetPosition(p)
}
4 Likes