# Calculating a spectral envelope

I'm trying to calculate the envelope of an arbitrary spectrum but I'm slightly lost as to the best way to do this.

I've looked at cepstral enveloping but its very fiddly and I can't seem to get it to give the right results. I've also tried LPC but again it eems to miss a lot of the minor peaks while enveloping the major peaks perfectly.

I'm beginning to wonder of the best way would be just to run a sliding window across each frequency bin in an FFT returned magnitude spectrum and select the maximum value within that window. This way I'd simply pull out all the peaks (at whatever granularity I'm after) and then I can simply plot a curve through the resulting points.

Is there a correct way to calculate the spectral envelope?

• What's your ultimate goal for calculating this envelope? What do you plan to use it for? Nov 30 '11 at 17:08
• Not sure I understand your initial question/goal - you want a smooth version of your FFT, am I reading you right? Mar 24 '12 at 21:29

We use peak picking in the power spectrum followed by parabolic interpolation to get the envelope. As you said, you can set your granularity depending on how many peaks per octave you require. We used it to do formant preservation in speech pitch shifting within a phase vocoder framework....

• Ok this seems to be the best way to get a good, true, fit. Glad I'm not barking up the wrong tree!
– Goz
Dec 1 '11 at 9:05

Cepstral windowing is the most obvious way to extract a spectral envelope, you have a description here.

I've looked at cepstral enveloping but its very fiddly and I can't seem to get it to give the right results.

In the linked description, try lowering the lowpass "cut-off" sample (nc) until you retain the amount of detail you want. You can get useful implementation examples here.

I've also tried LPC but again it eems to miss a lot of the minor peaks while enveloping the major peaks perfectly.

Isn't that the point of extracting the spectral envelope? By LPC are you referring to the Linear Prediction Spectral Envelope?