Full documentation for AudioStreamPlayback methods?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By fuxoft

I was looking at the Audio Generator Demo which references AudioStreamPlayback and its methods. I wanted to know more about this class and its methods but the official docs page only contains the link to the demo linked above, nothing else. Where can I see how exactly push_frame() works and what other methods this class provides (e.g. for clearing the sample buffer).

:bust_in_silhouette: Reply From: voidshine

Code sleuthing:

I also found this helpful:

Here’s how I got it working in the editor:

  • Create an AudioStreamPlayer node.
  • In the inspector for this node, click Stream to create a new AudioStreamGenerator resource.
  • Attach a script to the node – here’s working C# code that generates noise.
    using Godot;

    public class AudioStreamPlayerSynth : AudioStreamPlayer
        AudioStreamGeneratorPlayback _Playback;
        RandomNumberGenerator _Rng = new RandomNumberGenerator();

        public override void _Ready() {
            _Playback = GetStreamPlayback() as AudioStreamGeneratorPlayback;

        public override void _Process(float delta) {

        void Fill() {
            int i = _Playback.GetFramesAvailable();
            while (i > 0) {
                _Playback.PushFrame(Vector2.One * (_Rng.Randf() * 2 - 1));

Note: AudioStreamPlayerSynth is not a Godot thing, just the custom node script class. I sometimes name nodes by tacking on the node’s purpose at the end of the default type name.

voidshine | 2021-07-17 16:42