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

Buffered audio frames in an AudioEffectRecordInstance are lost upon calling AudioServer::_update_bus_effects #75041

Open
Tracked by #76797
Rubonnek opened this issue Mar 17, 2023 · 2 comments

Comments

@Rubonnek
Copy link
Member

Godot version

3.x branch at commit 16df341

System information

Arch Linux

Issue description

Buffered audio frames through an AudioEffectRecordInstance are lost upon calling AudioServer::_update_bus_effects, which is called when a new audio effect gets added.

This happens because AudioEffectRecordInstance::instance() creates a brand new instance instead of using the currently available one.

Ref<AudioEffectInstance> fx = buses.write[p_bus]->effects.write[j].effect->instance();

Steps to reproduce

Run the MRP attached below. See the gdscript file within the project for more details.

Minimal reproduction project

audio_record_reset_bug.zip

@Rubonnek
Copy link
Member Author

This issue also affects master.

@Rubonnek
Copy link
Member Author

The issue is caused by AudioEffectRecord::instantiate() which returns a brand new instance of AudioEffectRecordInstance instead of reusing the one currently available.

All the other audio effects seem to do the same with their instantiate calls.

There's a also a design issue with AudioEffectCompressorInstance since AudioServer needs to know when it holds an instance but it shouldn't:

Ref<AudioEffectInstance> fx = buses.write[p_bus]->effects.write[j].effect->instantiate();
if (Object::cast_to<AudioEffectCompressorInstance>(*fx)) {
Object::cast_to<AudioEffectCompressorInstance>(*fx)->set_current_channel(i);
}
buses.write[p_bus]->channels.write[i].effect_instances.write[j] = fx;

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

No branches or pull requests

1 participant