opened 09:07AM - 26 Jul 23 UTC
feature request
engine
sound
I would like to be able to get and set the timeline positions of sounds in Defol…d.
Use case:
We have three intensity variations of a music track. At certain points in the track, we check if we want to switch to another intensity level. The variations are **not** mapped 1:1 in terms of duration and position, so for example if we're at 00:12 of one track we might want to switch to 00:23 for the other.
For get, I would expect something like:
```
go.get("#sound", "timeline_position")
```
You could do a workaround for the get side by tracking time elapsed since you started the track. I've tried this before, but do not find it to be a reliable solution. I can not think of a workaround for the set side.
For set, I would expect something like:
```
go.set("#sound", "timeline_position", 23.7)
```
However, for my use case it would also be acceptable if the timeline position is set on play (similar to the [offset parameter in sprite.play_flipbook](https://defold.com/ref/stable/sprite/#sprite.play_flipbook:url-id-[complete_function]-[play_properties])).
I've looked around for similar functions elsewhere: FMOD ([get](https://documentation.help/FMOD-Studio-API/FMOD_Channel_GetPosition.html) / [set](https://documentation.help/FMOD-Studio-API/FMOD_Channel_SetPosition.html)), Unity ([both](https://docs.unity3d.com/ScriptReference/AudioSource-time.html)), Godot (seemingly only [get](https://docs.godotengine.org/en/3.3/classes/class_audiostreamplayer.html#class-audiostreamplayer-method-get-playback-position))