Implement audio absolute time (DSP time) and scheduled play#107226
Implement audio absolute time (DSP time) and scheduled play#107226PizzaLovers007 wants to merge 1 commit intogodotengine:masterfrom
Conversation
|
I tried my best at the icons for these new nodes, but I can remove them if they don't meet standards! |
This comment was marked as outdated.
This comment was marked as outdated.
|
Just to check - does this let you schedule multiple playbacks on the same player without overwriting them? It would be really nice for a rhythm game like mine to be able to queue a big batch of hitsounds at the start of a chart instead of having to schedule each one individually as they come up. |
|
Yes you can queue multiple sounds, but you'll need to increase |
9294d58 to
6b2c40c
Compare
|
Is it possible to use this new node in C#? It took me a long time, but I managed to get your branch of Godot compiled and set up (building the mono branch took a lot of figuring out for me) I can see ScheduledAudioStreamPlayer when I'm working in GDScript, but I vastly prefer C#. I suppose I could try to learn enough GDScript to dual wield, but is there a way to reference this class in C#? Thank you for making this, it'll make my rhythm game easier to make |
|
If C# bindings don't get autogenned on this branch then they definitely will when this makes it into the engine proper, they get auto-generated upon mono engine build |
|
I'll try to run the build_script again (I'm a bit out of my depth when it comes to compiling from source code), If I can't get it, I'll toy around with GDScript until this makes it in |
|
This branch is so clutch for making a rhythm game. I love being able to pull the absolute time of the audio server and be able to pre-schedule audio stream plays. I have a couple of them in my scene with empty WAVs to throw the finished signal, to dynamically spawn notes in the playfield and account for audio lag. I can't wait for this to hit the main branch. Thank you |
6b2c40c to
ac58fbf
Compare
|
When trying to play sounds (e.g. hammer hitting, gunfire) at a steady rhythm (but not as a premade sound, but instead individual effects), this change is a game changer. This should really be considered for timely inclusion in official Godot, we cannot realize our projects without it, and as of now are required to always use a custom engine build. |
|
Small issue: Can you review the hash on |
ac58fbf to
ce64558
Compare
I removed the PR reference in the commit (if that's what you intended me to do). Sorry for the spam! |
|
I wasn't able to figure out why the pull request is blocked so you probably want to visit an audio team meeting or the godot chat instance #audio channel. |
|
This is an incredible feature, I've been really exercising it while working on a music-making game of sorts. Very pleased with it and would love to see this get merged. Awesome work! |
ce64558 to
09c8a94
Compare
This is a rewrite of PR 105510 that moves the silence frames logic into a separate AudioStreamPlaybackScheduled class and introduces new ScheduledAudioStreamPlayer/2D/3D nodes. The rewrite allows both the AudioServer and the player (mostly) to treat it as if it were a generic playback. Main differences: - ScheduledAudioStreamPlayer/2D/3D are new nodes inheriting from their AudioStreamPlayer/2D/3D counterparts. These nodes only contain one new method: play_scheduled. - play_scheduled returns an AudioStreamPlaybackScheduled instance, which is tied to the player that created it. - The start time can be changed after scheduling. - You can now set an end time for the playback. - The scheduled playback can be cancelled separately from other playbacks on the player. Co-Authored-By: K. S. Ernest (iFire) Lee <ernest.lee@chibifire.com>
09c8a94 to
ae0f5b8
Compare
|
Love this! Hoping it can get merged for 4.7 (or another version that's coming soon) because it doesn't look too far off to being done to me. Great work! |
|
Are there any more blocks on this PR? It'd be huge to have once the 4.7 cycle spins up! |
This is a rewrite of #105510 that introduces new ScheduledAudioStreamPlayer/2D/3D nodes and moves the silence frames logic into a separate AudioStreamPlaybackScheduled class. The rewrite allows both the AudioServer and the player (mostly) to treat it as if it were a generic playback.
Main differences:
play_scheduled.play_scheduledreturns an AudioStreamPlaybackScheduled instance, which is tied to the player that created it.Why new nodes? New nodes prevent feature creep on the original AudioStreamPlayer/2D/3D nodes and follows the "Prefer local solutions" best practice. Scheduling audio is an important use case, but not one that needs to be in core player functionality.
Why not use AudioServer directly? AudioServer methods are not available to GDScript as of writing. While this is not a hard change to make, AudioStreamPlayer/2D/3D nodes provide a significantly better user experience (editor UI) as well as provide panning, doppler effect, and other features that would be non-trivial to reimplement.
A demo of this feature can be found at godotengine/godot-demo-projects#1210.
Fixes godotengine/godot-proposals#1151.
Supersedes #105510.