-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
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
Fix Capture and Record AudioEffect bugs for surround systems #92532
base: master
Are you sure you want to change the base?
Conversation
servers/audio/audio_effect.h
Outdated
@@ -47,6 +47,7 @@ class AudioEffectInstance : public RefCounted { | |||
public: | |||
virtual void process(const AudioFrame *p_src_frames, AudioFrame *p_dst_frames, int p_frame_count); | |||
virtual bool process_silence() const; | |||
virtual void set_current_channel(int p_channel) {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
virtual void set_current_channel(int p_channel) {}; | |
virtual void set_current_channel(int p_channel) {} |
For format check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. Also added virtual
to compressor and capture set_current_channel
(I received email suggestions for these, but don't see them on github). I didn't add it to record as its set_current_channel
is a bit more nuanced, and if someone wants to override it, they can refactor it at that time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We always add both, not adding it won't stop overriding later you need final
for that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough.
3dca84f
to
c3f8750
Compare
Is anyone able to take a look at this? I can appreciate it might be hard to test without an affected audio setup. I have a (crude) change to the Audio Dummy Driver that could help with testing, if the audio setup is too much of an issue. The change just exposes the speaker mode as a configurable parameter when the dummy driver is active in the editor. |
Letting the tests run. |
I have a game where the entire gameplay is recording and playing back audio via AudioEffectRecord from players' microphones, and many players have reported that the recording doesn't work. Input is working, because they can hear themselves when the bus isn't muted and AudioEffectSpectrumAnalyzer works just fine. Only the recording is failing. Do you think my game's issue could also be due to the bug you describe? If so, what's the best way to try out your fix in my version of Godot? Apologies, I'm unfamiliar with both Github and how to change the Godot Engine's own code. |
I'm also experiencing this - as long as the output is a stereo 2.0 channel, recording works fine, but any HiFi / Surround configuration makes AudioEffectCapture unusable for my use case (speech to text). |
I do think this is the bug. AudioEffectRecord only records from the last channel (because of the bug), which on anything more than a stereo system will be silent (microphones normally only record stereo to the first channel). This should fix it. The SpectrumAnalyzer is one of the only effects that is channel aware, which is why it works. You select the effect instance (which is per-channel) with
Unfortunately I'm new here too, and am not sure what the best way to test would be. I setup a dev environment to build and test my own releases, but I don't think sharing executables is the way to go. Maybe one of the main contributors can chime in.
If this is the bug, the audio should sound very garbled and static-y. A work around I use in my own project (in GDScript) is to pull frames from the capture buffer in chunks of 512. Then before passing that array on, I loop over it, and check that both channels of every frame is exactly equal to 0.0. If so, I skip that chunk. This works because the |
c3f8750
to
b5a57de
Compare
@OpenFormEon I was looking at the Godot Contribution Workflow docs and see that you can download the editor with this PR applied for testing, once the workflow/tests are run on it again, or by using the nightly.link website. Details available here. |
The
AudioEffectCapture
andAudioEffectRecord
classes do not work properly when there is more than one audio channel active. This PR makes some changes to severalAudioEffect
classes to fix these bugs. Fixes #91133.I added
set_current_channel
toAudioEffectInstance
to keepAudioServer::_update_bus_effects
clean, since I wanted that functionality for capture and record. It was already part of compressor, and seems like something that could be useful for other effect instances if they needed it. The default implementation is a no-op.Added an
active_channel
property to bothAudioEffectCapture
andAudioEffectRecord
. Capture uses it to return early fromprocess
so that only the active instance writes data to the buffer.Record now stores all instances (that are registered) by channel, and when changing the
active_channel
, it changes the internalcurrent_instance
to reflect that.The
active_channel
property is exposed in the editor for both classes. It doesn't currently update the available drop-down options to reflect the actual number of channels available in theAudioServer
. Theset_active_channel
functions also don't explicitly check for the validity of thep_channel
args, but they do work with invalid inputs (it just disables capture/recording).