[Added] CHAN_OVERLAP sound flag

Moderator: GZDoom Developers

CHAN_OVERLAP sound flag

Postby Marisa Kirisame » Tue Dec 10, 2019 6:45 am

Makes it possible to have sounds overlap in one channel without interrupting each other.

PR here. Video showing the effect here.
User avatar
Marisa Kirisame
ZScript Crimester
 
 
 
Joined: 08 Feb 2008
Location: Vigo, Galicia
Discord: 霧雨魔理沙#1666
Twitch ID: magusmarisa
Github ID: OrdinaryMagician
Operating System: Other Linux 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: CHAN_OVERLAP sound flag

Postby Graf Zahl » Tue Dec 10, 2019 6:48 am

I'll have to check if this leaks any state. The 8 channel slots are used to track that state, after all.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: CHAN_OVERLAP sound flag

Postby Matt » Tue Dec 10, 2019 6:21 pm

This will definitely come in handy instead of setting up an int and cycling it just to access multiple channels...
User avatar
Matt
Putting the XD into *xdeath since 2007
 
Joined: 04 Jan 2004
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia

Re: CHAN_OVERLAP sound flag

Postby Nash » Tue Dec 10, 2019 8:38 pm

Damn, this collides with my game-specific CHAN_RADIO implementation. Looks like the bad design of the CHAN_ constants are starting to show its limitations...
User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes

Re: CHAN_OVERLAP sound flag

Postby Marisa Kirisame » Wed Dec 11, 2019 1:32 am

There's two other bits left, I could just shift it up. :P
User avatar
Marisa Kirisame
ZScript Crimester
 
 
 
Joined: 08 Feb 2008
Location: Vigo, Galicia
Discord: 霧雨魔理沙#1666
Twitch ID: magusmarisa
Github ID: OrdinaryMagician
Operating System: Other Linux 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: CHAN_OVERLAP sound flag

Postby Graf Zahl » Wed Dec 11, 2019 2:22 am

That's the risk when using bits in a system field.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: CHAN_OVERLAP sound flag

Postby Marisa Kirisame » Wed Dec 11, 2019 2:27 am

Actually, wait, there are even more bits, it's an int after all, dunno why I assumed it was a short.
User avatar
Marisa Kirisame
ZScript Crimester
 
 
 
Joined: 08 Feb 2008
Location: Vigo, Galicia
Discord: 霧雨魔理沙#1666
Twitch ID: magusmarisa
Github ID: OrdinaryMagician
Operating System: Other Linux 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: CHAN_OVERLAP sound flag

Postby Nash » Wed Dec 11, 2019 8:25 am

Eh, it's not a big deal, my project is very specific so I'll just shift my constant farther back to accommodate upstream's progress. I'm mainly just worried about "channels" being used for both actual sound channels and modifier flags... :P
User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes

Re: CHAN_OVERLAP sound flag

Postby Marisa Kirisame » Sat Dec 14, 2019 8:30 am

Any updates on this? Is it safe?
User avatar
Marisa Kirisame
ZScript Crimester
 
 
 
Joined: 08 Feb 2008
Location: Vigo, Galicia
Discord: 霧雨魔理沙#1666
Twitch ID: magusmarisa
Github ID: OrdinaryMagician
Operating System: Other Linux 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: CHAN_OVERLAP sound flag

Postby Graf Zahl » Sat Dec 14, 2019 9:41 am

I didn't find any time over the last week to think about it.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: CHAN_OVERLAP sound flag

Postby Graf Zahl » Mon Dec 16, 2019 4:19 pm

I finally managed to check this out. To my neverending surprise there is absolutely nothing in the sound backend that ever indexes an array or other data with the channel number - it's just an arbitrary identifier which makes the limit of 8 channels look even more ridiculous. I think in the past this was different but got refactored out at some point,

So, this PR is safe to add - and expanding the number of channels is just refactoring of the API, not internal reworking. Of course the API is one hell of a clusterfuck with its multitude of different variations of the same theme.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: CHAN_OVERLAP sound flag

Postby Major Cooke » Mon Dec 16, 2019 5:12 pm

Wait, so how many channels maximum can we have now?
User avatar
Major Cooke
QZDoom Maintenance Team
 
Joined: 28 Jan 2007

Re: CHAN_OVERLAP sound flag

Postby 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.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: CHAN_OVERLAP sound flag

Postby 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.
User avatar
phantombeta
In the meadow of sinful thoughts, every flower's a perfect one
 
Joined: 02 May 2013
Location: Brazil, South America, Earth, Orion-Cygnus Arm, Milky Way
Discord: phantombeta#2461
Twitch ID: phantombeta_
Github ID: Doom2fan
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: CHAN_OVERLAP sound flag

Postby 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.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Next

Return to Closed Feature Suggestions

Who is online

Users browsing this forum: No registered users and 0 guests