-
-
Notifications
You must be signed in to change notification settings - Fork 278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sound: get/set playback timeline position #7835
Comments
Are you talking about the next "start" position, or the position for an active voice? (Remember you can play a sound multiple time, and each will spawn a voice) |
I'm not intimately familiar with the sound API, but it doesn't seem like we ever really interact with specific voices? E.g. you can only stop all voices at the same time, not a specific one. I think setting the timeline position of the next voice (e.g. doing it on play, like the sprite offset parameter) would be fine for my use case I think. I wouldn't be playing multiple voices of the same sound anyway when we're talking about music tracks. |
I think it makes sense to have sound.play("#mysound", { start_time = 0.5 }) Changing |
start_time as an argument to the play properties sounds perfect to me. I can't imagine when it would be useful to set it for future calls (not to say there isn't a use case for it, just I don't see one). |
Agree, have the same issue I have a different parts of music which should be player in different game moments and for easier management and music creation I want to keep one music file It would be cool if it will able to set start time on sound.play or while playing sound |
Would also love the ability to get the playback position of an active sound to allow me to implement fades. Being able to query the length of a sound would be great too. |
This is more complicated since you can have multiple voices playing the same sound. The sound.play() is fire and forget and you do not get a handle or anything back that you can use at a later time to get the current position. So in order to solve this we need to return a voice handle to the user and then a new function to query the voice position. This is further complicated by the fact that sounds are mixed and played on a thread so you need to interrupt the thread to get the position.
I suppose this is mainly useful if you can also query for the current playback position? |
It would be, yes. For my usage, I have a soundtrack manager, with a playlist of three loopable tracks, and knowing when a track is coming near to the end to fade it out and fade in the next would be useful. I can't edit the tracks together as the last track would end abruptly. Currently I'm using the track length, and tracking the play time in Update, so hopefully this hacky way is accurate :) |
I would like to be able to get and set the timeline positions of sounds in Defold.
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:
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:
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).
I've looked around for similar functions elsewhere: FMOD (get / set), Unity (both), Godot (seemingly only get)
The text was updated successfully, but these errors were encountered: