How do I switch between AudioStreamInteractive clips with code, similar to the parameter that shows up in the editor? This may be a really dumb question but I really cant find anything out.
My closest guess would be the add_transition() function, but from what the docs say I think it just adds a transition, like in the transition editor.
Yeah, I had to do a little research just now to figure it out; it’s not immediately obvious how this AudioStream should be used. From the looks of it, though, it appears similar in nature to the animation system(s).
To play a specific clip, you can use the following line of code:
In terms of where these functions actually originate, get_stream_playback() is found in AudioStreamPlayer and returns an AudioStreamPlayback. Your AudioStreamInteractive makes use of a AudioStreamPlaybackInteractive to playback sound (which is a AudioStreamPlayback through inheritence) – notice the difference in naming. It is the AudioStreamPlaybackInteractive which is capable of changing the clip via either switch_to_clip() or switch_to_clip_by_name().
It sure got me confused!
For a simplified description:
All AudioStreamPlayers make use of a playback instance at run-time (AudioStreamPlayback). Therefore, it is the playback instance whose state must be changed. As far as I can tell, the AudioStream resources (not playbacks) just act as a blueprint for all its instances.
Here are the class references (listed in order of ownership or inheritance):