int outSamplingRate = 48000;AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(new File(inFilePath));AudioFormat sourceFormat = audioInputStream.getFormat();AudioFormat targetFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED,outSamplingRate,sourceFormat.getSampleSizeInBits(),sourceFormat.getChannels(),sourceFormat.getFrameSize(),sourceFormat.getFrameRate(),sourceFormat.isBigEndian());AudioInputStream inputStream = AudioSystem.getAudioInputStream(targetFormat, audioInputStream);AudioSystem.write(inputStream, AudioFileFormat.Type.WAVE, new File(outFilePath, outSamplingRate)));
You can find examples in "src/java/test" directory. If you want upsample from 8kHz to 48kHz, the solution is
int outSamplingRate = 48000;AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(new File(inFilePath));AudioFormat sourceFormat = audioInputStream.getFormat();AudioFormat targetFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED,outSamplingRate,sourceFormat.getSampleSizeInBits()
sourceFormat.getChannels(),sourceFormat.getFrameSize(),sourceFormat.getFrameRate(),sourceFormat.isBigEndian());AudioInputStream inputStream = AudioSystem.getAudioInputStream(targetFormat, audioInputStream);AudioSystem.write(inputStream, AudioFileFormat.Type.WAVE, new File(outFilePath, outSamplingRate)));
--
You received this message because you are subscribed to a topic in the Google Groups "JSSRC" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jssrc/crSSdWaAH9A/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to jssrc+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.