UDP sound transfer : played sound have big noise

为君一笑 提交于 2019-12-03 00:16:16

I have searched for the reason of this noise. Finally I could detect why this happened.

Actually, This program UDP transfer did not cause packet loss.

Even if it did, the sound do not have such a serious noise.


This program sent data correctly, and there are almost no packet loss, but the "receive" method could not receive data correctly.


In server program

def udpStream(CHUNK):

    udp = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    udp.bind(("127.0.0.1", 12345))

    while True:
        soundData, addr = udp.recvfrom(CHUNK)
        frames.append(soundData)

    udp.close()

This program could data only "25%". (I checked the amount of data)

So, I tried to receive the data multiply (CHANNELS * 2)

        soundData, addr = udp.recvfrom(CHUNK * CHANNELS * 2)

This results in the sound data can be received 100% completely.

Finally, the sound recorded by one PC is played in the other PC without noise.

I've run into the same problem, but your solution didn't help me. What I discovered was that using

stream.write(frames.pop(0))

instead of

stream.write(frames.pop(0), CHUNK)

Clears all the noise in the received signal.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!