You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The absolute time is calculated based on the total mixed frames and the mix rate. This means it only updates when a mix step happens.
Specific play_scheduled behaviors:
- If a sound is playing, play_scheduled() will stop that sound. This matches the behavior of play().
- If a sound is scheduled, then paused, then resumed before the schedule happens, the sound still plays at the correct scheduled time.
- If a playing sound is paused, then play_scheduled() is called, the sound will restart from the beginning. This matches the behavior of play().
- With a higher max_polyphony, multiple sounds can be scheduled.
- play_scheduled is unaffected by pitch scale
- play_scheduled does not support samples
Scheduled stop is not implemented due to limited use cases.
Co-authored-by: K. S. Ernest (iFire) Lee <ernest.lee@chibifire.com>
Returns the absolute time in seconds of the [AudioServer]'s timeline, based on the number of audio frames mixed. Used to schedule sounds to be played with high precision timing, such as with [method AudioStreamPlayer.play_scheduled].
42
+
[b]Note:[/b] This value only updates each time an audio chunk is mixed and should not be relied on as an accurate "current" time of the [AudioServer].
43
+
[b]Example:[/b] Schedule two sounds to be played at the same time, roughly 1 second in the future:
44
+
[codeblocks]
45
+
[gdscript]
46
+
var future_time = AudioServer.get_absolute_time() + 1
Copy file name to clipboardExpand all lines: doc/classes/AudioStreamPlayer.xml
+13-2Lines changed: 13 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -28,7 +28,7 @@
28
28
<methodname="get_stream_playback">
29
29
<returntype="AudioStreamPlayback" />
30
30
<description>
31
-
Returns the latest [AudioStreamPlayback] of this node, usually the most recently created by [method play]. If no sounds are playing, this method fails and returns an empty playback.
31
+
Returns the latest [AudioStreamPlayback] of this node, usually the most recently created by [method play] or [method play_scheduled]. If no sounds are playing, this method fails and returns an empty playback.
32
32
</description>
33
33
</method>
34
34
<methodname="has_stream_playback">
@@ -44,6 +44,17 @@
44
44
Plays a sound from the beginning, or the given [param from_position] in seconds.
Schedules a sound to be played on the [AudioServer]'s timeline at [param absolute_time] in seconds. If the sound is scheduled to play earlier than the value returned by [method AudioServer.get_absolute_time], it will be played immediately. The sound starts from the given [param from_position] in seconds.
53
+
Use this method for high precision playbacks, such as a metronome or other rhythm-based sounds.
54
+
[b]Note:[/b] Calling this method after [member max_polyphony] is reached will cut off the oldest sound playing on this node.
55
+
[b]Note:[/b] On the Web platform, [member playback_type] must be set to [constant AudioServer.PLAYBACK_TYPE_STREAM]. Otherwise, this method will behave like [method play].
56
+
</description>
57
+
</method>
47
58
<methodname="seek">
48
59
<returntype="void" />
49
60
<paramindex="0"name="to_position"type="float" />
@@ -67,7 +78,7 @@
67
78
[b]Note:[/b] At runtime, if no bus with the given name exists, all sounds will fall back on [code]"Master"[/code]. See also [method AudioServer.get_bus_name].
The maximum number of sounds this node can play at the same time. Calling [method play] after this value is reached will cut off the oldest sounds.
81
+
The maximum number of sounds this node can play and schedule at the same time. Calling [method play] or [method play_scheduled] after this value is reached will cut off the oldest sounds.
The mix target channels, as one of the [enum MixTarget] constants. Has no effect when two speakers or less are detected (see [enum AudioServer.SpeakerMode]).
Schedules a sound to be played on the [AudioServer]'s timeline at [param absolute_time] in seconds. If the sound is scheduled to play earlier than the value returned by [method AudioServer.get_absolute_time], it will be played immediately. The sound starts from the given [param from_position] in seconds.
47
+
Use this method for high precision playbacks, such as a metronome or other rhythm-based sounds.
48
+
[b]Note:[/b] Calling this method after [member max_polyphony] is reached will cut off the oldest sound playing on this node.
49
+
[b]Note:[/b] On the Web platform, [member playback_type] must be set to [constant AudioServer.PLAYBACK_TYPE_STREAM]. Otherwise, this method will behave like [method play].
50
+
</description>
51
+
</method>
41
52
<methodname="seek">
42
53
<returntype="void" />
43
54
<paramindex="0"name="to_position"type="float" />
@@ -70,7 +81,7 @@
70
81
Maximum distance from which audio is still hearable.
The maximum number of sounds this node can play at the same time. Playing additional sounds after this value is reached will cut off the oldest sounds.
84
+
The maximum number of sounds this node can play and schedule at the same time. Calling [method play] or [method play_scheduled] after this value is reached will cut off the oldest sounds.
Scales the panning strength for this node by multiplying the base [member ProjectSettings.audio/general/2d_panning_strength] with this factor. Higher values will pan audio from left to right more dramatically than lower values.
Schedules a sound to be played on the [AudioServer]'s timeline at [param absolute_time] in seconds. If the sound is scheduled to play earlier than the value returned by [method AudioServer.get_absolute_time], it will be played immediately. The sound starts from the given [param from_position] in seconds.
47
+
Use this method for high precision playbacks, such as a metronome or other rhythm-based sounds.
48
+
[b]Note:[/b] Calling this method after [member max_polyphony] is reached will cut off the oldest sound playing on this node.
49
+
[b]Note:[/b] On the Web platform, [member playback_type] must be set to [constant AudioServer.PLAYBACK_TYPE_STREAM]. Otherwise, this method will behave like [method play].
50
+
</description>
51
+
</method>
41
52
<methodname="seek">
42
53
<returntype="void" />
43
54
<paramindex="0"name="to_position"type="float" />
@@ -91,7 +102,7 @@
91
102
The distance past which the sound can no longer be heard at all. Only has an effect if set to a value greater than [code]0.0[/code]. [member max_distance] works in tandem with [member unit_size]. However, unlike [member unit_size] whose behavior depends on the [member attenuation_model], [member max_distance] always works in a linear fashion. This can be used to prevent the [AudioStreamPlayer3D] from requiring audio mixing when the listener is far away, which saves CPU resources.
The maximum number of sounds this node can play at the same time. Playing additional sounds after this value is reached will cut off the oldest sounds.
105
+
The maximum number of sounds this node can play and schedule at the same time. Calling [method play] or [method play_scheduled] after this value is reached will cut off the oldest sounds.
Scales the panning strength for this node by multiplying the base [member ProjectSettings.audio/general/3d_panning_strength] by this factor. If the product is [code]0.0[/code] then stereo panning is disabled and the volume is the same for all channels. If the product is [code]1.0[/code] then one of the channels will be muted when the sound is located exactly to the left (or right) of the listener.
0 commit comments