Grid Studies: Play ahead Simple counter problem

Hi, i have been scratching my head over this one.

On the Grid studies for Max, there is a part where it explains how to create a play ahead counter by turning on the corresponding LED position after first clearing the entire row.

*Clear row 7: /monome/grid/led/row 0 7 0 0
*After turn on the corresponding LED with a normal single-LED message: /monome/grid/led/set $1 7 1

This is done with a trigger t b i object.

That has been working fine for me, but i would like to use the same row for inputing notes, so i will have a counter on row 7 and also can input notes on row 7. The prolem as you can imagine is that the leds on (notes) get deleted by the clear row message.

A workaround is sending a bang from the t b i object to a matrixctrl holding the leds (notes) on off, but i get flashing notes which is kind of confusing.

I have tried looking into elquinto maxforlive suite, the patch called 128step, does exactly what i want but I was not able to back code it. The lights (notes on) dont flash, they stay on all the time.

I have tried with zl compare, and many other things without success,

Hope someone can give me some hints. Basically the delete message has to ignore the lights that are already on (noter on)

Thanks a lot!!!

what you’re getting into is basic programming problem solving.

the best approach is to have a “redraw” function for this row. it needs to know about the playhead, and which notes are need to be displayed. then it basically goes:

  1. clear row
  2. draw notes (don’t draw “off” notes)
  3. draw playhead

this same function (block, subpatcher, whatever) should get called whenever the playhead or the note data gets changed. this way a “complete” draw happens whenever the data changes.

Thanks for the reply Tehn, any chance of a quick example?
I have been using a t b b to first clear the matrixctrl, then a zl reg to save the matrixctrl elements (tried both lef and out inlet) and then banging the zl reg list back into the matrixctrl. I dont understand clearly the draw playahead part.No success yet.scrathing my head :frowning: