Read an compare 4 second MP3 sound

A step motor change its sound when trying to move it after reaching a stop position.
I would like to stop sending the movement order after detecting the new sound (1 to 4 seconds)
To do this action I can record the sound in MP3 (easy with a standard microphone) and compare with a reference sound (record and compare file?)
As the sound is not long I expect a small file to be able to handle by Arduino Uno or Mega2560
Any idea abou how to handle the project?

You may be able to recognize some change in the sound of the motor, but that's only because you are using the world's most powerful computer to do it - the one between your ears. Getting a machine to do the same thing is extremely difficult, and impossible for a mega 2560, I think.

You need to attach a sensor to detect when the motor has reached its stop position. This can be optical, magnetic, mechanical... perhaps even by detecting the change in the current flowing through the motor, if your motor driver modules can do that.

Firstly MP3 is hopeless for doing comparisons, its encoded and highly compressed.

A raw WAV file would be required. Then you'd probably need to take spectra and compare the spectra. Its a very complex way to do things - I wonder if this is an x-y problem here.

It actually sounds like you need a limit switch or encoder. But without knowing what the hardware actually is and what you are trying to do its basically guesswork.

Wild idea but good luck, who knows maybe you will be the next Elon Musk

It is one of those problems that sound easy to some one who knows little about audio.

You can't just make a recording and comparer the numbers in that to the numbers coming in from a microphone because even if the sound is identical the numbers will not be. This is because the samples that make up the sound are not taken at the same point in the waveform in each case.

The best way to distinguish different sounds is to use AI. You will need at least an Arduino BLE class of processor for this.
Here is an introduction to using AI on an Aruino

Also see the article
Recognising different sounds using AI from the MagPi98 page 30
Free PDF download available.

1 Like

A limit switch is the way to go. But if you insist on doing the sound comparison, forget mp3. Record your 4 second sound using the mic that you have in your system. Record it several times and import the recorded sound to Audacity. Compare all the signals you get, just by looking at them and zooming in. Are they identical? They might look very identical and there are methods for measuring how identical they are. Like subtracting one from another after carefully placing them exactly on top of each other, and measuring how little sound was left. But for this you need a computer like Raspberry Pi, and not an Arduino.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.