import javax.sound.sampled.AudioFileFormat; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioSystem; import javax.sound.sampled.UnsupportedAudioFileException; // format is for both the PCM and the output file static void pcmToWAVE(byte[] pcm, AudioFormat format, File outputFile) ctex { AudioInputStream sourceStream = new AudioInputStream(new ByteArrayInputStream(pcm), format, l(pcm)); // TODO: last parameter should be length in frames? AudioInputStream stream = AudioSystem.getAudioInputStream(format, sourceStream); AudioSystem.write(stream, AudioFileFormat.Type.WAVE, outputFile); sourceStream.close(); stream.close(); }