views:

22

answers:

1

I have a function that can play set frequencies. The function's inputs are frequency and duration. How can I analyze a sound file so that I have the output frequency for every milisecond of audio.

e.g.: MS, Frequency
1, 400
2, 401
3, 402
etc.

If there is Mac based software that can do this, I'd be fine with preprocessing the audio files and only inputing the frequency/duration combos.

Thanks!

A: 

Most sound files (recordings of anything other than a simple sin wave) do not have a single output frequency, so what you're trying to do is essentially impossible. It is possible to determine the dominant or fundamental frequency of a sound file, but this becomes more difficult to do (and less accurate) the shorter the file is. A one-millisecond snippet of CD-quality (mono) sound consists of only 441 samples.

Are you perhaps trying to convert a recording into its component notes, and then reproduce the tune with your function that plays frequencies? To see how fundamentally difficult this task is, try googling "wav-to-midi".

MusiGenesis
Oh, wow. Okay. I had (falsely) assumed that sound files were composed of constantly changing frequencies (because speakers could only produce one at a time...) Thanks for your input!
Oliver
@Oliver: you can think about a simple, single-frequency sound as a sin wave, where the speaker membrane moves in and out as the wave goes up and down. If you combine two sin waves (of different frequencies), you would see a more complex wave; the speaker can (and does) reproduce this more complex wave by moving in and out in a correspondingly more complex fashion. Any sound of any complexity can be displayed as a single wave changing through time, and a speaker can reproduce the sound by moving the same way.
MusiGenesis