Frequency Detection using MAX4466

Hi. I am trying to convert the audio input of the MAX4466 into frequency but nothing works for me. What i get is the detection of loudness. Can you guys give me codes and library for frequency detection? I am using arduino uno as a the processor. Thankyou.

Exactly what are you trying to do?

You can find examples of spectrum analyzers and guitar tuners. (From what I read, the guitar tuners are not very successful.)

You'll need an FFT, FHT, or Autocorrelation library ([u]Wikipedia - FFT[/u]).

Hello,

i will receive a MAX4466 in two days, and from what i saw:

mgieeeee:
Hi. I am trying to convert the audio input of the MAX4466 into frequency but nothing works for me. What i get is the detection of loudness. Can you guys give me codes and library for frequency detection? I am using arduino uno as a the processor. Thankyou.

we may have a similar idea.

My plan is to:

  1. use the MAX4466 connected to my ARDUINO UNO to listen to sounds,
  2. analyse this sounds (with a FFT function),
  3. when particular frequencies are detected, then activate a motor (also connected to an ARDUINO UNO).

While waiting the MAX4466 i reviewed some internet site to see how to do it. IT'S REALLY NOT CLEAR TO ME :o :confused:

Does any simple FFT librairies exist?

My idea of code was something like:

for(i ; i=1000 ; i++)
{ raw_sound(i) = analogRead(PinMic); }

sound_freq = FFT(raw_sound)

if (sound_freq = XX)
{ digitalWrite(pinMotor, High); }

But apparently the FFT part is not working that way at all :frowning:

Thanks in advance for your help

(the whole stuff is about: detecting a baby crying and start a baby mobile to calm him/her down)

Detecting a specific frequency is one thing, recognising a complex real world sound is totally an other thing, and way beyond the power in an Arduino Uno.

Hi Grumpy_Mike thanks for the warning :wink:

Aside of that, do you know how i can sample a sound (baby cry, guitar, washing machine,...) and run an FFT analysis on this sound to determine the frequencies of this given sound?

(unless i mis-understood something, when you run FFT on a sound sample, you have peaks on the stronger frequencies, if i have that, i would already be very happy :slight_smile: )

unless i mis-understood something, when you run FFT on a sound sample, you have peaks on the stronger frequencies,

While you have not misunderstood anything, what you have is a gross over simplification of the process. There is a lot more to it than.

I have used this FFT libiary on a Due and Zero.
https://coolarduino.wordpress.com/2014/09/25/splitradixreal-fft-library/
There are others that will run on the Uno, but you only get a tiny sample of the sound to do the FFT on due to the small amount of memory the Uno has to store the sound. The most you can manage is about one tenth of a second of sound, which is not enough for a sound that changes over time like a babies cry.

To give you an idea of what an FFT will show, down load an application called Audacity, it is available on all platforms and is free. It is a sort of photo shop for sound. It can record, playback and manipulate sound. One of the functions it has is an FFT with a graphical output. Try that and see what sort of data you get and how useful you think it is, before trying to do it on a stand alone processor.

run an FFT analysis on this sound to determine the frequencies of this given sound?

Real sounds do not have one frequency they have many and they change over time. The highest peak frequency in the collection often has no relationship to the frequency a sound is pecieved to be.

ahhhhh now it makes sense! You are right, i didn't take into account the available memory and so the size of the sample :cry:
Thanks for pointing that out!

I'll take a look at the links you provided, and i'll see if i can move on from there :slight_smile:

Regarding your point about the capacity of one tenth of a second: I did some research + math... baby cry are between 200Hz & 500Hz, with a sample rate of 1000Hz and 0.128s record (<=> 128 points), mathematically speaking FFT is able to detect the frequencies.
So it might do the trick :sweat_smile:

baby cry are between 200Hz & 500Hz,

Yes but my point is that there are lots of other sounds that have frequencies in that range.
For example music notes from G to B an octave and a half above it are all in that range. So the scope for a false positive are vast. And a mobile suddenly turning on may actually wake of a sleeping baby. Speaking from my experance of bringing up two of them, that is the last thing you want to do.

Grumpy_Mike:
Speaking from my experance of bringing up two of them, that is the last thing you want to do.

LOL!

@guillaume_f
you can experiment but, as Grumpy_Mike said, it is very difficult to obtain useful results.
Maybe this

can be useful, it's a rude speech recognition toolkit for Arduino ATmega328.

My plan is to:

  1. use the MAX4466 connected to my ARDUINO UNO to listen to sounds,
  2. analyse this sounds (with a FFT function),
  3. when baby cry detected, then activate a motor to swing the cradle(also connected to an ARDUINO UNO).
    iam also doing the same.did u get any idea how to proceed.i have arduino uno,max4466

I would advise you get the free app Audacity, this runs on a laptop and lets you sample sound and take an FFT of a sample.

Then just see if you can recognise a baby cry from other noises. Only when / if you can is it worth attempting this on an Arduino.

The MAX4466 is "optimized" for extremely low power, in other words its very low performance compared to other opamps.

In particular it is very noisy for an opamp and its a joke to suggest it for microphone use unless you are constrained to running from a few dozen microamps of supply current. Its 6dB noisier than the LM358, and 29dB noisier than my go-to 5V rail-to-rail dual opamp (AD8656).

Yes, it generates about 1000 times more noise power than a good opamp...