feat(audio): play the DualSense speaker and vibration ports on its USB sound card #180

Merged
oneandonlydean merged 1 commit from upstream-pr/180 into main 2026-09-30 18:35:16 +00:00
oneandonlydean commented 2026-09-30 11:47:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-09-30T11:47:42Z.


What

A title can open AudioOut2 ports of type 0x3 and 0x6 next to its bed and object ports. AudioOut2MixPorts folded them into the TV mix like any other port. In PPSA21564 their grains show what they carry: type 0x6 (stereo) holds short bursts with 95% of their energy below 200 Hz, fired by menu moves and confirms, which are the DualSense's two voice-coil actuators; type 0x3 (mono) holds small UI effects at the same moments, which is the controller's speaker. So the haptics came out of the PC speakers as low thumps and the controller got nothing.

A USB DualSense is also a 4-channel 48 kHz sound card: channels 1-2 feed the speaker and headset jack, channels 3-4 the left and right actuators.

  • AudioOut2PadMix holds the routing: AudioOut2RouteForPort sends 1- and 2-channel ports of type 0x3 to the speaker and of type 0x6 to the actuators; every other type and channel count stays in the main mix. A mono speaker port feeds both speaker channels, and the vibration port's left and right channels drive channels 3 and 4, at the port volumes. The pad mix is clamped to full scale (no master gain: each channel carries one port).
  • When SDL lists an audio device whose name contains "DualSense" and that reports 4 channels, a context with such ports opens it and queues the pad mix on it with every push, and those ports leave the main mix. The card's queue gets the main queue's silence cushion when it runs dry and drops grains that run more than two grains beyond the main queue, so the controller keeps pace with the TV. An unplugged card is closed (its ports return to the main mix) and looked for again every 2 s. Without a card nothing changes.
  • SDL2's PulseAudio backend labels a 4-channel stream FL FR FC LFE instead of quad, and the sound server then folds channels 3-4 into the speaker (measured on the card's monitor: a tone on channel 3 came out on channels 1 and 2 at -3 dB). Under that backend the card is opened as 5.1 with FC and LFE silent and the actuators on the back pair, which lands on the card's RL/RR. Other backends take quad as it is.

The meaning of the two port types comes from PPSA21564's audio content, not from an SDK header. On Windows the DualSense's audio endpoint is not named after the controller, so it is not found there and nothing changes.

Tested

  • Linux (CachyOS, RTX 4090): new ctest audio_out2_pad_mix covers the routing table, the device name match, the speaker and vibration channel mapping with per-channel volumes, summing and clamping, the refusal of a port that does not play on the controller, and the quad and PulseAudio frame layouts. Main has no pad routing, so the test does not build there.
  • The card itself needs a controller. Exercised in PPSA21564 on our integration branch with a USB DualSense: on the card's monitor, channels 3-4 carried the vibration port bit-exactly (gain 1.000, residual -83 dB) and channels 1-2 the speaker port; the TV mix no longer contains either port.
  • ctest: 65/65 pass (64 plus the new audio_out2_pad_mix).

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source (none added)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4690037615 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/180). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-09-30T11:47:42Z. --- ### What A title can open AudioOut2 ports of type 0x3 and 0x6 next to its bed and object ports. `AudioOut2MixPorts` folded them into the TV mix like any other port. In PPSA21564 their grains show what they carry: type 0x6 (stereo) holds short bursts with 95% of their energy below 200 Hz, fired by menu moves and confirms, which are the DualSense's two voice-coil actuators; type 0x3 (mono) holds small UI effects at the same moments, which is the controller's speaker. So the haptics came out of the PC speakers as low thumps and the controller got nothing. A USB DualSense is also a 4-channel 48 kHz sound card: channels 1-2 feed the speaker and headset jack, channels 3-4 the left and right actuators. - `AudioOut2PadMix` holds the routing: `AudioOut2RouteForPort` sends 1- and 2-channel ports of type 0x3 to the speaker and of type 0x6 to the actuators; every other type and channel count stays in the main mix. A mono speaker port feeds both speaker channels, and the vibration port's left and right channels drive channels 3 and 4, at the port volumes. The pad mix is clamped to full scale (no master gain: each channel carries one port). - When SDL lists an audio device whose name contains "DualSense" and that reports 4 channels, a context with such ports opens it and queues the pad mix on it with every push, and those ports leave the main mix. The card's queue gets the main queue's silence cushion when it runs dry and drops grains that run more than two grains beyond the main queue, so the controller keeps pace with the TV. An unplugged card is closed (its ports return to the main mix) and looked for again every 2 s. Without a card nothing changes. - SDL2's PulseAudio backend labels a 4-channel stream FL FR FC LFE instead of quad, and the sound server then folds channels 3-4 into the speaker (measured on the card's monitor: a tone on channel 3 came out on channels 1 and 2 at -3 dB). Under that backend the card is opened as 5.1 with FC and LFE silent and the actuators on the back pair, which lands on the card's RL/RR. Other backends take quad as it is. The meaning of the two port types comes from PPSA21564's audio content, not from an SDK header. On Windows the DualSense's audio endpoint is not named after the controller, so it is not found there and nothing changes. ### Tested - Linux (CachyOS, RTX 4090): new ctest `audio_out2_pad_mix` covers the routing table, the device name match, the speaker and vibration channel mapping with per-channel volumes, summing and clamping, the refusal of a port that does not play on the controller, and the quad and PulseAudio frame layouts. Main has no pad routing, so the test does not build there. - The card itself needs a controller. Exercised in PPSA21564 on our integration branch with a USB DualSense: on the card's monitor, channels 3-4 carried the vibration port bit-exactly (gain 1.000, residual -83 dB) and channels 1-2 the speaker port; the TV mix no longer contains either port. - `ctest`: 65/65 pass (64 plus the new `audio_out2_pad_mix`). ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in TechnicalDebt - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source (none added) - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!180
No description provided.