I am writing a program to stream audio over a network, so I have a thread to record data and one to send it. When testing the audio has noticeable gaps. I beleive this is due to the sounddevice.play()
function, the example below has the same problem.
import sounddevice as sd
len = 5
fs = 44100
sd.default.device = [2,1]
myrec=sd.rec(int(fs*len), samplerate=fs, channels=2, blocking=True) #fill an array with some sound
while True:
sd.play(myrec, blocking=True)
#loop plays 5 second audio clip with slight gaps
The gaps coincide with the play length, so it appears to be caused by a delay in the play function. In continious audio this becomes very noticeable and annoying. The same thing also happens in the documentation audio passthrough example here.
Is there any was to make the playback continuous?