I'm trying to work on the code of a mixing console and I need some advices before coding (hoping that my question won't be "off topic").
In my project, on each "stripe" of the mixing console, I'll can enter a source : an audio file player, a microphone... I succed for this first part. In the last stripe called "Master", I have to collect all the sound signals to mix them together. For a first test, I'll just try to add them (and see what happens).
But my question is : what's the best way to send the sound from a stripe to my master ? The lag have to be very short : if I sing in the microphone while the music is playing, my voice collected in the microphone have to arrive in the Master "immediatly" to be mixed, and not 15 seconds later...
So, I thought about using a simple UDP transfert : it's fast comparated to TCP. As I'll "stream" each stripe on the local address 127.0.0.1 (and not over the whole internet), could I consider that "datagram losses" will be insignificant ? Or shall I try to implement something like a RTP (really heavier...) over my UDP ? Or something else I didn't thought about ?
I don't post any code for now because my aim is to have some good advices BEFORE writing line and lines and noticing that I'm in the wrong way...
Thank you for your answers. Regards.
If you send a TCP packet from New York to Tokyo it will take less than 300 ms. If you send a TCP packet across a city it should be less that 25 ms via the internet. If you send a packet via Wifi, it should take less than a few milli-seconds and over local LAN you should get under 0.1 ms.
Note: if you send a packet to the Moon and back it will take 2.5 seconds.
However, if you use UDP it might be faster, or it might be slower, or it might not arrive at all. UDP is a lossy protocol so there is no guarantee a packet will be received, and no built in way to detect such a packet was lost.
In short, use TCP. The micro-second difference won't be as important as lost packets.