A_StopSounds

Moderator: GZDoom Developers

Post Reply
User avatar
Major Cooke
Posts: 8175
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

A_StopSounds

Post by Major Cooke »

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
Posts: 8175
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: A_StopSounds

Post by Major Cooke »

This submission wasn't actually added. Not to be confused with A_StopAllSounds.
User avatar
wildweasel
Posts: 21706
Joined: Tue Jul 15, 2003 7:33 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): A lot of them
Graphics Processor: Not Listed
Contact:

Re: A_StopSounds

Post by wildweasel »

What differentiates this from A_StopAllSounds, and what's the specific use case?
User avatar
Major Cooke
Posts: 8175
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: A_StopSounds

Post by Major Cooke »

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 all

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
Matt
Posts: 9696
Joined: Sun Jan 04, 2004 5:37 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Debian Bullseye
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Contact:

Re: A_StopSounds

Post by Matt »

Can these be merged into a single function with all sounds being stopped if you don't specify any range?
User avatar
Major Cooke
Posts: 8175
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: A_StopSounds

Post by Major Cooke »

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

Re: A_StopSounds

Post by Graf Zahl »

This is confusing. Please merge it into one.
User avatar
Major Cooke
Posts: 8175
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: A_StopSounds

Post by Major Cooke »

Post Reply

Return to “Closed Feature Suggestions [GZDoom]”