Input & Output

Provides a demonstration of functions available in JDSP for reading and writing different file formats

Reading from a WAV File

Code

                    
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'
                    
                  

Output

                    
System.out.println(objRead1.getProperties());
OUTPUT: {Channels=2, Frames=268237, ValidBits=16, BlockAlign=4, SampleRate=8000, BytesPerSample=2}                    
                  

Writing to a WAV File

                    
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
                    
                  

Reading from a WAV File

                    
Csv readObj = new Csv(',');
//inputFilename holds the path to the CSV file to be read from
HashMap< String, ArrayList< Object>> out = readObj.readCSV(inputFilename, true);
                    
                  

Writing to a WAV File

                    
HashMap< String, ArrayList< Object>> result = new HashMap< String, ArrayList< Object>>();
//Fill the result variable with the key and ArrayList
Csv writeObj = new Csv(',');
// outputFilename holds the path to the CSV file to be written to
writeObj.writeCSV(outputFilename, result);