hold last sensor value

I can still not dynamically update the value without releasing.

I suspect that you are flooding the MIDI device with lots of note on messages and only on release you have a note off.

You need to see if the value has changed even though it is not gone down to zero. Then turn the old note off and the new note on.