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 some AudioStreamPlayback methods (namely mix_audio()). #86539

Merged

Conversation

stechyo
Copy link
Contributor

@stechyo stechyo commented Dec 27, 2023

Pretty much the same as:

The former is archived, and the latter seems to go against the maintainers' wishes that start, stop, and mix should not be exposed outward. I added some shim functions to get around this, not sure if that's fine. There are several proposals with different use cases for this:

My usecase is embedding steam-audio as a GDExtension, which requires me to have these functions available as bound methods.

@stechyo stechyo requested review from a team as code owners December 27, 2023 10:15
@AThousandShips AThousandShips added this to the 4.x milestone Dec 27, 2023
@stechyo stechyo force-pushed the gdext/expose-audio-playback-methods branch 2 times, most recently from 455463d to 18ce8c7 Compare December 27, 2023 11:54
@stechyo stechyo force-pushed the gdext/expose-audio-playback-methods branch 3 times, most recently from 6d233fe to d9d1cc4 Compare December 27, 2023 15:11
@ellenhp
Copy link
Contributor

ellenhp commented Dec 27, 2023

We really should have a story here because a lot of users want to get raw pcm data from a stream and it is currently impossible without a gdextension. In gdext you can just call mix repeatedly on a playback but that's not reasonable to make every user do who wants this. It feels like every few weeks in the discord someone asks about it.

@stechyo
Copy link
Contributor Author

stechyo commented Dec 28, 2023

We really should have a story here because a lot of users want to get raw pcm data from a stream and it is currently impossible without a gdextension. In gdext you can just call mix repeatedly on a playback but that's not reasonable to make every user do who wants this. It feels like every few weeks in the discord someone asks about it.

Just a note, correct me if I'm wrong: unless you're referring to something other than the _mix() method that gets generated for AudioStreamPlayback, I don't think that works. That method is virtual and, when called in GDExt for a native audio stream, does nothing (at least in my experience, I may have missed something of course).

@theraot
Copy link
Contributor

theraot commented May 29, 2024

I remember pushback on the lines of "GDScript is too slow for that", but we should be able to use GDScript to connect this to a mixing solution in GPU, for example with compute shaders. In fact, I was able to use the fragment shader in Godot 3.x to generate audio. I shared a proof of concept in discussions: godotengine/godot-proposals#6476 (comment)

Futhermore, Godot have integration with other lnaguages that are considered faster such as C# and rust.

I have a post by Juan Linietsky agreeing on exposing more audio internals: https://x.com/reduzio/status/1683126371013349378

Thus, I hope this does not get the "It won't work on GDScript" treatment.

@stechyo
Copy link
Contributor Author

stechyo commented May 30, 2024

I dislike the fact that I'm exposing this to GDScript at all but "should some things only be exposed on GDExt and not C#/GDS" is a much larger and possibly controversial discussion. This PR is not the ideal solution (I've learned this with time, see stechyo/godot-steam-audio#39), but I'm not aware of any efforts to do something similar but in a cleaner way (again, "knowing what is being worked on" is sometimes an issue in Godot, but again, that's another discussion).

doc/classes/AudioStreamPlayback.xml Outdated Show resolved Hide resolved
@reduz
Copy link
Member

reduz commented Jun 16, 2024

Looks good to me other than what I mentioned.

@stechyo stechyo force-pushed the gdext/expose-audio-playback-methods branch from cd288b5 to 5f70fe0 Compare June 16, 2024 08:04
@stechyo stechyo force-pushed the gdext/expose-audio-playback-methods branch 2 times, most recently from 82eaf7f to 0c1c485 Compare June 16, 2024 08:40
@AThousandShips
Copy link
Member

Since much of the code and especially the documentation is the same as my original PR I have to ask if you salvaged that one?

@stechyo
Copy link
Contributor Author

stechyo commented Jun 16, 2024

Yeah, as I said in the description it's pretty much the same as two other PRs. Is there some "salvaging etiquette" I'm not aware of?

@AThousandShips
Copy link
Member

AThousandShips commented Jun 16, 2024

I'd say that explicitly stating it would be good in the future as it's not clear from "essentially the same", copying code is something you need to be explicit about (doing so without being clear would usually be called plagiarism)

I'd ask that you add me as a co-author in that case, by adding:


Co-authored-by: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com>

To your commit (the empty line is important)

Thank you!

@stechyo stechyo force-pushed the gdext/expose-audio-playback-methods branch from 0c1c485 to 5170a6c Compare June 16, 2024 09:09
@stechyo
Copy link
Contributor Author

stechyo commented Jun 16, 2024

The XML description was certainly salvaged, so it's more than reasonable to add you as a co-author. Sorry for not having done so previously!

@akien-mga akien-mga requested a review from reduz July 9, 2024 07:29
@stechyo stechyo force-pushed the gdext/expose-audio-playback-methods branch from 5170a6c to 683127d Compare July 9, 2024 07:47
@jams3223

This comment was marked as off-topic.

@MasterDingo
Copy link

Any chances to see this PR merged into 4.3?

@AThousandShips
Copy link
Member

4.3 is in final release phase so this will be not be merged before 4.4

Co-authored-by: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com>
@stechyo stechyo force-pushed the gdext/expose-audio-playback-methods branch from 683127d to e479c23 Compare August 15, 2024 13:37
@stechyo
Copy link
Contributor Author

stechyo commented Aug 17, 2024

Now that 4.3 has released, when could we merge this so that it's ready for 4.4? It seems there's no issues remaining with the code.

@AThousandShips
Copy link
Member

It needs an approval by the audio team

@adamscott adamscott self-requested a review August 17, 2024 16:08
@adamscott
Copy link
Member

Just wondering, before approving the PR.

  1. Is it just to tweak the PackedVector2Array in order to playback the data afterwards?
  2. What about surround systems/mixing?

@stechyo
Copy link
Contributor Author

stechyo commented Aug 17, 2024

  1. My use case is for tweaking the audio frame array, yes. I believe there are also use cases for audio visualisers and the like.
  2. I haven’t considered surround systems.

@mk56-spn
Copy link

mk56-spn commented Aug 17, 2024

  1. My use case is for tweaking the audio frame array, yes. I believe there are also use cases for audio visualisers and the like.
  2. I haven’t considered surround systems.

To add a bit to this. It was specifically static ( so audio visualizers that show the whole songs graph ( think audacity ) as opposed to the ones you'd see on a music player) that were a major pain to do beforehand. So yeah this is very much appreciated for that sort of thing.

@stechyo
Copy link
Contributor Author

stechyo commented Aug 24, 2024

@adamscott do these answers block your approval? Just wondering

@adamscott
Copy link
Member

@adamscott do these answers block your approval? Just wondering

@stechyo I'm investigating. I'm gonna give you an answer shortly.

@adamscott
Copy link
Member

I haven’t considered surround systems.

It seems that surround is only done at the server level when adjusting volume, so no need for a special case for surround systems. Sorry, I mixed up stuff.

Copy link
Member

@adamscott adamscott left a comment

Choose a reason for hiding this comment

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

Small changes IMO, but your PR is close to be merged!

servers/audio/audio_stream.cpp Outdated Show resolved Hide resolved
servers/audio/audio_stream.h Outdated Show resolved Hide resolved
servers/audio/audio_stream.cpp Outdated Show resolved Hide resolved
servers/audio/audio_stream.cpp Outdated Show resolved Hide resolved
@adamscott adamscott changed the title Expose some AudioStreamPlayback methods. Expose some AudioStreamPlayback methods (namely mix_audio()). Aug 26, 2024
@stechyo
Copy link
Contributor Author

stechyo commented Aug 27, 2024

I think all changes should be addressed :) could someone approve the workflow?

@stechyo
Copy link
Contributor Author

stechyo commented Sep 13, 2024

@adamscott is anything missing to merge? Just checking, idk what the etiquette is on this repo (if the commenter needs to resolve conversations, or if it's the PR author who does so).

Copy link
Member

@adamscott adamscott left a comment

Choose a reason for hiding this comment

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

Seems good to me!

@adamscott adamscott modified the milestones: 4.x, 4.4 Sep 13, 2024
@stechyo
Copy link
Contributor Author

stechyo commented Sep 13, 2024

Awesome! @reduz I think your requested change should be addressed as well, can we merge this?

@stechyo
Copy link
Contributor Author

stechyo commented Oct 19, 2024

@reduz @AThousandShips my apologies for double-pinging here, but this PR has been approved by one engine maintainer and the comment of another maintainer has been addressed for a while now. Is there anything I can do to help merge this? I would love to get this in before the 4.4 freeze begins, and it seems to be ready to merge.

@adamscott
Copy link
Member

adamscott commented Oct 22, 2024

I set the PR in the merge queue, so it should be merged as soon as possible. Thanks again for the PR!

@Repiteo Repiteo merged commit 8c52533 into godotengine:master Oct 24, 2024
18 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Oct 24, 2024

Thanks, and congratulations on your first contribution! 🎉

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

Successfully merging this pull request may close these issues.