Max - how to store a rolling sequence of numbers

I’m looking for a way to make simple rolling sequencers. I remember seeing a while ago a way to do it in maxmsp but I can’t find it anymore.

The behaviour of the object I’m looking for is:

  • you specify a sequence length
  • everytime you input a number, it shift the existing sequence to store it
  • you have bang and messages to make the sequence roll without new number input
  • there’s outlets to let you access and display the rolling values

Thank you!

lotsa ways to do this, but the most convenient that comes to mind is, which implements a FIFO queue.

fifo.maxpat (6.8 KB)

"specify a sequence length " and “outlet per history stage” are mildy sticky requirements when taken together. here, unpack is used to split the queue contents to multiple outlets. if you needed a dynamically sized FIFO, and also needed one outlet per stage in the queue, then i think you would have to allocate the maximum queue size worth of outlets up front. ( itself is happy to resize the internal FIFO size on the fly.)

as an alternative, you could use things like zl.iter, spray, coll or listfunnel to access the queue elements sequentially or by index, rather than in parallel.

multislider will happily display/edit lists of dyamic size if that is useful.

(a more horrible alternative would be javascripting the creation/destruction of outlets on the fly, yuck.)

1 Like

oh, i just realized that by “roll sequence” you probably meant, “rotate the contents of the queue.” so, 1 sec…

Hey thanks for that! In my memory there’s an object that was doing all of that, but that might as well be my mind playing tricks (maybe I had an abstraction for it?).

Your patch is getting me most of the way to what I need, and that’s a good reminder that I should learn the zl objects more.

(and now seeing your second message, looking forward to see what you’re cooking :smiley: )

yeah, i’d guess some abstraction or custom object.

inevitably, here comes the spaghetti, which will not win me any games of “max golf”, but it does the thing.

fifo_rot.maxpat (9.6 KB)

this, of course, is exemplary of how, when making control structures in max, one eventually starts using javascript or custom objects. without which it is sort of like playing a weird videogame.


It indeed does what I was looking for! Thanks a lot for taking the time to help me, this is very helpful :slight_smile:

That’s not the one, but I definitely will have a look :slight_smile:

thank you!

1 Like

I might be off here, but it sounds like you’re describing [bucket].

I don’t think you can change the size of the bucket after the object is created though.


That’s the one! thank you <3


Cool! I made a little sequencer a while back built around bucket and it was really fun to play with. Bucket is a good time. :vulcan_salute:


warg, can’t believe i forgot [bucket], one of the classics! :man_facepalming:

well, fwiw i did clean this up as an abstraction called [lfsr] after another classic. (disclaimer: it is not a real LFSR.)

lfsr.maxpat (8.3 KB)

for tidiness, just outputs a list (which you can unpack later)

this does have a couple new tricks compared to [bucket]:

  • dynamically change the shift register size (call it N)
  • “roll” in either direction by an arbitrary increment. (call it R)

together, these features do a musically useful thing, which is to allow the creation of a certain family of complex sequences (period is least common multiple of N and R.) this is a classic pattern in modular synthesis.

to demonstrate:
lfsr_demo.maxpat (8.4 KB)

i guess maybe this is also useful as an example of how to do control feedback in max without overflow. (judicious use of [trigger] and [set $1] or equivalent)


Ooh excellent! Thank you for sharing! :slight_smile:

I’m knee deep in building sequencers at the moment, I’m definitely going to explore this version, these extra features are nice!