CHAN_OVERLAP sound flag

Post a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is OFF
Smilies are ON

Topic review
   

Expand view Topic review: CHAN_OVERLAP sound flag

Re: CHAN_OVERLAP sound flag

by Player701 » Tue Dec 17, 2019 4:52 am

Okay, see my report here.

Re: CHAN_OVERLAP sound flag

by Graf Zahl » Tue Dec 17, 2019 4:45 am

Player701 wrote:Hmm. I've run some tests, and it seems that if CHAN_OVERLAP is not specified, then it always overrides the most recently started sound that is still playing. So I guess I can't implement my use case with only one channel.

In addition, it looks like IsActorPlayingSomething is bugged: if multiple sounds are playing, it will only report true for one of them (which also happens to be the one started most recently), and false for all others. Should I report this?
It may not be the only thing that needs adjustment for CHAN_OVERLAP. The old story: Even simple features often have farther reaching consequences. Let's collect all related issues here.

Re: CHAN_OVERLAP sound flag

by Marisa the Magician » Tue Dec 17, 2019 4:27 am

If it's not returning true even if the previous sounds are longer then yes, that's a problem.

Re: CHAN_OVERLAP sound flag

by Player701 » Tue Dec 17, 2019 3:27 am

Hmm. I've run some tests, and it seems that if CHAN_OVERLAP is not specified, then it always overrides the most recently started sound that is still playing. So I guess I can't implement my use case with only one channel.

In addition, it looks like IsActorPlayingSomething is bugged: if multiple sounds are playing, it will only report true for one of them (which also happens to be the one started most recently), and false for all others. Should I report this?

Re: CHAN_OVERLAP sound flag

by Graf Zahl » Tue Dec 17, 2019 3:00 am

Like I said, in this case you first need to check the channel with the newly added IsActorPlayingSound function and then do different things based on the result.

Re: CHAN_OVERLAP sound flag

by Player701 » Tue Dec 17, 2019 2:58 am

Sorry, I've described my use case slightly wrong.
Player701 wrote:ideally, I'd like to start a new sound on the same channel ONLY if said channel is not already playing this sound.
I forgot to add that if the channel IS playing the requested sound, the sound is overridden (i.e. starts playing again). This is how I'd like it to work.

Re: CHAN_OVERLAP sound flag

by Marisa the Magician » Tue Dec 17, 2019 2:57 am

Actually due to the order in which the flags are handled, it'd probably work to just use CHAN_NOSTOP and CHAN_OVERLAP at the same time for the behaviour described.

Re: CHAN_OVERLAP sound flag

by Graf Zahl » Tue Dec 17, 2019 2:53 am

No, for that you'll have to do a check up front what the channel is playing.

Re: CHAN_OVERLAP sound flag

by Player701 » Tue Dec 17, 2019 2:45 am

This looks interesting. However, I have another use case: ideally, I'd like to start a new sound on the same channel ONLY if said channel is not already playing this sound. This way, if the sounds are different, they will overlap, but if they are the same, only one instance will play at a time. Or does it already work like that? I'm imagining a ZScript solution to this (that uses multiple channels instead of the new flag) but it looks a little bit hacky to me.

Re: CHAN_OVERLAP sound flag

by Graf Zahl » Tue Dec 17, 2019 12:58 am

Yes, that may make sense. The name isn't that great.

Re: CHAN_OVERLAP sound flag

by Major Cooke » Mon Dec 16, 2019 6:20 pm

This is fantastic stuff Graf!
Small nitpick but wouldn't it make more sense to call S_IsActorPlayingSomething as S_IsActorPlayingSound instead?

Re: CHAN_OVERLAP sound flag

by phantombeta » Mon Dec 16, 2019 5:37 pm

Graf Zahl wrote:No, that's not possible. The channel parameter has changed its meaning and using the same function would be very, very problematic. In this case the two new functions are the lesser evil, in case of S_Sound it allowed a clean deprecation, in case of A_PlaySound this still requires changing 240 lines of script code before it can be done. But deprecation is preferable to a change in behavior.
There would be no change in behaviour with any of my proposed methods. Two would only trigger the new behaviour if the modder specifically requested it, and one would only do it based on the ZScript version or if the modder unset the flag.

Re: CHAN_OVERLAP sound flag

by Graf Zahl » Mon Dec 16, 2019 5:26 pm

No, that's not possible. The channel parameter has changed its meaning and using the same function would be very, very problematic. In this case the two new functions are the lesser evil, in case of S_Sound it allowed a clean deprecation, in case of A_PlaySound this still requires changing 240 lines of script code before it can be done. But deprecation is preferable to a change in behavior.

Re: CHAN_OVERLAP sound flag

by phantombeta » Mon Dec 16, 2019 5:21 pm

Graf Zahl wrote:As many as you like. There never was a real limit aside from the stupid API.
👀
That would be quite awesome, and I think everyone would love that.
Perhaps a way to do it without replacing A_PlaySound and introducing even more functions would be to add a "flags" int at the end of the function, that is set to a "Old channel compat" flag by default that makes the channel parameter behave as it currently does, and not setting it would make the channel int not have flags. Could also automatically enable or disable based on ZScript version, maybe...
Or introduce #pragma to ZScript and have the default flag be disabled through that. That would be the better option IMO.

Re: CHAN_OVERLAP sound flag

by Graf Zahl » Mon Dec 16, 2019 5:15 pm

As many as you like. There never was a real limit aside from the stupid API. All the changes were only in the calling code to add the new parameter. In the backend the entire actual change was the one line that split the channel word into the channel and the flags.

Top