#include #include #include #define BASEFREQ 1024 static int nint(double d) { if (d < 0) return(d-.5); else return(d+.5); } static void write_sample(int s) { if (s < -32767) s = -32767; if (s > 32767) s = 32767; putchar((s>>8)&0xff); putchar(s&0xff); } int main(void); int main(void) { int t; int n; double k; double x; double ph; double ln2; double v[4001]; ln2 = log(2); n = ((BASEFREQ/ln2) * (sqrt(2)-1)) + 1; k = log((n*ln2/BASEFREQ)+1) / ln2; ph = 0; for (t=0;t<4001;t++) { x = (t * k) / 4000; v[t] = (BASEFREQ / ln2) * 2 * M_PI * (pow(2,x) - 1); } if (v[4000]-(n*2*M_PI) > 1e-10) abort(); for (t=0;t<4000;t++) write_sample(nint(sin(v[t])*3000)); for (t=3999;t>=0;t--) write_sample(nint(sin(-v[t])*3000)); exit(0); }