Skip to content

libobs, win-wasapi: Enable channel routing for Audio Input Capture#12942

Open
pkviet wants to merge 3 commits intoobsproject:masterfrom
pkviet:channelselect
Open

libobs, win-wasapi: Enable channel routing for Audio Input Capture#12942
pkviet wants to merge 3 commits intoobsproject:masterfrom
pkviet:channelselect

Conversation

@pkviet
Copy link
Copy Markdown
Member

@pkviet pkviet commented Dec 21, 2025

Description

On libobs side, this adds the capability for the audio resampler (relying on swresampler lib) to
set a matrix for routing of channels.
On win-wasapi side, this applies the new capability to enable channel selection.
This brings parity to wasapi input capture with coreaudio input capture on macOS.

Screenshots

obs64_2025-12-17_17-35-57 obs64_2025-12-17_17-36-14

Motivation and Context

One motivation for that feature are devices which separate stereo inputs.
So if a mike is connected to , say, Input 1 while nothing is connected to Input 2, wasapi usually treats them as
stereo pairs and when obs audio is set to Stereo, the captured Right channel will be silent.
With channel routing capability, it is now possible to duplicate the left channel to the right and have a consistent level.
The issue was brought to my attention by @Fenrirthviti

How Has This Been Tested?

Tested on windows 11 pro 25H2 w/ a logitech webcam + USB sound board.
Disabling the downmix cehckbox enables channel routing.
Swapping between devices resets the channel selections.
Changing the channel selections updates the captured channel.

Types of changes

  • New feature (non-breaking change which adds functionality)

Checklist:

  • My code has been run through clang-format.
  • I have read the contributing document.
  • My code is not on the master branch.
  • The code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.

@pkviet pkviet added Seeking Testers Build artifacts on CI platform/windows Categorizes issue or PR as affecting Windows specifically kind/feature Functionality or other elements that the project doesn't currently have. labels Dec 21, 2025
@pkviet pkviet added this to the OBS Studio 32.1 milestone Dec 21, 2025
Copy link
Copy Markdown
Member

@PatTheMav PatTheMav left a comment

Choose a reason for hiding this comment

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

Looks fine to me overall, also tested this with an virtual 6-ch audio device and allowed me to map them as expected.

Haven't done in-depth checks whether the audio is correctly routed though.

Comment thread plugins/win-wasapi/win-wasapi.cpp Outdated
Comment thread plugins/win-wasapi/win-wasapi.cpp Outdated
Comment thread plugins/win-wasapi/win-wasapi.cpp Outdated
@pkviet pkviet force-pushed the channelselect branch 2 times, most recently from b044cb4 to 0922dcc Compare January 16, 2026 14:15
@RytoEX RytoEX removed this from the OBS Studio 32.1 milestone Jan 16, 2026
@psyirius
Copy link
Copy Markdown
Contributor

Just wondering,
Why don't we have speaker-layout selection like obs-asio has?

image

@psyirius
Copy link
Copy Markdown
Contributor

Just built this pr from the current master.
Can't able to select channels in the channel comboboxes.

@pkviet
Copy link
Copy Markdown
Member Author

pkviet commented Feb 19, 2026

Just built this pr from the current master. Can't able to select channels in the channel comboboxes.

yes there was a regression but it is fixed with last push

@pkviet
Copy link
Copy Markdown
Member Author

pkviet commented Feb 19, 2026

Just wondering, Why don't we have speaker-layout selection like obs-asio has?

Because I want to avoid an uncontrolled upmix or downmix.
In obs-asio , if the input audio format differs from obs format (set in Settings > Audio), there is automatically an swresampler called in the audio pipeline which will make the conversion. The channel weights are sane only for the most common conversions (xxx ==> stereo, stereo ===> xxx ) as stated explicitly by the swresampler API. There can be surprising defaults with odd channel volumes otherwise.
There is no conversion though if the input speaker format is the same that is set in obs settings.
Channel routing is imo an advanced feature for people who want fine grained audio control; so the uncontrolled upmixer/downmixer insertion defeats that purpose and that is why I have avoided that here, very deliberately.

@Warchamp7 Warchamp7 added this to the OBS Studio 32.2 milestone May 6, 2026
Copy link
Copy Markdown
Member

@RytoEX RytoEX left a comment

Choose a reason for hiding this comment

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

cc @Warchamp7 on brace changes. If needed, we can just update all of these in the clang-format PR, but we will soon be requiring and enforcing braces for all control statements in C++.

Comment thread plugins/mac-capture/data/locale/en-US.ini Outdated
Comment thread plugins/win-wasapi/data/locale/en-US.ini Outdated
Comment thread plugins/win-wasapi/win-wasapi.cpp Outdated
Comment thread plugins/win-wasapi/win-wasapi.cpp Outdated
Comment thread plugins/win-wasapi/win-wasapi.cpp Outdated
Comment thread plugins/win-wasapi/win-wasapi.cpp Outdated
Comment thread plugins/win-wasapi/win-wasapi.cpp Outdated
Comment thread plugins/win-wasapi/win-wasapi.cpp Outdated
Comment thread plugins/win-wasapi/win-wasapi.cpp Outdated
Comment thread plugins/win-wasapi/win-wasapi.cpp Outdated
@pkviet pkviet force-pushed the channelselect branch 4 times, most recently from 07c9cb1 to cb66f5a Compare May 7, 2026 21:18
Copy link
Copy Markdown
Member

@Warchamp7 Warchamp7 left a comment

Choose a reason for hiding this comment

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

A couple bits of feedback and some questions.

Can we invert the checkbox?
i.e. Unchecked by default, and the label is instead "Enable custom channel routing"


When Device is set to Default the channel selection dropdowns are missing a device name and simply say channel 1, etc.

Image

Ideally the actual device name should be used in the device channel dropdowns and not just Default.


At time of review, wasapi output devices don't appear to be working:

17:18:30.101: [win-wasapi: 'Audio Output Capture'] update settings:
17:18:30.101: 	device id: {0.0.0.00000000}.{825bd69f-078a-481c-831c-eda29a7002bb}
17:18:30.101: 	use device timing: 1
17:18:30.108: Device 'Speakers (Scarlett 2i2 4th Gen)' invalidated.  Retrying (source: Audio Output Capture)
17:18:30.118: warning: Input channel layout "" is invalid or unsupported.
17:18:30.118: avresample_open failed: error code -22
17:18:30.118: WASAPI: Device 'Speakers (Realtek USB2.0 Audio)' [48000 Hz] initialized (source: Audio Output Capture)```

@pkviet
Copy link
Copy Markdown
Member Author

pkviet commented May 7, 2026

A couple bits of feedback and some questions.

Can we invert the checkbox? i.e. Unchecked by default, and the label is instead "Enable custom channel routing"

This can be done, but this means wasapi would not be aligned with core audio where the feature was first implemented.

When Device is set to Default the channel selection dropdowns are missing a device name and simply say channel 1, etc.
Ideally the actual device name should be used in the device channel dropdowns and not just Default.

Ok I will add the logic for that.

At time of review, wasapi output devices don't appear to be working:

Indeed. My scope was to bring parity to wasapi with coreaudio.
I didn't consider Audio Output Capture.
I'll investigate the extent of changes that would be required for that and either add that or defer to another PR.

@Warchamp7
Copy link
Copy Markdown
Member

A couple bits of feedback and some questions.
Can we invert the checkbox? i.e. Unchecked by default, and the label is instead "Enable custom channel routing"

This can be done, but this means wasapi would not be aligned with core audio where the feature was first implemented.

I'd like to update core audio to match that as well then. It can be a separate PR though.

@Warchamp7 Warchamp7 self-assigned this May 7, 2026
@pkviet
Copy link
Copy Markdown
Member Author

pkviet commented May 8, 2026

Update
Addressed @Warchamp7 comments.

  1. Changed UI so that the checkbox now enables channel routing ; checkbox unchecked:
obs64_pZWnelHwtl

checkbox checked:
obs64_IiMGxFsxQn

  1. Default device now displays the device name in channels list:
obs64_ZVGYtk3YO9
  1. Fixed the issue where Audio Output Capture wouldn't capture anymore.

Comment thread plugins/win-wasapi/data/locale/en-US.ini Outdated
pkviet added 3 commits May 8, 2026 22:38
This adds a function allowing to set a custom channel matrix, allowing
channel rerouting. This is useful when sources provide layouts not
supported by obs or to correct incorrect channel assignments.

Signed-off-by: pkv <pkv@obsproject.com>
This adds a hint for the 'downmix' checkbox.
It is likely unclear to users what this checkbox does or does not.
When disabled, it allows channel selection; when enabled it lets obs
deal with speaker layout mismatches between source and obs.

Signed-off-by: pkv <pkv@obsproject.com>
This adds the capability to select input channels exposed to obs.
(The same is already possible for coreaudio input sources.)

Signed-off-by: pkv <pkv@obsproject.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/feature Functionality or other elements that the project doesn't currently have. platform/windows Categorizes issue or PR as affecting Windows specifically Seeking Testers Build artifacts on CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants