Closed ClementSparrow closed 2 years ago
As Karoo noticed, my comment in point 2. is wrong.
The SOUND_VOL
is actually used to compute the value of the gain with the formula gain = e^SOUND_VOL -1 ~= 0.284 for the default value of SOUND_VOL=0.25. The gain is used during sound generation as a multiplier for the buffer's value and the buffer is played directly without volume specification.
So there is no reason to limit the volume in the seed, except that high values will create a lot of distortion. Actually, it can create distortion as soon as e^(SOUND_VOLvol/100)-1>1 <=> vol > 100ln(2)/SOUND_VOL ~= 277... So, we may add a warning in case volume values higher than that are used. It also mean we can limit the volume to three-digits numbers, as 999 already gives a gain of 11.152.
That said, I still believe we don't need to express the volume in percents but that tenths is enough precision.
See #increpare/PuzzleScript/pull/920.
Things to change:
100/SOUND_VOL
so that users can boost a sound up to 100% the volume allowed by the browser, while using values expressed relatively toSOUND_VOL
).