|
Post by tosiabunio on Aug 15, 2015 22:01:59 GMT
One of the decisive factors of buying Master Audio for my project is that it could allow me to use decibels for volumes.
Unfortunately I quickly learned that the current implementation is flawed and usable at all.
First of all, I was puzzled by the scale of sliders: -140dB do 0dB. In real life scenarios (and I've been doing game's audio for 15 years now) I rarely decrease volume of my individual effects to lower than -30dB.
-72dB is perceived as silence by most of the listeners - so wasting half of the volume scale for silence is even worse than using float 0.0-1.0 for volume.
But I fiddled with the volume sliders and numeric values to quickly find that the numbers shown have no real relation to what they represent (e.g. -6dB should halve the volume). I spent some time to setup audio metering pipeline to measure what I heard with my ears.
This is what I've found (the source was 1kHz sine wave at 0dB). Numbers are - Master Level volume : actual output volume as measured:
-1dB : -0.4dB -3dB : -1.3dB -6dB : -2.6dB -10dB : -4.3dB -12dB : -5.2dB -20dB : -8.7dB -24dB : -10.4dB -30dB : -13dB -72dB : -31.3dB -90dB : -39dB
The volume changes are off but still linear up to -24dB (or something) and then calculations are way off for lower volumes. With master level at -90dB I can still hear the signal - it's just -39dB at the output - but it should be silent.
Anyway, what went wrong with those two functions? linear-to-db(x) = log10(x) * 20 db-to-linear(x) = 10^(x / 20)
|
|
|
Post by DarkTonic Dev on Aug 15, 2015 22:12:21 GMT
Good information. I was probably given the wrong formulas when I did this originally. I have changed my formulas to the following based on your recommendation.
public static float GetDbFromFloatVolume(float vol) { return Mathf.Log10(vol) * 20; }
public static float GetFloatVolumeFromDb(float db) { return Mathf.Pow(10, db/20); }
This is in AudioUtil.cs if you want to try the change. Also I changed this line in DTGUIHelper.cs:
private const float MinDb = -80;
So the minimum DB is now -80db, which equates to .0001 on the 0-1 scale.
Let me know if this is entirely correct please before I publish the fix. This means that .5 volume = -6db.
|
|
|
Post by tosiabunio on Aug 15, 2015 23:39:08 GMT
New functions work as expected. My suggestion is to make MinDb to -90 just to satisfy possible audio purists Thanks for the fix. Now I'm return back to try figuring out how MA works.
|
|
|
Post by DarkTonic Dev on Aug 16, 2015 0:46:47 GMT
Ok, -90 it will be No problem.
|
|