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 ++++++++++++++ objects/faust/moog_vcf.axo | 205 ++++++++++++++++++++++++++++ objects/faust/phaser_mono.wip | 90 +++++++++++++ objects/faust/phaser_mono_float.axo | 36 +++++ objects/faust/phaser_mono_float.cpp | 129 ++++++++++++++++++ objects/faust/phaser_stereo_float.axo | 70 ++++++++++ objects/faust/phaser_stereo_float.cpp | 215 ++++++++++++++++++++++++++++++ objects/faust/phaser_stereo_optimised.axo | 180 +++++++++++++++++++++++++ 8 files changed, 1023 insertions(+) create mode 100644 objects/faust/karplus.axo create mode 100644 objects/faust/moog_vcf.axo create mode 100644 objects/faust/phaser_mono.wip create mode 100644 objects/faust/phaser_mono_float.axo create mode 100644 objects/faust/phaser_mono_float.cpp create mode 100644 objects/faust/phaser_stereo_float.axo create mode 100644 objects/faust/phaser_stereo_float.cpp create mode 100644 objects/faust/phaser_stereo_optimised.axo (limited to 'objects/faust') 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]; + } +]]> + + diff --git a/objects/faust/moog_vcf.axo b/objects/faust/moog_vcf.axo new file mode 100644 index 0000000..8abb697 --- /dev/null +++ b/objects/faust/moog_vcf.axo @@ -0,0 +1,205 @@ + + + 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; } +]]> + + + + diff --git a/objects/faust/phaser_mono.wip b/objects/faust/phaser_mono.wip new file mode 100644 index 0000000..9966c00 --- /dev/null +++ b/objects/faust/phaser_mono.wip @@ -0,0 +1,90 @@ + + virtual void instanceInit(int samplingFreq) { + } + virtual void compute (int count, FAUSTFLOAT** input, FAUSTFLOAT** output) { + // TODO: find replacements for: expf, cosf, sinf + // values must be scaled to fit into the range expected by arm_{cos,sin}_q31 + // they all take radians! + // cosf --> arm_cos_q31 + // sinf --> arm_sin_q31 + + int32_t fSlow0 = param_fcheckbox0 ? 0x00200000 /*"1"*/ : (param_fslider0>>1); + int32_t fSlow1 = param_fcheckbox1 ? __QSUB(0, fSlow0) : fSlow0; + // TODO: find replacement for expf + // e ^ -1 * const1 * pi * slider3 + // It's a value between 0.72 and 1.0, but for now we pretend it's just the value of fslider3. + // float fSlow4 = expf((fConst1 * (0 - (3.141592653589793f * float(fslider3))))); + int32_t fSlow4 = param_fslider3; + int32_t fSlow5 = __SMMUL(fSlow4, fSlow4); + int32_t fSlow6 = __SMMUL(fConst2, param_fslider4); + int32_t fSlow7 = arm_cos_q31(fSlow6); + int32_t fSlow8 = arm_sin_q31(fSlow6); + int32_t fSlow9 = __QSUB(0, fSlow8); + int32_t fSlow11 = ___SMMUL(TAU, param_fslider5); + int32_t fSlow12 = (__SMMUL(TAU, MAX(param_fslider5, param_fslider6)) - fSlow11) >>1; + int32_t fSlow15 = __QSUB(0, fSlow4<<1); + int32_t fSlow14 = __SMMUL(fConst1, param_fslider7); + int32_t fSlow16 = __SMMUL(fSlow14, param_fslider7); + int32_t fSlow17 = __SMMUL(fSlow16, param_fslider7); + int32_t fSlow18 = __SMMUL(fSlow17, param_fslider7); + int32_t fSlow19 = __QSUB(1, fSlow0); + + int32_t* input0 = input[0]; + int32_t* input1 = input[1]; + int32_t* output0 = output[0]; + int32_t* output1 = output[1]; + + for (int i=0; i + + Phaser Mono (from Faust) + Ricardo Wurmus + GPL + + + + + + + + + + + + + + + + ./phaser_mono_float.cpp + + + + + + diff --git a/objects/faust/phaser_mono_float.cpp b/objects/faust/phaser_mono_float.cpp new file mode 100644 index 0000000..d3cc774 --- /dev/null +++ b/objects/faust/phaser_mono_float.cpp @@ -0,0 +1,129 @@ +//----------------------------------------------------- +// name: "Phaser Mono" +// +// Code generated with Faust 0.9.67 (http://faust.grame.fr) +//----------------------------------------------------- +/* link with */ +#ifndef FAUSTPOWER +#define FAUSTPOWER +#define faustpower4(x) ((x)*(x)*(x)*(x)) +#define faustpower3(x) ((x)*(x)*(x)) +#define faustpower2(x) ((x)*(x)) +#define max(a, b) ((a) > (b) ? (a) : (b)) +#define min(a, b) ((a) < (b) ? (a) : (b)) +#endif +//---------------------------------------------------------------------------- +// FAUST generated signal processor +//---------------------------------------------------------------------------- + +#ifndef FAUSTFLOAT +#define FAUSTFLOAT float +#endif + +#ifndef FAUSTCLASS +#define FAUSTCLASS mydsp +#endif + +class Dsp { + private: + int iVec0[2]; + int iConst0; + float fConst1; + float fConst2; + FAUSTFLOAT speed; //default: 0.5f; range: 0..10 + float fConst3; + float fRec5[2]; + float fRec6[2]; + float fConst4; + float fConst5; + float fRec4[3]; + float fConst6; + float fRec3[3]; + float fConst7; + float fRec2[3]; + float fConst8; + float fRec1[3]; + float fRec0[2]; + public: + static void classInit(int samplingFreq) { + } + virtual void instanceInit(int samplingFreq) { + int fSamplingFreq = samplingFreq; + for (int i=0; i<2; i++) iVec0[i] = 0; + iConst0 = min(192000, max(1, fSamplingFreq)); + fConst1 = 0.9366460212365959; //expf((0 - (3141.592653589793f / float(iConst0)))); + fConst2 = faustpower2(fConst1); + speed = 0.5f; + fConst3 = (6.283185307179586f / float(iConst0)); + for (int i=0; i<2; i++) fRec5[i] = 0; + for (int i=0; i<2; i++) fRec6[i] = 0; + fConst4 = (2.0f / float(iConst0)); + fConst5 = (0 - (2 * fConst1)); + for (int i=0; i<3; i++) fRec4[i] = 0; + fConst6 = (4.0f / float(iConst0)); + for (int i=0; i<3; i++) fRec3[i] = 0; + fConst7 = (8.0f / float(iConst0)); + for (int i=0; i<3; i++) fRec2[i] = 0; + fConst8 = (16.0f / float(iConst0)); + for (int i=0; i<3; i++) fRec1[i] = 0; + for (int i=0; i<2; i++) fRec0[i] = 0; + } + virtual void init(int samplingFreq) { + classInit(samplingFreq); + instanceInit(samplingFreq); + } + // 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 ConvertFracToFloat(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); + } + + virtual void compute (int count, + const int32_t** input, + int32_t* output, + int32_t speed) { + float fSlow0 = 100; + float fSlow1 = 0.01f * fSlow0; + float fSlow2 = (fConst3 * 10*ConvertFracToFloat(speed)); + float fSlow3 = cosf(fSlow2); + float fSlow4 = sinf(fSlow2); + float fSlow5 = (0 - fSlow4); + float fSlow6 = (1 - (0.01f * fSlow0)); + const int32_t* input0 = *input; + int32_t* output0 = output; + for (int i=0; i + + Phaser Stereo (from Faust) + Ricardo Wurmus + GPL + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ./phaser_stereo_float.cpp + + + + + + + diff --git a/objects/faust/phaser_stereo_float.cpp b/objects/faust/phaser_stereo_float.cpp new file mode 100644 index 0000000..9e3e587 --- /dev/null +++ b/objects/faust/phaser_stereo_float.cpp @@ -0,0 +1,215 @@ +//----------------------------------------------------- +// name: "Phaser" +// +// Code generated with Faust 0.9.67 (http://faust.grame.fr) +//----------------------------------------------------- +/* link with */ +#ifndef FAUSTPOWER +#define FAUSTPOWER +#define faustpower4(x) ((x)*(x)*(x)*(x)) +#define faustpower3(x) ((x)*(x)*(x)) +#define faustpower2(x) ((x)*(x)) +#define max(a, b) ((a) > (b) ? (a) : (b)) +#define min(a, b) ((a) < (b) ? (a) : (b)) +#endif +/************************************************************************ + ************************************************************************ + FAUST Architecture File + Copyright (C) 2003-2011 GRAME, Centre National de Creation Musicale + --------------------------------------------------------------------- + + This is sample code. This file is provided as an example of minimal + FAUST architecture file. Redistribution and use in source and binary + forms, with or without modification, in part or in full are permitted. + In particular you can create a derived work of this FAUST architecture + and distribute that work under terms of your choice. + + This sample code is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ************************************************************************ + ************************************************************************/ + + +/****************************************************************************** +******************************************************************************* + + VECTOR INTRINSICS + +******************************************************************************* +*******************************************************************************/ + + +/****************************************************************************** +******************************************************************************* + + ABSTRACT USER INTERFACE + +******************************************************************************* +*******************************************************************************/ + +//---------------------------------------------------------------------------- +// FAUST generated signal processor +//---------------------------------------------------------------------------- + +#ifndef FAUSTFLOAT +#define FAUSTFLOAT float +#endif + +class Dsp { +public: + int fSamplingFreq; + FAUSTFLOAT fslider0; + FAUSTFLOAT fcheckbox0; + FAUSTFLOAT fcheckbox1; + int iVec0[2]; + FAUSTFLOAT fslider1; + FAUSTFLOAT fslider2; + FAUSTFLOAT fslider3; + int iConst0; + float fConst1; + FAUSTFLOAT fslider4; + float fConst2; + float fRec5[2]; + float fRec6[2]; + FAUSTFLOAT fslider5; + FAUSTFLOAT fslider6; + FAUSTFLOAT fslider7; + float fRec4[3]; + float fRec3[3]; + float fRec2[3]; + float fRec1[3]; + float fRec0[2]; + float fRec11[3]; + float fRec10[3]; + float fRec9[3]; + float fRec8[3]; + float fRec7[2]; + + void instanceInit(int samplingFreq) { + fSamplingFreq = samplingFreq; + fslider0 = 1.0f; + fcheckbox0 = 0.0; + fcheckbox1 = 0.0; + for (int i=0; i<2; i++) iVec0[i] = 0; + fslider1 = 0.0f; + fslider2 = 0.0f; + fslider3 = 1e+03f; + iConst0 = min(192000, max(1, fSamplingFreq)); + fConst1 = (1.0f / float(iConst0)); + fslider4 = 0.5f; + fConst2 = (6.283185307179586f / float(iConst0)); + for (int i=0; i<2; i++) fRec5[i] = 0; + for (int i=0; i<2; i++) fRec6[i] = 0; + fslider5 = 1e+02f; + fslider6 = 8e+02f; + fslider7 = 1.5f; + for (int i=0; i<3; i++) fRec4[i] = 0; + for (int i=0; i<3; i++) fRec3[i] = 0; + for (int i=0; i<3; i++) fRec2[i] = 0; + for (int i=0; i<3; i++) fRec1[i] = 0; + for (int i=0; i<2; i++) fRec0[i] = 0; + for (int i=0; i<3; i++) fRec11[i] = 0; + for (int i=0; i<3; i++) fRec10[i] = 0; + for (int i=0; i<3; i++) fRec9[i] = 0; + for (int i=0; i<3; i++) fRec8[i] = 0; + for (int i=0; i<2; i++) fRec7[i] = 0; + } + void init(int samplingFreq) { + instanceInit(samplingFreq); + } + // 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 ConvertFracToFloat(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); + } + + void compute (int count, + const int32_t** input, + int32_t* left, + int32_t* right, + int param_fcheckbox0, + int param_fcheckbox1, + int param_fslider0, + int param_fslider1, + int param_fslider3, + int param_fslider4, + int param_fslider5, + int param_fslider6, + int param_fslider7) { + float fSlow0 = (0.5f * ((int(float(param_fcheckbox0)))?2:float(fslider0))); + float fSlow1 = ((int(float(param_fcheckbox1)))?(0 - fSlow0):fSlow0); + float fSlow2 = float(fslider1); + float fSlow3 = 10; //powf(10,(0.05f * float(fslider2))); + float fSlow4 = 0.8; //expf((fConst1 * (0 - (3.141592653589793f * float(fslider3))))); + float fSlow5 = faustpower2(fSlow4); + float fSlow6 = (fConst2 * 10*ConvertFracToFloat(param_fslider4)); + float fSlow7 = cosf(fSlow6); + float fSlow8 = sinf(fSlow6); + float fSlow9 = (0 - fSlow8); + float fSlow10 = float(fslider5); + float fSlow11 = (6.283185307179586f * fSlow10); + float fSlow12 = (0.5f * ((6.283185307179586f * max(fSlow10, float(fslider6))) - fSlow11)); + float fSlow13 = float(fslider7); + float fSlow14 = (fConst1 * fSlow13); + float fSlow15 = (0 - (2 * fSlow4)); + float fSlow16 = (fConst1 * faustpower2(fSlow13)); + float fSlow17 = (fConst1 * faustpower3(fSlow13)); + float fSlow18 = (fConst1 * faustpower4(fSlow13)); + float fSlow19 = (1 - fSlow0); + const int32_t* input0 = *input; + const int32_t* input1 = *input; + int32_t* output0 = left; + int32_t* output1 = right; + for (int i=0; i + + Phaser Stereo (from Faust) hand-optimised + Ricardo Wurmus + GPL + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + (b) ? (a) : (b)) + #define cosf arm_cos_q31 + #define intTAU 0x00c90fdb + /*"6.283185307179586f"*/ +]]> + + arm_cos_q31 + // sinf --> arm_sin_q31 + + int32_t fSlow0 = param_fcheckbox0 ? 0x00200000 /*"1"*/ : (param_fslider0>>1); + int32_t fSlow1 = param_fcheckbox1 ? __QSUB(0, fSlow0) : fSlow0; + // TODO: find replacement for expf + // e ^ -1 * const1 * pi * slider3 + // It's a value between 0.72 and 1.0, but for now we pretend it's just the value of fslider3. + // float fSlow4 = expf((fConst1 * (0 - (3.141592653589793f * float(fslider3))))); + int32_t fSlow4 = 0x00200000; //param_fslider3; + int32_t fSlow5 = ___SMMUL(fSlow4, fSlow4); + int32_t fSlow6 = ___SMMUL(fConst2, param_fslider4); + int32_t fSlow7 = arm_cos_q31(fSlow6); + int32_t fSlow8 = arm_sin_q31(fSlow6); + int32_t fSlow9 = __QSUB(0, fSlow8); + + int32_t minFreq; + MTOF(param_fslider5, minFreq); + int32_t maxFreq; + MTOF(param_fslider6, maxFreq); + + int32_t fSlow11 = ___SMMUL(intTAU, minFreq); + int32_t fSlow12 = __QSUB(___SMMUL(intTAU, MAX(minFreq, maxFreq)), fSlow11) >>1; + int32_t fSlow15 = __QSUB(0, fSlow4<<1); + int32_t fSlow14 = ___SMMUL(fConst1, param_fslider7); + int32_t fSlow16 = ___SMMUL(fSlow14, param_fslider7); + int32_t fSlow17 = ___SMMUL(fSlow16, param_fslider7); + int32_t fSlow18 = ___SMMUL(fSlow17, param_fslider7); + int32_t fSlow19 = __QSUB(0x00200000 /*"1.0"*/, fSlow0); + + const int32_t* input0 = inlet_in; + const int32_t* input1 = inlet_in; + int32_t* output0 = outlet_left; + int32_t* output1 = outlet_right; + + for (int i=0; i + + -- cgit v1.2.3