Digital signal derivative
In theory, M[0] doesn't exist. Your discrete derivative is only defined on [1,127].

As a practical solution, you can define M[0] as a null element of your signal. For example if you expect values between -1 and 1, take M[0] = 0.

In the case of real-time, there is two options:


Either you save the last value of your buffer so you can take M[0] = last for the next ones, and initialize last as 0, or whatever seems coherent with your expected signal;
Either you start computing the derivative at M[1] and your processing will have a latency of 1 sample.