Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WASAPI multi-channel microphone input #96947

Closed
wants to merge 7 commits into from

Conversation

SleeeepyZhou
Copy link

@SleeeepyZhou SleeeepyZhou commented Sep 13, 2024

Support multi-channel microphone input by downmixing to stereo

  • Enhanced the WASAPI audio driver to support microphones with any number of channels.
  • This modification ensures compatibility with a broader range of multi-channel microphones, allowing for more versatile input handling in Godot.
  • Regarding “WASAPI: unsupported channel count in microphone!” error.

Fix #82823
Fix #30313
Related issues

I tried compiling and testing the four channel microphone on my laptop, and it turned out to be error free. This enables the successful use of multi-channel microphones in Godot.

Thank you for reviewing !

Support multi-channel microphone input by downmixing to stereo
- Enhanced the WASAPI audio driver to support microphones with any number of channels.
- This modification ensures compatibility with a broader range of multi-channel microphones, allowing for more versatile input handling in Godot.
Regarding “WASAPI: unsupported channel count in microphone!” error.
@SleeeepyZhou SleeeepyZhou requested a review from a team as a code owner September 13, 2024 06:17
@Chaosus Chaosus added this to the 4.4 milestone Sep 13, 2024
@akien-mga
Copy link
Member

Thanks for opening your first Godot PR!

For information, the audio area in Godot doesn't have a dedicated maintainer right now, so it might take some time to assess. That being said the changes seem fairly straightfoward and fixing long standing issues so I think with some testing from Windows users with multi-channel microphones, it should be easy enough to approve and merge.

@akien-mga akien-mga requested a review from a team September 13, 2024 06:49
drivers/wasapi/audio_driver_wasapi.cpp Outdated Show resolved Hide resolved
l += sample;
}
}
int32_t last_sample = read_sample(ad->audio_input.format_tag, ad->audio_input.bits_per_sample, data, j * channels + (channels - 1));
Copy link
Member

Choose a reason for hiding this comment

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

Can input have the odd number of channels at all (the assumption here seems to be L,R,Center channel config)?
Also, do this odd/even channel distribution to left/right always holds (is defined somewhere in the WASAPI documented, or based on specific mic sample)?

Copy link
Author

Choose a reason for hiding this comment

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

I made the assumption that the microphone might have a potential configuration with odd channels (e.g., Left, Right, Center), although such configurations are uncommon (in some professional audio equipment). The goal was to ensure that the microphone is at least usable within Godot, regardless of the channel count. The WASAPI documentation itself doesn't explicitly specify how multi-channel microphones should be handled, so I aimed for a more general solution to accommodate various configurations.

@SleeeepyZhou SleeeepyZhou requested a review from bruvzg September 13, 2024 08:54
@SleeeepyZhou
Copy link
Author

I apologize for the inconvenience caused by the multiple review requests. Due to my unfamiliarity with the process, I made several revisions which have led to some wasted time. I have now reviewed and confirmed that everything is correct.
Thank you for your understanding and patience. 🥲

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants