Skip to content

Polyphonic Audio Resources missing documentation #8172

Open
@nonfinity

Description

@nonfinity

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 #4622 ... but for version 4.x and polyphony specifically.

Activity

added
area:class referenceIssues and PRs about the class reference, which should be addressed on the Godot engine repository
content:new pageIssues and PRs related to creation of new documentation pages for new or undocumented features
area:manualIssues and PRs related to the Manual/Tutorials section of the documentation
on Oct 10, 2023
amarraff

amarraff commented on Jan 18, 2024

@amarraff

I was having a similar issue. I was trying to play multiple UI sounds in rapid succession using one AudioStreamPlayer. AudioStreamPolyphonic provides this functionality, but getting it set up requires a couple of steps, such as initializing and retrieving the AudioStreamPlayer's playback object. That would be very helpful info to provide in the docs.

AThousandShips

AThousandShips commented on Jan 18, 2024

@AThousandShips
Member

SoundDisplay2.zip

This shows how to use them (though not all the features), you need to add two sound files and update the paths (I don't have any free sounds available at the moment so can't include anything), unsure how to phrase it but can look into improving the documentation when I have the time

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:class referenceIssues and PRs about the class reference, which should be addressed on the Godot engine repositoryarea:manualIssues and PRs related to the Manual/Tutorials section of the documentationcontent:new pageIssues and PRs related to creation of new documentation pages for new or undocumented featuresenhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Polyphonic Audio Resources missing documentation · Issue #8172 · godotengine/godot-docs