View Issue Details

IDProjectCategoryView StatusLast Update
0000232Gameplay + OpenGL[All Projects] Featurepublic2017-04-30 19:27
ReporterEnjay 
Assigned ToRachael 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionopen 
Summary0000232: Fix "Sound Popping" issue please
DescriptionCan anything be done to fix this issue?

As discussed here:

https://forum.zdoom.org/viewtopic.php?f=3&t=55212

And according to torridgristle:

"It's the sound of the waveform truncating to restart since only one sound can play at a time in the pickup channel, making popping sounds.

It's not clipping, it's popping from the sound truncating / suddenly switching to 0."
Steps To ReproduceLoad the test PK3 in the above linked thread.
TagsNo tags attached.

Relationships

Activities

Rachael

Rachael

2017-02-11 04:22

administrator   ~0000503

As stated in the thread, we really need someone who is willing to dive into the sound code for this issue. What would be perfect is if the guy who did the OpenAL came back and took a look at it. I think he, besides Marisa, is more well versed than anyone else right now about it. Failing that, myself, Graf, or dpJudas can look at it when we have some extra time.
Chris

Chris

2017-04-19 18:09

developer   ~0001465

(Since my forum account has been manually deactivated, I guess I'll post here instead of the forum thread. Where can I contact an admin to get it reactivated?)

OpenAL Soft does fading with volume changes (I imagine other implementations do too, but I can't vouch for them). So you could set the old sound source's volume to 0 to silence it without popping, calling alSourceStop/Rewind() some 20+ms later in a future UpdateSounds() call, and use another source for the new sound copy (the code will already do this part).
Graf Zahl

Graf Zahl

2017-04-21 03:38

administrator   ~0001497

About the forum, read this:

https://forum.zdoom.org/viewtopic.php?f=48&t=55791
Graf Zahl

Graf Zahl

2017-04-21 03:41

administrator   ~0001498

About the issue at hand, please keep in mind that my knowledge of the sound code, both low and high level is rather superficial, so I'd need a bit more detailed explanations. Is this something that needs to be done inside the sound backend or in s_sound.cpp?
Chris

Chris

2017-04-21 04:51

developer   ~0001501

Last edited: 2017-04-21 04:52

View 2 revisions

Inside the sound backend would be the most sensible place.

The general gist of it is, in OpenALSoundRenderer::StopChannel, rather than calling

alSourceRewind(source);
alSourcei(source, AL_BUFFER, 0);
...
FreeSfx.Push(source);

to stop the source and make it available for use again, you'd instead set the source's AL_GAIN property to 0 and push it onto a different array with the current clock time. In OpenALSoundRenderer::UpdateSounds you'd check through that array, and if the current clock time is far enough ahead of the stored time, then you call alSourceRewind+alSourcei+FreeSfx.Push with the source as you clear the entry from the array.

There's a few details to watch for though, such as checking if the source is actually stopped already in StopChannel (from reaching the end), so it can be cleaned up without delay. And there's a few places that expect StopChannel to free up the source immediately (for situations where it's out of sources and needs to forcefully take one, or the sound is being unloaded while something's still playing it), so that would need some fixing up too (a separate method that does what StopChannel currently does to free up the source immediately for those edge cases wouldn't be hard).

Issue History

Date Modified Username Field Change
2017-02-10 09:23 Enjay New Issue
2017-02-11 04:22 Rachael Status new => confirmed
2017-02-11 04:22 Rachael Note Added: 0000503
2017-04-19 18:09 Chris Note Added: 0001465
2017-04-21 03:38 Graf Zahl Note Added: 0001497
2017-04-21 03:41 Graf Zahl Note Added: 0001498
2017-04-21 04:51 Chris Note Added: 0001501
2017-04-21 04:52 Chris Note Edited: 0001501 View Revisions
2017-04-30 19:27 Rachael Assigned To => Rachael
2017-04-30 19:27 Rachael Status confirmed => closed