I am planning to build a puzzle box for my son’s graduation. He is very musical so I want one part of the puzzle to require playing a specific tune on a piano, flute, whistling or whatever to cause a servo to actuate. I was thinking a Raspberry Pi based application might be just the thing.
I understand how to set up a microphone to record and how to actuate a servo when the correct tune is detected. While I do have background in signal processing and FFTs, I have no interest in making a project out of writing elaborate code to sort out the sounds. Surely (I am hoping at least) this is a common function for things like song identification etc. 🙂
-
1Unless you are good at harmonics and understand music encoding and how to analyze it, I’d suggest you look at machine learning models built for harmonical analitics. However, none of these topics are easy, and have little to do with the Raspberry Pi specifically. – user96931 1 hour ago
Answer
Ah, let me see, I agree real time FFT is too complicated and over killing.
Goggle tensorFlow trained on very limited, say only 3 very short, 2 seconds long target tunes might be easier. But it might be a bit tedious to train the stupid tensorFlow ears.
Easiest might be to use Rpi and ADC to do “structured” and “statistical” pattern recognition, as summarized blow:
(1) Chop/structured the converted digital signal string into 4 or more sections,
(2) Get the statistically overall, moving time max, min, and avg values of each section,
(3) Compare/contrast/correlate the above overall/section values with that of the three target tunes to pick your educated/calculated guess.
You might need to try and error to trade off recognition time and successful recognition rate etc for optimal parameters of say, chopping number, moving time period etc.
For real time streaming audio hobbyists, I would recommend dirt cheap PCM1802 (Ref 1).
If you find the project too simple or too easy, you can add some bells and whistles like using the also dirt cheap PCM1808 DAC studies in the project to play back the tune you are guessing.
References
(1) How to use Rpi python to control PCM1802 24-bit HiFi stereo ADC and MAX4466 microphone amplifier
End of answer.
Categories: Uncategorized