I am trying to change the speed of an audio file, if I do it with unsigned values all is all right, but once I start using double values things get messy, for instance, my code
Your reading-from falls on odd barriers: that is because of truncation the read-from byte starts at an odd location. Use the following to start from even location:
for (i=0; i<(b2.length/frameSize); i++) {
int ind=(int)((i*frameSize*playBackSpeed));
if((ind%2)==1) ind++;
for (j=0; j<frameSize; j++) {
b2[(i*frameSize)+j] = b1[ind+j];
}
}
Or you can change the jump to 4:
if((ind%4)>0) ind+=(4-(ind%4));