godotengine / godotengine/godot-docs

Polyphonic Audio Resources missing documentation

Open
#8,172 2 comments 2 reactions 0 assignees View on GitHub
area:class reference area:manual content:new page enhancement
Dominant language
reStructuredText
Stars
5.7k
Forks
3.8k
Avg merge
1d 20h
Merged PRs (30d)
25

Description

Your Godot version: 4.1.1.stable.mono.official [bd6af8e0e]

Issue description:
From the documentation on AudioStreamPolyphonic, it appears I should be able to load multiple different AudioStreams into it somehow and play them. But it is not clear how to make this work. A short sample would be extremely helpful. There appears to be no information available anywhere on the internet that describes to use this functionality (in English at least)

URL to the documentation page (if already existing):
https://docs.godotengine.org/en/stable/classes/class_audiostreampolyphonic.html
https://docs.godotengine.org/en/stable/classes/class_audiostreamplaybackpolyphonic.html

This is what I've pieced together. It doesn't throw any errors, but it also doesn't play any audio:

func _on_button_pressed():
var asset1 = preload("res://assets/audio/sfx/Dash_Reset.wav")
var asset2 = preload("res://assets/audio/sfx/Fox_Hurt.wav")

var player: AudioStreamPlayer = $AudioStreamPlayer
var stream: AudioStreamPolyphonic = player.stream # set in the Inspector UI to Polyphonic

var pback: AudioStreamPlaybackPolyphonic
if player.has_stream_playback():
# this never gets called, even hitting the button very very quickly
pback = stream.get_stream_playback()
else:
pback = stream.instantiate_playback()

var sound1 = pback.play_stream(asset1)
var sound2 = pback.play_stream(asset2)

print("stream sound1 (", sound1, ") is playing? ", str(pback.is_stream_playing(sound1)) )
print("stream sound2 (", sound2, ") is playing? ", str(pback.is_stream_playing(sound2)) )
# always prints that sound is playing, but play_stream integers never change and not audio is heard

This is similar to https://github.com/godotengine/godot-docs/issues/4622 ... but for version 4.x and polyphony specifically.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.