There appears to be problems with SSRC when compiled using Microsofts compilers, compiling ssrc.exe in VC v6 (without modification) gives the bug, but ssrc compiled with gcc seems not to (atleast the supplied gcc already compiled ssrc). It appears to be a rounding error in data lengths, so not really a bug but something brought on through compiler differences.
To recreate (I am guessing SSRC downsampling in foobar might have the same problem), downsample this file (a strange part triangle wave, don't try to play it though speakers):
http://www.dbpoweramp.com/beta/SSRC-48khz-Source.wav
64KB
Down-sample it to 44100 HZ, then look at the resulting wave in a wave editor, around sample 5010 there are 22 bad samples ~ 57ms in.
So...my first question is has anyone seen this before?
Looking at the code, at the end of a down sample pass it is copying too many samples across from the end of buffer 2 down to the beginning of buffer 2:
int ds = (rp2-1)/(fs2/fs1);
if (ds > n1b2)
ds = n1b2;
// <<<<<<<< BUG IS here somewhere moving 35 sample from end of buffer even though only 34 samples, there is a NAN after that
for(ch = 0; ch < nch; ch++)
memmove(buf2[ch],buf2[ch]+ds,sizeof(REAL_SSRC)*(n2x+1+n1b2-ds));
rp2 -= ds*(fs2/fs1);
for(ch = 0; ch < nch; ch++)
memcpy(buf2[ch]+n2x+1,buf1[ch]+n1b2,sizeof(REAL_SSRC)*n1b2);
My next question, what is the best way of debugging with gcc? in windows, if I can step that code in gcc it should be an easy fix.