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

174
Vistas
Clap detection using Javascript

I'm quite new to the question but I try something like this.

I know Audio api is powerfull but I'm not understand much, so I came with :

let asClap = false;
let tampon = 60;
navigator.mediaDevices.getUserMedia({
  "audio": {
      "mandatory": {
          "googEchoCancellation": "false",
          "googAutoGainControl": "false",
          "googNoiseSuppression": "false",
          "googHighpassFilter": "false"
      },
      "optional": []
  },
}).then(function(stream) {
    
    const audioContext = new AudioContext();
    
    /* use the stream */
    let gain_node = audioContext.createGain();
    gain_node.connect( audioContext.destination );
    
    let microphone_stream = audioContext.createMediaStreamSource(stream);
    
    let analyser = audioContext.createAnalyser()
    microphone_stream.connect(analyser)
    analyser.fftSize = 256;
    isClaping(analyser)
   

  }).catch(function(err) {
    console.log(err)
});




function isClaping(analyser){
  const bufferLength = analyser.frequencyBinCount;
  var data = new Uint8Array(bufferLength);
  analyser.getByteFrequencyData(data);
  
  const arraySum = data.reduce((a, value) => a + value);
  if(arraySum >= 3000){   
    if(!asClap){
      asClap = true;
      clap()
    }
  }
  requestAnimationFrame(()=>{isClaping(analyser)});
  tampon--
  if(tampon === 0){
    tampon = 60
    asClap = false
  }
}

I really need to do it in Javascript, since I'm more familliar with Is that correct and how can i detect double clap ?

about 4 years ago · Juan Pablo Isaza
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