0
$\begingroup$

I've been lurking around these forums for a while and they've been a great help to me in the past. However, I've been researching this problem for the past 2 days or so and can't seem to find a solution even though I feel it should be fairly simple. What I want to do is read in the audio stream, and essentially ignore every frequency except for a specific one (or range), the particular one isn't really important at the moment. Anyways, I want to be able to detect when this frequency reaches a certain magnitude (ie the pi recognizes the frequency is playing) and record the time its detected. About I'll I've been able to figure out so far is how to record a wav file from the terminal using the arecord command. I seem to understand that I need to perform an fft on that file and read the magnitude of the corresponding frequency range, but I've hit a brick wall in attempting this. Any help would be greatly appreciated.

EDIT Sorry, I am not allowed to comment until I have a minimum of 50 posts, and I've found that most forum type sites I use do not notify the others in the conversation of the change. As for the multiple accounts, one I created on stack exchange, and the next time I logged in I clicked the google log in and not the stack exchange one. I apologize for any inconvenience and appreciate you moving my mistaken answer box to the correct location. I'd appreciate it if you cold direct me in deleting one of the accounts, but more importantly how to get numeric level for a specific frequency(or range) for either a wav file or input stream in python haha :).

$\endgroup$
  • $\begingroup$ If it's any help, recording a file in audacity and clicking the analyze toolbar at the top followed by plot spectrum gives me a graph identical to what I need, except I need to be able to manipulate the data points in my program and not get a visual graph. $\endgroup$ – CharminXtra Nov 25 '14 at 17:47
  • $\begingroup$ Take a look at en.wikipedia.org/wiki/Goertzel_algorithm -- if you're interested in a single frequency, it's much more efficient than the FFT. $\endgroup$ – MBaz Nov 25 '14 at 19:00
  • $\begingroup$ Thanks a lot MBaz, that seems to be exactly what I'm trying to do. Unfortunately my programming background is focused on c/java on Windows and arduino, therefore I struggle a bit with python. If you could point me in the right direction to applying that algorithm to the recorded wave file so I can have a numerical value of the magnitude with which to compare to a threshold value that'd be awesome. If you knew a way to do it on the fly instead of constantly recording and analyzing wave files I'd greatly appreciate that too, it's meant to detect the tone during live recording and then perform an $\endgroup$ – CharminXtra Nov 26 '14 at 1:31

Your Answer

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

Browse other questions tagged or ask your own question.