This content has been marked as final. Show 1 reply
user13514642 wrote:I know that I am loosing audio bytes because of of the signals I am using is a perfect sinusoid at 50hz, but when I plot it using java (after converting to doubles) sometimes I get discontinuities in the ploted sinusoid.
byteOutputStream = new ByteArrayOutputStream( );
bufferSize = targetDataLine.getBufferSize() / 5;
tempAudioBytes = new byte[bufferSize];
numBytesRead = targetDataLine.read(tempAudioBytes, 0, tempAudioBytes.length );
byteOutputStream.write( tempAudioBytes, 0, numBytesRead );
// send buffer data to a queue
audioBytesQueue.offer(byteOutputStream.toByteArray()); // << you should check the boolean return value from offer()
I've read that data will be discarded by the line if it tries to write to the internal buffer while we are reading from it. This is why I use a small buffer to access to lines internal buffer, but this doesn't seem to solve my problem...
Any ideas how I can solve this? Or let me know if I'm doing something wrong? You should check the boolean return value from offer()