我需要将音频数据作为“16位整数数组”(来自我有限的文档)传递到第三方系统。Java - 将音频的字节数组转换为整数数组
这是我到目前为止所尝试过的(系统从生成的bytes.dat文件中读取它)。
AudioInputStream inputStream = AudioSystem.getAudioInputStream(new File("c:\\all.wav"));
int numBytes = inputStream.available();
byte[] buffer = new byte[numBytes];
inputStream.read(buffer, 0, numBytes);
BufferedWriter fileOut = new BufferedWriter(new FileWriter(new File("c:\\temp\\bytes.dat")));
ByteBuffer bb = ByteBuffer.wrap(buffer);
while (bb.remaining() > 1) {
short current = bb.getShort();
fileOut.write(String.valueOf(current));
fileOut.newLine();
}
这似乎并不奏效 - 第三方系统无法识别它,我也无法将该文件导入Audacity作为原始音频。
有没有什么明显的我做错了,还是有更好的方法来做到这一点?
额外信息:波形文件是16bit,44100Hz,单声道。
你能告诉我更多关于这个第三方系统吗? – akarnokd 2009-06-25 15:03:38