Max4live, Sequential Chain Selector Problem. Plz help!

Ye Sol Choi's icon

I need help creating a Max for Live patch where the chain selector changes sequentially each time a MIDI note is triggered on a MIDI track.

The basic functionality works, but I’m facing two issues:

  1. When I stop and then restart playback, the chain selector visually resets to 0, but the sound still comes from a different chain.
    Only after stopping and restarting playback again does the sound correctly match chain 0.

  2. When the chain selector moves from 0 to 1, the sound still comes from chain 0.
    Then when it moves to 2, the sound comes from chain 1. When it moves to 3, the sound comes from chain 2, and so on.

It seems like the audio is always one step behind the chain selector value.

This is a bit too much for me to figure out on my own, so I’m asking for help here.
Thanks for reading!