Date: Wed, 22 Aug 2001 16:04:00 -0400 (EDT) From: Stuart Barkley <stuartb@4gh.net> To: The Anarcat <anarcat@anarcat.dyndns.org> Cc: <freebsd-multimedia@FreeBSD.ORG> Subject: Re: precisions of pcm driver problems and update of rec program Message-ID: <20010822154117.S12745-100000@precipice.4gh.net> In-Reply-To: <20010822135453.W8939-100000@precipice.4gh.net>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 22 Aug 2001, Stuart Barkley wrote: > The main thing is to find minimum and maximum values over an > interval of interest. You will be clipping if you are hitting the > maximum or minimum values. My initial code just displayed these > values over each 1 second interval so I could visually see what > was happening. > > To convert these numbers to dB use something like: > > #include <limits.h> > #include <math.h> > > float dB = log10((double)SHRT_MAX / max) * 10.0; > > This can let you see the range of your data (how many dB below the > maximum signal). For recording you do not want to reach 0dB or > you will be clipping. Opps. That formula I gave above is wrong. It should really be: float dB = log10((double)SHRT_MAX / max) * 20.0; The extra factor of two is necessary because dB is log10(x^2) and pulling the square outside of the log10 is more efficient computationally. In addition, sometimes you will see systems showing negative dB. This comes from inverting the SHRT_MAX/max component or equivalently multiplying log10 by -1. dB can also be shown relative to other base values which can effectively add or subtract constants when converting between dB levels. You might also want to use the difference between min and max to get the full power range. However, if the signal is offset from zero it will be the the actual max or min which causes clipping. log10( (2^16)^2 ) * 10 = log10(2^16) * 20 = 96.3 which is where the 96 dB range for 16 bit sound cards comes from. log10(2^1) * 20 = 6.02 dB per bit. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-multimedia" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010822154117.S12745-100000>