Express volume in db instead of percent...

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Express volume in db instead of percent...

Yogesh Marwaha
Is following a correct method for converting volume from percent to decibel: -

db = 20 * log (percent/100)


Regards,


--
Yogesh M
http://sparklemedia.sourceforge.net/
http://mazedaar.wordpress.com/
http://snakeeyes.wordpress.com/

------------------------------------------------------------------------------
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Express volume in db instead of percent...

Sjoerd Op 't Land
Op 1 jan 2010, om 10:23 heeft Yogesh Marwaha het volgende geschreven:

> Is following a correct method for converting volume from percent to  
> decibel: -
>
> db = 20 * log (percent/100)
Assuming that 'percent' is proportional to the voltage (for example,  
an RMS calculated from a number of samples), yes. In digital audio  
terms, this would then be dBFS (decibel full scale). See also:
  http://en.wikipedia.org/wiki/DBFS

Regards,
Sjoerd

>
>
> Regards,
>
>
> --
> Yogesh M
> http://sparklemedia.sourceforge.net/
> http://mazedaar.wordpress.com/
> http://snakeeyes.wordpress.com/
>
> ------------------------------------------------------------------------------
> 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
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>


------------------------------------------------------------------------------
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Express volume in db instead of percent...

Yogesh Marwaha
2010/1/2 Sjoerd Op 't Land <[hidden email]>:

> Op 1 jan 2010, om 10:23 heeft Yogesh Marwaha het volgende geschreven:
>
>> Is following a correct method for converting volume from percent to
>> decibel: -
>>
>> db = 20 * log (percent/100)
> Assuming that 'percent' is proportional to the voltage (for example,
> an RMS calculated from a number of samples), yes. In digital audio
> terms, this would then be dBFS (decibel full scale). See also:
>  http://en.wikipedia.org/wiki/DBFS
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.
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));
}

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,

>
> Regards,
> Sjoerd
>
>>
>>
>> Regards,
>>
>>
>> --
>> Yogesh M
>> http://sparklemedia.sourceforge.net/
>> http://mazedaar.wordpress.com/
>> http://snakeeyes.wordpress.com/
>>
>> ------------------------------------------------------------------------------
>> 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
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>>
>
>
> ------------------------------------------------------------------------------
> 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
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>



--
Yogesh M
http://sparklemedia.sourceforge.net/
http://mazedaar.wordpress.com/
http://snakeeyes.wordpress.com/

------------------------------------------------------------------------------
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Express volume in db instead of percent...

Yogesh Marwaha
Hi,

Can someone please shed some light on this too?

Regards,

--
Yogesh M
http://sparklemedia.sourceforge.net/
http://mazedaar.wordpress.com/
http://snakeeyes.wordpress.com/

------------------------------------------------------------------------------
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Express volume in db instead of percent...

Maarten Bosmans
In reply to this post by Yogesh Marwaha
2010/1/4 Yogesh Marwaha <[hidden email]>:
> 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

> 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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Express volume in db instead of percent...

Stefan Sauer
Am 12.01.2010 12:03, schrieb Maarten Bosmans:

> 2010/1/4 Yogesh Marwaha <[hidden email]>:
>> 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
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel


------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel