Skip to content

usb_audio.USBSpeaker: Speaker audio does not adjust based on Windows volume slider/mute. #11302

Description

@jbirchall-svg

CircuitPython version and board name

Adafruit CircuitPython 10.3.0-alpha.4; Adafruit QT Py RP2040 with rp2040

Code/REPL

# in boot.py
import usb_audio
usb_audio.enable(speaker=True, microphone=False)

Behavior

The device correctly registers to Windows 11 Pro 25H2 as a CircuitPython Speaker but adjusting the master volume slider or muting it at the Windows level has no effect on the audio.

Description

No response

Additional information

AI Analysis (Cursor Grok 4.6)

Windows volume does nothing because USBSpeaker claims hardware volume, then never applies it.

The taskbar slider and keyboard volume keys are endpoint volume. On a USB Audio Class 2 speaker, Windows treats that as a hardware Feature Unit control: it sends full-scale PCM and a SET_CUR volume/mute request, and it does not insert a software volume APO.

CircuitPython does the first half of that contract and skips the second.

  1. The descriptor advertises a real volume control. The speaker Feature Unit marks mute and volume as read/write on master and both channels:

shared-module/usb_audio/init.c
Ln 173–174
/* Feature Unit Descriptor(4.7.2.8) */
TUD_AUDIO20_DESC_FEATURE_UNIT(..., AUDIO20_CTRL_RW << MUTE | AUDIO20_CTRL_RW << VOLUME, ...)
Windows therefore binds the system slider to hardware and will not attenuate the stream itself.

  1. Firmware stores the host’s volume, then ignores it. tud_audio_set_req_entity_cb writes usb_audio_mute[] / usb_audio_volume[]. Those arrays are only read back for GET_CUR / GET_RANGE. They are never used when samples are copied.

usb_audio_usbspeaker_background_drain() and usb_audio_usbspeaker_get_buffer() memcpy the USB PCM unchanged. There is no scale, no mute-to-zero, and USBSpeaker exposes no volume/mute property you could apply in Python.

So the slider moves (the SET_CUR succeeded) and the speaker stays at unity gain.

  1. That is why this is a Windows-specific complaint. macOS and Linux often still apply software volume in the host mixer. Windows does not, once a Feature Unit Volume control exists. Per-app sliders in Volume Mixer can still work, because those are session volumes applied before USB. System / keyboard volume cannot.

A firmware fix has to do one of these:

Apply it: scale (and mute) each sample from the per-channel Feature Unit values. Windows prefers channel 1/2 over master when both are advertised.

Stop claiming it: clear Volume/Mute from the Feature Unit so Windows inserts its software volume APO instead.
Until one of those lands, the host-side workaround is the same as for DACs that advertise volume and ignore it: force software attenuation (WinSoftVol, Equalizer APO, or the per-app mixer).

Delegate it: expose the audio channel mute and audio channel volume parameters from Windows and let other code decide what to do with it.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions