blaa / WaveSync

Multi-room synchronised audio playback over shaky network connections and cheap (rasbperry pi) hardware.
MIT License
64 stars 13 forks source link

Configuration steps #11

Open tgsavs69 opened 3 years ago

tgsavs69 commented 3 years ago

Hello,

I want to use your project for a personal project but I struggle to configure the pulseaudio properly.

I tried to create a virtual sink and to output the audio from vlc to this sink then run your code but all I could get was about 1 sec of playtime at the beginning then it is silence. Can you provide me further assistance how to properly configure the pulseaudio?

What I plan to do is to have to raspberries (1 sender and 1 receiver). The communication should be unicast because I don't want to receive anything from receiver. I tried to follow your instruction and I suppose that the problem is how I configure the pulseaudio.

Thanks

blaa commented 3 years ago

Hello, it general configuration is not really complicated, but maybe there's something else that's problematic.

On sender: that's a source I use: load-module module-simple-protocol-unix rate=44100 format=s16le channels=2 playback=true sink=0 socket=/tmp/music.sink

But also my pulseaudio does not PLAY by itself, ie. I've removed the module-udev-detect, so the pulseaudio doesn't hog the sound card.

It's the wavesync sender that receives audio over pipe and plays and transmits.

Drop me a note if that helped, or include your pulseaudio config.

Receiver:

Some comments below,

Hello,

I want to use your project for a personal project but I struggle to configure the pulseaudio properly.

I tried to create a virtual sink and to output the audio from vlc to this sink then run your code but all I could get was about 1 sec of playtime at the beginning then it is silence. Can you provide me further assistance how to properly configure the pulseaudio?

What I plan to do is to have to raspberries (1 sender and 1 receiver). The communication should be unicast because I don't want to receive anything from receiver. I tried to follow your instruction and I suppose that the problem is how I configure the pulseaudio.

Which raspberry version?

If it doesn't work completely - you can try using snapserver which I heard is useable.

Cheers,

-- Tomasz bla Fortuna pgp: C009FC9BD59B22FE @ pgp.mit.edu www: http://bla.thera.be

tgsavs69 commented 3 years ago

Hello, First of all, thank you for the very fast reply! Much appreciated!

I tried this line: load-module module-simple-protocol-unix rate=44100 format=s16le channels=2 playback=true sink=0 socket=/tmp/music.sink but it seems that it blocks somehow the wavesync because when i run wavesync --tx /tmp/sink i don't receive any output from it. If I change from playback to record it seems to work again.

I attached the content of the default.pa below. default.pa.txt

Thanks!

blaa commented 3 years ago

tgsavs69 notifications@github.com writes:

Hello,

Thank you for the fast reply. Much appreciated. Currently, i can't test what you suggested because the ntp is broken and ntptime always returns error code 5 ntp_gettime() returns code 5 (ERROR) time e3bd6cf0.99dd4000 Thu, Jan 28 2021 19:03:44.601, (.601032), maximum error 16000000 us, estimated error 16000000 us, TAI offset 0 ntp_adjtime() returns code 5 (ERROR) modes 0x0 (), offset 0.000 us, frequency 0.000 ppm, interval 1 s, maximum error 16000000 us, estimated error 16000000 us, status 0x41 (PLL,UNSYNC), time constant 7, precision 1.000 us, tolerance 500 ppm,

Both raspberries are 4 with 1Gb and 2Gb ram.

I haven't tested on 4, but it should be a way better than on earlier models though. Recently (heh, last year) I've tried to redo most of wavesync for some really bad devices (cubie board 1), but failed to do it much better then it worked.

Unsure how to help you with ntp. You can either set both to the same source, or even default servers on the Internet. This should mostly just work.

Or, simply point one to the other and alter config to allow remote queries, but you'd have to allow in in /etc/ntp.conf I guess: restrict default limited kod nomodify notrap nopeer noquery according to http://support.ntp.org/bin/view/Support/AccessRestrictions#Section_6.5.1.1.3.

Something with the "restrict" though. ;) And add server on the other one.

If debugging, except for ntptime command you can try ntpq and pe/as.

I don't remember what I've wrote in the readme and what not.

Good luck, Cheers

Thanks!

-- Tomasz bla Fortuna pgp: C009FC9BD59B22FE @ pgp.mit.edu www: http://bla.thera.be

tgsavs69 commented 3 years ago

Hello,

I was able to somehow run both wavesync tx and rx. The sound quality is good but unfortunately they are not in sync. I tried to use --sink-latency but for every value i use, the receiver drops all packages. I tried --sink-latency from 1 to 1000 but same result. The ntptime estimated error for both Raspberries is below 2200 us. I have attached the output: output.txt

Also, do you have any idea how to fix the warning/error from the beginning of the file?

Thanks!

blaa commented 3 years ago

tgsavs69 notifications@github.com writes:

Hello,

I was able to somehow run both wavesync tx and rx. The sound quality is good but unfortunately they are not in sync. I tried to use --sink-latency but for every value i use, the receiver drops all packages. I tried --sink-latency from 1 to 1000 but same result. I have attached the output: output.txt

Try using the sink-latency only if you get the audio pretty synced, yet in consistent way one is faster than the other. Ensure first that the NTP is OK.

Your delay is really rather high. You've got a version from the PyPI (installed with pip) or from the github?

There was a bug that the sink-latency was in seconds, and not in milliseconds. This really broke a lot of things when used. I could fix it probably on sunday on PyPI. Haven't touched it for ages and I don't remember. 0.01 won't work as argument on pypi version though.

I guess that's here in chunk_player.py: desired_time = mark - self.audio_config.sink_latency_ms it should be _s instead of _ms

PyPI doesn't have the fix as I see.

Also - when increasing the sink-latency much, make sure the general --latency is increased as well. Wavesync can only correct the sync-latency within the bounds of the global delay.

My guess is that in your version the sink-latency is in seconds, and the latency is 1 second and hence - receiver drops everything.

So, back to beginnings: When not using sink-latency, how much the audio is not in sync? Is it consistently lagging? Is the NTP currently happy? Have you got something complicated as output device or just a speaker?

Also, do you have any idea how to fix the warning/error from the beginning of the file? The Alsa logs are happening in the lib. Also, it's trying to connect to jack and can't - thats still ok.

Thanks!

Hope it helps a bit. ;-)

-- Tomasz bla Fortuna pgp: C009FC9BD59B22FE @ pgp.mit.edu www: http://bla.thera.be

tgsavs69 commented 3 years ago

Hello,

Yes, I installed wavesync from the pip.

The delay is between 500ms to 1s I can't remember properly but it is really obvious. The NTP seems to be all good now (estimated error is below 2100 us for both Raspberries). The output for both devices is the built in sound card.

Everytime i started a new .mp3, it was already desync from the beginning. The connection between both devices is via cable (with avg ping time about 0.2ms). I will try tomorrow the version from the github, maybe the syncronization is better.

Thank you for your help and great work tho! Keep it up mate!