diff options
author | Juan Linietsky <reduzio@gmail.com> | 2023-01-22 13:48:43 +0100 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2023-01-22 16:22:45 +0100 |
commit | f18d408c087041f5d02835643fcb591a5a876110 (patch) | |
tree | abf6b2cb5b59fcc6faba4c0a3c8a61966d1ac4d1 /servers/audio/audio_effect.cpp | |
parent | c3539b4561f9b4d7dc4ba1c5859217e7fbf9c6fe (diff) |
Add AudioStreamPolyphonic to make it easier to play polyphonic sound from code
* 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
```
Diffstat (limited to 'servers/audio/audio_effect.cpp')
0 files changed, 0 insertions, 0 deletions