Thread: Extracting frequencies from a wav file

  1. #1
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607

    Extracting frequencies from a wav file

    I didn't know where to post this but here goes.

    I'm re-mixing an album for my friend using Sony's Sound Forge Audio Studio and several other tools. However I really need access to the tracks in the song and all I have is the final mix.

    Is there a way to extract the separate tracks from the final mix? Also can I write something in C to extract data within a certain frequency range and if so how do I convert from sample value to actual frequency??

    It would be nice too, to be able to write my own mixer and my own frequency readout displays that show me exactly what is going on in the music. But I'm not sure how to convert a value like 16500 into a 20 band frequency readout. FFT perhaps?

  2. #2
    5|-|1+|-|34|) ober's Avatar
    Join Date
    Aug 2001
    Posts
    4,429
    You never do anything easy, do you?

  3. #3
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    It wouldn't be a challenge if I did.


  4. #4
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    There's no easy way to seperate tracks from a mixed/mastered recording. All the tracks are merged and the only separation is the stereo channels. Your best bet would be professional recording software... im not really sure what sony's Sound Forge is capable of.

  5. #5
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    How can I program a visual representation of the frequency ranges? Media player does this with just about everything like waves, bars, etc. But how do they do it?

    I know how to do a wave - take a sample, plot it, take next sample plot it. Large sample values would mean large y displacement and vice versa. But to separate them into bars is something I don't know how to do.

    EQ's do this in real time - a visual display that shows frequency ranges and db in that range.

  6. #6
    Senior Member joshdick's Avatar
    Join Date
    Nov 2002
    Location
    Phildelphia, PA
    Posts
    1,146
    The difference between a wave and a bar is simply a matter of how many values you're displaying. If you display a bar graph with bars each a pixel wide, that'll look like a wave. Just make the bars wider and it'll look more like a bar graph. Just sample values less frequently.
    FAQ

    "The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs." -- Joseph Weizenbaum.

    "If you cannot grok the overall structure of a program while taking a shower, you are not ready to code it." -- Richard Pattis.

  7. #7
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    Fourier transforms.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  8. #8
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    Quote Originally Posted by joshdick
    The difference between a wave and a bar is simply a matter of how many values you're displaying. If you display a bar graph with bars each a pixel wide, that'll look like a wave. Just make the bars wider and it'll look more like a bar graph. Just sample values less frequently.
    No, they are not the same. Bar graphs show what frequencies the sound is made up of.

    As has been said, fourier transform should do the trick.
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  9. #9
    The C-er
    Join Date
    Mar 2004
    Posts
    192
    Bubba, techniques that could help are -


    FFT's (Fast fourier transforms) and DCT (Discrete Cosine Transforms). These are quick ways of doing Fourier analysis..

    Standard fourier analysis is slow, because it depends on adding series of sines + cosines. But I would suggest understanding the principle of this before moving on to FFT/DCT. I would think that a graphics guru, you would find the maths quite accessible.

    Also digital filtering techniques could be useful for extracting bands of frequencies.
    There is an excellent book "The Art of Digital Audio" on this. Can't remember the author.

    Another idea to extract a single instrument is to look at the relative amplitude /phase of the two stereo channels. For instance,consider an instrument that is directly ahead of the listener (in the centre of the stereo "soundstage"). Assuming that the phase and amplitude for each channel for this instrument are the same, then subtracting say the left channel from the right would make this instrument dissappear from the sound. Somebody demonstrated this concept a few years ago, but I can't remember more details.

    Maybe you could combine this idea with the FFT thing. The fourier equations will give you information on the phase too.

  10. #10
    PC Fixer-Upper Waldo2k2's Avatar
    Join Date
    May 2002
    Posts
    2,001
    goldwave and audacity can both seperate out the stereo tracks, but goldwave has some great advanced filtering features. You could try to seperate frequencies out and save them off as seperate tracks...this would be as accurate (or more) than programming it yourself, and neither method will be perfect. Good luck.
    PHP and XML
    Let's talk about SAX

  11. #11
    Registered User
    Join Date
    May 2005
    Posts
    7
    ok let me say I am not a computer expert, in fact I just started learning C++ today. I can help with the audio side of things though let me explain...

    It is going to be next to imposible to extract an insturment based on its frequency range. This is because all complex wave forms (all sounds not generated by math that ocour in our world) contain ALL of the frequencies, but at different amplitudes. For example: a bass guitar has much higher amplitude in the lower part of the frequency band, but also has significant amplitude(data-wise, not perceptual) as high as 10khz and higher.

    EQ is not going to help here. The only things you have to work with are time( 44.1k samples per second), amplitude(volume) and frequency. and that is not enough.

  12. #12
    PC Fixer-Upper Waldo2k2's Avatar
    Join Date
    May 2002
    Posts
    2,001
    what you say is true, but like I said the good people at goldwave.com have already taken that into account and have come up with the best (non-commercial) filters I've seen. It is true that the instruments will have some sound coming from them in other ranges...but you must also realize that most people's ears won't pick that up (plus when recording they usually use highpass filters on instruments like the bass guitar for example to constrict it to a certain range). No matter how he tries to do this, it can't be perfect. He' trying to strip apart a mastered recording and there will always be the sound of other instruments in the background. But if filtered correctly he can make them less audible.
    PHP and XML
    Let's talk about SAX

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File Writing Problem
    By polskash in forum C Programming
    Replies: 3
    Last Post: 02-13-2009, 10:47 AM
  2. Need Help Fixing My C Program. Deals with File I/O
    By Matus in forum C Programming
    Replies: 7
    Last Post: 04-29-2008, 07:51 PM
  3. Can we have vector of vector?
    By ketu1 in forum C++ Programming
    Replies: 24
    Last Post: 01-03-2008, 05:02 AM
  4. WAV file problems...
    By snerl in forum C Programming
    Replies: 4
    Last Post: 06-11-2003, 03:00 PM
  5. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM