Comparing Simple Sounds - What is the Closest Frequency
I have a rather interesting problem to solve.
I want to take a very simple sound (one note played on the piano) and try to process it in such a way that I can print out which note is most likely being played.
From some googling and searching I have come across the fast fourier transform but am not entirely sure how I开发者_如何学运维 would use this to analyze data from a wav file.
Another thought I had was that a note should be more or less the same each time it is played. If that is the case could a percentage match on two wav files turned into byte arrays be of any use?
Thoughts and ideas would be much appreciated.
The FFT is a much better option than comparing two WAVs. The FFT will produce a frequency spectrum, and since the piano produces a relatively pure tone, you will observe very distinct spikes when you plot it. The position of each spike denotes one of the constituent frequencies of the waveform, with the largest spike representing the note.
You should be analyzing the frequency of the note being played. Im a bit rusty but FFT i think should do this as it breaks down the waveform into frequency spectrum.
You do not want to be comparing the wav file with an already stored one, as the period amplitude etc could be different. A 'percentage match' would produce erroneous results.
Once you have the frequency of the waveform,you can then devise the note that is being played.
I would start reading up on Digital Signal Processing (DSP) and spectral analysis. Sounds like you're trying to find the fundamental frequency of your piano note.
To do any meaningful work with a WAV or other file format, you'll need to extract and interpret the audio samples. If not wanting to do so by hand, I'd suggest looking into a myriad of existing DSP libraries. I'm not sure what good c# libraries exist.
The Fast Fourier Transform (FFT) will essentially convert your power over the time domain to the frequency domain, essentially adding a z-axis to your audio.
精彩评论