Why do you restrict volumes to the 0-1 range?

Well, i do see the reason. You don’t want people cranking the volume up and their sound sounding distorted because they don’t understand clipping.


I think this should be something the user has control over. Example:

  • An explosion

In real life, and explosion will clip-out the diaphram of any microphone you set to record it unless it is really far away. When my player fires a missile point-blank into a wall, clipping is perfectly acceptable.
So I can either have a sound that has the clipping built in to it, and then when the explosion is far away it sounds clipped, or have it actually have a high volume and do the clipping on the soundcard!

I have checked, removing the clamp statements from playcanvas and setting volumes larger than 1 works just fine.

Setting the volume on an audiosource component modifies the gain value on the internal GainNode. The Web Audio API spec says the gain is a value between 0 and 1. From the spec, it says:

“The nominal maxValue is 1, but higher values are allowed (no exception thrown)”

So I’m not sure exactly what the behaviour is when you go above 1, but that is why we are clamping.