Add AudioDevice.volume_percent property (percentage based master volume)#109
Merged
AndreMiras merged 1 commit intoJul 19, 2026
Merged
Conversation
Convenience getter/setter exposing the master volume on the 0-100 scale the Windows volume mixer uses, wrapping Get/SetMasterVolumeLevelScalar so users don't reach for the decibel based SetMasterVolumeLevel by mistake. The setter clamps values to the valid range. Includes a runnable example, a unit test, and README/CHANGELOG updates. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Owner
|
Thanks for the contribution |
ahmetberber
added a commit
to ahmetberber/windows-apple-music-remote
that referenced
this pull request
Jul 19, 2026
…llback volume_percent (merged AndreMiras/pycaw#109) exposes the 0-100 master volume directly; use it when the installed pycaw provides it and fall back to the existing GetMasterVolumeLevelScalar()*100 path on older releases so the autostart server never crashes on an outdated pycaw. No behaviour change today (current PyPI pycaw 20251023 lacks the property); picks up the property automatically once a pycaw release ships it. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #13, where percentage based volume control was requested and a PR was invited — this adds it as a small convenience on
AudioDevice.What
AudioDevice.volume_percentproperty (getter/setter) exposing the master volume on the 0–100 scale the Windows volume mixer uses, wrappingGetMasterVolumeLevelScalar()/SetMasterVolumeLevelScalar(). The setter clamps out-of-range values.examples/master_volume_percent_example.py— runnable example (reads, sets to 50 %, restores).Why
The dB based
SetMasterVolumeLevel()vs. scalar confusion is a recurring stumbling block for pycaw users (see #13); a discoverablevolume_percentnext toEndpointVolumemakes the common case obvious without changing any existing API.Verification
Tested on Windows 11, Python 3.12.10, real hardware (TOPPING USB DAC):
tests/test_core.py— 5 passed (including the newtest_volume_percent).black/isort/flake8clean on the touched files.🤖 Generated with Claude Code