Also you can linear interpolate the sound wave which will take some of the 'squareness' of the wave out. To linear interpolate it use the slice of time you want as the basis for the interpolation.
If you want the sound that should be halfway between certain bytes or words of sound then use .5 as the value.
Code:
double LI(double v1,double v2,double f1)
{
return (v1+f1*(v2-v1));
}
double LI(double v1,double v2,double f1)
{
double result=0.0;
asm {
fld [v2]
fsub [v1]
fmul [f1]
fadd [v1]
fstp [result]
}
return result;
}
for (int i=0;i<Buffer_length-1;i++)
{
BYTE ss1=PrimaryBuffer[i];
BYTE ss2=PrimaryBuffer[i+1];
double interpolatedsample=LI((double)ss1,(double)ss2,.5);
PrimaryBuffer[i]=(BYTE)interpolatedsample;
}
Returning values in variables that are popped off of the stack is not a good practice. I only did it here because it was the easiest to represent.