First of all sorry if this is a stupid question, but I am an absolute beginner in this field and have been trying for days now. I'm working on a java program that uses fft to analyze audio files. To test the results I'm getting from the fft I drew some spectrograms, which are working perfectly for WAV files. But I get weird effects when using mp3 or mp4 files. I use the Jtransform library from wendykierp.
This is what it should look like.
And this is what is looks like.
It is also half the width of the wav spectrogram (due to compression?). If yes can this be compensated for?
The samples seem to be correct:
From Audacity:
And here are the spectrograms for the Mp3 and Mp4 of a 1khz Sinus wave.
Mp4:
EDIT:
The suggestion to test with octave helped quite a bit. I changed the code to just take the first half of the FFT output and added channel separation for the samples of the mp3. Now I get the correct specrogram for mp3 files.
But there are still two problems:
The first is that the mp3 spectrogram has only 1/4th of the width and 1/2 of the height of the wav specrogram because of the sample count. It also seems to be cut of[f] a bit at the top. Can I solve the width problem by just interpolationg new samples or is there a better way?
The second is that mp4 files still look like above, which probably has more to do with the samples or channel layout than the FFT itself (?)
fft
function and the complex input is perfectly fine.Does the second image remind you of... $\endgroup$ – A_A Dec 24 '18 at 20:37