Skip to content

WAV File IO

Sambit Paul edited this page Feb 22, 2021 · 3 revisions

Reading a WAV File

Variable inputFilename contains the path of the file to be read as a string.

Wav objRead1 = new Wav();
objRead1.readWav(inputFilename);
Hashtable<String, Long> propsOut = objRead1.getProperties(); // Gets the WAV file properties 
double[][] signal = objRead1.getData("int"); // Can be 'int', 'long' 'double'

Writing to a WAV File

Variable outputFilename contains the path of the file to be written to as a string. Variable signal is a 2D array which contains channels and channel content

Wav objWrite = new Wav();
int samplingRate = 44100;
objWrite.putData(signal, samplingRate, "int", outputFileName); // Can be "int", "long" or "double' depending on the content of signal
Clone this wiki locally