f18d408c08
* This new audio stream allows to play multiple sounds and control them over time from code. * It greatly simplifies tasks such as generative music (music generated from code) or audio. This new type of stream was added with the goal of fixing audio blending in AnimationPlayer and AnimationTree, but can be used by others for their regular audio needs. Does not fix anything currently, but should help implement #69758 properly. Some demo code of how to use this: ```GDScript var player = $SomeNode as AudioStreamPlayer player.stream = AudioStreamPolyphonic.new() var playback = player.get_stream_playback() as AudioStreamPlaybackPolyphonic var id = playback.play_stream(preload("res://Clip1.ogg")) await get_tree().create_timer(1).timeout playback.set_stream_volume(id,-12) # Set volume to half after one second await get_tree().create_timer(2).timeout var id2 = playback.play_stream(preload("res://Clip2.ogg")) # 2 seconds later, start another clip await get_tree().create_timer(1).timeout playback.stop_stream(id) # 1 second later, kill the first clip playback.set_stream_pitch_scale(id2,1.5) # Make the second clip go 50% faster ```
17 lines
1.1 KiB
XML
17 lines
1.1 KiB
XML
<?xml version="1.0" encoding="UTF-8" ?>
|
|
<class name="AudioStreamPolyphonic" inherits="AudioStream" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
|
<brief_description>
|
|
AudioStream that lets the user play custom streams at any time from code, simultaneously using a single player.
|
|
</brief_description>
|
|
<description>
|
|
AudioStream that lets the user play custom streams at any time from code, simultaneously using a single player.
|
|
Playback control is done via the [AudioStreamPlaybackPolyphonic] instance set inside the player, which can be obtained via [method AudioStreamPlayer.get_stream_playback], [method AudioStreamPlayer2D.get_stream_playback] or [method AudioStreamPlayer3D.get_stream_playback] methods. Obtaining the playback instance is only valid after the [code]stream[/code] property is set as an [AudioStreamPolyphonic] in those players.
|
|
</description>
|
|
<tutorials>
|
|
</tutorials>
|
|
<members>
|
|
<member name="polyphony" type="int" setter="set_polyphony" getter="get_polyphony" default="32">
|
|
Maximum amount of simultaneous streams that can be played.
|
|
</member>
|
|
</members>
|
|
</class>
|