# How do I get frequency data from a .WAV?

What I want to do is create a visual spectrum of a concurrently playing audio file like this

What I’ve gathered is that I need to read in the samples from the wav file and run a Fourier Transform on it to get a frequency spectrum.
I’ve done this with code from scratch but the spectrum I’m getting doesn’t look right and I would like to find a library to help. Android friendly is preferable but I’ll take anything at this point to get me going.

Does anyone know of a library that can do this and possibly something with a basic tutorial?

You could try to understand what the tools do that you’re using. (not meant as a snarky remark :))

You’re saying you’ve gathered to read in samples, and apply a FFT on it, and your output looks off.

Did you try to analyze what actually goes wrong? You can feed in a nice sine-wave of a known frequency and actually look at what your FFT spectrum looks like. Does it have a peak at the expected frequency? That’s a valuable starting point for troubleshooting, and actually solving the problem step by step.

Yes I did do that and I understand the value of diving deep into technicalities but I’m trying to make a game not a game engine.

I found what I needed so here it is for those interested.

An excellent, free resource for learning about the FFT is the following eBook:

Scientist and Engineer’s Guide to Digital Signal Processing

It starts with the basics, and also contains excellent info about various filtering methods.

The code examples are in BASIC, so you would have to get your Java implementation elsewhere, or build on from the BASIC examples. Perhaps someone at JGO (@nsigma?, @Catharsis?, @ShannonSmith?, others?) has a recommendation or code to share?

It you have difficulties with any part of the text, I’ve found that a good place to ask questions is the
Signal Processing section of Stack Overflow.

[When asked earlier in a PM, I recommended the OP make a public post, so anyone else that has a similar question could use the answers provided as a reference. We are also requesting this thread be moved to the Java Sound section, if that is not too much trouble.]

Moved it to the new board - this was the closest fit (not perfect)