From owner-freebsd-multimedia Wed Aug 22 13: 6:37 2001 Delivered-To: freebsd-multimedia@freebsd.org Received: from precipice.4gh.net (precipice.4gh.net [63.73.57.6]) by hub.freebsd.org (Postfix) with ESMTP id C371237B421 for ; Wed, 22 Aug 2001 13:06:19 -0700 (PDT) (envelope-from stuartb@4gh.net) Received: from localhost (stuartb@localhost) by precipice.4gh.net (8.9.3/8.9.3) with ESMTP id QAA12820; Wed, 22 Aug 2001 16:04:00 -0400 (EDT) (envelope-from stuartb@4gh.net) Date: Wed, 22 Aug 2001 16:04:00 -0400 (EDT) From: Stuart Barkley To: The Anarcat Cc: Subject: Re: precisions of pcm driver problems and update of rec program In-Reply-To: <20010822135453.W8939-100000@precipice.4gh.net> Message-ID: <20010822154117.S12745-100000@precipice.4gh.net> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-multimedia@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org 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 > #include > > 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