what would be the most efficient ("cheap" in terms of system resources etc.) way to compare 2 sound files?

Here is the scenario. Sound A comes as an input. There is sound B stored in memory. We need to see if sound A is identical to sound B. We know that both sounds can be copies of the same sound file, but there is a chance that sound B was processed to reduce the size.

What would be the most efficient ways to compare these sounds and see if they are similar (or rather the same).


  • "Cheap", architecture is Cortex ARM M0. 16kb ram, 256kb flash.
  • "Identical" means that these 2 sounds come from the same sound file (same exact sound effect). THe difference may be that sound B (stored on the microcontroller side) may be processed to reduced size. Basically imagine we have 10 sound files, we copy N7 to MCU (maybe process it to reduce size) and then play them and expect MCU to recognize the sound file when it's played.

The kind of sound - technically it can be any sound (within the frequencies recognizable by humans). Sound effects (explosions, weapons firing, tires screeching), people saying words, melodies played by musical instruments. But the common thing is that they are all identical (instruments playing melodies would be same instruments same room, same time, recorded with the same microphone etc.).

Worth mentioning (to avoid confusion), that the sound is being sent to MCU from a sound output, not as a file.

  • $\begingroup$ Please define: * "Cheap". What is your target architecture, the clock rate, the amount of RAM and flash you have access to? * "Identical". What if the sensor used to record A is not the same as the one to record B? What if there is background noise when A is recorded? What if the acoustic environment is different when A is recorded? What if A is slightly different (for example B is a recording of someone clapping their hands, A is an other person clapping their hands - this won't be the actual recorded sound but everybody would agree that it is the same kind of sound)? If we're talking about s $\endgroup$ Aug 10, 2013 at 9:59
  • $\begingroup$ I added answers to your questions, hope they clarify things, please let me know if they do not. Also which characteristic /process would be a good candidate for that ad-hoc solution? $\endgroup$
    – Stpn
    Aug 11, 2013 at 0:56
  • $\begingroup$ So what your MCU will receive on its ADC input is not a "live" recording from a microphone, but the signal emitted by a computer (or any other device) playing back the exact same sound file it has in memory? $\endgroup$ Aug 11, 2013 at 9:20
  • $\begingroup$ yes that is correct. $\endgroup$
    – Stpn
    Aug 11, 2013 at 10:33

1 Answer 1


Matched filtering, or cross-correlation, is a pretty cheap and easy way to determine the similarity between signals. Otherwise you could try implementing the algorithm Shazam uses.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.