I presumed if I use line.read(), it will return as soon as it reads the number of bytes requested, however I'm finding that it won't return until a much larger sample has been taken.
I initialize AudioFormat: (rate = 44100)
return new AudioFormat(rate, 16, 1, true, false);
I run this in a full-out loop:
int available = line.available();
int read = line.read(tmp, 0, 916);
What I see is that line.available will reach some number around 10k and then actually start returning samples, here's a typical output:
(notice it decreases by 916 each time, as if no new samples are coming in)
Its apparently waiting until it has a certain number of samples and then "releasing" them to the line.read() method. Doing some testing, apparently if I wait until .available() >= 2756, I can actually obtain just that number of samples. I see that 2756 is 44.1k / 16. HOWEVER, if I put 2756 in the .read() line above, it still waits until it gets to about 10k samples before "releasing" the data, it only works if I test the .available() for having 2756 bytes.
I'm trying to do close to real-time data analysis, but if it waits to release the samples, I have to wait too, I'd really like to get to 916 sample frame (of the most recent data of course). Is this the API, my hardware, or is there a better way/API? Funny because on Android this is not a problem at all, it notifies me at the rate I choose.