From 8a4bca986c57062e96f1e58281b3eff52a856ee6 Mon Sep 17 00:00:00 2001 From: rekado Date: Tue, 6 Sep 2016 22:13:03 +0200 Subject: Initial commit. --- objects/faust/karplus.axo | 98 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 objects/faust/karplus.axo (limited to 'objects/faust/karplus.axo') diff --git a/objects/faust/karplus.axo b/objects/faust/karplus.axo new file mode 100644 index 0000000..60035a6 --- /dev/null +++ b/objects/faust/karplus.axo @@ -0,0 +1,98 @@ + + + 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]; + } +]]> + + -- cgit v1.2.3