Potentiometer reading

Hi, I'm working on MIDI controler using USB/MIDI cable. It works nicely, but when I a rotate pot it starts to flicker. I looked at the console and it seems like my filtering doesn't work, because the value is changing by 1. I mean like 125,124,125,124 and causing to my master volume in a DAW go crazy. Could anyone help me to create a filtering, that will elliminate this problem? Thanks a lot.

I assume the solution is to take the average of multiple readings, or to average the current reading with the previous one.
(depending on the reactivity you want)