Skip to content

Expose AudioServer stream playback functions#117430

Open
Spartan322 wants to merge 1 commit intogodotengine:masterfrom
Spartan322:expose/audio-server-playback
Open

Expose AudioServer stream playback functions#117430
Spartan322 wants to merge 1 commit intogodotengine:masterfrom
Spartan322:expose/audio-server-playback

Conversation

@Spartan322
Copy link
Contributor

@Spartan322 Spartan322 commented Mar 15, 2026

Since MixTarget needs to be handled by the exposed start_playback_stream now, I moved it to AudioServer, AudioStreamPlayer needs AudioServer anyway, so I mimicked the compatibility resolution in #116839.

Code Example:

extends Node2D

const test_stream : AudioStreamMP3 = preload("res://test.mp3")

func _on_button_pressed() -> void:
	var playback := test_stream.instantiate_playback()
	AudioServer.start_playback_stream(playback, &"Master")
	await get_tree().create_timer(1).timeout
	AudioServer.stop_playback_stream(playback)

Demo Project

expose-audio-server-playback-test.zip

Consideration

  • Should this implement start_playback_stream functions whose signatures are:
void start_playback_stream(
	Ref<AudioStreamPlayback> p_playback,
	const Dictionary &p_bus_volumes, // Dictionary[StringName, Array[Vector2]]
	float p_start_time = 0,
	float p_pitch_scale = 1,
	float p_highshelf_gain = 0,
	float p_attenuation_cutoff_hz = 0
);

void start_playback_stream(
	Ref<AudioStreamPlayback> p_playback,
	const StringName &p_bus,
	const TypedArray<Vector2> &p_volume_db_vector,
	float p_start_time = 0,
	float p_pitch_scale = 1
);

@Spartan322 Spartan322 requested review from a team as code owners March 15, 2026 07:08
@Spartan322 Spartan322 force-pushed the expose/audio-server-playback branch 2 times, most recently from bf10c38 to b7c84c5 Compare March 15, 2026 07:22
@Nintorch Nintorch added this to the 4.x milestone Mar 15, 2026
@Spartan322 Spartan322 force-pushed the expose/audio-server-playback branch from b7c84c5 to 0b484fb Compare March 15, 2026 07:43
@Spartan322 Spartan322 requested review from a team as code owners March 15, 2026 07:43
Expose `AudioServer::start_playback_stream`
Expose `AudioServer::stop_playback_stream`
Move `AudioStreamPlayer::MixTarget` to `AudioServer`
@Spartan322 Spartan322 force-pushed the expose/audio-server-playback branch from 0b484fb to 58df991 Compare March 16, 2026 00:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose AudioServer methods which allow playing sounds to GDScript

2 participants