I'm working on a project that detects the pulse width of an audio signal, which uses a microphone as an input. The user gives 2 different types of sounds one last less 0.3 seconds and other lasting less than 0.7 seconds. I've attached the audio visualisation of the signal pic in the attachment. All want to detect is their pulse widths.

I tried Pulsein() - but as you can see that it has a variable until 0.3 or 0.7 seconds it only detect the first and most peak and returns the value which is almost zero.

But all I need is the total time taken for the pulse to rise from 0 and to variate and then become 0 this total time period is what I require. would duty cycle help ? or any other functions available to detect two different sounds in arduino ?

Audio visualization

pulse width

  • @Egar Bonet I even tied setting up an threshold upto which the unwanted signals are removed but after that would it possible to recover the pulse width of it ! – satabios Jun 24 '16 at 11:49
  • It is better to include the images in the question rather than a link to some offsite drive. I've done one for you, the other I can't open (which is why you should do it yourself in the first place). – Nick Gammon Aug 14 '16 at 21:03
  • If you are just detecting Morse code (which it looks a bit like you are from the file name you used (ditandddat.jpg)) then a simple on/off test should do it. – Nick Gammon Aug 14 '16 at 21:05

You will need some sort of interface circuit between your mic and your Arduino. Best would probably be to have some kind of external peak detection. This way the Arduino reads instantaneous wave amplitude. The other option is to only shift and scale the signal so that it fits the Arduino ADC, acquire the signal at a high enough sampling rate, and compute the instantaneous amplitude in software.

I suggest you take a look at this sound-meter program. You could use it as a basis for your own processing.

Then you just have to define a threshold and time how long the amplitude remains above that threshold.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.