Vec2<float> trunc(const Vec2<float> &v) { Vec2<float> rv; rv.x = trunc_float(v.x); rv.y = trunc_float(v.y); return rv; }
Vec4<float> trunc(const Vec4<float> &v) { Vec4<float> rv; rv.x = trunc_float(v.x); rv.y = trunc_float(v.y); rv.z = trunc_float(v.z); rv.w = trunc_float(v.w); return rv; }
VecN<float, N> trunc(const VecN<float, N> &v) { VecN<float, N> rv; for(unsigned int i=0; i < N; i++) { rv.v[i] = trunc_float(v.v[i]); } return rv; }
void fir_float(float x,float *z) { static float x_1 = 0.0; static float x_2 = 0.0; // z[n] = alpha*x[n] + beta*x[n-1] + alpha*x[n-2]; float zRR_i0M = select_float_scale(x,8,4,11,-4,1); float zRR_i0R = trunc_float(select_float(zRR_i0M,16,8,11,4),8,4,8,4); float zRR_i0 = zRR_i0R; float zRR_i1M = select_float_scale(x_1,8,4,11,-4,0) + select_float_scale(x_1,8,4,11,-4,1); float zRR_i1R = trunc_float(select_float(zRR_i1M,16,8,11,4),8,4,8,4); float zRR_i1 = zRR_i1R; float zRR_i2M = select_float_scale(x_2,8,4,11,-4,1); float zRR_i2R = trunc_float(select_float(zRR_i2M,16,8,11,4),8,4,8,4); float zRR_i2 = zRR_i2R; float zR = trunc_float(zRR_i0 + zRR_i1 + zRR_i2,8,4,8,4); *z = zR; // Signal Delay x_2 = x_1; x_1 = x; }
float trunc(const float v) { return trunc_float(v); }
Fixed trunc_fixed(Fixed v) { return FloatToFixed( trunc_float(FixedToFloat(v)) ); }