CHAN_OVERLAP sound flag

Moderator: GZDoom Developers

User avatar
phantombeta
Posts: 2175
Joined: Thu May 02, 2013 1:27 am
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: Brazil

Re: CHAN_OVERLAP sound flag

Post by phantombeta »

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.
User avatar
Major Cooke
Posts: 8209
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: GZBoomer Town
Contact:

Re: CHAN_OVERLAP sound flag

Post by Major Cooke »

This is fantastic stuff Graf!
Small nitpick but wouldn't it make more sense to call S_IsActorPlayingSomething as S_IsActorPlayingSound instead?
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49230
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: CHAN_OVERLAP sound flag

Post by Graf Zahl »

Yes, that may make sense. The name isn't that great.
User avatar
Player701
 
 
Posts: 1710
Joined: Wed May 13, 2009 3:15 am
Graphics Processor: nVidia with Vulkan support
Contact:

Re: CHAN_OVERLAP sound flag

Post by Player701 »

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.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49230
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: CHAN_OVERLAP sound flag

Post by Graf Zahl »

No, for that you'll have to do a check up front what the channel is playing.
User avatar
Marisa the Magician
Banned User
Posts: 3886
Joined: Fri Feb 08, 2008 9:15 am
Preferred Pronouns: She/Her
Operating System Version (Optional): (btw I use) Arch
Graphics Processor: nVidia with Vulkan support
Location: Vigo, Galicia
Contact:

Re: CHAN_OVERLAP sound flag

Post by Marisa the Magician »

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.
User avatar
Player701
 
 
Posts: 1710
Joined: Wed May 13, 2009 3:15 am
Graphics Processor: nVidia with Vulkan support
Contact:

Re: CHAN_OVERLAP sound flag

Post by Player701 »

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.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49230
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: CHAN_OVERLAP sound flag

Post by Graf Zahl »

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.
User avatar
Player701
 
 
Posts: 1710
Joined: Wed May 13, 2009 3:15 am
Graphics Processor: nVidia with Vulkan support
Contact:

Re: CHAN_OVERLAP sound flag

Post by Player701 »

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?
User avatar
Marisa the Magician
Banned User
Posts: 3886
Joined: Fri Feb 08, 2008 9:15 am
Preferred Pronouns: She/Her
Operating System Version (Optional): (btw I use) Arch
Graphics Processor: nVidia with Vulkan support
Location: Vigo, Galicia
Contact:

Re: CHAN_OVERLAP sound flag

Post by Marisa the Magician »

If it's not returning true even if the previous sounds are longer then yes, that's a problem.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49230
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: CHAN_OVERLAP sound flag

Post by Graf Zahl »

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.
User avatar
Player701
 
 
Posts: 1710
Joined: Wed May 13, 2009 3:15 am
Graphics Processor: nVidia with Vulkan support
Contact:

Re: CHAN_OVERLAP sound flag

Post by Player701 »

Okay, see my report here.
Post Reply

Return to “Closed Feature Suggestions [GZDoom]”