Page 1 of 1

Set start time to play sound in A_PlaySound

PostPosted: Fri Jun 01, 2018 1:56 pm
by Nash
As a follow up to my previous request, I'd like a new parameter in A_PlaySound to set the starting time to play the sound from.

Re: Set start time to play sound in A_PlaySound

PostPosted: Mon Jun 04, 2018 10:22 am
by ZzZombo
Sorry? Isn't it there you just set the preceding state's duration equal to the desired delay?

Re: Set start time to play sound in A_PlaySound

PostPosted: Mon Jun 04, 2018 10:43 am
by wildweasel
I suspect Nash is asking for the other way around: not delaying the A_PlaySound, but specifying that the A_PlaySound should start somewhat further in to the sound than from its beginning.

Re: Set start time to play sound in A_PlaySound

PostPosted: Mon Jun 04, 2018 10:46 am
by Nash
Yeah the whole point is not to delay when the sound starts. But to make it play from a random starting position.

Say you have a long, 1 minute ambient sound loop (played in UI context). Every time you enter the level, the sound keeps playing at the start. You'll eventually recognize the sound patterns and then you'll get sick of hearing it.

Re: Set start time to play sound in A_PlaySound

PostPosted: Mon Jun 04, 2018 1:58 pm
by RockstarRaccoon
I'd really like to be able to do this sort of thing for music too, being able to see where it is in one track and starting at the same place in a different track, for things like having multiple versions of a song that switch between each other at certain points...


That said, Nash, I think you should consider having said Ambient sound play differently in different parts...

Re: Set start time to play sound in A_PlaySound

PostPosted: Mon Jun 04, 2018 3:30 pm
by Graf Zahl
RockstarRaccoon wrote:I'd really like to be able to do this sort of thing for music too, being able to see where it is in one track and starting at the same place in a different track, for things like having multiple versions of a song that switch between each other at certain points...


Most music renderers do not support any fast forwarding to a given position so this is very unlikely.

Re: Set start time to play sound in A_PlaySound

PostPosted: Sun Dec 23, 2018 12:56 am
by Nash
This is directed to Chris:

I'm sorry for bumping this, but think you could take a look at this?

I have already tried to do it on my own and maybe help submit a PR but OpenAL is really strange to me.

I did try - I tried to see what the engine is doing with the "load game" code - because I know for sure that loading a game would set the sound position to whatever it was previously at - I thought I could somehow do some copy pasta here and apply the same concept - but no luck so far. :(

Forgive me if I'm wrong but the feature suggestion in the OP - to my inexperienced eyes as least - sounds like something that'll be trivial to do; in fact I was so confident that it is, hence why I tried to do it myself... it's just that I really have no idea how to do anything with OpenAL. :S

If you'd rather not do it, then perhaps you'd be willing to provide me some pointers on where to start looking? I'm comfortable enough with doing my own PRs, after all.

Thanks, and sorry for the bump again.

Re: Set start time to play sound in A_PlaySound

PostPosted: Sun Dec 23, 2018 10:08 am
by Chris
This will probably need a bit of work in both the higher and lower level sound code. It's trivial for OpenAL itself, but the OpenAL backend only knows to set a time offset when the sound-to-play comes with a predetermined FISoundChannel, as a result of loading a save game or restarting a sound that got preempted. For it to work with a freshly started sound, you'd need to add another parameter to the SoundRenderer's StartSound and StartSound3D (and MarkStartTime) methods that specifies a start offset (either in samples or (milli/micro)seconds, given the available information and desired precision).

It's the higher level code (src/s_sound.cpp and related places with scripting glue) that I would be completely lost on.