Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

161
Views
¿Cómo implementar un control deslizante de rango logarítmico para audio?

Los humanos no perciben el sonido linealmente. Percibimos el sonido en una escala logarítmica así:

 Linear Scale 0 1 2 3 4 5 6 7 8 9 10 (+1) Logarithmic Scale 1 2 4 8 16 32 64 128 256 512 1024 (x2)

Esto crea un problema cuando se trata de usar un <input type="range" /> como atenuador de audio porque el sonido silencioso ocupa la mayor parte de la escala y luego se vuelve muy fuerte al final.

¿Alguien sabe cómo implementar una escala logarítmica en una entrada de rango? Hice este mezclador de audio, pero nunca pude descubrir cómo implementar un control deslizante de rango logarítmico. https://codesandbox.io/s/audio-mixer-linear-35cl7k?file=/src/components/ChannelStrip.js

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Esto lo hizo funcionar.

 function scale(val, f0, f1, t0, t1) { return ((val - f0) * (t1 - t0)) / (f1 - f0) + t0; } function changeVolume(e) { const value = parseInt(e.target.value, 10); const vol = Math.log(value + 101) / Math.log(113); const scaledVol = scale(vol, 0, 1, -100,12); channel.set({ volume: scaledVol }); setVolume(Math.round(scaledVol)); } <input type="range" min={-100} max={12} step={0.1} onChange={changeVolume} /> 

 function scale(val, f0, f1, t0, t1) { return ((val - f0) * (t1 - t0)) / (f1 - f0) + t0; } document.querySelector("#slider").addEventListener("change", function(e) { const value = parseInt(e.target.value, 10); const vol = Math.log(value + 101) / Math.log(113); const scaledVol = scale(vol, 0, 1, -100, 12); document.querySelector("#vol").innerText = vol; document.querySelector("#scaledVol").innerText = scaledVol; });
 <input id="slider" type="range" min="-100" max="12" step="0.1" /> <div> <div>Volume : <span id="vol"></span></div> <div>Scaled : <span id="scaledVol"></span></div> </div>

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!