# What are best practices to compute an audio spectrogram?

The spectrogram if generally defined with the squared magnitude of the fft. However, in lots of implementation, it seems that people just use the magnitude without square.

Moreover an audio signal is by convention scale between -1 and 1. This scaling often needs a supplementary step in implementations, in python language for example, which is not always do.

Finally, what are best practices to compute an audio spectrogram? - square magnitude of the fft / magnitude of the fft ? - Integer audio values / scaling (-1 to 1) audio values

EDIT

As the comments tell, these are questions without consequences if the aim is to plot an image of the spectrogram.

However, I would like to use the matrix of the spectrogram as an entry point for sound analysis and recognition. In this case, the computation process matters and I find curious that the implementations differ so often.

• Aren't all those issues mute, given the next step is a commonly a fairly arbitrary color mapping? – hotpaw2 Nov 19 '15 at 17:36
• @hotpaw2 Indeed, when the final goal is to plot an image, this questions can be useless. However, I want to do some process on the matrix of the spectrogram. In this case, it matters. – sandoval31 Nov 19 '15 at 22:01
• The best practices to display a nice or informative looking spectrogram (the most common use) are likely not the same as needed for doing some other processing on the data. So you will need to specify the needs of your desired processing to get a useful answer. – hotpaw2 Nov 19 '15 at 22:25
• In most cases the best practice is to use a logarithmic scale such as decibels (dB). In this case there is no difference between magnitude and magnitude squared. The absolute scaling is just an offset and the best choice depends on the specific application – Hilmar Nov 20 '15 at 6:44
• Mute and moot are different. These issues are moot - irrelevant. Mute means they can't speak, which is true but moot. :) – JRE Nov 20 '15 at 11:27

The square magnitude of a DFT is formally known as the Power Spectrum.