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

Expose AudioStream + AudioStreamPlayback methods to GDExtension #8609

Closed
stechyo opened this issue Dec 7, 2023 · 3 comments
Closed

Expose AudioStream + AudioStreamPlayback methods to GDExtension #8609

stechyo opened this issue Dec 7, 2023 · 3 comments

Comments

@stechyo
Copy link

stechyo commented Dec 7, 2023

Describe the project you are working on

I would like to integrate Steam Audio with Godot, and GDExtension seems like the best way to go about it.

Describe the problem or limitation you are having in your project

The methods that Godot exposes to GDExtension are virtual versions, which are fine for making completely new audio streams but not for e.g. passing the audio from an existing stream through custom processing. See the example below (and if I'm doing something wrong, let me know):

// stream_playback is a Ref<AudioStreamPlaybackMP3> in this case
AudioFrame input[frames];
int mixed = stream_playback->_mix(input, rate_scale, frames);
// mixed == 0, all audio frames in `input` are zero

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Calling _mix() doesn't do anything, what I think I want to do is to call mix() (no underscore!), get the resulting audio frame array, and pass it through SteamAudio processing.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

We could expose mix() and perhaps other methods. The way I understand this is done is by referencing them in the _bind_methods() func in audio_stream.cpp. Exposing mix this way, however, exposes it to GDScript/C# (if there's another way to expose mix to just GDExt let me know), and this is something which the maintainers may not want to do (esp. seeing as we'd have to make AudioFrame not just a simple C++ struct but something that's more compatible with GDScript.)

If this enhancement will not be used often, can it be worked around with a few lines of script?

I don't believe so, but please let me know if there's another way to go about this.

Is there a reason why this should be core and not an add-on in the asset library?

It must be in the core code afaik.

@AThousandShips
Copy link
Member

See also:

@darkcanopy
Copy link

The fact that Steam Audio is now open source means that it would be really nice to be able to easily use official Godot with a Godot Steam Audio gdextension (like stechyo here has created.)

@stechyo
Copy link
Author

stechyo commented Oct 25, 2024

Closing this as the related PR got merged.

@stechyo stechyo closed this as completed Oct 25, 2024
@Calinou Calinou added this to the 4.4 milestone Oct 25, 2024
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

4 participants