static FP_TYPE* synth_sinusoid_frame(FP_TYPE* freq, FP_TYPE* ampl, FP_TYPE* phse, int nhar, int fs, int length) { FP_TYPE* x = calloc(length, sizeof(FP_TYPE)); for(int i = 0; i < nhar; i ++) { FP_TYPE h_f = freq[i]; FP_TYPE h_a = ampl[i]; FP_TYPE h_p = phse[i]; if(i > 0 && h_f < 50.0) // reaching the end break; FP_TYPE tphffs = 2.0 * M_PI / fs * h_f; for(int t = - length / 2; t < length / 2; t ++) x[t + length / 2] += fastcosfull(tphffs * t + h_p) * h_a; } return x; }
eiFORCEINLINE vector rotate_vector(const vector & p, const vector & a, scalar rdn) { const scalar c = fastcosfull(rdn); const scalar t = 1 - c; const scalar s = fastsinfull(rdn); const scalar txy = t * a.x * a.y; const scalar tyz = t * a.y * a.z; const scalar txz = t * a.x * a.z; const scalar sx = s * a.x; const scalar sy = s * a.y; const scalar sz = s * a.z; return vector( p.x * (t * a.x * a.x + c) + p.y * (txy - sz) + p.z * (txz + sy), p.x * (txy + sz) + p.y * (t * a.y * a.y + c) + p.z * (tyz - sx), p.x * (txz - sy) + p.y * (tyz + sx) + p.z * (t * a.z * a.z + c)); }