Moog VCF (from Faust) Ricardo Wurmus GPL filter.axh math.h > 2 // now is 2^27 = 134 217 728 // 2^32 = 4 294 967 296 // 2^29 = 536 870 912 (3:29) int32_t preout = int32_t(((f < 0) ? (-f) : f) * (1<<29)); return ((f < 0) ? ~preout : preout); } // convert fixed point to float // * invert bits if sign bit is set (0x08000000, or (1<<27)) // * cast int to float // * divide by constant to shift decimal point // * multiply by -1 if sign bit was set float frac32ToFloat(int32_t frac) { bool neg = (((1<<27) & frac) != 0); float res = (float)(neg ? frac : ~frac); res = res / (float(1<<29)); return (neg ? (-1 * res) : res); } float fslider0; float fslider1; float fslider2; float fcheckbox0; float fcheckbox1; float fcheckbox2; float fRec0[2]; float fRec1[2]; float fRec2[2]; float fRec3[2]; float fRec4[2]; float fRec5[2]; float fRec6[3]; float fRec7[3]; float fRec8[2]; float fRec10[2]; float fRec11[2]; float fRec13[2]; float fRec14[2]; float fConst1; float fConst2; float fSqrtTwo; inline float faustpower2(float x) { return powf(x,2); } inline float faustpower4(float x) { return powf(x,4); } // template inline float faustpower(float x) { return powf(x,N); } // template inline double faustpower(double x) { return pow(x,N); } // template inline int faustpower(int x) { return faustpower(x) * faustpower(x); } // template <> inline int faustpower<0>(int x) { return 1; } // template <> inline int faustpower<1>(int x) { return x; } ]]>