Not stable MPU6050 value

Hello everybody.
I’m trying to send a MIDI message every time I simulate to push a virtual key with my finger. (in the air)… To do this, I’m using MPU6050 sensor with the library MPU6050_light. (I’ve also tried other libraries like MPU6050). I’ve a threshold. Everytime I pass this threshold the MIDI Note goes ON. Everytime I pass again this threshold the MIDI Note goes OFF.

My problem is that the values aren’t stable. In this example I’m supposing that the threshold is set to 0 and I have pushed my finger. As you can see in this curve, the value goes under the 0, then goes over the 0, then again under the 0 value. This is a problem because it could be a linear curve with a single Note ON. Instead in this situation, my arduino sent Note ON Note OFF Note ON quickly.
How can I get stable value ?
Thank you