JavaSound API를 사용하여 오디오 파일을 읽고 쓰는 오디오 필터를 만들려고합니다.JavaSound 스트림을 사용하여 오디오 파일에 쓰기
ByteArrayOutputStream b_out = new ByteArrayOutputStream();
// Read a frame from the file.
while (audioInputStream.read(audioBytes) != -1) {
//Do stuff here....
b_out.write(outputvalue);
}
// Hook output stream to output file
ByteArrayInputStream b_in = new ByteArrayInputStream(b_out.toByteArray());
AudioInputStream ais = new AudioInputStream(b_in, format, length);
AudioSystem.write(ais, inFileFormat.getType(), outputFile);
이것은, 스트림으로 입력 파일을 읽고 그것을 처리하고있는 ByteArrayOutputStream에 기록하지만, 전체 파일을 디스크에 쓰기 전에 처리 된 때까지 기다립니다 다음과 같이 현재 내 코드가 구성되어있다. 이상적으로는 각 샘플을 처리 할 때마다 디스크에 기록하는 것이 좋습니다. 여러 조합의 스트림 구조를 시도했지만 AudioSystem.write()가 입력 스트림을 취할 때이를 수행하는 방법을 찾을 수 없습니다. 어떤 아이디어?