# Preparations to implement FFT on a wav file (code Java, not Library)

I am making preparations to implement FFT on a wav File.wav Only Java. I'm reluctant to use matlab

I have a File wav stereo, 16 bits.

I need to calculate the FFT, but I have confusing.

My File has a Frequency of 44100, the samples in bytes are 10 minuts ->

(10 minuts)*(60 seconds)*(44100 sample rate)*(2 bytes because are 16 bits)
= 52920000 >~ 52MB per channel.


As you can see it's a big file.

1. Question. Can I to split my file in order to make smaller calculus? If yes, My file can be variable, How I can calculate a moderate lenght working in function of frequency (greater frequency will need greater length FFT).

2. Question. According to FFT the size need to have a lenght = mantissa = Pow(2, Integer). Can I to fill with zeros to reach Pow(2, Integer), Example I have a file with a lenght of 65000 samples, then I will need a FFT with order of 16 -> mantissa = 65536, Can i to fill with zeros the others 536 samples?

Thank you.

• Can you explain the goal of calculating of FFT for whole file? It is possible that you need STFT (Short time Fourier transform) - en.wikipedia.org/wiki/Short-time_Fourier_transform . About your questions. The frequency resolution depend on length of input array. Maximum frequency depend on time step. It is good idea to read textbook second time before implementing FFT. I think there are a lot java FFT library (see for example - stackoverflow.com/questions/3287518/…). Why do you need implement it? (homework?). Oct 11, 2013 at 4:20
• Thank you.__________Can you explain the goal of calculating of FFT for whole file?------> I want to extract the main frequency of Sample, example of sound of piano recorded into file.__________ Why do you need implement it?------>I want to implement something like: WaveSpectra -> s000.tinyupload.com/… But I need Full control of process and my data. Now, I need implement STFT. Oct 11, 2013 at 14:46
• SergV: rework your comment into a proper answer, maybe by elaborating a bit more on why it doesn't make sense to compute the FFT of 10 minutes of audio (concept of stationarity), and maybe give a short overview of the STFT computation process (with references to windowing and zero-padding, maybe a warning about the time/frequency resolution trade-off), you'll get an upvote on that :) Oct 11, 2013 at 16:47
• You can to obtasin WaveSpectra here: mediafire.com/download/uv92kugn52650wo/WaveSpectra.zip May 19, 2014 at 3:15

Simply taking the Fourier transform of a ten minute signal is unlikely to provide you with any useful information - I suspect what is actually of interest to you is the spectral information at intervals throughout the signal, e.g. 600 frequency plots at 1 second intervals, which if you so desire can be combined into a spectographic image for analysis. This can be achieved by performing multiple windowed Short Time Fourier Transforms (STFT) and storing the results.

Can I to split my file in order to make smaller [calculations]?

Yes, it is up to you what granularity of frequency information you wish to obtain. Small FFT lengths will afford you a better time resolution, longer FFT lengths will afford you a better frequency resolution. For purely visualisation purposes an FFT length of 1024 is generally sufficient.

Can I to fill with zeros to reach Pow(2, Integer) [for my FFT length]?

Yes, if you do not have sufficient samples to reach a power of two length for your FFT then you should zero pad the input. This will introduce the minimal amount of spectral error into your frequency domain results.

• Thank you for your answer, Now It's clear that The FT isn't the best choice._________________ I was thinking about of granularity of representation of frequency it's a problem._________________ I had not heard of STFT neither Wavelet. Now I'm thinking in this last option._________________. Now my option will be Wavelet. _________________How can I refute (looking for more information or answer) in this site taking similar question avoiding the mark "duplicate question"? Thank you again for your time... Oct 12, 2013 at 0:27
• I think you can probably just re-ask the question provided the answer will be something different. I can't make any guarantees about it not being closed as a duplicate though... Oct 14, 2013 at 10:15