How I use AudioStreamPlaybackPolyphonic / AudioStreamPolyphonic?

Hi,

I want to play 5 instrument tracks simultaneous and synchronous. I found this very up-to-date Godot 4 tutorial:

But it seems some code lines don’t work with the current Godot 4 version because some methods no longer exist…

Is there a simple example how I play some tracks with AudioStreamPolyphonic in sync?

Thanks.

Why get_stream_playback() returns a Null-Object?

func _ready():
	var player = AudioStreamPlayer.new()
	var stream = AudioStreamPolyphonic.new()
	var playback:AudioStreamPlaybackPolyphonic
	stream.polyphony = 10
	player.stream = stream
	player.play()
	playback = player.get_stream_playback()
	print(playback)
func _ready():
 var player = AudioStreamPlayer.new()
 var stream = AudioStreamPolyphonic.new()
 var playback:AudioStreamPlaybackPolyphonic
 stream.polyphony = 10
 player.stream = stream
 add_child(player)
 player.play()
 playback = player.get_stream_playback()
 print(playback)

Thats it! Thanks!

Is it possible to loop polyphonic streams?

Unlike AudioStreamMP3/OGG/WAV, Polyphonic indeed does not have a loop property;

BUT

AudioStreamPlaybackPolyphonic is derived from AudioStreamPlayback that has virtual method:

_get_loop_count()

So, it may be possible to do it natively, but it seens to not be implemented.

Nice Post

Website