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. This way I can save only 1 byte array of data. It don't waits for next piece of data. Would you advice me something?
You could use a WaveFileWriter like so:
InputStream in = ...;
OutputStream out = ...;
AudioInputStream in = AudioSystem.getAudioInputStream(in);
WaveFileWriter writer = new WaveFileWriter();
writer.write(in, AudioFileFormat.Type.WAVE, outStream);
我有解决方案: samlpesCount
必须是总样本计数,不仅是一个容器的大小
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.