w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
java sound on linux: how to capture from TargetDataLine quickly enough to keep up?
private static final int MIC_FETCH_SIZE = 480; // 0.12 seconds
of data 

This is far too small a buffer size for reliable performance. At 16 bit mono, it represents just 240 sound samples. Make it something more like 16000 samples, or:

private static final int MIC_FETCH_SIZE = 32000; // 2 seconds of
data

Note: Java Sound will not guarantee that amount is read, and will instead return the number of bytes that are actually read. The point is, to allow the opportunity to read up to 2 seconds of data (if it is available).

I think this should solve most of the problems described above.





© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.