Results 1 to 16 of 16

Thread: [2008] Convert Wave File To Frequencies

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2006
    Location
    Scotland
    Posts
    1,054

    [2008] Convert Wave File To Frequencies

    Is there any way I can convert a wave file into a list of frequencies and durations of these frequencies?

  2. #2

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2006
    Location
    Scotland
    Posts
    1,054

    Re: [2008] Convert Wave File To Frequencies

    If it is unclear what I am asking for I am happy to give more information?

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2006
    Location
    Scotland
    Posts
    1,054

    Re: [2008] Convert Wave File To Frequencies

    Hate doing this but.... Bump!

  4. #4
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    Re: [2008] Convert Wave File To Frequencies

    I'd start will Googleing around on exactly how WAV files store audio data. I think they just store amplitude levels at finite sample rates (for example, 44000 hz).

    You'd need some form of math algorithm to find peaks within a timeframe of sample (1 sec) and count them.

    So, if I run an analysis on the first 44000 samples, and I find 2500 peaks, then for that second of time, my frequency is 2.5khz.

    If you're having trouble finding an algorithm for detecting the peaks, hit up the math forums on here and ask if anyone knows of an algorithm for determining frequency of a set of point data.
    My CodeBank Submissions: TETRIS using VB.NET2010 and XNA4.0, Strong Encryption Class, Hardware ID Information Class, Generic .NET Data Provider Class, Lambda Function Example, Lat/Long to UTM Conversion Class, Audio Class using BASS.DLL

    Remember to RATE the people who helped you and mark your forum RESOLVED when you're done!

    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe. "
    - Albert Einstein

  5. #5
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: [2008] Convert Wave File To Frequencies

    There are probably audio libraries out there that can do this for you. Try googling.
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2006
    Location
    Scotland
    Posts
    1,054

    Re: [2008] Convert Wave File To Frequencies

    It's been a while since I thought about this. A friend reminded me today and I dug up the thread. Just to check to see if I am doing this correctly. If a wav file has a sample rate of 44KHz then it will play 44000 notes in 1 second. Each note will have a duration of 1/44000s which comes to 2.73x10^-5s.

    Everyone of these notes (which have a set duration) has a frequency and amplitude. And that is all that is needed to play any set of sounds, no matter what instrument. Everything there correct?

  7. #7

    Re: [2008] Convert Wave File To Frequencies

    Human hearing upper limit approx. 22,000Hz

    To reproduce digitally 2 x 22,000 = 44,000

    http://en.wikipedia.org/wiki/Nyquist...mpling_theorem

  8. #8
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    Re: [2008] Convert Wave File To Frequencies

    No, 44kHz isn't 44000 notes... it's 44000 dots on a graph. When you connect the dots you get a wave. You count how many peaks are in that wave and that is your average frequency.

    My CodeBank Submissions: TETRIS using VB.NET2010 and XNA4.0, Strong Encryption Class, Hardware ID Information Class, Generic .NET Data Provider Class, Lambda Function Example, Lat/Long to UTM Conversion Class, Audio Class using BASS.DLL

    Remember to RATE the people who helped you and mark your forum RESOLVED when you're done!

    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe. "
    - Albert Einstein

  9. #9

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2006
    Location
    Scotland
    Posts
    1,054

    Re: [2008] Convert Wave File To Frequencies

    So what I really need is the troughs and peaks and the times between them?

  10. #10
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    Re: [2008] Convert Wave File To Frequencies

    Yea, you can divide the time as thin as you want, if you want to get a reading every 1/2 second, then you'll have to multiply your count by 2.
    My CodeBank Submissions: TETRIS using VB.NET2010 and XNA4.0, Strong Encryption Class, Hardware ID Information Class, Generic .NET Data Provider Class, Lambda Function Example, Lat/Long to UTM Conversion Class, Audio Class using BASS.DLL

    Remember to RATE the people who helped you and mark your forum RESOLVED when you're done!

    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe. "
    - Albert Einstein

  11. #11

    Re: [2008] Convert Wave File To Frequencies


  12. #12
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    Re: [2008] Convert Wave File To Frequencies

    Heh... wow the WAV format is complex. It's nothing like a bitmap... I had no idea WAV could hold compressed audio.
    My CodeBank Submissions: TETRIS using VB.NET2010 and XNA4.0, Strong Encryption Class, Hardware ID Information Class, Generic .NET Data Provider Class, Lambda Function Example, Lat/Long to UTM Conversion Class, Audio Class using BASS.DLL

    Remember to RATE the people who helped you and mark your forum RESOLVED when you're done!

    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe. "
    - Albert Einstein

  13. #13
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: [2008] Convert Wave File To Frequencies

    Sorry but I just have to interfere, even though I'm not good at .NET (I'm good with VB6).

    You guys are really off...

    That 44100 Hz (or 44.1KHz) is how many samples are in one second. This defines how clear the sound is recorded, nothing else....

    This also means that the highest frequency you can have in a 44100 Hz wave file is 22050 Hz.

    You should see my sound tutorial, at least the first post where it explains what sound is.
    VB6.0 – Sound and DirectXSound Tutorial

    You can't get the frequency by how many peeks you find, because sound is made of many frequencies. And that means that each has it's own peeks within another frequency's peeks and so on.

    Imagine 100 frequencies at the same time, if you count the peeks, you are basically doing a SUM of all 100 frequencies at the same time.

    And on top of that... not all frequencies start at the same time... one frequency could start from the beginning of the sound and another from the middle of the sound, and another from the end of the sound...

    To do this you have to use FFT (Fast Fourier transform), look it up on Google.

    You have to Process wave file through the FFT, 512 or 1024 samples at a time depending of the resolution you want to get, overlapping the last 256 or 512 samples for each pass.

    Anyways, I don't have time to say more... but I just wanted to tell you that you are going about this the wrong way. FFT is the right way, and do your research on that...

  14. #14
    Member
    Join Date
    Nov 2006
    Posts
    39

    Re: [2008] Convert Wave File To Frequencies

    Quote Originally Posted by CVMichael
    Sorry but I just have to interfere, even though I'm not good at .NET (I'm good with VB6).

    You guys are really off...

    That 44100 Hz (or 44.1KHz) is how many samples are in one second. This defines how clear the sound is recorded, nothing else....
    maybe a bit off-topic... but I'm trying to plot on screen the waveform contained into a WAV file.
    I don't care the frequencies, as the waveform actually represents a digital signal a few ms long, so I just need to know when the waveform is high and when it is low.
    I parse the DATA chunk word by word and I just plot values on the screen: it works pretty well... but in several points of the resulting graph I see "peaks", which, when compared to the WAV file, correspond to values over 65000. But the file displayed in Audacity shows no peeks, just kind of a square wave (zeroes and ones).

    What am I doing wrong?

  15. #15
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: [2008] Convert Wave File To Frequencies

    Well, I can't guess...

    Post your code, and post a screen shot of the peaks you are talking about...

  16. #16
    Member
    Join Date
    Nov 2006
    Posts
    39

    Re: [2008] Convert Wave File To Frequencies

    Quote Originally Posted by CVMichael
    Well, I can't guess...

    Post your code, and post a screen shot of the peaks you are talking about...
    Thanks, I opened a separate thread:
    http://www.vbforums.com/showthread.php?t=526712

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width