
Envoyé par
http://www.thatsjava.com/java-tech/7058/
First, you need to get an AudioInputStream from AudioSystem.getAudioInputStream(File file)
or the like. That needs to be converted from mp3 or wav to a PMC format using AudioSystem.getAudioInputStream(AudioFormat targetFormat, AudioInputStream sourceStream)
. Then, using the read() methods, you can get an array of raw data.
From there, if it's a 16-bit little-endian PMC, every 2 bytes should look like this:
62Hz--31Hz--0--0--0--0--0--0--16KHz--8KHz--4KHz--2KHz--1KHz--500Hz--250Hz--125Hz
or
8KHz--16KHz--0--0--0--0--0--0--31Hz--62Hz--125Hz--250Hz--500Hz--1KHz--2KHz--4KH z
With 16-bit big-endian PMC, it should look like:
16KHz--8KHz--4KHz--2KHz--1KHz--500Hz--250Hz--125Hz--62Hz--31Hz--0--0--0--0--0--0
or
31Hz--62Hz--125Hz--250Hz--500Hz--1KHz--2KHz--4KHz--8KHz--16KHz--0--0--0--0--0--0
I'm completely unsure which order it is. Try both. The smaller ones (31Hz, 62Hz, etc.) should be the lowest, bassiest sounds.
Thanks to CodeGuru.com and Windows Media Player. I could never have guessed all of this without you.
Partager