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.
A_StopSounds
Moderator: GZDoom Developers
- Major Cooke
- Posts: 8175
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team
A_StopSounds
Last edited by Major Cooke on Sun Mar 01, 2020 12:36 pm, edited 1 time in total.
- Major Cooke
- Posts: 8175
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team
Re: A_StopSounds
This submission wasn't actually added. Not to be confused with A_StopAllSounds.
- 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
What differentiates this from A_StopAllSounds, and what's the specific use case?
- Major Cooke
- Posts: 8175
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team
Re: A_StopSounds
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:
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.
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);
- 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
Can these be merged into a single function with all sounds being stopped if you don't specify any range?
- Major Cooke
- Posts: 8175
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team
Re: A_StopSounds
Not unless Graf wants that. If something changes between 0 and -1 being off limits for starting sound that'd cause compatibility issues.
- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49067
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: A_StopSounds
This is confusing. Please merge it into one.
- Major Cooke
- Posts: 8175
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team