Karplus (from Faust) Ricardo Wurmus GPL filter.axh arm_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 fVec0[2]; float fRec1[2]; int iRec2[2]; float fslider1; float fslider2; int IOTA; float fVec1[512]; float fslider3; float fRec0[3]; ]]> 0.0f)) - (fSlow0 * (fRec1[1] > 0.0f))); iRec2[0] = (12345 + (1103515245 * iRec2[1])); fVec1[IOTA&511] = ((fSlow3 * (fRec0[1] + fRec0[2])) + (fSlow2 * (iRec2[0] * (fRec1[0] > 0.0f)))); fRec0[0] = fVec1[(IOTA-iSlow4)&511]; arm_float_to_q31(&fRec0[0], &output0[i], 0); // output0[i] = floatToFrac32(fRec0[0]); // post processing fRec0[2] = fRec0[1]; fRec0[1] = fRec0[0]; IOTA = IOTA+1; iRec2[1] = iRec2[0]; fRec1[1] = fRec1[0]; fVec0[1] = fVec0[0]; } ]]>