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

Add support for DSP buffer size #96

Merged
merged 6 commits into from
Nov 15, 2021
Merged

Add support for DSP buffer size #96

merged 6 commits into from
Nov 15, 2021

Conversation

bitbrain
Copy link
Contributor

As explained in #91 there is currently the issue on certain systems that the audio plays back with delay. The reason is that the default DSP buffer size has the wrong configuration.

This pull request allows to configure the DSP buffer size like so in Godot:

Fmod.set_dsp_buffer_size(512, 4)
Fmod.init(1024, Fmod.FMOD_STUDIO_INIT_LIVEUPDATE, Fmod.FMOD_INIT_NORMAL)

I tested this with my game and the audio playback latency is now near real-time. No more audible lag after setting this in my game code!

  • added GUT tests
  • updated README.md

src/godot_fmod.h Outdated
@@ -111,6 +111,8 @@ namespace godot {
int actualListenerNumber = 0;
Listener listeners[FMOD_MAX_LISTENERS];
bool listenerWarning = true;
unsigned int bufferlength = 0;
Copy link
Member

Choose a reason for hiding this comment

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

I think there is no value in storing those variables inside the class.

In the 2 getters, you can just create a local variable, pass its pointers to FMOD, then return it.

Copy link
Member

Choose a reason for hiding this comment

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

I agree

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed!

}
}

int Fmod::getSystemDSPBufferLength() {
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure if we should not return an array containing lenght and num instead of having two getter that does same things but only return partial information ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had a long think about this: from a usability perspective, it will be quite confusing to Godot users to suddenly get an Array as return type as it is not very explicit what these values actually mean. On the contrary, it is not performant to request both values separately, however, the FMOD C++ binding forces us to pass in both by reference always.

If you are happy I can make that change to return an Array, however, it may get confusing to users what these values mean.

Copy link
Member

@CedNaru CedNaru Nov 11, 2021

Choose a reason for hiding this comment

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

I'm more on the side of having 2 getters. It's not like we need performance for that, it's just a simple API call. So it's better to favor usability.
We can also gave both: 2 separate getter returning one value, and one getter getSystemDSPInfo that returns an array or dictionnary with string key.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pushed!

@bitbrain bitbrain merged commit 1273d53 into master Nov 15, 2021
@CedNaru CedNaru deleted the dsp-buffer-size-support branch December 1, 2022 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants