summaryrefslogtreecommitdiff
path: root/scene/resources/audio_stream_polyphonic.cpp
AgeCommit message (Collapse)Author
2023-01-23Merge pull request #71801 from akien-mga/codespell-en-GB-to-en-USRémi Verschelde
Convert en_GB spelling to en_US with codespell
2023-01-23Convert en_GB spelling to en_US with codespellRémi Verschelde
2023-01-23Simplify AudioStreamPolyphonicJuan Linietsky
* Make AudioStreamPolyphonic not requre a polling thread (simpler, faster) * Improve error reporting in AudioStreamPlayer*::get_stream_playback() error reporting to improve usability.
2023-01-22Add AudioStreamPolyphonic to make it easier to play polyphonic sound from codeJuan Linietsky
* 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 ```