0

I'm wondering if Arduino is able to not just measure sound and work based on hearing a sound that is "loud enough", but if it is able to identify a specific sound (say the first few seconds of a song). Is this possible, and how would one go about doing so?

If identifying the first few seconds of a song isn't really feasible, is it at least possible to do so with a consistent (but particular) pitch (rather than a general loudness threshold)?

0

No, you cannot recognize a song with an Arduino. It doesn't have enough computing power. I think most solutions, that recognize a song, are based on some kind of machine learning or similar, which is totally out of scope for an Arduino. For this you need a real processor like on a Raspberry Pi or similar Single Board Computers.

Identifying a specific pitch/frequency in a sound signal is possible, but you shouldn't expect great accuracy. As Duncan already wrote in his answer, you need a Fourier transformation for this. It transforms the audio signal (voltage level dependent on time) into the frequency domain (amplitude dependent on frequency). So, if you do a fourier transformation on a short audio signal, you get data about, what frequencies are in that signal with which amplitudes. You can then wait for a peak in a specific frequency range.

Doing a FFT (Fast Fourier Transformation) on an Arduino is slow and not accurate. You also only have very limited memory. So your analysed audio signals will be rather short.


There is another way to detect a specific pitch/frequency, which is more a hardware task. You can feed the audio signal into an RC resonator circuit, which is tuned to the frequency, that you are interested in. The circuit will amplify the frequency, that it is tuned to, and dampen all other frequencies (of course it is not really one specific frequency, but a small range of frequencies). The resulting signal can then be checked for threshold values, since it only contains frequencies around the tuning frequency.

  • What you're describing is a passive hardware notch filter. That will only respond to a specific frequency range. I guess you could build several notch filters and monitor them to detect a number of notes... – Duncan C Oct 21 '19 at 19:56
  • Yes, but I doubt, that you would really be able to recognize real songs. Simple "songs" with only a few notes at a time might work, but normal songs have multiple instruments plus the voice line in them. I think, this makes it really hard (since most instruments also emit many higher harmonics of the played note). Though I haven't tried that ever, so I cannot be sure here. – chrisl Oct 21 '19 at 20:07
  • Agreed. We're saying the same thing: An AVR-based Arduino is not up to the job. – Duncan C Oct 22 '19 at 12:09
  • Thanks for your guy's input. I've been wanting to take on a machine learning project, so the idea of achieving actual song recognition with Raspberry Pi is intriguing... – ttc100 Oct 23 '19 at 0:07
1

It sounds like you need to do Fourier analysis on the sound. (Breaking up the sound into its component frequencies.) Most Arduinos are based on AVR chips, which do not have hardware support for floating point math. They use software to do floating point, which makes them a poor choice for this sort of thing.

There are FFT libraries for Arduino, but they will be slow and fairly crude. You'd probably be better off using a board like a Raspberry Pi that has an ARM processor for signal processing like this.

1

As stated in other answers, sound recognition is completely out of the realm of what an Arduino can do, but recognizing a specific pitch is possible.

However, contrary to previous answers, I would recommend against using an FFT. The FFT is the right tool when you need to get all the frequency components. It is, however, overkill when you want to look at a single frequency. Given the low processing power at your disposal, I suggest you try instead an homodyne detection scheme. An Arduino Uno, or similar board, has enough resources to sample an input at 9.6 kHz, and extract in real time a specific frequency component. See for example this homodyne detection program.

  • The OP's stated goal is to recognize a specific sound, like the first few seconds of a song. I don't think identifying single frequency components is going to work for that application. – Duncan C Oct 22 '19 at 13:27
  • @DuncanC: C.f. the OP's second paragraph. – Edgar Bonet Oct 22 '19 at 16:15
  • Right. Thank you though as a single pitch is acceptable and this gives me a start. – ttc100 Oct 23 '19 at 0:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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