Go Down

Topic: Playing sounds using audio trigger (Read 309 times) previous topic - next topic


I haven't been able to find a project like this but maybe someone here can help.  I've never done any arduino projects so I don't know if this is possible or not.

I would like to play a sound for a set duration (maybe 2 or 3 seconds) based off of input from a microphone.

So the audio plays when X number of inputs over a certain db within a specified time range.  Like 3 consecutive inputs over 30db within 10 seconds.  Then play audio for 3 seconds.  Then reset and wait for more input.

I have an audio source and amplifier so I considered using a relay.  But I've also read that the arduino can generate audio sounds as well.  I'm open to either.

Is this something that can be accomplished with an arduino or should I be looking at a different platform?


Also, I found this device that has an adjustable microphone on it and can output the voltage that the microphone produces.  Maybe hook this device to the arduino to measure the output voltage of the mic then act on a speciffic output range?


The signal directly from a microphone is too low for the Arduino's analog-to-digital converter (0-5V) so you'll need a preamp or you can get an Microphone Board with a mic & preamp.    

The Arduino can't read the negative half of an AC audio waveform so the input needs to be biased (if you want to read the full-waveform).   Most of these microphone boards have outputs biased at 2.5V so the Arduino's 10-bit ADC will read ~512 with silence.     (You can subtract that out in software if you wish.)

...If you're not familiar with digital audio and how it's sampled, take a look at this little tutorial.    Your readings will "look random" and you'll have to either find the peaks, take an average of the absolute values (or the positive values), or calculate the RMS, etc to get meaningful results.     Or, there are some audio boards that put-out a varying DC voltage proportional to the signal (usually proportional to the peak).

over 30db
30dB SPL* is very-quiet.  Common Environmental Noise Levels.   You may never get below  30dB and/or you'll probably get electrical noise and a low electrical signal making it difficult to measure such low levels.

And if you need a particular dB level you'll also need an SPL meter to calibrate** your setup.      It's not easy to make a homemade SPL meter (because of SPL weighting & averaging) but if you are always measuring the same kind of noise you can make a reasonable calibration between your setup and a real SPL meter.

Do you know how to calculate decibels once you have a reference?

I have an audio source and amplifier
You'll probably need an amplifier & speakers no matter what.   The Arduino can directly drive a small Piezo transducer.  It can't directly-drive a 4 or 8 Ohm speaker.

But I've also read that the arduino can generate audio sounds as well.  I'm open to either.
The Arduino can generate square waves with the tone() function.  Played through a Piezo transducer it sounds like a musical greeting card.    Through an amplifier & speaker you can get lower-frequency tones but it's simple square waves, one note at a time all at the same volume.    If you want to play MP3s or WAV files you can get an add-on Audio Board

* The dB SPL reference is approximately the quietest sound that can be heard so dB SPL readings are positive.    The digital dB reference (0dBFS = zero decibels full-scale) is the highest you can "count" with a given number of bits, so digital dB levels are usually negative.    For analog electrical signals there are a variety of different 0dB references.

** It's all correlated so if you drop the digital or electrical level by -6dB the SPL level will drop by -6dB.   But in general it's not calibrated so we don't know how loud (in SPL) a 0dBFS digital file will play.    (i.e.  It depends on the volume control, amplifier, speakers, and how close you are to the speakers, etc.)

Go Up