We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 3507

Summary: audio glitch after internal resampling
Product: SDL Reporter: Sylvain <sylvain.becker>
Component: audioAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: don't know   
Hardware: x86_64   
OS: Linux   
Attachments: sound

Description Sylvain 2016-12-05 12:34:29 UTC
Created attachment 2647 [details]
sound

Since audio converter code https://hg.libsdl.org/SDL/rev/bb99dede0675
There is a glitch after playing attached wav sound file.

Some log:
Build format 8010->8010, channels 1->2, rate 48000->22050
Comment 1 Sylvain 2016-12-14 13:38:44 UTC
Ryan, 

I think there may be an issue when downsampling (and also upsampling), 
I would apply this patch (and the same for upsampling):

--- a/src/audio/SDL_audiotypecvt.c	Tue Dec 13 00:22:42 2016 -0500
+++ b/src/audio/SDL_audiotypecvt.c	Wed Dec 14 14:37:06 2016 +0100
@@ -283,11 +283,11 @@
     SDL_memcpy(last_sample, src, cpy);
 
     while (dst < target) {
-        src += 8;
+        src += channels;
         eps += dstsize;
         if ((eps << 1) >= srcsize) {
             SDL_memcpy(dst, sample, cpy);
-            dst += 8;
+            dst += channels;
             for (i = 0; i < channels; i++) {
                 sample[i] = (float) ((((double) src[i]) + ((double) last_sample[i])) * 0.5);
             }
Comment 2 Ryan C. Gordon 2016-12-17 21:16:20 UTC

Whoops, sorry! This is fixed now in https://hg.libsdl.org/SDL/rev/f6cd81aab88e !

--ryan.