I have a sound file and I am using the audio gain node to control how loud the file should play. The sound values go from 0 to 1, 1 being the max volume
The user can pick between 12 levels of volume, which should change the sound in a logarithmic way. I just can't figure out the formula for it.
I'm currently using a formula to normalize the 1-2 values to a 0 to 1 range, however I'm not sure how to increase the gain non linearly.
// sound level = the value between 0 and 1, corresponding to the user input which is from 1 to 12.
export const setSoundFileVolume = (soundLevel) => {
return (((100 / 12) * Number(soundLevel));
};
How can I set the sound logarithmically?