Get audio from Microphone and get frequency.

47 views
Skip to first unread message

Victor Martinez

unread,
Aug 2, 2024, 8:20:06 PM8/2/24
to Mozzi-users
How can I get the frequency of a monophonic audio fed into Arduino UNO using Mozzi?

Thanks
Victor Martinez

Mozzi-users

unread,
Aug 3, 2024, 6:51:59 AM8/3/24
to Mozzi-users
Hi Victor,
interesting question!  Mozzi doesn't have any spectral analysis tools, but you could try a really rough approach by counting zero-crossings of the audio signal.  It would help to filter out the high frequencies first.  You could try Mozzi's LowpassFilter, but If you're using a UNO, it might be worth making a basic analog hardware filter to save on processing.  It might sound like an overly-simple method, but vintage octave dividers worked in a similar way (you could look at Craig Anderton's "Rocktave Divider" design in the book "Do-It-Yourself Projects for Guitarists" or elsewhere).

Victor Martinez

unread,
Aug 3, 2024, 10:40:33 AM8/3/24
to Mozzi-users
Thanks a lot for your response. 
I will check on that approach.

Thanks,
Victor

Mozzi-users

unread,
Aug 4, 2024, 8:20:22 AM8/4/24
to Mozzi-users
Oh, by zero-crossing, zero would mean the mid-point of your signal.  So on a UNO, if you had a 0-5v input, the sampling width is 0-1023, and assuming the signal is centred in the 0-5v range, the mid point would be 512.  But that might take some adjusting of your actual input, how it's biased and probably nothing will be as simple as hoped!  Do you have a preamp that can get your mic signal into the 0-5v range?  I think there are some condenser mic modules designed for Arduino...

Victor Martinez

unread,
Aug 13, 2024, 3:40:17 PM8/13/24
to Mozzi-users
Thanks for the additional information. Yes I  built a mic preamp that do exactly that ; I runs the signal in the 0-5v range. I found a code example to capture the mic signal and get the fundamental note , by using zero crossing.
Reply all
Reply to author
Forward
0 new messages