Skip to content

WAV File IO

Sambit Paul edited this page Sep 15, 2020 · 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 channels = 2;
objWrite.putData(signal, channels, "int", outputFileName); // Can be "int", "long" or "double' depending on the content of signal
boolean fileExists = new File("./"+outputFileName).exists();
Assertions.assertTrue(fileExists);

Clone this wiki locally