Onset Detection for Audio Signals
First of all, the title of your question is misleading because onset detection is very different from envelope detection. The onset detection function won't tell you how long a note is played or how slow its attack is... the envelope will. If the problem you are trying to solve is envelope detection, you might get inspiration from onset detection literature, but at some points the methods diverge. Onset detection extracts a "cartoon" version of the envelope in which all sudden changes are emphasized to make their detection easy.


  I think we then alter those coefficients in such a way that the new
  Fourier transform coefficients are now balanced perceptually(ie the
  coefficients are now what a person's ear would perceive them to be)


This is done by summing the energy (squared magnitude) of the FFT across 40 ranges of frequencies defined by the mel scale - usually with a triangular shape to emphasize a different center frequency.

Check point 4 of my answer to this question.


  Why and how would we calculate the first order difference?


This is the $1 - z^-1$ filter.

So the first order difference is simply the energy in a given Mel band at time t minus the energy in the same Mel band at time t-1.

We are interested in detecting onsets. Onsets are mostly characterized by a sudden rise of energy across the entire spectrum. A positive value of the first order difference indicate that energy is rising in one band. When summing across all bands, this gives a value that is very likely to be high when there is a note onset.

We do this detection across 40 frequency bands rather than in the time domain to detect events that would be masked by loud sounds in the time domain. For example, imagine a recording in which a high-hat cymbal sound is played on top of a loud, droning bass synth. In the time domain, the envelope of the signal will be a solid line with just a tiny wiggle when the high-hat plays, because the most dominant sound is the bass. But in the frequency domain, the bass note will only occupy the lowest frequencies, and it'll be easy to notice the attack of the high-hat sound, extending from mids to high frequencies.


  Why do we need the signal to be locally zero-mean?


It makes it easier to detect onsets by thresholding. The high-pass filter (or subtraction of median, which is another commonly used detrending method) will make sharp peaks in the detection function more prominent.