Graphic display / display of the jav wav file

im pretty new for java ... I would like to plot a frequency / time graph or sample image from a wav file. for starters, I'm struggling to get the original data array from a Wav file using AudioInputStream, also referring to Reading a wav file in Java . I also tried the WavFile class, referencing http://www.labbookpages.co.uk/audio/javaWavFiles.html , but when testing, I could not find the correct packages to satisfy the "WavFile" - cannot find the character. "Delivered java import .io. *; for this sample this did not satisfy ...

to repeat, I want to get raw data in a Wav file array format.

I would love small examples of this, as I learned from the examples a lot easier! thank you for your time

+6
source share
2 answers

Skip the first 44 bytes from the wav file (header), then read the 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 a number from -1 to 1, which you can draw on your chart. I hope this might work

+3
source

In my Java DSP assembly, there is a test program called TestSignalPlot.java that can display WAV files. It uses AudioIo.loadWavFile () to load the contents of the WAV file into memory and the SignalPlot class to display the audio signal. All classes are part of the open source collection.

0
source

Source: https://habr.com/ru/post/916165/


All Articles