[gst-devel] Express volume in db instead of percent...

Stefan Kost ensonic at hora-obscura.de
Fri Jan 15 09:07:32 CET 2010


Am 12.01.2010 12:03, schrieb Maarten Bosmans:
> 2010/1/4 Yogesh Marwaha <yogeshm.007 at gmail.com>:
>> http://en.wikipedia.org/wiki/DBFS is not clear enough for me. Now I'll
>> try to be more specific on my question.
>> I am to use volume element as preamp for gstiirequalizer plugin and
>> as you must know that volume is expressed in percent whereas I want it
>> to be expressed in db. So, I want a formula to convert to and from
>> percent to decibel.
> 
> As Sjoerd said, db = 20 * log (percent/100) is correct.
> You'll get 0dB = 100% and attenuation with dB < 0 and a volume  gain
> with dB > 0.
> 
>> Here is what I got from searching the net:
>> volume_in_db = 20 * log (volume_in_percent / 100)
>> volume_in_percent = 10 ^ (volume_in_db / 20) * 100
>>
>> When I peeked into gstreamer source, I get to see something like this
>> in gstiirequalizer.c
>>
>> static inline gdouble
>> arg_to_scale (gdouble arg)
>> {
>>  return (pow (10.0, arg / 40.0));
>> }
> 
> This has changed in
> http://cgit.freedesktop.org/gstreamer/gst-plugins-good/commit/?id=27ea0b076a1f1d44c3da1c677eddf62d01eef1f1
> It seems that the calculated value is not proportional to pressure or
> voltage, but rather to the square root of it. It is a bit of a unusual
> quantity, but used in the filters on which the GStreamer equalizer is
> based, as described here:
> http://www.musicdsp.org/files/Audio-EQ-Cookbook.txt
> 

Yes, that is right. I was wondering also about that, but have not experiented
with it. If anyone has time, try the traditional scaling and report back.

Stefan


>> while peeking into banshee source, I get following code in gstiirequalizer.c
>>
>> static inline gdouble
>> arg_to_scale (gdouble arg)
>> {
>>  return (pow (10.0, arg / 20.0));
>> }
>>
>> I have no idea about how above code is being used but banshee's
>> formula seems similar to what I got from internet.
>>
>> Any ideas??
>>
>> Regards,
> 
> Take home message: use the 20.
> 
> Maarten
> 
> ------------------------------------------------------------------------------
> This SF.Net email is sponsored by the Verizon Developer Community
> Take advantage of Verizon's best-in-class app development support
> A streamlined, 14 day to market process makes app distribution fast and easy
> Join now and get one step closer to millions of Verizon customers
> http://p.sf.net/sfu/verizon-dev2dev 
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel





More information about the gstreamer-devel mailing list