Resampler: Fix crackles when looping the audio #2762
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I "only" needed 4 hours to come up with this solution. Well, after debugging for 4 hours I finally understood how our resampler works. I was also able to simplify the code alot until I discovered where the crackles are coming from: The wrapped_decoder is not looping.
Refactoring the resampler to get it merged with the decoder will take a while, so I provide here a workaround to get rid of the crackles for now.
For a smooth looping without gaps the wrapped_decoder must be able to loop.
The solution is more of a hack / short-term solution:
All loop-related methods were forwarded to the wrapped_decoder
The better, more complex solution is refactoring the code by merging Decoder+Resampler
to give more control about the decoding process without all this ugly forwarding.
Fix #2666