[Added] A_StopSounds

Moderator: GZDoom Developers

A_StopSounds

Postby Major Cooke » Sat Feb 29, 2020 2:11 pm

Pull Request

I realized recently that I needed a means to stop certain sounds, but not all of them from playing. A for loop with A_StopSound can be pretty tasking when there's a large number of sounds to search through, so I made this to alleviate that problem.
Last edited by Major Cooke on Sun Mar 01, 2020 12:36 pm, edited 1 time in total.
User avatar
Major Cooke
QZDoom Maintenance Team
 
Joined: 28 Jan 2007

Re: A_StopSounds

Postby Major Cooke » Sat Feb 29, 2020 5:31 pm

This submission wasn't actually added. Not to be confused with A_StopAllSounds.
User avatar
Major Cooke
QZDoom Maintenance Team
 
Joined: 28 Jan 2007

Re: A_StopSounds

Postby wildweasel » Sat Feb 29, 2020 7:16 pm

What differentiates this from A_StopAllSounds, and what's the specific use case?
User avatar
wildweasel
change o' pace.
Moderator Team Lead
 
Joined: 16 Jul 2003

Re: A_StopSounds

Postby Major Cooke » Sat Feb 29, 2020 7:31 pm

A_StopAllSounds stops every sound.
A_StopSounds, you specify a range of sounds to stop and the rest outside the range aren't affected.

A_StopSounds(5, 10) will stop all sounds that are between and including channels 5 and 10. Sounds beyond this range will continue playing, which is important for a few things that I need such as keeping certain sounds playing while swapping out others.

The primary use case is to avoid doing this:

Code: Select allExpand view
for (int i = 10; i < 1095; i++) // Exaggerated but if there's an actor playing a lot of sounds, this would be bad news.
    A_StopSound(i);


Because this would be bad, and cause a significant delay in the game if called repeatedly. The internal handling of A_StopSounds is a linked list which dramatically simplifies this process, so this is very important.
User avatar
Major Cooke
QZDoom Maintenance Team
 
Joined: 28 Jan 2007

Re: A_StopSounds

Postby Matt » Sat Feb 29, 2020 9:42 pm

Can these be merged into a single function with all sounds being stopped if you don't specify any range?
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: A_StopSounds

Postby Major Cooke » Sat Feb 29, 2020 10:07 pm

Not unless Graf wants that. If something changes between 0 and -1 being off limits for starting sound that'd cause compatibility issues.
User avatar
Major Cooke
QZDoom Maintenance Team
 
Joined: 28 Jan 2007

Re: A_StopSounds

Postby Graf Zahl » Sun Mar 01, 2020 12:21 am

This is confusing. Please merge it into one.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: A_StopSounds

Postby Major Cooke » Sun Mar 01, 2020 12:36 pm

User avatar
Major Cooke
QZDoom Maintenance Team
 
Joined: 28 Jan 2007


Return to Closed Feature Suggestions

Who is online

Users browsing this forum: No registered users and 1 guest