[英]How to save more that one byte array using Java AudioSystem.write
public void run(){
AudioInputStream audioInputStream= new AudioInputStream(pis,audioFormat,samlpesCount);
try {
AudioSystem.write(audioInputStream, AudioFileFormat.Type.WAVE, file);
} catch (Exception e) {
e.printStackTrace();
} finally{
try {
pis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
pis
is a PipedInputStream
, through I send byte arrays with data. pis
是PipedInputStream
,通过我发送带有数据的字节数组。 This way I can save only 1 byte array of data. 这样,我只能保存1个字节的数据数组。 It don't waits for next piece of data. 它不等待下一个数据。 Would you advice me something? 你能给我一些建议吗?
You could use a WaveFileWriter like so: 您可以像这样使用WaveFileWriter:
InputStream in = ...;
OutputStream out = ...;
AudioInputStream in = AudioSystem.getAudioInputStream(in);
WaveFileWriter writer = new WaveFileWriter();
writer.write(in, AudioFileFormat.Type.WAVE, outStream);
我有解决方案: samlpesCount
必须是总样本计数,不仅是一个容器的大小
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.