Change list value by index at midi event

sparsepix's icon

Hi,
I want to programm a Step Sequencer which I can operate with an external controller and so I want to be able to change the list value representing the state of a step by an index number (There are only 2 states, 0 and 1 and so everytime I hit the Button for a certain step I want this number to be changed either to 1 or to 0)
But I wasn't able to find a nice object in Max to do this. I Could only find this mxj list.replace java implementation but it didn't worked properly for me.

Thanks a lot,
Greetings Sparsepix

hankwitecki's icon

Try the [sel] object

hankwitecki's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Or maybe this is what you were asking for...

sparsepix's icon

yeah thanks, that works for inverting the value but I can't see any way how to change the internal value of a list with this object. Could you help me out ?

MIB's icon

have a look at the [zl nth] object. there you can replace any index of a list with a new value... I think that's what you are asking for...

sparsepix's icon

nth: accepts a list in the left inlet and outputs the nth element of the list out the left outlet.

the tooltips of the outlets say that they output the nth element of the list on the left and the list without the nth element on the right ... but I cant find a way to just change the nth element / put a new element in at the nth position ;/

Roman Thilenius's icon

if the lenght of your sequencer is fixed or at least limited to a known length, [pack 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] will be your friend.

MIB's icon
Max Patch
Copy patch and select New From Clipboard in Max.

not to seem grumpy, but read the entire help file for [zl nth]: extra argument to right inlet specifies . nth element will be replaced with in right oulet list.

sparsepix's icon

oh you're so kind ! I where the hell did you find this ? I thought I looked up the whole reference page for zl ^^
Anyway thanks a lot I think that will fix my problem.
Greets Sparsepix

m1ndbullet's icon

hey i'm having a similar step sequencer related problem. I'm using the coloured buttons on an xbox 360 controller to input dater into the matrix control object. The butons work on 1's and 0's so when i press a button it show up on the matrixctrl.

any help would be appreciated.

3100.stepseqhelp.maxpat
Max Patch