Skip to content

Use sendspin built-in volume control for instant response#15

Merged
marcelveldt merged 2 commits intomusic-assistant:mainfrom
teancom:test/sw-vol-ctrl-local
Mar 2, 2026
Merged

Use sendspin built-in volume control for instant response#15
marcelveldt merged 2 commits intomusic-assistant:mainfrom
teancom:test/sw-vol-ctrl-local

Conversation

@teancom
Copy link
Copy Markdown
Contributor

@teancom teancom commented Feb 21, 2026

Replace the app-side SoftwareGainState (which applied gain before enqueue, causing ~2s latency) with sendspin's new GainControl that applies gain in the cpal output callback. Volume and mute changes now take effect instantly.

  • Add volume control mode setting (auto/hardware/software/disabled)
  • Add volume control UI to settings page
  • Remove software_gain.rs (now handled by sendspin)
  • Simplify playback thread: no more buffer mutation before enqueue

Depends on: Sendspin/sendspin-rs#10

NOTE: I tested this locally against the sendspin-rs in that PR but until that PR is merged, this code won't build. And even after, I'll need to update the Cargo.lock. So I'm marking this as DRAFT for now. But testing should be as easy as checking out the branch in the sendspin-rs PR, pointing the src-tauri/Cargo.toml to the local copy and building.

teancom and others added 2 commits February 25, 2026 10:03
Use sendspin's lock-free GainControl for software volume instead of
only supporting hardware (OS-level) volume. The player mode is
configurable in settings (hardware/software/disabled). Software mode
applies a perceptual gain curve in the audio callback for instant,
click-free response.

Key changes:
- Add volume mode setting (hardware/software/disabled) to settings UI
- Route volume/mute commands to SyncedPlayer when in software mode
- Track volume/mute state across player recreations (format changes)
- Always echo volume state back to server to prevent slider desync
- Pass initial volume/mute to SyncedPlayer constructor

Note: Cargo.toml temporarily points to local sendspin-rs path for
development. Will be switched back to git dependency before merge.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Guard volume_change_rx on Hardware mode only
- Extract build_volume_state_msg() and save_volume_state() helpers
- Consolidate redundant hardware volume reads at connection start
- Persist software volume and mute state across reconnects
- Add error handling with revert for volume mode changes in settings UI
- Add restart warning text for volume mode dropdown
- Log when volume commands are ignored in disabled mode
- Add settings tests for software_volume and muted fields

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@teancom teancom force-pushed the test/sw-vol-ctrl-local branch from 709428d to d6c9d00 Compare February 27, 2026 03:25
@teancom
Copy link
Copy Markdown
Contributor Author

teancom commented Feb 27, 2026

Alright! I've been testing and iterating on this, along with Sendspin-rs changes, for a few days. The Sendspin-rs PR was merged and is available to build against now. I would love some feedback, if anyone has a chance to review this.

@teancom teancom marked this pull request as ready for review February 27, 2026 03:49
Copy link
Copy Markdown
Member

@marcelveldt marcelveldt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @teancom !

@marcelveldt marcelveldt merged commit ec3d69f into music-assistant:main Mar 2, 2026
1 check passed
@marcelveldt marcelveldt changed the title feat: use sendspin built-in volume control for instant response Use sendspin built-in volume control for instant response Mar 2, 2026
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

Successfully merging this pull request may close these issues.

2 participants