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

178
Views
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
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!