This post ist a continuation developed this other: Goal: capture sound in Pc "A" and send it by UDP protocol to PC "B" and play it
Now the problem its that:
I have a code A in a pc A. Here the sound its capture by microphone and codified in a string. I send this string at remote pc B. In pc B, code B convert the string in float array numbers = sound buffer in code A ( I cheked this in console print ) When i reproduce it, I hearing pops and chunkrys, white noise. I need hearing the same sound captured in Pc A in code A.
Any person know make this ??
code A: ( transmit )
ofApp.cpp (1,8 KB)
code B: ( received )
ofApp.cpp (2,4 KB)
I haven’t tried or confirmed, but browsing your code, it looks like you are sending/receiving messages at the display rate, and not audio rate. The audio thread (audioIn/audioOut) runs in a different thread with a different speed than the update/draw functions. At 44100 Hz and 256 samples per buffer, it should run at around 170 frames a second, while your update/draw should run at 60 frames per second. If you were successfully getting the frames of audio at 60 frames per second, then there are still gaps in between the audio which are going to be repeated frames of 256 samples, and would explain the pops. You can try instead to send the data in your audio thread (move your send/receive message code in the audioIn/audioOut functions instead of update/draw), but I’m guessing it will not be able to send that much at once, and you will instead need to come up with a smarter solution using a ring buffer or some other buffering solution, introducing latency in your audio playback, so that you are not sending so many messages. An even better solution would probably require encoding/decoding your data using something like a discrete cosine transform and inverse discrete cosine transform, though I’ve never tried this (always wanted to though!). You may want to consider trying another library using RTSP, e.g., something like this: http://www.pjsip.org/ - though I’ve never tried myself.