Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Common question to clarify best practice for "audio synchronization" (between owntone and clients) #1635

Closed
ffatgit opened this issue Aug 6, 2023 · 3 comments

Comments

@ffatgit
Copy link

ffatgit commented Aug 6, 2023

Hello Folks,

could you explain the best practice (and the basic behind) for "audio synchronization".
Call it "multiroom-audio", "buffering", "delay", "response", "time-ticks", in the end it means accurate playback on different output devices / instances without for (humans) audible difference in the position of the playback track or stream.
Where is the difference between shairport-sync in Airplay 1 and Airplay 2 mode connected to owntone?

Devices included (in my goal setup):
"Sender / Transmitter":

  • owntone-server
    "Receiver / Client"
  • Airplay 1 (=AP1 Protocol) and Airplay 2 (=AP2 Protocl) devices
  • Shairport-Sync (=AP1 Protocol and AP2 Protocol)
  • Chromecast

I read in the owntone documentation and over several "issues", but I'm pretty sure, I don't understand "at which time (combinations)", "what (and in deep WHAT)" is todo.

Test setup as follows:
owntone (on RPI 3B+, Raspberry Pi OS Lite "based on Debian "bullseye", Openmediavault 6, Linuxserver.IO docker "daapd")

  • local output to either RPI Headphones or active Speaker connected via USB = working!
    shairport-sync (in Airplay 2 mode, on RPI2B+ V1.1, DietPi OS V8.20 based Debian "bookworm")
  • output to RPI Headphones = working!

Result
Not in synchronization for round about 0,5s to 1,0s (based on my hearing, feeling).
If I send audio from a MacBook to the shairport-sync client, these two are in harmony = sync (no audible difference).

I'm thankful for hint to start for my test setup.

But in a common view it would be helpful (for more people on planet earth) if the documentation could more "clearer" to this item.
The documentation has a status that other projects would be proud of ✔️
But here and there it could be extend.
I loved to see a section of "sync" as the "alsa" section is (with the concrete/detailed examples) .

By the way a proposal for a addition of the "Chromecast" section with the information of the "issue" #1516.

Quote from the "issue" to Chromecast:
#1516

"You can use the "offset_ms" setting to control when your CC starts. You can set it in the config file like this:

chromecast "My Speaker" {
offset_ms = 123
}"

Thank you in forward!

@ejurgensen
Copy link
Member

Not totally sure what your question is, but I understand you would like to know how sync works?

With Airplay 1 and 2 it's basically that the speakers syncronize their internal clocks with OwnTone via ntp. This happens both when playback starts and during playback (to avoid drift). This should assure that they are in sync. Airplay 2 also supports ptp instead of ntp, but OwnTone doesn't support that (yet).

Then there is audio played locally - i.e. coming out of the audio jack. This is via alsa or pulseaudio. Owntone syncs this with what is played via Airplay (or would be, if no Airplay speaker is active). This is done by 1) delaying playback start to match Airplay, 2) adapting the sample rate to how quickly the sound card is consuming audio so it follows the internal clock. A bit complicated, but the bottom line is playback start can be out of sync in some cases so can be adjusted with offset_ms.

Finally the Chromecast implementation doesn't really have sync, meaning that Owntone can't do any adjustment if the speaker is slow or fast. Owntone also doesn't know exactly when it starts, so the default is a best guess, but can be adjusted with the per speaker offset_ms config option.

Btw I removed the log, since it didn't contain anything of relevance.

@ffatgit
Copy link
Author

ffatgit commented Aug 7, 2023

Hello @ejurgensen,

thank you for the information / explaining and yes you understood my main part of the question.
And if I understand you right, in a use case of owntone and shairport-sync, in both modes of shairport-sync (AP1 and AP2) there should be a sync (without any audible difference)?!
Or is one mode to prefer?

by the way (for other newbies as me):
NTP = Network Time Protocol
https://en.wikipedia.org/wiki/Network_Time_Protocol
PTP = Precision Time Protocol
https://en.wikipedia.org/wiki/Precision_Time_Protocol

Second part of my "issue" is a friendly request to extend the documentation with examples of "device constellation" and actions / config adjustment to make (similar to the very good section "output/alsa")

Thank you in forward!

@ejurgensen
Copy link
Member

And if I understand you right, in a use case of owntone and shairport-sync, in both modes of shairport-sync (AP1 and AP2) there should be a sync (without any audible difference)?! Or is one mode to prefer?

You can only use AP1 with shairport-sync, since its AP2 mode requires ptp, and OwnTone doesn't support that. But it wouldn't make a difference with regard to sync anyway. The advantages of AP2 with OwnTone as source is mostly just lower bandwidth consumption.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants