Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

152
Vistas
How to set the volume logarithmically instead of linearly?

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?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I normally use this function (in C):

double linear_to_logarithmic(double x){
    return log2(1+x);
};

But in javascript, maybe you should have a look at this:

https://stackoverflow.com/a/846249/5832844

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda