Skip to content

WASAPI multi-channel microphone input #96947

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

Closed
wants to merge 32 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
047501c
WASAPI multi-channel microphone input
SleeeepyZhou Sep 13, 2024
880b066
Fix bugs
SleeeepyZhou Sep 13, 2024
b8c4040
Improve robustness
SleeeepyZhou Sep 13, 2024
ce41fc3
Fix bugs
SleeeepyZhou Sep 13, 2024
0d2f1e8
Fix initialization
SleeeepyZhou Sep 13, 2024
7d8b73c
Merge branch 'godotengine:master' into master
SleeeepyZhou Sep 14, 2024
d4ca15c
Merge branch 'godotengine:master' into master
SleeeepyZhou Sep 30, 2024
e93c7c3
Update README.md
SleeeepyZhou Sep 30, 2024
5f5f0ac
Replace icon
SleeeepyZhou Sep 30, 2024
1c1c4ff
Replace icon
SleeeepyZhou Sep 30, 2024
216efd4
Update README
SleeeepyZhou Sep 30, 2024
b98d639
Update README
SleeeepyZhou Sep 30, 2024
a806e92
Update inf
SleeeepyZhou Sep 30, 2024
492e9b5
Cat
SleeeepyZhou Sep 30, 2024
a15af16
Merge branch 'godotengine:master' into Main
SleeeepyZhou Oct 3, 2024
8a4665f
Merge branch 'godotengine:master' into Main
SleeeepyZhou Oct 4, 2024
1a1702a
New icon
SleeeepyZhou Oct 5, 2024
8b2105b
Merge branch 'godotengine:master' into Main
SleeeepyZhou Oct 5, 2024
2048838
icon
SleeeepyZhou Oct 5, 2024
41394dc
test
SleeeepyZhou Oct 5, 2024
4bafe64
test
SleeeepyZhou Oct 5, 2024
c59c615
Update and test
SleeeepyZhou Oct 6, 2024
591e185
Test
SleeeepyZhou Oct 9, 2024
079aa4f
Merge branch 'godotengine:master' into dev
SleeeepyZhou Oct 9, 2024
b84e915
Test
SleeeepyZhou Oct 9, 2024
488d421
Merge branch 'dev' of https://github.com/SleeeepyZhou/Maodot into dev
SleeeepyZhou Oct 9, 2024
bc108e7
test
SleeeepyZhou Oct 9, 2024
7fb850b
Clean
SleeeepyZhou Oct 9, 2024
5286be7
Icons
SleeeepyZhou Oct 11, 2024
85aa601
2024.10.13
SleeeepyZhou Oct 13, 2024
0517795
2024.10.13
SleeeepyZhou Oct 15, 2024
5a81510
Merge pull request #1 from SleeeepyZhou/dev
SleeeepyZhou Oct 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 36 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,71 +1,79 @@
# Godot Engine
# Maodot Engine

<p align="center">
<a href="https://godotengine.org">
<img src="logo_outlined.svg" width="400" alt="Godot Engine logo">
<img src="logo_outlined.png" width="400" alt="Godot Engine logo">
</a>
</p>

## All the reactionaries are the Papertiger

## Focused on game development ~~(and cat)~~

## No SB, No DEI, No Political Correctness

## 2D and 3D cross-platform game engine

**[Godot Engine](https://godotengine.org) is a feature-packed, cross-platform
**[Maodot Engine](https://redotengine.org) is a feature-packed, cross-platform
game engine to create 2D and 3D games from a unified interface.** It provides a
comprehensive set of [common tools](https://godotengine.org/features), so that
comprehensive set of common tools, so that
users can focus on making games without having to reinvent the wheel. Games can
be exported with one click to a number of platforms, including the major desktop
platforms (Linux, macOS, Windows), mobile platforms (Android, iOS), as well as
Web-based platforms and [consoles](https://docs.godotengine.org/en/latest/tutorials/platform/consoles.html).
Web-based platforms and consoles.

## Free, open source and community-driven

Godot is completely free and open source under the very permissive [MIT license](https://godotengine.org/license).
Maodot is a completely free and open source fork of Godot under the very permissive MIT license.
No strings attached, no royalties, nothing. The users' games are theirs, down
to the last line of engine code. Godot's development is fully independent and
to the last line of engine code. Maodot's development is fully independent and truly
community-driven, empowering users to help shape their engine to match their
expectations. It is supported by the [Godot Foundation](https://godot.foundation/)
not-for-profit.
expectations.

Before being open sourced in [February 2014](https://github.com/godotengine/godot/commit/0b806ee0fc9097fa7bda7ac0109191c9c5e0a1ac),
Godot had been developed by [Juan Linietsky](https://github.com/reduz) and
[Ariel Manzur](https://github.com/punto-) (both still maintaining the project)
[Ariel Manzur](https://github.com/punto-) (both still maintaining Godot)
for several years as an in-house engine, used to publish several work-for-hire
titles.

![Screenshot of a 3D scene in the Godot Engine editor](https://raw.githubusercontent.com/godotengine/godot-design/master/screenshots/editor_tps_demo_1920x1080.jpg)
Maodot was forked from Godot in [September 2024](https://github.com/Redot-Engine/redot-engine/commit/a12e9de5dd831e1ce0c839f0420b278ef0a6aa5b),
intending to improve upon Godot in order to fulfill its potential and contribute to the shared
codebase of both through a more genuinely community-driven model than Godot.

![Screenshot of a 3D scene in the Maodot Engine editor](https://raw.githubusercontent.com/godotengine/godot-design/master/screenshots/editor_tps_demo_1920x1080.jpg)

## Getting the engine

### Binary downloads

Official binaries for the Godot editor and the export templates can be found
[on the Godot website](https://godotengine.org/download).
Official binaries for the Maodot editor and the export templates will be found on the [GitHub page](https://github.com/SleeeepyZhou/Maodot) until then.

### Compiling from source

[See the official docs](https://docs.godotengine.org/en/latest/contributing/development/compiling)
[For the time being, see the official Godot docs](https://docs.godotengine.org/en/latest/contributing/development/compiling)
for compilation instructions for every supported platform.

## Community and contributing

Godot is not only an engine but an ever-growing community of users and engine
developers. The main community channels are listed [on the homepage](https://godotengine.org/community).

The best way to get in touch with the core engine developers is to join the
[Godot Contributors Chat](https://chat.godotengine.org).
Maodot is not only an engine but an ever-growing community of users and engine
developers. Please visit our [Discord server](https://discord.gg/redot)!

To get started contributing to the project, see the [contributing guide](CONTRIBUTING.md).
This document also includes guidelines for reporting bugs.

Follow [Maodot on Twitter](https://x.com/redotengine)!


## Documentation and demos

The official documentation is hosted on [Read the Docs](https://docs.godotengine.org).
It is maintained by the Godot community in its own [GitHub repository](https://github.com/godotengine/godot-docs).
It is maintained by the Maodot community in its own [GitHub repository](https://github.com/godotengine/godot-docs).

The [class reference](https://docs.godotengine.org/en/latest/classes/)
is also accessible from the Godot editor.
is also accessible from the Maodot editor.

We also maintain official demos in their own [GitHub repository](https://github.com/godotengine/godot-demo-projects)
as well as a list of [awesome Godot community resources](https://github.com/godotengine/awesome-godot).
as well as a list of [awesome Maodot community resources](https://github.com/godotengine/awesome-godot).

There are also a number of other
[learning resources](https://docs.godotengine.org/en/latest/community/tutorials.html)
Expand All @@ -76,3 +84,9 @@ for more information.
[![Code Triagers Badge](https://www.codetriage.com/godotengine/godot/badges/users.svg)](https://www.codetriage.com/godotengine/godot)
[![Translate on Weblate](https://hosted.weblate.org/widgets/godot-engine/-/godot/svg-badge.svg)](https://hosted.weblate.org/engage/godot-engine/?utm_source=widget)
[![TODOs](https://badgen.net/https/api.tickgit.com/badgen/github.com/godotengine/godot)](https://www.tickgit.com/browse?repo=github.com/godotengine/godot)






3 changes: 2 additions & 1 deletion SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ opts.Add(BoolVariable("werror", "Treat compiler warnings as errors", False))
opts.Add("extra_suffix", "Custom extra suffix added to the base filename of all generated binary files", "")
opts.Add("object_prefix", "Custom prefix added to the base filename of all generated object files", "")
opts.Add(BoolVariable("vsproj", "Generate a Visual Studio solution", False))
opts.Add("vsproj_name", "Name of the Visual Studio solution", "godot")
opts.Add("vsproj_name", "Name of the Visual Studio solution", "maodot")
opts.Add("import_env_vars", "A comma-separated list of environment variables to copy from the outer environment.", "")
opts.Add(BoolVariable("disable_3d", "Disable 3D nodes for a smaller executable", False))
opts.Add(BoolVariable("disable_advanced_gui", "Disable advanced GUI nodes and behaviors", False))
Expand All @@ -274,6 +274,7 @@ opts.Add(BoolVariable("engine_update_check", "Enable engine update checks in the
opts.Add(BoolVariable("steamapi", "Enable minimal SteamAPI integration for usage time tracking (editor only)", False))

# Thirdparty libraries
opts.Add(BoolVariable("builtin_aisuite", "Use the built-in AIsuit library", True))
opts.Add(BoolVariable("builtin_brotli", "Use the built-in Brotli library", True))
opts.Add(BoolVariable("builtin_certs", "Use the built-in SSL certificates bundles", True))
opts.Add(BoolVariable("builtin_clipper2", "Use the built-in Clipper2 library", True))
Expand Down
25 changes: 24 additions & 1 deletion drivers/wasapi/audio_driver_wasapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@ void AudioDriverWASAPI::thread_func(void *p_udata) {

// fixme: Only works for floating point atm
for (UINT32 j = 0; j < num_frames_available; j++) {
int32_t l, r;
int32_t l = 0, r = 0;

if (flags & AUDCLNT_BUFFERFLAGS_SILENT) {
l = r = 0;
Expand All @@ -859,6 +859,29 @@ void AudioDriverWASAPI::thread_func(void *p_udata) {
r = read_sample(ad->audio_input.format_tag, ad->audio_input.bits_per_sample, data, j * 2 + 1);
} else if (ad->audio_input.channels == 1) {
l = r = read_sample(ad->audio_input.format_tag, ad->audio_input.bits_per_sample, data, j);
} else if (ad->audio_input.channels > 2) {
int64_t ltemp = 0, rtemp = 0;
int channels = ad->audio_input.channels;
for (int ch = 0; ch < channels - 1; ch++) {
int32_t sample = read_sample(ad->audio_input.format_tag, ad->audio_input.bits_per_sample, data, j * channels + ch);
if (ch % 2 == 0) {
rtemp += sample;
} else {
ltemp += 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.

r += last_sample;
if (channels % 2 != 0) {
ltemp += last_sample;
ltemp /= ((channels + 1) / 2);
rtemp /= ((channels + 1) / 2);
} else {
ltemp /= (channels / 2);
rtemp /= (channels / 2);
}
l = static_cast<int32_t>(ltemp);
r = static_cast<int32_t>(rtemp);
} else {
l = r = 0;
ERR_PRINT("WASAPI: unsupported channel count in microphone!");
Expand Down
Loading
Loading