Java Sound PCM Stream over wifi/tcp is very "staticy"
I've written a program that transmits a PCM stream from my pc to another pc or my android(using an AudioTrack). It uses java sound 开发者_JS百科and takes the target and source lines from the Stereo Mix mixer. Everything technically works (sockets, mixers, lines, streams, buffers, etc.) but the output on the remote speakers is very static-y sounding. Even when there isn't sound coming through, there is a constant crackling sound. I've tested the programs on my phone and computer with the same result.
What can I do? Thanks, Bill
ps The code is pretty big, and kinda messy, but I can post it somewhere if you ask.
Typically the static means you're feeding incorrect data to the audio subsystem: given what you describe there's probably an error in the audio path, and I'd suspect you are either:
- Experiencing some byte alignment issue when reading/transmitting/receiving the audio data from the source.
- Inadvertently mixing your network stream with local loopback audio on the receiving end.
- Feeding in invalid silence data (for sound subsystems that need to be constantly fed with audio data).
- Not feeding in silence data when you should be.
精彩评论