sfmlguitaraudio

Qt4 and SFML pitch recognition and processing


I am writing a program that displays a random natural note and waits for the user to play that note on the guitar. The audio input is processed to see if the correct pitch was played, and if it was, the next note is shown and the score of the user is updated. The idea is to teach basic guitar notes.

I intend to use SFML for audio processing and QT4 for the gui. I will have a widget derived from the relevant QObject and SFML classes.

Question: How do I detect the pitch of microphone input using SFML? Is it possible to simply store a part of the input in an sf::sound object and call it's getPitch() method?


Solution

  • As it turns out, SFML does not have any algorithms for detecting pitch built in. Thanks to LBg for getting my mind working in the right direction. SFML only provides the tools needed to record the sounds and store them in a buffer.

    I found out that I can use a Fast Fourier transform to evaluate the buffer for a frequency. This frequency can then be compared to a list of known pitch frequencies, together with a pitch threshold.

    While SFML doesn't have an fft algorithm built in, it does have the tools needed to get a sound buffer. I will have to check and see if this is the most cross-platform way of doing things.