Here are some dB values and corresponding amplitude values to help you better understand how dB and amplitude are related. Inline float AmplitudeTodB(float amplitude) ![]() Here’s some c++ code which does those two operations: ![]() Note that when converting audio samples to dB, you want to take the absolute value of the audio sample, since sign doesn’t matter for loudness. To convert from dB to amplitude, the formula is: amplitude = 10^(db/20) To convert from amplitude to dB, the formula is: dB = 20 * log10(amplitude) This has a nice side benefit that you can make the cutoff point of “assumed silence” be above the level that floating point denormals are (very small numbers that need special processing and are slower to work with than regular floating point numbers), so that in effect you can use this to remove denormals from your processing, which can boost the performance of your code. People will usually adopt a convention of saying that below -60dB is silence, or below -96dB is silence. Doing the same with amplitude, 0.5 means that the volume is cut in half, and then you multiply that by 0.5 to get 0.25 to make it 1/4 as loud, and multiply again to get 0.125 which is 1/8 as loud.Ī fun byproduct of this is that using dB you can never describe zero (silence) exactly. 6db means that the volume has been cut in half, and -12db means that it has been cut in half again (so is 1/4 as loud) and -18db means that it has been cut in half yet again (now 1/8 as loud). 0dB means full volume and positive numbers means a boost in volume, while negative numbers mean a decrease in volume.ĭB combines linearly, unlike amplitudes which have to multiply together. The main issue is that our ears do not hear linear adjustments in amplitude as linear adjustments in loudness, but linear adjustments in dB do sound like they are linear adjustments in loudness.ĭB is a bit easier to understand as well. If you work with musicians or other audio folk, chances are they are not going to think in amplitude, may not be able to easily adjust to thinking in amplitude, and instead will talk to you in terms of decibels or dB, which is as foreign to you as amplitude is to them. ![]() That 0.5 is a scalar value in amplitude space. If you are a programmer, chances are that when you think of volume or volume adjustments of audio signals (or other streams of data), you are thinking in terms of amplitude.įor instance, to make an audio stream quieter, you are probably going to multiply all the samples by 0.5 to bring it down in volume.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |