Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reading wav file in Java

I want to read wav files in Java and I am going to classify them with K-means.

How can I read wav files in Java and assign them into an array or something like that(you can suggest ideas for it) to classify them?

EDIT: I want to use APIs for reading wav files and for K-means.

like image 752
kamaci Avatar asked Mar 06 '11 11:03

kamaci


People also ask

Does Java support WAV?

Java Sound supports a set of audio file formats, for example AU, AIF, and WAV.

How do I write a WAV file in Java?

AudioSystem. write(audioInputStream, AudioFileFormat. Type. WAVE, wavFile);

How do I open a WAV file?

Windows and Mac are both capable of opening WAV files. For Windows, if you double-click a WAV file, it will open using Windows Media Player. For Mac, if you double-click a WAV, it will open using iTunes or Quicktime.


2 Answers

The official Java Sound Programmer Guide walks through reading and writing audio files.

This article by A Greensted: Reading and Writing Wav Files in java should be helpful. The WavFile class is very useful and it can be tweaked to return the entire data array instead of buffered fragments.

like image 119
shams Avatar answered Sep 28 '22 19:09

shams


Equivalent to matlab's wavread function:

http://web.archive.org/web/20120531113946/http://www.builogic.com/java/javasound-read-write.html

like image 43
aishas11 Avatar answered Sep 28 '22 18:09

aishas11