# Drawing a Spectrogram off of FFT - what are the decibels relative to?

I am trying to draw a spectrogram from FFT data I get from audio files. The problem is that I can't figure out is what the yielded power (decibels) are relative to. I'm getting some arbitrary -100db-ish numbers, but I don't understand how I can have them represent a finite intensity-scale. If I have a gradient which will represent the intensity of these numbers, where silence is black and the maximum is yellow I need to know what the maximum is. I'm really not good in the DSP-area so help would be appreciated.

## 3 Answers

For audio files you want to use dBFS, dB relative to full scale:

• Ah this made it look so much better! Though I saw this formula at the stack-exchange 'valueDBFS = 20*log10(abs(value)/maxValue)' and I'm wondering what the maxvalue is supposed to be? Currently I have the maxvalue to be set of the songs maximum reached magnitude. Is this the correct way? – Tokfrans Jun 18 '15 at 0:01
• Any more explanation would be appreciated in order to expand your answer. – jojek Jun 18 '15 at 6:31
• Full scale for an audio file format is the highest amplitude that can be represented by the format. If you're reading raw PCM frames from a wav file, this will depend on the bit depth: – Daverz Jul 22 '17 at 1:11

An accurate FFT should give you an estimate of the volume of the component sines contained in one area of the sound graph. If you have 3 sines playing of energy level 0.33 of max SPL, and the FFT shows 3 peaks, there should be 3 peaks who's value is 0.33. the values will be averaged in F and T, however the ideal theoretical value is the real value of the individual sines that make up the sound, or the sum of the sines that cohabit that area of the graph.

dB are in fact meaningless units on their own. They are a ratio unit, so for dB to be meaningful, it needs to be computed within a context. For example, dB SPL (sound pressure level) is computed with respect to the pressure of 20 micropascals, which is the threshold of audibility in terms of sound pressure.

http://artsites.ucsc.edu/ems/music/tech_background/te-06/teces_06.html