im fairly new to java... i would like to plot a frequency/time graph or sample image from a wav file. to start off i am struggling to get the raw data array from the Wav file using AudioInputStream also referencing from Reading wav file in Java. I also tried the WavFile class referring http://www.labbookpages.co.uk/audio/javaWavFiles.html but when testing, i was unable to find the correct packages to satisfy the "WavFile" - "cannot find symbol" error. the supplied import java.io.*; for that sample didn't satisfy this...
to reiterate i wish to get a the raw data in array format of a Wav file.
i would love any small examples of this, as i learn from examples much easier! thanks for your time
Skip first 44 bytes from the wav file (header), then read data using this function:
private static double readLEShort(RandomAccessFile f) {
try {
byte b1 = (byte) f.read();
byte b2 = (byte) f.read();
return (double) (b2 << 8 | b1 & 0xFF) / 32767.0;
} catch (IOException e) {
e.printStackTrace();
}
return 0;
}
One value for each channel. This will give you number between -1 and 1, which you can draw on your graph. I hope that may work
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With