latency and jitter or stutter (clicks and pops)

hello all. I have developed a sound server with 3 java apps, first one captures audio and ships it to the server, then from the server ships it to the clients, i have been tinkering with the buffer values for over two days now, (a lotta tinkering with just numbers) all values greater than 1024 in the client for playback seems to create a queue and make a latency which perpetually gains a second of delay per minute of playback.

I found that having the buffer on the socket set to 1024 and having the java sound buffer at 512 creates a near realtime situation, however it constantly jitters and stutters as well as clicks and pops to maintain its position and not to get a latency.

How do i stop this from happening? Has anyone else experienced the same thing and corrected it? Thanks much in advance for your help.

[836 byte] By [DJHotIcea] at [2007-11-27 1:07:21]
# 1

it seems to be a server issue also...

psudo code of what applies here,

input comes in

read into byte array and a bool is set to false.

all the connected clients output the data read from the global byte array

the byte array is outputted then the bool is set to true

this is on separate threads but continues in a perpetual cycle. There is a thread sleep at a value of (0,1) to keep the cpu low as it goes through two while loops one continues infinitely while the capture is read. Removing this block does not cause the jitters. However cpu goes to 50%. There has to be a better way for me to implement this.

BTW I'm also writing the audio to a file and it does not jitter.

DJHotIcea at 2007-7-11 23:42:35 > top of Java-index,Security,Cryptography...
# 2

Well, the buffer of size 512 is very small for Java Sound. Better solution would be to rewrite socket with bigger buffer and use the modified version everywhere in your project.

Also, this is an incovenience of PipedInputStream and PipedOutputStream - they have buffer of 1024 too, and it is small too.

With most built-in sound cards, the typical size of sound chunk is 10 ms, that is, 4 * 441 = 1764 bytes.

MaxBuzza at 2007-7-11 23:42:35 > top of Java-index,Security,Cryptography...
# 3
Also, look at my recent post (Realtime Sound Processing) to test its speed. Probably, it is one of best ways to sync input and output.
MaxBuzza at 2007-7-11 23:42:35 > top of Java-index,Security,Cryptography...