You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This probably needs a lot more work/adaptation to fit into the codebase properly! I just want to share the current state I have before I start my vacation.
Prerequisites
Mute your capturing device before starting (to avoid interference)
Have a chirp signal ready to play in Music Assistant (you can generate one using the included helper script)
This tool cannot reliably calibrate the CLI client itself, as microphone AEC will interfere with measurements
Calibration Steps
Start the calibrator:
sendspin --calibrate-sync --mic-device 0
Set up playback:
Sync your command-line player with another player
Mute the command-line player
Position your microphone:
Hold your device's microphone as close as possible to the other device's speaker
Minimizing distance reduces interference from room echoes
Capture the reference offset:
Start playback (preferably using a chirp signal)
Look for a single offset that stands out clearly in the histogram—this is your reference offset
Measure additional devices:
Stop playback on the first device
Repeat steps 2–4 for each additional device you want to calibrate
The difference between two devices' histogram peaks is their relative offset—adjust accordingly
Known Limitations
Sample rate: 48 kHz works better for capturing on some microphones (this is now the default throughout the codebase)
Microphone drift: Some mics drift over time. Internal laptop mics tend to be stable, but external mics (e.g., webcams) may drift ~1 ms every 30 seconds. No reliable compensation method has been found yet.
Offset accuracy: The reported offset isn't absolute—ADC latency isn't fully accounted for, and your device's mic latency may vary.
Debug logging: There are still many debug logs printing that need to be removed before merging. You typically don't see them because of the calibration UI covering it.
george@G-Thinkpad:~$ uvx --from git+https://github.com/Sendspin/sendsp
in-cli@sync-calibration sendspin --url ws://192.168.0.30:8927/sendspin
Updated https://github.com/Sendspin/sendspin-cli (1fe394be2c3ccd03
Built sendspin @ git+https://github.com/Sendspin/sendspin-cli@1f
Installed 29 packages in 163ms
Using client ID: sendspin-cli-G-Thinkpad
Traceback (most recent call last):
File "/home/george/.cache/uv/archive-v0/AkW1oSrZenvvfZPQgQITl/bin/sendspin", line 12, in <module>
sys.exit(main())
^^^^^^
File "/home/george/.cache/uv/archive-v0/AkW1oSrZenvvfZPQgQITl/lib/python3.12/site-packages/sendspin/cli.py", line 285, in main
return asyncio.run(app.run())
^^^^^^^^^^^^^^^^^^^^^^
File "/home/george/.local/share/uv/python/cpython-3.12.12-linux-x86_64-gnu/lib/python3.12/asyncio/runners.py", line 195, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "/home/george/.local/share/uv/python/cpython-3.12.12-linux-x86_64-gnu/lib/python3.12/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/george/.local/share/uv/python/cpython-3.12.12-linux-x86_64-gnu/lib/python3.12/asyncio/base_events.py", line 691, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/home/george/.cache/uv/archive-v0/AkW1oSrZenvvfZPQgQITl/lib/python3.12/site-packages/sendspin/app.py", line 576, in run
audio_device = resolve_audio_device(config.audio_device)
^^^^^^^^^^^^^^^^^^^^
NameError: name 'resolve_audio_device' is not defined
I tried using this with music rather than a test tone with not very much success:
Thanks for the rebase. I am continually get +0ms delay, even on devices I know are out of sync. Here's what I did.
I ran uvx --from git+https://github.com/Sendspin/sendspin-cli@sync-calibration sendspin --url ws://192.168.0.30:8927/sendspin --calibrate-sync --mic-device 0 on Windows Subsystem for Linux
I started a sendspin session with music assistant and set music to a variety of devices but all muted
I placed a VAPE against my laptop microphone and got a peak at +45ms on both histograms
I closed the cli and then ran uvx --from git+https://github.com/Sendspin/sendspin-cli@sync-calibration sendspin --url ws://192.168.0.30:8927/sendspin --calibrate-sync --mic-device 0 --static-delay 45 and got a peak at 0ms, so far so good. My CLI is calibrated against my VAPE
I then placed my laptop microphone against a variety of google home devices (making sure to mute other devices and my laptop) that I had tuned by ear and consistently got a peak at 0ms
I then turned the offset on one of my chromecast audio devices from -330 to 0 making it audibly out of sync and tried again. Again a peak at 0ms.
Note between testing each device I closed and re-opened the cli to clear the histogram.
I tried again with --static-delay 0 rather than 45 I confirmed that with the VAPE I was getting -45. However with other devices I was getting 0 again. I am going to try with a test tone next
The + and - is confusing, which direction is it in, and as is it the error or the correction that needs to be made?
In the end I found it was the latter. If the current set delay was -330 and the histogram showed -5 the -335 would bring the histogram to 0
Turn the speaker to the loudest volume you can bear and get the microphone as close to the speaker as possible
The difference between the two histograms was unclear, and sometimes they differed by 1ms
For stereo speakers - remove/mute one of them
Let go of the laptop/microphone
No need to reload the cli between devices, just give a bit of time with background noise to let the histograms fade into randomness
It was quite common to get a histogram with a very strong peak at lets say +6ms that would then, without intervention, slowly trend towards 0 over about 30 seconds- at which point I would satisfy myself that it was perfectly calibrated. Now as I write this I wonder if I should have kept on waiting and might have found some drift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This probably needs a lot more work/adaptation to fit into the codebase properly! I just want to share the current state I have before I start my vacation.
Prerequisites
Calibration Steps
Start the calibrator:
Set up playback:
Position your microphone:
Capture the reference offset:
Measure additional devices:
Known Limitations