Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need to read a .wav file to an array of frequency/duration pairs for use in a Console.Beep(int,int)-type function. So far, I have read the data into a float array and performed an FFT, but I can't make heads or tails of the complex number results. Having searched all over the internet, I can't seem to find quite what I need. How should I use the outputs of the FFT to a pitch (in Hertz) and a duration (preferably in milliseconds, but I can convert if I need to). Thanks!
Posted
Comments
Sergey Alexandrovich Kryukov 26-Jul-14 21:58pm    
It is totally unclear to me what is that pitch/duration pair, I can only guess. In general case, and, in theoretical continuous spectrum, there is no such "duration", or, of you will, the duration of each frequency is zero. You may operate the range of frequencies, but probably this is not what you mean. Probably you want to find a "musical" presentation of the waveform: what pitches "starts" and "finishes" at what time. This is not an easy task and, in general cases, the problem is not solvable, because there is no such thing. Even if you play real musical instrument, what appears to be a mix of pure musical tons is in fact a continuous spectrum. If you play just one note for a limited period of time, you will get a continuous spectrum with a pitch being a dominating, but not the only frequency. The single-pitch spectrum (delta-function) is the abstraction which appears only for a uniform sound infinite in time. And the discrete spectrum takes place only if your function in time space is strictly periodical, which is, strictly speaking, never the case...
—SA

1 solution

Please see my comment to the question. This problem is quite complex, as far as I can understand it, something like "image recognition", only for music. I tried some software product doing that, and they all worked quite poorly, even when I used a very clear waveform.

So, sorry for not answering your question, it could be a difficult thing. I believe solving such problem should be possible, but I never saw really good solutions.

Before you can even get to the problem, you should first understand how to formulate it. You are not doing it correctly — I tried to provide some hints to understanding why in my comment to the question. Just for figuring out the formulation of the problem, you should better understand how spectrum and Fourier analysis/transform works and what it really means. I'm afraid it's more complex (even for general understanding) than you imagine right now. You can start here:
http://en.wikipedia.org/wiki/Discrete_Fourier_transform[^],
http://en.wikipedia.org/wiki/Fourier_transform[^],
http://en.wikipedia.org/w/index.php?title=Special:Search&search=Fourier+analysis&profile=default[^].

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900