Loudness

From Unify Community Wiki
(Difference between revisions)
Jump to: navigation, search
(C# - Loudness.cs)
(Description)
Line 4: Line 4:
 
==Description==
 
==Description==
  
Unity's standard volume control uses a "linear taper", and humans hear on a roughly exponential scale.  "Loudness", unlike the Audio Source's "Volume", will yield perceptually equivalent loudness changes for equivalent value changes.  (Changing the Loudness from 0.2 to 0.3 will yield a similar difference in loudness between 0.7 to 0.8, etc.)
+
Unity's standard volume control uses a "linear taper", which does not correspond with human hearing.  "Loudness", unlike the Audio Source's "Volume", will yield perceptually equivalent loudness changes for equivalent value changes.  (Changing the Loudness from 0.2 to 0.3 will yield a similar difference in loudness between 0.7 to 0.8, etc.)
  
 
== JavaScript - Loudness.js ==
 
== JavaScript - Loudness.js ==

Revision as of 20:29, 8 April 2009

Author: Jessy

Description

Unity's standard volume control uses a "linear taper", which does not correspond with human hearing. "Loudness", unlike the Audio Source's "Volume", will yield perceptually equivalent loudness changes for equivalent value changes. (Changing the Loudness from 0.2 to 0.3 will yield a similar difference in loudness between 0.7 to 0.8, etc.)

JavaScript - Loudness.js

<javascript> var loudness : float = 1; private var sqrtOf10 = Mathf.Sqrt(10);

// I would not leave this in Update() for a release. // Put it wherever you need it, to change the volume in-game.

function Update () { audio.volume = (Mathf.Pow(sqrtOf10, Mathf.Log(loudness, 2))); } </javascript>

Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox