Create the sine wave and then use linear interpolation, bi linear interpolation, or cubic interpolation to smooth it out. This will get you past the exact timing problem.
Just create it via a Windows timer with a set period and then smooth it.
Linear interpolation: f1 is smoothing coefficient
As a function
Code:
double LI(double v1,double v2,double f1)
{
return (v1+f1*(v2-v1));
}
As a #define
Code:
#define LI(v1,v2,f1) (v1+f1*(v2-v1))
As a pure 16-bit TASM assembly function
32-bit only differs in stack and ebp esp.
Code:
_LI proc
ARG v1:QWORD,v2:QWORD,f1:QWORD
push bp
mov bp,sp
fld [v2]
fsub [v1]
fmul [f1]
fadd [v1]
pop bp
ret
_LI endp
As an inline assembly function
Code:
void LI(double v1,double v2,double f1,double result)
{
asm {
fld [v2]
fsub [v1]
fmul [f1]
fadd [v1]
fstp [result]
}
}
Bi linear interpolation:
Code:
double BI(double v1,double v2,double v3,double v4,double f1,double f2)
{
double val1=(v1+f1*(v2-v1));
double val2=(v3+f1*(v4-v3));
return (val1+f2*(val2-val1));
}
or
Code:
#define LI(v1,v2,f1) (v1+f1*(v2-v1));
double BI(double v1,double v2,double v3,double v4,double f1,double f2)
{
double val1=LI(v1,v2,f1);
double val2=LI(v3,v4,f1);
return LI(val1,val2,f2);
}
Pure 16-bit TASM assembly function
Code:
_BI proc
ARG v1:QWORD,v2:QWORD,v3:QWORD,v4:QWORD,f1:QWORD,f2:DWORD
LOCAL val1:WORD,val2:QWORD
push bp
mov bp,sp
fld [v2]
fsub [v1]
fmul [f1]
fadd [v1]
fstp [val1]
fld [v4]
fsub [v3]
fmul [f1]
fadd [v3]
fstp [val2]
fld [val2]
fsub [val1]
fmul [f2]
fadd [val1]
pop bp
ret
_BI endp
Anyways, you get the idea. There are other smoothing functions out there - look on www.google.com
SoundBlaster Live Series cards can do linear interpolation on waves to make the sound better and crisper - they also do loads of other things.