Arduino process .mp3 file

Hi guys,
I want to create an embedded system that detects notes played to a microphone.
Currently I have the algorithm for note detection, and I want to check it (without recording from a mic). I've downloaded an mp3 file and I want arduino to analogue read it in a desired sampling rate and number of samples.
Is there a way to do so?
Thanks :slight_smile:

The decoded MP3 data are in fact the analog audio signal to be analyzed.

MP3 decoding is not easy, so a "raw" .wav file (without file header) would simpler, as there is no need to decode it.

I want arduino to analogue read it in a desired sampling rate and number of samples.

Resampling (changing the data rate) is not easy, either.

I've never done this but people have made (or attempted to make) guitar tuners. and a lot of people have made spectrum analyzer "music visualizers". You can search for what's been done.

Since it's analog it doesn't matter if it comes from an MP3. :wink:

But it would be "easier" to use a regular computer to decompress the MP3 and analyze the digital data, if doesn't have to work in real-time.

It may also be easer to make a direct electrical connection from an audio line-out or headphone output, if you don't want to pick-up other sounds-noise from the room.

From what I've read, something called autocorrelation works best when making a guitar tuner. Spectrum analyzers normally use FFT or FHT and there are libraries for that. I'm sure those libraries allow you to set the sample rate... FFT/FHT require that the sample rate is known. I don't know if there's an autocorrelation library but maybe it's simple enough that you don't need one.

There are microphone boards that have a mic, preamp, and a biased output for the Arduino. (It has to be biased because the Arduino can't read the negative-half of the waveform.) I have this one. It's not that sensitive so the sound has to be rather loud but there are plenty of others. But there are a few different types of "sound sensors" so make sure to get one that puts-out an analog audio signal (if you want to stick with that plan).

The regular Arduino with the ATmega chip the ADC is only 10-bits and when you go above a sample rate of something like 17kHz you lose resolution... It may be OK but you can't get "CD quality".

...In case you don't know this, all real world sounds contain harmonics & overtones. That's why two different signers singing the same song and the exact same notes sound different. And it's the main thing that a makes a guitar sound different from a saxophone, etc.

With most music there are chords and multiple instruments often playing different notes.

The bottom line is, it's usually very difficult to pick-out a note.

You can get a free multi platform app called Audacity.

Here is the link to it:-
Audacity

It allows file conversion for example MP3 to a .wav file, which is the closest you can get to a raw file format. But you can also specify a raw file as well, which might be better for your application.

The problem with picking out a specific note from an instrument is that the fundamental is rarely the strongest harmonic.