0

I have been willing to develop an application which transmits real-time audio over a local network with the lowest latency possible in python.

So I ran into this program (the last UDP version) and I have been trying to tweak a few variables to achieve the lowest latency possible, which I guess can be pretty low in a localhost environment. However removing the 5 seconds wait time and reducing the CHUNK size down to 1024 still results in an audible latency.

Does the BUFF_SIZE and the sleep time of the server_socket.sendto() loop have to do with it? Are they related to each other?

It seems that with a BUFF_SIZE lower than 4096 (which is approximately the latency that I experience) the client does not playback the stream.

Is it then related to the client's queue?

My MAIN QUESTION would be: how do you fine tune these parameters to achieve the lowest latency possible?

Thank you very much!

1 Answer 1

0

If you want to reduce latency, use a smaller chunk size in your packets. When I worked on a well known voice over IP system years back, UDP packets only had between 30-90ms of audio in each.

It seems that with a BUFF_SIZE lower than 4096 (which is approximately the latency that I experience) the client does not playback the stream.

That would be a bug in the client you need to investigate and address. Glancing at your code, I don't see an immediate issue. Nor do I see any debugging print/log statements revealing if packets are being received and have the expected payloads.

2
  • Thank you very much for your answer! Indeed lowering the CHUNK size down to 64 brings down the latency! and I also finally understood that the BUFF_SIZE only sets the maximum amount of data that can be sent over to the client...but may I again take advantage of your expertise? how would you fine tune the transmission rate (i.e. the time.sleep() interval right...?) of the server? I thought that CHUNK/SAMPLE_RATE would be appropriate, but it seems too slow...Is it relevant or should I put it "as low as possible" and handle the incoming data on the client? Thank you very much again
    – ddgg
    Feb 13 at 13:01
  • ...is there some "entry level literature" that I could study?
    – ddgg
    Feb 13 at 13:01

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.