Storing clips in AudioStreamInteractive to resume them later

Godot Version

v4.3.stable.official [77dcf97d8]

Question

Hi there! I’m currently building the audio system for a gamejam entry, and seemed like a great opportunity to test the AudioStreamInteractive resource for AudioStreamPlayer.

I have set a music controller on autoload, and set some basic functions to control the playback and call whichever track I need based on clip_name. I also edited transitions (I presume) accordingly.

So “zone_0” and “zone_1” can both transition to “minigame”, in the actual minigame the track loops till you win/lose and then it should switch back to the previous zone clip.

I wanted to store the previous clip name in a variable, but through the official documentation I was unable to find a method to get the current playing clip’s name or clip_id. I am not super well-versed in reading through doc and implementing it correctly to suit my needs, so I am grateful if anyone knows how to solve this in particular.

extends Node2D

@onready var music_interactive_player := $Loop
@onready var playback: AudioStreamPlaybackInteractive = music_interactive_player.get_stream_playback()
@onready var previous_clip

func play_loop() -> void:
	music_interactive_player.stream_paused = false

func pause_loop() -> void:
	music_interactive_player.stream_paused = true

func stop_loop() -> void:
	music_interactive_player.stop()
	
func play_music(clip: StringName) -> void:
	playback.switch_to_clip_by_name(clip)
		
func play_music_minigame() -> void:
	playback.switch_to_clip_by_name("minigame")
``

Correct me if I’m wrong but I actually don’t think it’s possible. I’ve looked at every related documentation page for AudioStreamInteractive and I can’t find anything that lets you read either the index or the name of the clip playing.

This particular class is a recent addition to Godot and it was promoted as a means to implement interactive sound systems. I gotta say, that is quite hard if you can’t actually properly interact with the class itself. I assume there’s a design philosophy behind it but the class doesn’t provide the utility you would hope for – at least not if you’re looking to compose the class into your own system.

I could be wrong though. Perhaps the documentation is not completed.

Yeah, I guess the system expects me to use stingers (short music tracks) with ReturnToHold set as the auto advance option. Thing is this game is somewhat fast paced and I’m not considering using stingers when you win or lose (and there’s two forms of losing).

I’m actually quite pleased with these new resources since my team gives priority to the web version of the game so people can click and play right away, something not possible with tools like FMOD and Wwise which I’m already familiar with.

I would love to see those methods we talked added to the documentation in the future, as well as having Volume control per clip in the AudioStreamInteractive, just as AudioStreamPlaylist does right now.