# Audio Signal dB levels Matlab

I am trying to develop a GUI in MATLAB to allow the presentation of a tone.

One of the input parameters is the dB the user wants.

So the way I tried to do this is:

y = factor * sin (2*pi*500*t);


The "factor" parameter is: 10^(x/20).

I tried using the y values and do a mag2db conversion on matlab to see if I am getting the db back. And I do!

However, if I put in 0dB, I am still obtaining a tone. I have to go down as low as -50dB to not get a tone.

So my question is : Is there some kind of a way to make it such that there is no tone at 0dB and below.

Thank you so much for your help.

Appreciate it!

Note: my PC speakers are at MAX level.

• By the way, how did you convert dBFS to dBSPL? Did you use any SPL meter? – user71897 Apr 9 '15 at 17:35

It is not correct to have 0dB represent "off". dB is a relative scale and 0 dB, effectively, means "the same as some reference value", and your reference value can't be silence.

A more common implementation of such a control would be to have 0dB represent maximum volume and negative values represent lower output. This is what you see on all professional audio equipment analog and digital. You would then use -Infinity for no output. Many applications approximate this by making the slider go from 0 at the top to -96 [1] dB or so at the bottom. When the user slides the slider down all the way, the application will turn off the output.

[1] 96 is chosen because that's the approximate dynamic range of 16-bit audio. In the presence of dither, this value has no real special meaning, though, so some applications use an even larger value.

• "naked" dB cannot represent a level, period. dB can only represent a ratio to a reference power. Other units such as dBm, etc include a reference and so state absolute levels. – Chris Stratton Jul 20 '13 at 3:05
• Chris is correct. In the case of my example, 0dB should be interpreted to mean "maximum", which is often denoted dBFS, for dB Full Scale. An alternative interpretation is that of a volume control, where the incoming signal is already the maximum. In this case, the reference level is the incoming signal, and dB can be thought of as the change between input and output. – Bjorn Roche Jul 20 '13 at 13:19
• Hi; I understand that part. However, I am now trying to actually measure the tone in a sound level meter which uses dBSPL. So the value i input is in dB full scale and the sound I get back is in dBSPL. They do not seem to relate to each other. For instance if I go down by 6dBFS I get -10dBSPL down. Any idea on how to get -6dBFS = dBSPL level down by 6 ? – Ali P Jul 31 '13 at 16:22
• It's very hard to measure the amplitude of pure tones in dBSPL because they tend to generate standing waves, even in rooms with complex shapes. (try this: output the tone, plug one ear and move your head around slowly. You will usually find the amplitude goes up and down with no particular relationship to the distance from the speaker.) It's possible that in your case, simply mounting the sound level meter on a proper stand as you adjust the levels will help. – Bjorn Roche Jul 31 '13 at 19:59
• Hi; thanks for the reply. Actually the issue was with maxing my speakers out. At that level the response is not linear and the levels do not change accordingly. Works fine at half the MAX level of the sound card. – Ali P Jul 31 '13 at 21:48

0dB is a reference level at which all other dB levels are set. A +dB setting means the amplitude is greater and a -dB levels means the amplitude are less.

Think about it - if x = 0 then what does 10^(x/20) equal? Well it equals 10^0 = 1

What if x = -50dB, then "factor" equals 10^(-2.5) = 0.00316 and below (possibly) the resolution you have for producing a sinewave.

Here's what wiki says and note the following table: -

• No, dB is not a level, it is a ratio. 0 dB merely means a ratio of 1 - which is meaningless until someone states what we are comparing to. – Chris Stratton Jul 20 '13 at 3:06

Hi; I understand that part. However, I am now trying to actually measure the tone in a sound level meter which uses dBSPL. So the value i input is in dB full scale and the sound I get back is in dBSPL. They do not seem to relate to each other. For instance if I go down by 6dBFS I get -10dBSPL down. Any idea on how to get -6dBFS = dBSPL level down by 6 ?

With regards to the above, dBSPL is an analog unit, while dBFs is a digital unit. So, it is not a straightforward question. As others have mentioned, the 'dBXX' uses a reference power/voltage/sample value to measure the signal level relative to that reference. In the case of dBSPL, it is the sound pressure relative to 20microPascals which is the threshold of human hearing.

To get to dBSPL, first, you have to convert your digital dBFs to an analog voltage level that will be generated by the D/A converter on your sound card. Then, that voltage will feed into the speakers on which you play it back. The speaker converts the voltage to an equivalent sound pressure level based on the transfer function of the speaker. Different frequencies may have different pressures, as speakers typically do not have a flat frequency response.

So, there is no fixed conversion from dBFs to dBSPL, as these are in different domains (digital vs. analog). It will be different for each speaker/DAC pair.