godotengine / godotengine/godot-docs

AudioStreamPolyphonic not obvious how it works

Open
#9,488 4 comments 13 reactions 0 assignees View on GitHub
area:class reference enhancement topic:audio
Dominant language
reStructuredText
Stars
5.7k
Forks
3.8k
Avg merge
1d 20h
Merged PRs (30d)
25

Description

**Your Godot version:**
4.3 beta 1

**Issue description:**

When looking at AudioStreamPolyphonic, there is no code example. There should be one, because it took me a lot of digging and some luck to find out how it works.

```gdscript
extends AudioStreamPlayer
var polyphonic = AudioStreamPolyphonic.new()
var playback : AudioStreamPlaybackPolyphonic

var my_sound = load("res://my_sound.wav")

func _ready():
stream = polyphonic
play()
playback = get_stream_playback() # you need to do this for it to work

func process():
if Input.is_action_just_pressed("ui_accept"):
playback.play_stream(my_sound, 0, 0, 1) # stream, volume, from, pitch
```

**URL to the documentation page (if already existing):**
it's AudioStreamPolyphonic, but there is also a page for the playback class. It would be good to include it at least once.
https://docs.godotengine.org/en/stable/classes/class_audiostreampolyphonic.html

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.