How to Convert Sampling Rate with Java

This worked for me.

You can convert by applying AudioSystem.getAudioInputStream to an AudioInputStream object, and you get another AudioInputStream as the result.  Here is the sample code of the part:

AudioInputStream inStream = AudioSystem.getAudioInputStream(soundFile); AudioFormat outDataFormat = new AudioFormat(8000.0f, 16, 1, 2, true, false); AudioInputStream outStream = AudioSystem.getAudioInputStream(outDataFormat, inStream);

In order to make above code work, we need following two extensions.  Without these extensions, we get exception on the execution above.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.