First of all, I am working on a small project to see a spectrum of some sounds.
I worked with a microphone: alt text http://img25.imageshack.us/img25/4271/spectrumanalyzerfourier.png
The image above is just what I say and scream through the microphone for a few seconds. It looks good to me.
But when I try to read an MP3 file and make it, it looks a little different. I tried Aphex Twin - Windowlicker, where you usually should see a face in a spectral image or at least darker colors. But it doesn’t look so good: alt text http://img10.imageshack.us/img10/3475/aphextwinhmm.png
Here is what I did with the microphone:
byte tempBuffer[] = new byte[10000]; ByteArrayOutputStream out = new ByteArrayOutputStream(); counter = 20;
And here is how I do it with MP3:
I used the same code for the conversion and rendering only for the audio capture part (I only adjusted the height in the drawing method to see if there was a difference, but it wasn’t):
byte tempBuffer[] = new byte[10000]; ByteArrayOutputStream out = new ByteArrayOutputStream(); FileInputStream input = null; File mp3 = new File("Aphex Twin - Widowlicker.mp3"); input = new FileInputStream(mp3); int len; while((len = input.read(tempBuffer)) > 0) { out.write(tempBuffer, 0, len); } out.close(); input.close();
It would be nice if someone could tell me what I'm doing wrong with the MP3 file.
These are my settings:
- Poll Frequency: 44100
- Bit for sample: 8
- Channels: 1 (mono)
- signed: true
- big endian: true (I use AudioFormat in Java)
- tempBuffer for reading audio: 10000 (bytes tempBuffer [] = new byte [10000];)
- and for FFT I share the audio in bytes 4096 (should be 2)
By the way: are these settings OK, or should I use 16 bit / s or stereo or 10000 for a buffer too large or 4096 for small / large?
Thanks in advance
source share